Bug 1291110 Part 3 - Enforce float available space never grow on either side. r=dbaron
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 08 Nov 2016 15:20:58 +0800
changeset 348555 5ebd8aebc99f26443b596cb026ab025585a9260d
parent 348554 0ddd1de392d811da6cf3497a42f2b833e53c093e
child 348556 ae7543286030724b9aa495792c86085265e0f711
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1291110
milestone52.0a1
Bug 1291110 Part 3 - Enforce float available space never grow on either side. r=dbaron This patch is based on bug 1291110 comment 29, but |aCanGrow| is preserved, since the set of float available spaces we'll be testing in Part 4 are difference from the one we enforced here. MozReview-Commit-ID: LswbIaRukVR
layout/generic/nsBlockFrame.cpp
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -4481,16 +4481,31 @@ nsBlockFrame::PlaceLine(BlockReflowInput
   aFloatAvailableSpace =
     aState.GetFloatAvailableSpaceForBSize(aLine->BStart(),
                                           aAvailableSpaceBSize,
                                           aFloatStateBeforeLine).mRect;
   NS_ASSERTION(aFloatAvailableSpace.BStart(wm) ==
                oldFloatAvailableSpace.BStart(wm), "yikes");
   // Restore the BSize to the position of the next band.
   aFloatAvailableSpace.BSize(wm) = oldFloatAvailableSpace.BSize(wm);
+
+  // Enforce both IStart() and IEnd() never move outwards to prevent
+  // infinite grow-shrink loops.
+  const nscoord iStartDiff =
+    aFloatAvailableSpace.IStart(wm) - oldFloatAvailableSpace.IStart(wm);
+  const nscoord iEndDiff =
+    aFloatAvailableSpace.IEnd(wm) - oldFloatAvailableSpace.IEnd(wm);
+  if (iStartDiff < 0) {
+    aFloatAvailableSpace.IStart(wm) -= iStartDiff;
+    aFloatAvailableSpace.ISize(wm) += iStartDiff;
+  }
+  if (iEndDiff > 0) {
+    aFloatAvailableSpace.ISize(wm) -= iEndDiff;
+  }
+
   // If the available space between the floats is smaller now that we
   // know the BSize, return false (and cause another pass with
   // LineReflowStatus::RedoMoreFloats).  We ensure aAvailableSpaceBSize
   // never decreases, which means that we can't reduce the set of floats
   // we intersect, which means that the available space cannot grow.
   if (AvailableSpaceShrunk(wm, oldFloatAvailableSpace, aFloatAvailableSpace,
                            false)) {
     return false;