Follow up the parent chain when making continuations non-fluid at the end of a directional run. Bug 989994, r=roc, a=lsblakk
authorSimon Montagu <smontagu@smontagu.org>
Thu, 01 May 2014 01:30:14 -0700
changeset 192183 3c6892869d25
parent 192182 d9336eebf796
child 192184 0678e5469636
push id3514
push usersmontagu@mozilla.com
push date2014-05-01 08:30 +0000
Treeherderresults
reviewersroc, lsblakk
bugs989994
milestone30.0
Follow up the parent chain when making continuations non-fluid at the end of a directional run. Bug 989994, r=roc, a=lsblakk
layout/base/nsBidiPresUtils.cpp
--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -482,16 +482,33 @@ MakeContinuationFluid(nsIFrame* aFrame, 
                 "next-in-flow is not next continuation!");
   aFrame->SetNextInFlow(aNext);
 
   NS_ASSERTION (!aNext->GetPrevInFlow() || aNext->GetPrevInFlow() == aFrame,
                 "prev-in-flow is not prev continuation!");
   aNext->SetPrevInFlow(aFrame);
 }
 
+static void
+MakeContinuationsNonFluidUpParentChain(nsIFrame* aFrame, nsIFrame* aNext)
+{
+  nsIFrame* frame;
+  nsIFrame* next;
+
+  for (frame = aFrame, next = aNext;
+       frame && next &&
+         next != frame && next == frame->GetNextInFlow() &&
+         IsBidiSplittable(frame);
+       frame = frame->GetParent(), next = next->GetParent()) {
+
+    frame->SetNextContinuation(next);
+    next->SetPrevContinuation(frame);
+  }
+}
+
 // If aFrame is the last child of its parent, convert bidi continuations to
 // fluid continuations for all of its inline ancestors.
 // If it isn't the last child, make sure that its continuation is fluid.
 static void
 JoinInlineAncestors(nsIFrame* aFrame)
 {
   nsIFrame* frame = aFrame;
   do {
@@ -838,30 +855,17 @@ nsBidiPresUtils::ResolveParagraph(nsBloc
             /*
              * If the directional run ends at the end of the frame, make sure
              * that any continuation is non-fluid, and do the same up the
              * parent chain
              */
             nsIFrame* next = frame->GetNextInFlow();
             if (next) {
               currentLine->MarkDirty();
-              nsIFrame* parent = frame;
-              nsIFrame* nextParent = next;
-              while (parent && nextParent) {
-                if (parent == nextParent ||
-                    nextParent != parent->GetNextInFlow() ||
-                    !IsBidiSplittable(parent)) {
-                  break;
-                }
-                parent->SetNextContinuation(nextParent);
-                nextParent->SetPrevContinuation(parent);
-
-                parent = parent->GetParent();
-                nextParent = nextParent->GetParent();
-              }
+              MakeContinuationsNonFluidUpParentChain(frame, next);
             }
           }
           frame->AdjustOffsetsForBidi(contentOffset, contentOffset + fragmentLength);
         }
       } // isTextFrame
       else {
         ++lineOffset;
       }
@@ -1657,21 +1661,17 @@ nsBidiPresUtils::RemoveBidiContinuation(
       }
     }
   }
 
   // Make sure that the last continuation we made fluid does not itself have a
   // fluid continuation (this can happen when re-resolving after dynamic changes
   // to content)
   nsIFrame* lastFrame = aBpd->FrameAt(aLastIndex);
-  nsIFrame* next = lastFrame->GetNextInFlow();
-  if (next && IsBidiSplittable(lastFrame)) {
-    lastFrame->SetNextContinuation(next);
-    next->SetPrevContinuation(lastFrame);
-  }
+  MakeContinuationsNonFluidUpParentChain(lastFrame, lastFrame->GetNextInFlow());
 }
 
 nsresult
 nsBidiPresUtils::FormatUnicodeText(nsPresContext*  aPresContext,
                                    char16_t*       aText,
                                    int32_t&         aTextLength,
                                    nsCharType       aCharType,
                                    bool             aIsOddLevel)