Bug 1097894: if the embedding level of a frame is unset, get the direction from style, r=dholbert
authorSimon Montagu <smontagu@smontagu.org>
Thu, 20 Nov 2014 12:45:22 +0200
changeset 216606 d90b4907a287547c46e18a2c10b1a5d24c142fb2
parent 216605 beb6d3e078d0eb1802922431af4e63e0fc85d0b5
child 216607 086c21f9b16fe8a497a64eb7b0c6813e56070a07
push id52102
push usersmontagu@mozilla.com
push dateThu, 20 Nov 2014 10:45:45 +0000
treeherdermozilla-inbound@1bee60dc14ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1097894
milestone36.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 1097894: if the embedding level of a frame is unset, get the direction from style, r=dholbert
layout/generic/nsFrame.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -5895,17 +5895,28 @@ nsFrame::GetPointFromOffset(int32_t inOf
   nsRect contentRect = GetContentRectRelativeToSelf();
   nsPoint pt = contentRect.TopLeft();
   if (mContent)
   {
     nsIContent* newContent = mContent->GetParent();
     if (newContent){
       int32_t newOffset = newContent->IndexOf(mContent);
 
-      bool isRTL = (NS_GET_EMBEDDING_LEVEL(this) & 1) == 1;
+      // Find the direction of the frame from the EmbeddingLevelProperty,
+      // which is the resolved bidi level set in
+      // nsBidiPresUtils::ResolveParagraph (odd levels = right-to-left).
+      // If the embedding level isn't set, just use the CSS direction
+      // property.
+      bool hasEmbeddingLevel;
+      nsBidiLevel embeddingLevel =
+        NS_PTR_TO_INT32(Properties().Get(nsIFrame::EmbeddingLevelProperty(),
+                                         &hasEmbeddingLevel));
+      bool isRTL = hasEmbeddingLevel
+        ? (embeddingLevel & 1) == 1
+        : StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
       if ((!isRTL && inOffset > newOffset) ||
           (isRTL && inOffset <= newOffset)) {
         pt = contentRect.TopRight();
       }
     }
   }
   *outPoint = pt;
   return NS_OK;