Bug 1501145 Part 1 - Assign default values to ReflowConfig fields, and explicitly initialize them in ChooseColumnStrategy. r=mats
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 23 Oct 2018 13:08:59 +0000
changeset 490959 aa716a3cae86d41a1e40b1068549de2f303d2be8
parent 490958 4e9062d05672fe1494fb5562ba3726fa57d269ff
child 490960 fb761199e41a36b3adee582df40508acebca25c8
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersmats
bugs1501145
milestone65.0a1
Bug 1501145 Part 1 - Assign default values to ReflowConfig fields, and explicitly initialize them in ChooseColumnStrategy. r=mats The original statement is neat, but one cannot easily associates the values computed in ChooseColumnStrategy with the actually field name in ReflowConfig. Remove the aFeasibleBSize and aInfeasibleBSize for ChooseColumnStrategy() because they're not used. Differential Revision: https://phabricator.services.mozilla.com/D9467
layout/generic/nsColumnSetFrame.cpp
layout/generic/nsColumnSetFrame.h
--- a/layout/generic/nsColumnSetFrame.cpp
+++ b/layout/generic/nsColumnSetFrame.cpp
@@ -310,22 +310,18 @@ nsColumnSetFrame::ClampUsedColumnWidth(c
              "This should only be called when column-width is a <length>!");
 
   // Per spec, used values will be clamped to a minimum of 1px.
   return std::max(CSSPixel::ToAppUnits(1), aColumnWidth.GetCoordValue());
 }
 
 nsColumnSetFrame::ReflowConfig
 nsColumnSetFrame::ChooseColumnStrategy(const ReflowInput& aReflowInput,
-                                       bool aForceAuto = false,
-                                       nscoord aFeasibleBSize = NS_INTRINSICSIZE,
-                                       nscoord aInfeasibleBSize = 0)
+                                       bool aForceAuto = false)
 {
-  nscoord knownFeasibleBSize = aFeasibleBSize;
-  nscoord knownInfeasibleBSize = aInfeasibleBSize;
   WritingMode wm = aReflowInput.GetWritingMode();
 
   const nsStyleColumn* colStyle = StyleColumn();
   nscoord availContentISize = GetAvailableContentISize(aReflowInput);
   if (aReflowInput.ComputedISize() != NS_INTRINSICSIZE) {
     availContentISize = aReflowInput.ComputedISize();
   }
 
@@ -451,19 +447,28 @@ nsColumnSetFrame::ChooseColumnStrategy(c
                  " colBSize=%d, colGap=%d",
                  __func__,
                  numColumns,
                  colISize,
                  expectedISizeLeftOver,
                  colBSize,
                  colGap);
 
-  ReflowConfig config = { numColumns, colISize, expectedISizeLeftOver, colGap,
-                          colBSize, isBalancing, knownFeasibleBSize,
-                          knownInfeasibleBSize, computedBSize, consumedBSize };
+  ReflowConfig config;
+  config.mBalanceColCount = numColumns;
+  config.mColISize = colISize;
+  config.mExpectedISizeLeftOver = expectedISizeLeftOver;
+  config.mColGap = colGap;
+  config.mColMaxBSize = colBSize;
+  config.mIsBalancing = isBalancing;
+  config.mKnownFeasibleBSize = NS_INTRINSICSIZE;
+  config.mKnownInfeasibleBSize = 0;
+  config.mComputedBSize = computedBSize;
+  config.mConsumedBSize = consumedBSize;
+
   return config;
 }
 
 static void
 MarkPrincipalChildrenDirty(nsIFrame* aFrame)
 {
   for (nsIFrame* childFrame : aFrame->PrincipalChildList()) {
     childFrame->AddStateBits(NS_FRAME_IS_DIRTY);
--- a/layout/generic/nsColumnSetFrame.h
+++ b/layout/generic/nsColumnSetFrame.h
@@ -97,52 +97,52 @@ protected:
   nsReflowStatus mLastFrameStatus;
 
   /**
    * These are the parameters that control the layout of columns.
    */
   struct ReflowConfig {
     // The number of columns that we want to balance across. If we're not
     // balancing, this will be set to INT32_MAX.
-    int32_t mBalanceColCount;
+    int32_t mBalanceColCount = INT32_MAX;
 
     // The inline-size of each individual column.
-    nscoord mColISize;
+    nscoord mColISize = NS_INTRINSICSIZE;
 
     // The amount of inline-size that is expected to be left over after all the
     // columns and column gaps are laid out.
-    nscoord mExpectedISizeLeftOver;
+    nscoord mExpectedISizeLeftOver = 0;
 
     // The width (inline-size) of each column gap.
-    nscoord mColGap;
+    nscoord mColGap = NS_INTRINSICSIZE;
 
     // The maximum bSize of any individual column during a reflow iteration.
     // This parameter is set during each iteration of the binary search for
     // the best column block-size.
-    nscoord mColMaxBSize;
+    nscoord mColMaxBSize = NS_INTRINSICSIZE;
 
     // A boolean controlling whether or not we are balancing. This should be
     // equivalent to mBalanceColCount == INT32_MAX.
-    bool mIsBalancing;
+    bool mIsBalancing = false;
 
     // The last known column block-size that was 'feasible'. A column bSize is
     // feasible if all child content fits within the specified bSize.
-    nscoord mKnownFeasibleBSize;
+    nscoord mKnownFeasibleBSize = NS_INTRINSICSIZE;
 
     // The last known block-size that was 'infeasible'. A column bSize is
     // infeasible if not all child content fits within the specified bSize.
-    nscoord mKnownInfeasibleBSize;
+    nscoord mKnownInfeasibleBSize = 0;
 
     // block-size of the column set frame
-    nscoord mComputedBSize;
+    nscoord mComputedBSize = NS_INTRINSICSIZE;
 
     // The block-size "consumed" by previous-in-flows.
     // The computed block-size should be equal to the block-size of the element
     // (i.e. the computed block-size itself) plus the consumed block-size.
-    nscoord mConsumedBSize;
+    nscoord mConsumedBSize = 0;
   };
 
   /**
    * Some data that is better calculated during reflow
    */
   struct ColumnBalanceData {
     // The maximum "content block-size" of any column
     nscoord mMaxBSize;
@@ -175,18 +175,17 @@ protected:
   /**
    * The basic reflow strategy is to call this function repeatedly to
    * obtain specific parameters that determine the layout of the
    * columns. This function will compute those parameters from the CSS
    * style. This function will also be responsible for implementing
    * the state machine that controls column balancing.
    */
   ReflowConfig ChooseColumnStrategy(const ReflowInput& aReflowInput,
-                                    bool aForceAuto, nscoord aFeasibleBSize,
-                                    nscoord aInfeasibleBSize);
+                                    bool aForceAuto);
 
   /**
    * Perform the binary search for the best balance height for this column set.
    *
    * @param aReflowInput The input parameters for the current reflow iteration.
    * @param aPresContext The presentation context in which the current reflow
    *        iteration is occurring.
    * @param aConfig The ReflowConfig object associated with this column set