mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Always use the visual iterator when moving visually in a bidi page, even if the current line or adjacent lines are LTR. bug=309432 r=smontagu sr=roc
This commit is contained in:
parent
3a1f4012bf
commit
6f21109f82
@ -102,6 +102,10 @@
|
||||
#include "nsIPercentHeightObserver.h"
|
||||
#include "nsTextTransformer.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsBidiPresUtils.h"
|
||||
#endif
|
||||
|
||||
// For triple-click pref
|
||||
#include "nsIServiceManager.h"
|
||||
#ifndef MOZ_CAIRO_GFX
|
||||
@ -4474,51 +4478,53 @@ nsFrame::GetFrameFromDirection(nsPresContext* aPresContext, nsPeekOffsetStruct *
|
||||
nsresult result = blockFrame->QueryInterface(NS_GET_IID(nsILineIteratorNavigator),getter_AddRefs(it));
|
||||
NS_ASSERTION(NS_SUCCEEDED(result) && it, "GetLineNumber() succeeded but no block frame?");
|
||||
|
||||
PRBool atLineEdge;
|
||||
nsIFrame *firstFrame;
|
||||
nsIFrame *lastFrame;
|
||||
nsRect nonUsedRect;
|
||||
PRInt32 lineFrameCount;
|
||||
PRUint32 lineFlags;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
/* Check whether the visual and logical order of the frames are different */
|
||||
PRBool lineIsReordered = PR_FALSE;
|
||||
nsIFrame *firstVisual;
|
||||
nsIFrame *lastVisual;
|
||||
|
||||
if (aPos->mVisual) {
|
||||
result = it->CheckLineOrder(thisLine, &lineIsReordered, &firstVisual, &lastVisual);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
}
|
||||
|
||||
if (lineIsReordered) {
|
||||
firstFrame = firstVisual;
|
||||
lastFrame = lastVisual;
|
||||
}
|
||||
else
|
||||
if (aPos->mVisual && aPresContext->BidiEnabled()) {
|
||||
PRBool lineIsRTL;
|
||||
it->GetDirection(&lineIsRTL);
|
||||
PRBool isReordered;
|
||||
result = it->CheckLineOrder(thisLine, &isReordered, &firstFrame, &lastFrame);
|
||||
nsIFrame** framePtr = aPos->mDirection == eDirPrevious ? &firstFrame : &lastFrame;
|
||||
nsBidiLevel embeddingLevel = nsBidiPresUtils::GetFrameEmbeddingLevel(*framePtr);
|
||||
if (((embeddingLevel & 1) && lineIsRTL || !(embeddingLevel & 1) && !lineIsRTL) ==
|
||||
(aPos->mDirection == eDirPrevious)) {
|
||||
GetFirstLeaf(aPresContext, framePtr);
|
||||
} else {
|
||||
GetLastLeaf(aPresContext, framePtr);
|
||||
}
|
||||
atLineEdge = *framePtr == traversedFrame;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
nsRect nonUsedRect;
|
||||
PRInt32 lineFrameCount;
|
||||
PRUint32 lineFlags;
|
||||
result = it->GetLine(thisLine, &firstFrame, &lineFrameCount,nonUsedRect,
|
||||
&lineFlags);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
lastFrame = firstFrame;
|
||||
for (;lineFrameCount > 1;lineFrameCount --){
|
||||
result = it->GetNextSiblingOnLine(lastFrame, thisLine);
|
||||
if (NS_FAILED(result) || !lastFrame){
|
||||
NS_ASSERTION(0,"should not be reached nsFrame\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
if (aPos->mDirection == eDirPrevious) {
|
||||
GetFirstLeaf(aPresContext, &firstFrame);
|
||||
atLineEdge = firstFrame == traversedFrame;
|
||||
} else { // eDirNext
|
||||
lastFrame = firstFrame;
|
||||
for (;lineFrameCount > 1;lineFrameCount --){
|
||||
result = it->GetNextSiblingOnLine(lastFrame, thisLine);
|
||||
if (NS_FAILED(result) || !lastFrame){
|
||||
NS_ASSERTION(0,"should not be reached nsFrame\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
GetLastLeaf(aPresContext, &lastFrame);
|
||||
atLineEdge = lastFrame == traversedFrame;
|
||||
}
|
||||
}
|
||||
|
||||
GetFirstLeaf(aPresContext, &firstFrame); // XXX Should be GetFirstVisualLeaf
|
||||
GetLastLeaf(aPresContext, &lastFrame); // XXX Should be GetLastVisualLeaf
|
||||
//END LINE DATA CODE
|
||||
if ((aPos->mDirection == eDirNext && lastFrame == traversedFrame)
|
||||
|| (aPos->mDirection == eDirPrevious && firstFrame == traversedFrame))
|
||||
if (atLineEdge)
|
||||
{
|
||||
if (aPos->mJumpLines != PR_TRUE)
|
||||
return NS_ERROR_FAILURE;//we are done. cannot jump lines
|
||||
@ -4534,7 +4540,7 @@ nsFrame::GetFrameFromDirection(nsPresContext* aPresContext, nsPeekOffsetStruct *
|
||||
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
||||
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
|
||||
#ifdef IBMBIDI
|
||||
lineIsReordered ? VISUAL :
|
||||
aPos->mVisual && aPresContext->BidiEnabled() ? VISUAL :
|
||||
#endif
|
||||
LEAF,
|
||||
aPresContext,
|
||||
|
@ -438,9 +438,6 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
|
||||
if (!mFirstChild)
|
||||
return nsnull;
|
||||
|
||||
if (aFrame && aFrame->GetType() == nsLayoutAtoms::blockFrame)
|
||||
return GetPrevSiblingFor(aFrame);
|
||||
|
||||
nsIFrame* parent = mFirstChild->GetParent();
|
||||
if (!parent)
|
||||
return aFrame ? GetPrevSiblingFor(aFrame) : LastChild();
|
||||
@ -509,9 +506,6 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
|
||||
if (!mFirstChild)
|
||||
return nsnull;
|
||||
|
||||
if (aFrame && aFrame->GetType() == nsLayoutAtoms::blockFrame)
|
||||
return aFrame->GetNextSibling();
|
||||
|
||||
nsIFrame* parent = mFirstChild->GetParent();
|
||||
if (!parent)
|
||||
return aFrame ? GetPrevSiblingFor(aFrame) : mFirstChild;
|
||||
|
@ -746,10 +746,6 @@ nsLineIterator::CheckLineOrder(PRInt32 aLine,
|
||||
}
|
||||
|
||||
nsPresContext* presContext = line->mFirstChild->GetPresContext();
|
||||
if (!presContext->BidiEnabled()) {
|
||||
*aIsReordered = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
|
||||
|
||||
@ -761,20 +757,6 @@ nsLineIterator::CheckLineOrder(PRInt32 aLine,
|
||||
*aFirstVisual = mRightToLeft ? rightmostFrame : leftmostFrame;
|
||||
*aLastVisual = mRightToLeft ? leftmostFrame : rightmostFrame;
|
||||
|
||||
// an RTL paragraph is always considered as reordered
|
||||
if (mRightToLeft)
|
||||
*aIsReordered = PR_TRUE;
|
||||
|
||||
// Check the preceding and following line, since we might be moving into them
|
||||
if (!*aIsReordered && aLine > 0) {
|
||||
nsLineBox* line = mLines[aLine - 1];
|
||||
*aIsReordered = bidiUtils->CheckLineOrder(line->mFirstChild, line->GetChildCount(), nsnull, nsnull);
|
||||
}
|
||||
if (!*aIsReordered && aLine < mNumLines - 1) {
|
||||
nsLineBox* line = mLines[aLine + 1];
|
||||
*aIsReordered = bidiUtils->CheckLineOrder(line->mFirstChild, line->GetChildCount(), nsnull, nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
|
Loading…
Reference in New Issue
Block a user