Bug 1291110 Part 3 - Reflow the line again after splitting if it has floats and itss BSize() shrinks. draft
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 02 Sep 2016 17:22:50 +0800
changeset 411669 4992f8804511c6765b3044c48ef44966dda2a0d9
parent 411668 3d9968415fccbb311c3b06453a7c51fd85bc527a
child 530781 d2c44011df73c97780d2403191e239538808d514
push id28949
push userbmo:tlin@mozilla.com
push dateThu, 08 Sep 2016 12:27:36 +0000
bugs1291110
milestone51.0a1
Bug 1291110 Part 3 - Reflow the line again after splitting if it has floats and itss BSize() shrinks. MozReview-Commit-ID: m62IEItMD2
layout/generic/nsBlockFrame.cpp
layout/reftests/floats/reftest.list
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -4346,22 +4346,37 @@ nsBlockFrame::SplitLine(BlockReflowInput
 #endif
 
     // Let line layout know that some frames are no longer part of its
     // state.
     aLineLayout.SplitLineTo(aLine->GetChildCount());
 
     // If floats have been placed whose placeholders have been pushed to the new
     // line, we need to reflow the old line again. We don't want to look at the
-    // frames in the new line, because as a large paragraph is laid out the 
+    // frames in the new line, because as a large paragraph is laid out the
     // we'd get O(N^2) performance. So instead we just check that the last
     // float and the last below-current-line float are still in aLine.
     if (!CheckPlaceholderInLine(this, aLine, GetLastFloat(aLine)) ||
         !CheckPlaceholderInLine(this, aLine, aState.mBelowCurrentLineFloats.Tail())) {
       *aLineReflowStatus = LINE_REFLOW_REDO_NO_PULL;
+    } else if (CheckPlaceholderInLine(this, aLine, aLine->GetFirstFloat())) {
+      // If the line has floats, we need to check whether aLine's BSize()
+      // shrinks due to some frames are pushed to the new line. If its BSize()
+      // does shrink, its position might be changed as well because it might not
+      // intersect with some of the floats. We'll have to reflow the old line
+      // again.
+      nscoord oldLineBSize = aLine->BSize();
+
+      // Update aLine's BSize().
+      aLineLayout.VerticalAlignLine();
+
+      // aLine has been reflowed and now its size shrinks.
+      if (oldLineBSize > 0 && aLine->BSize() < oldLineBSize) {
+        *aLineReflowStatus = LINE_REFLOW_REDO_NO_PULL;
+      }
     }
 
 #ifdef DEBUG
     VerifyLines(true);
 #endif
   }
 }
 
--- a/layout/reftests/floats/reftest.list
+++ b/layout/reftests/floats/reftest.list
@@ -6,17 +6,17 @@ fails == other-float-outside-rule-3-righ
 fails == other-float-outside-rule-7-left.html other-float-outside-rule-7-left-ref.html # bug 616334
 fails == other-float-outside-rule-7-right.html other-float-outside-rule-7-right-ref.html # bug 616334
 fuzzy-if(gtkWidget,1,10) == float-outside-block-push.html float-outside-block-push-ref.html # bug 815612
 == relative-float-1.html relative-float-1-ref.html
 == relative-float-2.html relative-float-2-ref.html
 == zero-height-float-base.html zero-height-float-ref.html
 fails == zero-height-float.html zero-height-float-ref.html # bug 81710
 == 345369-1.html 345369-1-ref.html
-fails == 345369-2.html 345369-2-ref.html
+== 345369-2.html 345369-2-ref.html
 == 345369-3.html 345369-3-ref.html
 == 345369-4.html 345369-4-ref.html
 == 345369-5.html 345369-5-ref.html
 == 429974-1.html 429974-1-ref.html
 == 478834-1.html 478834-1-ref.html
 == 546048-1.html 546048-1-ref.html
 == 775350-1.html 775350-1-ref.html
 == 1114329.html 1114329-ref.html