Bug 1462854 part 2 - [css-grid] Handle [max-]width/height percentages in min-size contributions according to spec. r=dholbert
authorMats Palmgren <mats@mozilla.com>
Sat, 02 Jun 2018 00:08:26 +0200
changeset 420955 547112cf70032742672310176b0b879f2e177c55
parent 420954 34278b2ad4b9ac1fdd074a573baab1c6db013ca3
child 420956 55e6a68a50561a86d2fee9b56626a9b04930c9fd
push id34083
push userapavel@mozilla.com
push dateSat, 02 Jun 2018 23:03:25 +0000
treeherdermozilla-central@1f62ecdf59b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1462854, 1463700
milestone62.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 1462854 part 2 - [css-grid] Handle [max-]width/height percentages in min-size contributions according to spec. r=dholbert Background: https://github.com/w3c/csswg-drafts/issues/2674 calc() percentages for replaced boxes are still not according to spec. Bug 1463700 will fix that.
layout/base/nsLayoutUtils.cpp
layout/generic/nsGridContainerFrame.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -5524,16 +5524,22 @@ nsLayoutUtils::MinSizeContributionForAxi
   if (minSizeUnit == eStyleUnit_Auto) {
     if (aFrame->StyleDisplay()->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE) {
       style = aAxis == eAxisHorizontal ? &stylePos->mWidth
                                        : &stylePos->mHeight;
       if (GetAbsoluteCoord(*style, minSize)) {
         // We have a definite width/height.  This is the "specified size" in:
         // https://drafts.csswg.org/css-grid/#min-size-auto
         fixedMinSize = &minSize;
+      } else if (::IsReplacedBoxResolvedAgainstZero(aFrame, *style,
+                     eAxisHorizontal ? stylePos->mMaxWidth
+                                     : stylePos->mMaxHeight)) {
+        // XXX bug 1463700: this doesn't handle calc() according to spec
+        minSize = 0;
+        fixedMinSize = &minSize;
       }
       // fall through - the caller will have to deal with "transferred size"
     } else {
       // min-[width|height]:auto with overflow != visible computes to zero.
       minSize = 0;
       fixedMinSize = &minSize;
     }
   } else if (GetAbsoluteCoord(*style, minSize)) {
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -3710,34 +3710,34 @@ MaxContentContribution(const GridItemInf
                                   aCache->mPercentageBasis,
                                   nsLayoutUtils::PREF_ISIZE,
                                   aCache->mMinSizeClamp);
   aCache->mMaxContentContribution.emplace(s);
   return s;
 }
 
 // Computes the min-size contribution for a grid item, as defined at
-// https://drafts.csswg.org/css-grid/#min-size-contributions
+// https://drafts.csswg.org/css-grid/#min-size-contribution
 static nscoord
 MinSize(const GridItemInfo&    aGridItem,
         const GridReflowInput& aState,
         gfxContext*            aRC,
         WritingMode            aCBWM,
         LogicalAxis            aAxis,
         CachedIntrinsicSizes*  aCache)
 {
   if (aCache->mMinSize.isSome()) {
     return aCache->mMinSize.value();
   }
   nsIFrame* child = aGridItem.mFrame;
   PhysicalAxis axis(aCBWM.PhysicalAxis(aAxis));
   const nsStylePosition* stylePos = child->StylePosition();
   const nsStyleCoord& sizeStyle =
     axis == eAxisHorizontal ? stylePos->mWidth : stylePos->mHeight;
-  if (sizeStyle.GetUnit() != eStyleUnit_Auto) {
+  if (sizeStyle.GetUnit() != eStyleUnit_Auto && !sizeStyle.HasPercent()) {
     nscoord s =
       MinContentContribution(aGridItem, aState, aRC, aCBWM, aAxis, aCache);
     aCache->mMinSize.emplace(s);
     return s;
   }
 
   if (aCache->mPercentageBasis.isNothing()) {
     aCache->mPercentageBasis.emplace(aState.PercentageBasisFor(aAxis, aGridItem));