From c4edf79a42525f84eb3107a309ac5be003bf6eeb Mon Sep 17 00:00:00 2001 From: "uriber%gmail.com" Date: Mon, 14 Aug 2006 11:25:57 +0000 Subject: [PATCH] In GetPrevNextBidiLevels, treat the "before
" case as if we were end-of-line. bug=330461 r=smontagu sr=roc git-svn-id: svn://10.0.0.236/trunk@207306 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsSelection.cpp | 33 ++++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index c7c3b5a2190..2d0b2212e86 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -1988,20 +1988,27 @@ nsFrameSelection::GetPrevNextBidiLevels(nsIContent *aNode, if (NS_SUCCEEDED(rv)) newFrame = pos.mResultFrame; - if (direction == eDirNext) { - levels.SetData(currentFrame, newFrame, - NS_GET_EMBEDDING_LEVEL(currentFrame), - newFrame ? NS_GET_EMBEDDING_LEVEL(newFrame) : - NS_GET_BASE_LEVEL(currentFrame)); - return levels; - } - else { - levels.SetData(newFrame, currentFrame, - newFrame ? NS_GET_EMBEDDING_LEVEL(newFrame) : - NS_GET_BASE_LEVEL(currentFrame), - NS_GET_EMBEDDING_LEVEL(currentFrame)); - return levels; + PRUint8 baseLevel = NS_GET_BASE_LEVEL(currentFrame); + PRUint8 currentLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); + PRUint8 newLevel = newFrame ? NS_GET_EMBEDDING_LEVEL(newFrame) : baseLevel; + + // If not jumping lines, disregard br frames, since they might be positioned incorrectly. + // XXX This could be removed once bug 339786 is fixed. + if (!aJumpLines) { + if (currentFrame->GetType() == nsLayoutAtoms::brFrame) { + currentFrame = nsnull; + currentLevel = baseLevel; + } + if (newFrame && newFrame->GetType() == nsLayoutAtoms::brFrame) { + newFrame = nsnull; + newLevel = baseLevel; + } } + + if (direction == eDirNext) + levels.SetData(currentFrame, newFrame, currentLevel, newLevel); + else + levels.SetData(newFrame, currentFrame, newLevel, currentLevel); return levels; }