Bug 846575: Clean up nsColumnSetFrame by adding an isBalancing convenience member to ReflowConfig. [r=fantasai]
authorScott Johnson <sjohnson@mozilla.com>
Fri, 08 Mar 2013 09:43:46 -0600
changeset 124220 31823d274fd163793ac64463103d10370b531c37
parent 124219 2c4a8bdb41eb8b2b03ac1e624c78fe2cbbcda0cb
child 124221 40dff07b49f5c794c26be24ca73d0c94b73125da
push id24296
push usersjohnson@mozilla.com
push dateFri, 08 Mar 2013 15:43:59 +0000
treeherdermozilla-inbound@31823d274fd1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfantasai
bugs846575
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 846575: Clean up nsColumnSetFrame by adding an isBalancing convenience member to ReflowConfig. [r=fantasai]
layout/generic/nsColumnSetFrame.cpp
--- a/layout/generic/nsColumnSetFrame.cpp
+++ b/layout/generic/nsColumnSetFrame.cpp
@@ -94,16 +94,17 @@ protected:
    * These are the parameters that control the layout of columns.
    */
   struct ReflowConfig {
     int32_t mBalanceColCount;
     nscoord mColWidth;
     nscoord mExpectedWidthLeftOver;
     nscoord mColGap;
     nscoord mColMaxHeight;
+    bool mIsBalancing;
   };
 
   /**
    * Some data that is better calculated during reflow
    */
   struct ColumnBalanceData {
     // The maximum "content height" of any column
     nscoord mMaxHeight;
@@ -428,17 +429,18 @@ nsColumnSetFrame::ChooseColumnStrategy(c
     //            change this value to match the appropriate spec(s).
     colHeight = std::max(colHeight, nsPresContext::CSSPixelsToAppUnits(1));
   }
 
 #ifdef DEBUG_roc
   printf("*** nsColumnSetFrame::ChooseColumnStrategy: numColumns=%d, colWidth=%d, expectedWidthLeftOver=%d, colHeight=%d, colGap=%d\n",
          numColumns, colWidth, expectedWidthLeftOver, colHeight, colGap);
 #endif
-  ReflowConfig config = { numColumns, colWidth, expectedWidthLeftOver, colGap, colHeight };
+  ReflowConfig config = { numColumns, colWidth, expectedWidthLeftOver, colGap,
+                          colHeight, isBalancing };
   return config;
 }
 
 // XXX copied from nsBlockFrame, should this be moved to nsContainerFrame?
 static void
 PlaceFrameView(nsIFrame* aFrame)
 {
   if (aFrame->HasView())
@@ -907,46 +909,45 @@ nsColumnSetFrame::Reflow(nsPresContext* 
   }
   else {
     RemoveStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT);
   }
 
   //------------ Handle Incremental Reflow -----------------
 
   ReflowConfig config = ChooseColumnStrategy(aReflowState);
-  bool isBalancing = config.mBalanceColCount < INT32_MAX;
   
   // If balancing, then we allow the last column to grow to unbounded
   // height during the first reflow. This gives us a way to estimate
   // what the average column height should be, because we can measure
   // the heights of all the columns and sum them up. But don't do this
   // if we have a next in flow because we don't want to suck all its
   // content back here and then have to push it out again!
   nsIFrame* nextInFlow = GetNextInFlow();
-  bool unboundedLastColumn = isBalancing && !nextInFlow;
+  bool unboundedLastColumn = config.mIsBalancing && !nextInFlow;
   nsCollapsingMargin carriedOutBottomMargin;
   ColumnBalanceData colData;
   colData.mShouldRevertToAuto = false;
 
   // This loop exists in order to try balancing initially. If the balancing
   // overflows, then we want to revert to column-fill: auto.
 
   // Our loop invariant is: colData.mShouldRevertToAuto is true if and only
   // if we've reflowed our children, and during the most recent reflow of
   // children, we were balancing and we overflowed in the block direction.
   do {
     if (colData.mShouldRevertToAuto) {
       config = ChooseColumnStrategy(aReflowState, true);
-      isBalancing = false;
+      config.mIsBalancing = false;
     }
 
     bool feasible = ReflowChildren(aDesiredSize, aReflowState,
       aStatus, config, unboundedLastColumn, &carriedOutBottomMargin, colData);
 
-    if (isBalancing && !aPresContext->HasPendingInterrupt()) {
+    if (config.mIsBalancing && !aPresContext->HasPendingInterrupt()) {
       nscoord availableContentHeight = GetAvailableContentHeight(aReflowState);
 
       // Termination of the algorithm below is guaranteed because
       // knownFeasibleHeight - knownInfeasibleHeight decreases in every
       // iteration.
       nscoord knownFeasibleHeight = NS_INTRINSICSIZE;
       nscoord knownInfeasibleHeight = 0;
       // We set this flag when we detect that we may contain a frame