Bug 1067788 - Part 5: Fix for parts of test_bug496275.html. r=smontagu
authorTed Clancy <tclancy@mozilla.com>
Sat, 30 May 2015 00:22:53 -0400
changeset 279075 90bdd7a731ef81c5241ef415469bb8298e9db448
parent 279074 237690e8e193b986935e144e9d3a857ab3c2a5a3
child 279076 7cd191b31b38def9689568491ef04429eebbb9a9
push id897
push userjlund@mozilla.com
push dateMon, 14 Sep 2015 18:56:12 +0000
treeherdermozilla-release@9411e2d2b214 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs1067788, 496275
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1067788 - Part 5: Fix for parts of test_bug496275.html. r=smontagu
layout/generic/nsSelection.cpp
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -1013,18 +1013,23 @@ nsFrameSelection::MoveCaret(nsDirection 
       theFrame->GetOffsets(frameStart, frameEnd);
     }
 
     if (context->BidiEnabled())
     {
       switch (aAmount) {
         case eSelectBeginLine:
         case eSelectEndLine:
-          // set the caret Bidi level to the paragraph embedding level
-          SetCaretBidiLevel(NS_GET_BASE_LEVEL(theFrame));
+          // In Bidi contexts, PeekOffset calculates pos.mContentOffset
+          // differently depending on whether the movement is visual or logical.
+          // For visual movement, pos.mContentOffset depends on the direction-
+          // ality of the first/last frame on the line (theFrame), and the caret
+          // directionality must correspond.
+          SetCaretBidiLevel(visualMovement ? NS_GET_EMBEDDING_LEVEL(theFrame) :
+                                             NS_GET_BASE_LEVEL(theFrame));
           break;
 
         default:
           // If the current position is not a frame boundary, it's enough just
           // to take the Bidi level of the current frame
           if ((pos.mContentOffset != frameStart &&
                pos.mContentOffset != frameEnd) ||
               eSelectLine == aAmount) {