Bug 1466231 Part 2a: Change nsBlockFrame::PlaceLine to accept an nsFlowAreaRect and update the mHasFloats flag if it shrinks the area due to a float. draft
authorBrad Werth <bwerth@mozilla.com>
Wed, 06 Jun 2018 12:02:36 -0700
changeset 805563 1c05ef1871db5fc2bce2b3e59f1c406d2ba80fc7
parent 805562 013bccdf5a9ed5c5dc09ed5f0099129a19e5857a
child 805564 ce3d6cb61a006000aa995833aba24890c26bd55e
push id112697
push userbwerth@mozilla.com
push dateFri, 08 Jun 2018 00:14:56 +0000
bugs1466231
milestone62.0a1
Bug 1466231 Part 2a: Change nsBlockFrame::PlaceLine to accept an nsFlowAreaRect and update the mHasFloats flag if it shrinks the area due to a float. MozReview-Commit-ID: 4stQQfboUl7
layout/generic/nsBlockFrame.cpp
layout/generic/nsBlockFrame.h
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -4079,17 +4079,17 @@ nsBlockFrame::DoReflowInlineFrames(Block
     // past the float.
   }
   else if (LineReflowStatus::Truncated != lineReflowStatus &&
            LineReflowStatus::RedoNoPull != lineReflowStatus) {
     // If we are propagating out a break-before status then there is
     // no point in placing the line.
     if (!aState.mReflowStatus.IsInlineBreakBefore()) {
       if (!PlaceLine(aState, aLineLayout, aLine, aFloatStateBeforeLine,
-                     aFloatAvailableSpace.mRect, aAvailableSpaceBSize,
+                     aFloatAvailableSpace, aAvailableSpaceBSize,
                      aKeepReflowGoing)) {
         lineReflowStatus = LineReflowStatus::RedoMoreFloats;
         // PlaceLine already called GetAvailableSpaceForBSize for us.
       }
     }
   }
 #ifdef DEBUG
   if (gNoisyReflow) {
@@ -4469,17 +4469,17 @@ nsBlockFrame::IsLastLine(BlockReflowInpu
   return true;
 }
 
 bool
 nsBlockFrame::PlaceLine(BlockReflowInput& aState,
                         nsLineLayout& aLineLayout,
                         LineIterator aLine,
                         nsFloatManager::SavedState *aFloatStateBeforeLine,
-                        LogicalRect& aFloatAvailableSpace,
+                        nsFlowAreaRect& aFlowArea,
                         nscoord& aAvailableSpaceBSize,
                         bool* aKeepReflowGoing)
 {
   // Trim extra white-space from the line before placing the frames
   aLineLayout.TrimTrailingWhiteSpace();
 
   // Vertically align the frames on this line.
   //
@@ -4536,42 +4536,45 @@ nsBlockFrame::PlaceLine(BlockReflowInput
   // 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, floatAvailableSpaceWithOldLineBSize,
                            floatAvailableSpaceWithLineBSize, false)) {
     // Prepare data for redoing the line.
     aState.mLineBSize = Some(aLine->BSize());
 
-    // Since we want to redo the line, we update aFloatAvailableSpace by
-    // using the aFloatStateBeforeLine, which is the float manager's state
-    // before the line is placed.
-    LogicalRect oldFloatAvailableSpace(aFloatAvailableSpace);
-    aFloatAvailableSpace =
+    // Since we want to redo the line, we update aFlowArea by using the
+    // aFloatStateBeforeLine, which is the float manager's state before the
+    // line is placed.
+    LogicalRect oldFloatAvailableSpace(aFlowArea.mRect);
+    aFlowArea.mRect =
       aState.GetFloatAvailableSpaceForBSize(aLine->BStart(),
                                             aAvailableSpaceBSize,
                                             aFloatStateBeforeLine).mRect;
-    NS_ASSERTION(aFloatAvailableSpace.BStart(wm) ==
+    NS_ASSERTION(aFlowArea.mRect.BStart(wm) ==
                  oldFloatAvailableSpace.BStart(wm), "yikes");
     // Restore the BSize to the position of the next band.
-    aFloatAvailableSpace.BSize(wm) = oldFloatAvailableSpace.BSize(wm);
+    aFlowArea.mRect.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);
+      aFlowArea.mRect.IStart(wm) - oldFloatAvailableSpace.IStart(wm);
     const nscoord iEndDiff =
-      aFloatAvailableSpace.IEnd(wm) - oldFloatAvailableSpace.IEnd(wm);
+      aFlowArea.mRect.IEnd(wm) - oldFloatAvailableSpace.IEnd(wm);
     if (iStartDiff < 0) {
-      aFloatAvailableSpace.IStart(wm) -= iStartDiff;
-      aFloatAvailableSpace.ISize(wm) += iStartDiff;
+      aFlowArea.mRect.IStart(wm) -= iStartDiff;
+      aFlowArea.mRect.ISize(wm) += iStartDiff;
     }
     if (iEndDiff > 0) {
-      aFloatAvailableSpace.ISize(wm) -= iEndDiff;
-    }
+      aFlowArea.mRect.ISize(wm) -= iEndDiff;
+    }
+
+    // We also update aFlowArea to note that the area is affected by floats.
+    aFlowArea.mHasFloats = true;
 
     return false;
   }
 
 #ifdef DEBUG
   if (!GetParent()->IsCrazySizeAssertSuppressed()) {
     static nscoord lastHeight = 0;
     if (CRAZY_SIZE(aLine->BStart())) {
--- a/layout/generic/nsBlockFrame.h
+++ b/layout/generic/nsBlockFrame.h
@@ -700,17 +700,17 @@ protected:
 
   // Return false if it needs another reflow because of reduced space
   // between floats that are next to it (but not next to its top), and
   // return true otherwise.
   bool PlaceLine(BlockReflowInput& aState,
                  nsLineLayout& aLineLayout,
                  LineIterator aLine,
                  nsFloatManager::SavedState* aFloatStateBeforeLine,
-                 mozilla::LogicalRect& aFloatAvailableSpace, //in-out
+                 nsFlowAreaRect& aFlowArea, // in-out
                  nscoord& aAvailableSpaceBSize, // in-out
                  bool* aKeepReflowGoing);
 
   /**
     * If NS_BLOCK_LOOK_FOR_DIRTY_FRAMES is set, call MarkLineDirty
     * on any line with a child frame that is dirty.
     */
   void LazyMarkLinesDirty();