From f21a8865d48024843c92fbe442bb29ae225b9a42 Mon Sep 17 00:00:00 2001 From: Ted Clancy Date: Sat, 30 May 2015 00:22:53 -0400 Subject: [PATCH] Bug 1067788 - Part 5: Fix for parts of test_bug496275.html. r=smontagu --- layout/generic/nsSelection.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 426ae0e4f850..6a027d3634f6 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -1018,8 +1018,13 @@ nsFrameSelection::MoveCaret(nsDirection aDirection, 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: