Bug 1291110 Part 3 - Enforce float available space never grow on either side.
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
--- 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;