Bug 1097499 part 6 - Inherit move direction from parent for horizontal-in-vertical text. r=jfkthame draft
authorXidorn Quan <quanxunzhen@gmail.com>
Fri, 18 Mar 2016 15:29:25 +0800
changeset 354601 b7bf6fecf93ce523e6250b2a4f39376eb665476d
parent 354600 fa096cf5c4c4b000013d44b3759a3a1c71c3b5ba
child 354602 4de6a97985313152d09e0706ccc1098a6ca2ac78
push id16138
push userxquan@mozilla.com
push dateThu, 21 Apr 2016 11:18:53 +0000
reviewersjfkthame
bugs1097499
milestone48.0a1
Bug 1097499 part 6 - Inherit move direction from parent for horizontal-in-vertical text. r=jfkthame MozReview-Commit-ID: 28mBKQnYydp
layout/generic/nsSelection.cpp
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -2121,17 +2121,27 @@ nsFrameSelection::PhysicalMove(int16_t a
   };
 
   WritingMode wm;
   nsIFrame *frame = nullptr;
   int32_t offsetused = 0;
   if (NS_SUCCEEDED(sel->GetPrimaryFrameForFocusNode(&frame, &offsetused,
                                                     true))) {
     if (frame) {
-      wm = frame->GetWritingMode();
+      if (!frame->StyleContext()->IsTextCombined()) {
+        wm = frame->GetWritingMode();
+      } else {
+        // Using different direction for horizontal-in-vertical would
+        // make it hard to navigate via keyboard. Inherit the moving
+        // direction from its parent.
+        MOZ_ASSERT(frame->GetType() == nsGkAtoms::textFrame);
+        wm = frame->GetParent()->GetWritingMode();
+        MOZ_ASSERT(wm.IsVertical(), "Text combined "
+                   "can only appear in vertical text");
+      }
     }
   }
 
   const PhysicalToLogicalMapping& mapping =
     wm.IsVertical()
       ? wm.IsVerticalLR() ? verticalLR[aDirection] : verticalRL[aDirection]
       : horizontal[aDirection];