Bug 1348857 part 2 - [css-grid] Propagate the ApplyAutoMinSize bit to nsFrame::ComputeSize (idempotent patch). r=dholbert a=gchang
authorMats Palmgren <mats@mozilla.com>
Tue, 18 Apr 2017 22:35:04 +0200
changeset 395992 20cc389b33bd8a4e80b253a14b7ee27e61f5acfa
parent 395991 0065e54275aa65e9718c7a67db5c002b9605e8af
child 395993 9019477162f6cc7070975ee16327729abeb7eecd
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, gchang
bugs1348857
milestone54.0
Bug 1348857 part 2 - [css-grid] Propagate the ApplyAutoMinSize bit to nsFrame::ComputeSize (idempotent patch). r=dholbert a=gchang MozReview-Commit-ID: DBU4hDfCAdE
layout/generic/ReflowInput.cpp
layout/generic/ReflowInput.h
layout/generic/nsGridContainerFrame.cpp
layout/generic/nsIFrame.h
--- a/layout/generic/ReflowInput.cpp
+++ b/layout/generic/ReflowInput.cpp
@@ -88,16 +88,19 @@ ReflowInput::ReflowInput(nsPresContext* 
     mFlags.mStaticPosIsCBOrigin = true;
   }
   if (aFlags & I_CLAMP_MARGIN_BOX_MIN_SIZE) {
     mFlags.mIClampMarginBoxMinSize = true;
   }
   if (aFlags & B_CLAMP_MARGIN_BOX_MIN_SIZE) {
     mFlags.mBClampMarginBoxMinSize = true;
   }
+  if (aFlags & I_APPLY_AUTO_MIN_SIZE) {
+    mFlags.mApplyAutoMinSize = true;
+  }
 
   if (!(aFlags & CALLER_WILL_INIT)) {
     Init(aPresContext);
   }
 }
 
 static bool CheckNextInFlowParenthood(nsIFrame* aFrame, nsIFrame* aParent)
 {
@@ -237,16 +240,17 @@ ReflowInput::ReflowInput(
   mFlags.mIsFlexContainerMeasuringHeight = false;
   mFlags.mDummyParentReflowInput = false;
   mFlags.mShrinkWrap = !!(aFlags & COMPUTE_SIZE_SHRINK_WRAP);
   mFlags.mUseAutoBSize = !!(aFlags & COMPUTE_SIZE_USE_AUTO_BSIZE);
   mFlags.mStaticPosIsCBOrigin = !!(aFlags & STATIC_POS_IS_CB_ORIGIN);
   mFlags.mIOffsetsNeedCSSAlign = mFlags.mBOffsetsNeedCSSAlign = false;
   mFlags.mIClampMarginBoxMinSize = !!(aFlags & I_CLAMP_MARGIN_BOX_MIN_SIZE);
   mFlags.mBClampMarginBoxMinSize = !!(aFlags & B_CLAMP_MARGIN_BOX_MIN_SIZE);
+  mFlags.mApplyAutoMinSize = !!(aFlags & I_APPLY_AUTO_MIN_SIZE);
 
   mDiscoveredClearance = nullptr;
   mPercentBSizeObserver = (aParentReflowInput.mPercentBSizeObserver &&
                             aParentReflowInput.mPercentBSizeObserver->NeedsToObserve(*this))
                            ? aParentReflowInput.mPercentBSizeObserver : nullptr;
 
   if ((aFlags & DUMMY_PARENT_REFLOW_STATE) ||
       (mParentReflowInput->mFlags.mDummyParentReflowInput &&
@@ -1658,16 +1662,20 @@ ReflowInput::InitAbsoluteConstraints(nsP
   if (mFlags.mIClampMarginBoxMinSize) {
     computeSizeFlags = ComputeSizeFlags(computeSizeFlags |
                          ComputeSizeFlags::eIClampMarginBoxMinSize);
   }
   if (mFlags.mBClampMarginBoxMinSize) {
     computeSizeFlags = ComputeSizeFlags(computeSizeFlags |
                          ComputeSizeFlags::eBClampMarginBoxMinSize);
   }
+  if (mFlags.mApplyAutoMinSize) {
+    computeSizeFlags = ComputeSizeFlags(computeSizeFlags |
+                         ComputeSizeFlags::eIApplyAutoMinSize);
+  }
   if (mFlags.mShrinkWrap) {
     computeSizeFlags =
       ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
   }
   if (mFlags.mUseAutoBSize) {
     computeSizeFlags =
       ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eUseAutoBSize);
   }
@@ -2371,16 +2379,20 @@ ReflowInput::InitConstraints(nsPresConte
       if (mFlags.mIClampMarginBoxMinSize) {
         computeSizeFlags = ComputeSizeFlags(computeSizeFlags |
                              ComputeSizeFlags::eIClampMarginBoxMinSize);
       }
       if (mFlags.mBClampMarginBoxMinSize) {
         computeSizeFlags = ComputeSizeFlags(computeSizeFlags |
                              ComputeSizeFlags::eBClampMarginBoxMinSize);
       }
+      if (mFlags.mApplyAutoMinSize) {
+        computeSizeFlags = ComputeSizeFlags(computeSizeFlags |
+                             ComputeSizeFlags::eIApplyAutoMinSize);
+      }
       if (mFlags.mShrinkWrap) {
         computeSizeFlags =
           ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
       }
       if (mFlags.mUseAutoBSize) {
         computeSizeFlags =
           ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eUseAutoBSize);
       }
--- a/layout/generic/ReflowInput.h
+++ b/layout/generic/ReflowInput.h
@@ -215,16 +215,17 @@ public:
                                         // but its in a paginated environment
                                         // (e.g. columns), it should always
                                         // reflow its placeholder children.
     bool mShrinkWrap : 1; // stores the COMPUTE_SIZE_SHRINK_WRAP ctor flag
     bool mUseAutoBSize : 1; // stores the COMPUTE_SIZE_USE_AUTO_BSIZE ctor flag
     bool mStaticPosIsCBOrigin : 1; // the STATIC_POS_IS_CB_ORIGIN ctor flag
     bool mIClampMarginBoxMinSize : 1; // the I_CLAMP_MARGIN_BOX_MIN_SIZE ctor flag
     bool mBClampMarginBoxMinSize : 1; // the B_CLAMP_MARGIN_BOX_MIN_SIZE ctor flag
+    bool mApplyAutoMinSize : 1;       // the I_APPLY_AUTO_MIN_SIZE ctor flag
 
     // If set, the following two flags indicate that:
     // (1) this frame is absolutely-positioned (or fixed-positioned).
     // (2) this frame's static position depends on the CSS Box Alignment.
     // (3) we do need to compute the static position, because the frame's
     //     {Inline and/or Block} offsets actually depend on it.
     // When these bits are set, the offset values (IStart/IEnd, BStart/BEnd)
     // represent the "start" edge of the frame's CSS Box Alignment container
@@ -734,16 +735,19 @@ public:
     // for the frame in question.)
     STATIC_POS_IS_CB_ORIGIN = (1<<4),
 
     // Pass ComputeSizeFlags::eIClampMarginBoxMinSize to ComputeSize().
     I_CLAMP_MARGIN_BOX_MIN_SIZE = (1<<5),
 
     // Pass ComputeSizeFlags::eBClampMarginBoxMinSize to ComputeSize().
     B_CLAMP_MARGIN_BOX_MIN_SIZE = (1<<6),
+
+    // Pass ComputeSizeFlags::eIApplyAutoMinSize to ComputeSize().
+    I_APPLY_AUTO_MIN_SIZE = (1<<7),
   };
 
   // This method initializes various data members. It is automatically
   // called by the various constructors
   void Init(nsPresContext*              aPresContext,
             const mozilla::LogicalSize* aContainingBlockSize = nullptr,
             const nsMargin*             aBorder = nullptr,
             const nsMargin*             aPadding = nullptr);
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -5252,16 +5252,19 @@ nsGridContainerFrame::ReflowInFlowChild(
     auto childBAxis = GetOrthogonalAxis(childIAxis);
     if (aGridItemInfo->mState[childBAxis] & ItemState::eClampMarginBoxMinSize) {
       flags |= ReflowInput::B_CLAMP_MARGIN_BOX_MIN_SIZE;
       aChild->Properties().Set(BClampMarginBoxMinSizeProperty(),
                                childCBSize.BSize(childWM));
     } else {
       aChild->Properties().Delete(BClampMarginBoxMinSizeProperty());
     }
+    if ((aGridItemInfo->mState[childIAxis] & ItemState::eApplyAutoMinSize)) {
+      flags |= ReflowInput::I_APPLY_AUTO_MIN_SIZE;
+    }
   }
 
   if (!isConstrainedBSize) {
     childCBSize.BSize(childWM) = NS_UNCONSTRAINEDSIZE;
   }
   LogicalSize percentBasis(cb.Size(wm).ConvertTo(childWM, wm));
   ReflowInput childRI(pc, *aState.mReflowInput, aChild, childCBSize,
                       &percentBasis, flags);
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2205,16 +2205,24 @@ public:
     eUseAutoBSize =      1 << 1,
     /**
      * Indicates that we should clamp the margin-box min-size to the given CB
      * size.  This is used for implementing the grid area clamping here:
      * https://drafts.csswg.org/css-grid/#min-size-auto
      */
     eIClampMarginBoxMinSize = 1 << 2, // clamp in our inline axis
     eBClampMarginBoxMinSize = 1 << 3, // clamp in our block axis
+    /**
+     * The frame is stretching (per CSS Box Alignment) and doesn't have an
+     * Automatic Minimum Size in the indicated axis.
+     * (may be used for both flex/grid items, but currently only used for Grid)
+     * https://drafts.csswg.org/css-grid/#min-size-auto
+     * https://drafts.csswg.org/css-align-3/#valdef-justify-self-stretch
+     */
+    eIApplyAutoMinSize = 1 << 4, // only has an effect when eShrinkWrap is false
   };
 
   /**
    * Compute the size that a frame will occupy.  Called while
    * constructing the ReflowInput to be used to Reflow the frame,
    * in order to fill its mComputedWidth and mComputedHeight member
    * variables.
    *