Bug 775624 Part 9 - Convert NS_FRAME_REFLOW_NEXTINFLOW to use bit-field and methods. r?dholbert draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 13 Feb 2017 14:56:45 +0800
changeset 488471 b1d5025e699132ff9839b7d305be43abe03ec25b
parent 488470 73421e7c6d002233002c61a488b3f5feb93de3da
child 488472 dcf513cd9191031d45f34ee3d954bb99fe56e3c9
push id46538
push userbmo:tlin@mozilla.com
push dateThu, 23 Feb 2017 05:39:06 +0000
reviewersdholbert
bugs775624
milestone54.0a1
Bug 775624 Part 9 - Convert NS_FRAME_REFLOW_NEXTINFLOW to use bit-field and methods. r?dholbert MozReview-Commit-ID: 1TXOShK62X8
layout/generic/nsBlockFrame.cpp
layout/generic/nsCanvasFrame.cpp
layout/generic/nsColumnSetFrame.cpp
layout/generic/nsContainerFrame.cpp
layout/generic/nsContainerFrame.h
layout/generic/nsFrame.cpp
layout/generic/nsGridContainerFrame.cpp
layout/generic/nsIFrame.h
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -1269,17 +1269,17 @@ nsBlockFrame::Reflow(nsPresContext*     
   if (NS_UNCONSTRAINEDSIZE != reflowInput->AvailableBSize() &&
       state.mReflowStatus.IsComplete() &&
       state.FloatManager()->ClearContinues(FindTrailingClear())) {
     state.mReflowStatus.SetIncomplete();
   }
 
   if (!state.mReflowStatus.IsFullyComplete()) {
     if (HasOverflowLines() || HasPushedFloats()) {
-      state.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+      state.mReflowStatus.SetNextInFlowNeedsReflow();
     }
 
 #ifdef DEBUG_kipp
     ListTag(stdout); printf(": block is not fully complete\n");
 #endif
   }
 
   // Place the "marker" (bullet) frame if it is placed next to a block
@@ -2679,17 +2679,17 @@ nsBlockFrame::ReflowDirtyLines(BlockRefl
           // If this is an inline frame then its time to stop
           ++line;
           aState.AdvanceToNextLine();
         }
       }
     }
 
     if (aState.mReflowStatus.IsIncomplete()) {
-      aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+      aState.mReflowStatus.SetNextInFlowNeedsReflow();
     } //XXXfr shouldn't set this flag when nextinflow has no lines
   }
 
   // Handle an odd-ball case: a list-item with no lines
   if (HasOutsideBullet() && mLines.empty()) {
     ReflowOutput metrics(aState.mReflowInput);
     nsIFrame* bullet = GetOutsideBullet();
     WritingMode wm = aState.mReflowInput.GetWritingMode();
@@ -3645,32 +3645,32 @@ nsBlockFrame::ReflowBlockFrame(BlockRefl
               if (NS_FAILED(rv)) {
                 return;
               }
               if (parent != this)
                 ReparentFrame(nextFrame, parent, this);
               mFrames.InsertFrame(nullptr, frame, nextFrame);
               madeContinuation = true; // needs to be added to mLines
               nextFrame->RemoveStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
-              frameReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+              frameReflowStatus.SetNextInFlowNeedsReflow();
             }
 
             // Push continuation to a new line, but only if we actually made one.
             if (madeContinuation) {
               nsLineBox* line = NewLineBox(nextFrame, true);
               mLines.after_insert(aLine, line);
             }
 
             PushLines(aState, aLine);
             aState.mReflowStatus.SetIncomplete();
 
             // If we need to reflow the continuation of the block child,
             // then we'd better reflow our continuation
-            if (frameReflowStatus & NS_FRAME_REFLOW_NEXTINFLOW) {
-              aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+            if (frameReflowStatus.NextInFlowNeedsReflow()) {
+              aState.mReflowStatus.SetNextInFlowNeedsReflow();
               // We also need to make that continuation's line dirty so
               // it gets reflowed when we reflow our next in flow. The
               // nif's line must always be either a line of the nif's
               // parent block (only if we didn't make a continuation) or
               // else one of our own overflow lines. In the latter case
               // the line is already marked dirty, so just handle the
               // first case.
               if (!madeContinuation) {
@@ -4102,17 +4102,17 @@ nsBlockFrame::DoReflowInlineFrames(Block
       // aLine is stale, it's associated with the main line list but it should
       // be associated with the overflow line list now
       aLine = overflowLines->mLines.begin();
     }
     nsBlockInFlowLineIterator iter(this, aLine, pushedToOverflowLines);
     if (iter.Next() && iter.GetLine()->IsInline()) {
       iter.GetLine()->MarkDirty();
       if (iter.GetContainer() != this) {
-        aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+        aState.mReflowStatus.SetNextInFlowNeedsReflow();
       }
     }
   }
 
   *aLineReflowStatus = lineReflowStatus;
 }
 
 /**
@@ -4145,17 +4145,17 @@ nsBlockFrame::ReflowInlineFrame(BlockRef
          aLineLayout.GetFirstLetterStyleOK() ? "on" : "off");
 #endif
 
   // Reflow the inline frame
   nsReflowStatus frameReflowStatus;
   bool           pushedFrame;
   aLineLayout.ReflowFrame(aFrame, frameReflowStatus, nullptr, pushedFrame);
 
-  if (frameReflowStatus & NS_FRAME_REFLOW_NEXTINFLOW) {
+  if (frameReflowStatus.NextInFlowNeedsReflow()) {
     aLineLayout.SetDirtyNextLine();
   }
 
 #ifdef REALLY_NOISY_REFLOW
   nsFrame::ListTag(stdout, aFrame);
   printf(": status=%x\n", frameReflowStatus);
 #endif
 
@@ -6278,18 +6278,18 @@ nsBlockFrame::ReflowFloat(BlockReflowInp
     aReflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
   } else if (aReflowStatus.IsIncomplete() &&
              (NS_UNCONSTRAINEDSIZE == aAdjustedAvailableSpace.BSize(wm))) {
     // An incomplete reflow status means we should split the float
     // if the height is constrained (bug 145305).
     aReflowStatus = NS_FRAME_COMPLETE;
   }
 
-  if (aReflowStatus & NS_FRAME_REFLOW_NEXTINFLOW) {
-    aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+  if (aReflowStatus.NextInFlowNeedsReflow()) {
+    aState.mReflowStatus.SetNextInFlowNeedsReflow();
   }
 
   if (aFloat->GetType() == nsGkAtoms::letterFrame) {
     // We never split floating first letters; an incomplete state for
     // such frames simply means that there is more content to be
     // reflowed on the line.
     if (aReflowStatus.IsIncomplete())
       aReflowStatus = NS_FRAME_COMPLETE;
@@ -7428,17 +7428,17 @@ nsBlockFrame::ComputeFinalBSize(const Re
       // so we should consume all the available height and then
       // break.  If our bottom border/padding straddles the break
       // point, then this will increase our height and push the
       // border/padding to the next page/column.
       aFinalSize.BSize(wm) = std::max(aReflowInput.AvailableBSize(),
                                       aContentBSize);
       aStatus->SetIncomplete();
       if (!GetNextInFlow())
-        *aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+        aStatus->SetNextInFlowNeedsReflow();
     }
   }
 }
 
 nsresult
 nsBlockFrame::ResolveBidi()
 {
   NS_ASSERTION(!GetPrevInFlow(),
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -712,17 +712,17 @@ nsCanvasFrame::Reflow(nsPresContext*    
                 kidWM, kidPt, containerSize, 0, aStatus);
 
     // Complete the reflow and position and size the child frame
     FinishReflowChild(kidFrame, aPresContext, kidDesiredSize, &kidReflowInput,
                       kidWM, kidPt, containerSize, 0);
 
     if (!aStatus.IsFullyComplete()) {
       nsIFrame* nextFrame = kidFrame->GetNextInFlow();
-      NS_ASSERTION(nextFrame || aStatus & NS_FRAME_REFLOW_NEXTINFLOW,
+      NS_ASSERTION(nextFrame || aStatus.NextInFlowNeedsReflow(),
         "If it's incomplete and has no nif yet, it must flag a nif reflow.");
       if (!nextFrame) {
         nextFrame = aPresContext->PresShell()->FrameConstructor()->
           CreateContinuingFrame(aPresContext, kidFrame, this);
         SetOverflowFrames(nsFrameList(nextFrame, nextFrame));
         // Root overflow containers will be normal children of
         // the canvas frame, but that's ok because there
         // aren't any other frames we need to isolate them from
--- a/layout/generic/nsColumnSetFrame.cpp
+++ b/layout/generic/nsColumnSetFrame.cpp
@@ -643,17 +643,17 @@ nsColumnSetFrame::ReflowChildren(ReflowO
       LogicalPoint origin(wm,
                           childOrigin.I(wm) +
                           kidReflowInput.ComputedLogicalMargin().IStart(wm),
                           childOrigin.B(wm) +
                           kidReflowInput.ComputedLogicalMargin().BStart(wm));
       ReflowChild(child, PresContext(), kidDesiredSize, kidReflowInput,
                   wm, origin, containerSize, 0, aStatus);
 
-      reflowNext = (aStatus & NS_FRAME_REFLOW_NEXTINFLOW) != 0;
+      reflowNext = aStatus.NextInFlowNeedsReflow();
 
 #ifdef DEBUG_roc
       printf("*** Reflowed child #%d %p: status = %d, desiredSize=%d,%d CarriedOutBEndMargin=%d\n",
              columnCount, (void*)child, aStatus, kidDesiredSize.Width(), kidDesiredSize.Height(),
              kidDesiredSize.mCarriedOutBEndMargin.get());
 #endif
 
       NS_FRAME_TRACE_REFLOW_OUT("Column::Reflow", aStatus);
@@ -689,50 +689,50 @@ nsColumnSetFrame::ReflowChildren(ReflowO
       break;
     } else {
       ++columnCount;
       // Make sure that the column has a next-in-flow. If not, we must
       // create one to hold the overflowing stuff, even if we're just
       // going to put it on our overflow list and let *our*
       // next in flow handle it.
       if (!kidNextInFlow) {
-        NS_ASSERTION(aStatus & NS_FRAME_REFLOW_NEXTINFLOW,
+        NS_ASSERTION(aStatus.NextInFlowNeedsReflow(),
                      "We have to create a continuation, but the block doesn't want us to reflow it?");
 
         // We need to create a continuing column
         kidNextInFlow = CreateNextInFlow(child);
       }
 
       // Make sure we reflow a next-in-flow when it switches between being
       // normal or overflow container
       if (aStatus.IsOverflowIncomplete()) {
         if (!(kidNextInFlow->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) {
-          aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+          aStatus.SetNextInFlowNeedsReflow();
           reflowNext = true;
           kidNextInFlow->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
         }
       }
       else if (kidNextInFlow->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) {
-        aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+        aStatus.SetNextInFlowNeedsReflow();
         reflowNext = true;
         kidNextInFlow->RemoveStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
       }
 
       if ((contentBEnd > aReflowInput.ComputedMaxBSize() ||
            contentBEnd > aReflowInput.ComputedBSize()) &&
            aConfig.mBalanceColCount < INT32_MAX) {
         // We overflowed vertically, but have not exceeded the number of
         // columns. We're going to go into overflow columns now, so balancing
         // no longer applies.
         aColData.mHasExcessBSize = true;
       }
 
       if (columnCount >= aConfig.mBalanceColCount) {
         // No more columns allowed here. Stop.
-        aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+        aStatus.SetNextInFlowNeedsReflow();
         kidNextInFlow->AddStateBits(NS_FRAME_IS_DIRTY);
         // Move any of our leftover columns to our overflow list. Our
         // next-in-flow will eventually pick them up.
         const nsFrameList& continuationColumns = mFrames.RemoveFramesAfter(child);
         if (continuationColumns.NotEmpty()) {
           SetOverflowFrames(continuationColumns);
         }
         child = nullptr;
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -1289,18 +1289,18 @@ nsContainerFrame::ReflowOverflowContaine
         else {
           NS_ASSERTION(frameStatus.IsComplete(),
                        "overflow container frames can't be incomplete, only overflow-incomplete");
         }
 
         // Acquire a next-in-flow, creating it if necessary
         nsIFrame* nif = frame->GetNextInFlow();
         if (!nif) {
-          NS_ASSERTION(frameStatus & NS_FRAME_REFLOW_NEXTINFLOW,
-                       "Someone forgot a REFLOW_NEXTINFLOW flag");
+          NS_ASSERTION(frameStatus.NextInFlowNeedsReflow(),
+                       "Someone forgot a NextInFlowNeedsReflow flag");
           nif = aPresContext->PresShell()->FrameConstructor()->
             CreateContinuingFrame(aPresContext, frame, this);
         }
         else if (!(nif->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) {
           // used to be a normal next-in-flow; steal it from the child list
           nsresult rv = nif->GetParent()->StealFrame(nif);
           if (NS_FAILED(rv)) {
             return;
@@ -2190,21 +2190,21 @@ nsOverflowContinuationTracker::Insert(ns
         if (f == nif) {
           mPrevOverflowCont = f->GetPrevSibling();
           break;
         }
       }
     }
 
     mOverflowContList->InsertFrame(mParent, mPrevOverflowCont, aOverflowCont);
-    aReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+    aReflowStatus.SetNextInFlowNeedsReflow();
   }
 
   // If we need to reflow it, mark it dirty
-  if (aReflowStatus & NS_FRAME_REFLOW_NEXTINFLOW)
+  if (aReflowStatus.NextInFlowNeedsReflow())
     aOverflowCont->AddStateBits(NS_FRAME_IS_DIRTY);
 
   // It's in our list, just step forward
   StepForward();
   NS_ASSERTION(mPrevOverflowCont == aOverflowCont ||
                (mSkipOverflowContainerChildren &&
                 (mPrevOverflowCont->GetStateBits() & NS_FRAME_OUT_OF_FLOW) !=
                 (aOverflowCont->GetStateBits() & NS_FRAME_OUT_OF_FLOW)),
--- a/layout/generic/nsContainerFrame.h
+++ b/layout/generic/nsContainerFrame.h
@@ -372,17 +372,17 @@ public:
    * width and horizontal position from their prev-in-flow.
    *
    * This method
    *   1. Pulls excess overflow containers from the prev-in-flow and adds
    *      them to our overflow container list
    *   2. Reflows all our overflow container kids
    *   3. Expands aOverflowRect as necessary to accomodate these children.
    *   4. Sets aStatus's mOverflowIncomplete flag (along with
-   *      NS_FRAME_REFLOW_NEXTINFLOW as necessary) if any overflow children
+   *      mNextInFlowNeedsReflow as necessary) if any overflow children
    *      are incomplete and
    *   5. Prepends a list of their continuations to our excess overflow
    *      container list, to be drained into our next-in-flow when it is
    *      reflowed.
    *
    * The caller is responsible for tracking any new overflow container
    * continuations it makes, removing them from its child list, and
    * making sure they are stored properly in the overflow container lists.
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -10336,17 +10336,17 @@ void
 nsFrame::Trace(const char* aMethod, bool aEnter, nsReflowStatus aStatus)
 {
   if (NS_FRAME_LOG_TEST(sFrameLogModule, NS_FRAME_TRACE_CALLS)) {
     char tagbuf[40];
     GetTagName(this, mContent, sizeof(tagbuf), tagbuf);
     PR_LogPrint("%s: %s %s, status=%scomplete%s",
                 tagbuf, aEnter ? "enter" : "exit", aMethod,
                 aStatus.IsIncomplete() ? "not" : "",
-                (aStatus & NS_FRAME_REFLOW_NEXTINFLOW) ? "+reflow" : "");
+                (aStatus.NextInFlowNeedsReflow()) ? "+reflow" : "");
   }
 }
 
 void
 nsFrame::TraceMsg(const char* aFormatString, ...)
 {
   if (NS_FRAME_LOG_TEST(sFrameLogModule, NS_FRAME_TRACE_CALLS)) {
     // Format arguments into a buffer
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -5513,17 +5513,17 @@ nsGridContainerFrame::ReflowInFragmentai
     }
   }
 
   // If we can't fit all rows then we're at least overflow-incomplete.
   if (endRow < numRows) {
     childAvailableSize = bEndRow;
     if (aStatus.IsComplete()) {
       aStatus.SetOverflowIncomplete();
-      aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+      aStatus.SetNextInFlowNeedsReflow();
     }
   } else {
     // Children always have the full size of the rows in this fragment.
     childAvailableSize = std::max(childAvailableSize, bEndRow);
   }
 
   return ReflowRowsInFragmentainer(aState, aContentArea, aDesiredSize, aStatus,
                                    aFragmentainer, aContainerSize, sortedItems,
@@ -5699,17 +5699,17 @@ nsGridContainerFrame::ReflowRowsInFragme
     }
   }
 
   if (!pushedItems.IsEmpty() ||
       !incompleteItems.IsEmpty() ||
       !overflowIncompleteItems.IsEmpty()) {
     if (aStatus.IsComplete()) {
       aStatus.SetOverflowIncomplete();
-      aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+      aStatus.SetNextInFlowNeedsReflow();
     }
     // Iterate the children in normal document order and append them (or a NIF)
     // to one of the following frame lists according to their status.
     nsFrameList pushedList;
     nsFrameList incompleteList;
     nsFrameList overflowIncompleteList;
     auto* pc = PresContext();
     auto* fc = pc->PresShell()->FrameConstructor();
@@ -6169,17 +6169,17 @@ nsGridContainerFrame::Reflow(nsPresConte
   aDesiredSize.SetSize(wm, desiredSize);
   nsRect frameRect(0, 0, aDesiredSize.Width(), aDesiredSize.Height());
   aDesiredSize.mOverflowAreas.UnionAllWith(frameRect);
 
   // Convert INCOMPLETE -> OVERFLOW_INCOMPLETE and zero bsize if we're an OC.
   if (HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER)) {
     if (!aStatus.IsComplete()) {
       aStatus.SetOverflowIncomplete();
-      aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
+      aStatus.SetNextInFlowNeedsReflow();
     }
     bSize = 0;
     desiredSize.BSize(wm) = bSize + bp.BStartEnd(wm);
     aDesiredSize.SetSize(wm, desiredSize);
   }
 
   if (!gridReflowInput.mInFragmentainer) {
     MOZ_ASSERT(gridReflowInput.mIter.IsValid());
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -190,42 +190,31 @@ enum nsSpread {
   eSpreadDown   = 2
 };
 
 // Carried out margin flags
 #define NS_CARRIED_TOP_MARGIN_IS_AUTO    0x1
 #define NS_CARRIED_BOTTOM_MARGIN_IS_AUTO 0x2
 
 //----------------------------------------------------------------------
-
-/**
- * NS_FRAME_REFLOW_NEXTINFLOW bit flag means that the next-in-flow is
- * dirty, and also needs to be reflowed. This status only makes sense
- * for a frame that is not complete, i.e. you wouldn't set both
- * NS_FRAME_COMPLETE and NS_FRAME_REFLOW_NEXTINFLOW.
- *
- * The low 8 bits of the nsReflowStatus are reserved for future extensions;
- * the remaining 24 bits are zero (and available for extensions; however
- * API's that accept/return nsReflowStatus must not receive/return any
- * extension bits).
- */
-
 // Reflow status returned by the Reflow() methods.
 class nsReflowStatus final {
 public:
   nsReflowStatus()
     : mStatus(0)
     , mIncomplete(false)
     , mOverflowIncomplete(false)
+    , mNextInFlowNeedsReflow(false)
   {}
 
   // Reset all the bit-fields.
   void Reset() {
     mIncomplete = false;
     mOverflowIncomplete = false;
+    mNextInFlowNeedsReflow = false;
   }
 
   nsReflowStatus(uint32_t aStatus)
     : mStatus(aStatus)
   {}
 
   uint32_t& operator=(uint32_t aRhs) {
     mStatus = aRhs;
@@ -285,22 +274,30 @@ public:
     mIncomplete = true;
     mOverflowIncomplete = false;
   }
   void SetOverflowIncomplete() {
     mIncomplete = false;
     mOverflowIncomplete = true;
   }
 
+  // mNextInFlowNeedsReflow bit flag means that the next-in-flow is dirty,
+  // and also needs to be reflowed. This status only makes sense for a frame
+  // that is not complete, i.e. you wouldn't set mNextInFlowNeedsReflow when
+  // IsComplete() is true.
+  bool NextInFlowNeedsReflow() const { return mNextInFlowNeedsReflow; }
+  void SetNextInFlowNeedsReflow() { mNextInFlowNeedsReflow = true; }
+
 private:
   uint32_t mStatus;
 
   // Frame completion status bit flags.
   bool mIncomplete : 1;
   bool mOverflowIncomplete : 1;
+  bool mNextInFlowNeedsReflow : 1;
 };
 
 #define NS_FRAME_COMPLETE             0       // Note: not a bit!
 #define NS_FRAME_NOT_COMPLETE         0x1
 #define NS_FRAME_REFLOW_NEXTINFLOW    0x2
 #define NS_FRAME_OVERFLOW_INCOMPLETE  0x4
 
 // This bit is set, when a break is requested. This bit is orthogonal