Bug 1314206 part 1 - [css-grid] Stretch the inline size when requested, unless we're measuring the shrink-wrap size. r=dholbert
authorMats Palmgren <mats@mozilla.com>
Sat, 05 Nov 2016 02:57:08 +0100
changeset 321125 1354f15ccab53581cd3d6ce25d625f2a8b09ff01
parent 321124 fb521e9bf8f8adc6631ea272669bb43999658b0b
child 321126 5eed1210b69a03c364741fa7b35107703e1114c2
push id83532
push usermpalmgren@mozilla.com
push dateSat, 05 Nov 2016 01:57:23 +0000
treeherdermozilla-inbound@253395be59f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1314206
milestone52.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 1314206 part 1 - [css-grid] Stretch the inline size when requested, unless we're measuring the shrink-wrap size. r=dholbert
layout/generic/nsFrame.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -4709,16 +4709,33 @@ nsFrame::ComputeSize(nsRenderingContext*
 
   // Compute inline-axis size
 
   if (inlineStyleCoord->GetUnit() != eStyleUnit_Auto) {
     result.ISize(aWM) =
       ComputeISizeValue(aRenderingContext, aCBSize.ISize(aWM),
                         boxSizingAdjust.ISize(aWM), boxSizingToMarginEdgeISize,
                         *inlineStyleCoord, aFlags);
+  } else if (MOZ_UNLIKELY(isGridItem) &&
+             !IS_TRUE_OVERFLOW_CONTAINER(this)) {
+    if (!(aFlags & nsIFrame::eShrinkWrap) &&
+        !StyleMargin()->HasInlineAxisAuto(aWM)) {
+      // 'auto' inline-size for grid-level box - apply 'stretch' as needed:
+      auto inlineAxisAlignment =
+        aWM.IsOrthogonalTo(GetParent()->GetWritingMode()) ?
+          StylePosition()->UsedAlignSelf(GetParent()->StyleContext()) :
+          StylePosition()->UsedJustifySelf(GetParent()->StyleContext());
+      if (inlineAxisAlignment == NS_STYLE_ALIGN_NORMAL ||
+          inlineAxisAlignment == NS_STYLE_ALIGN_STRETCH) {
+        result.ISize(aWM) = std::max(nscoord(0), aCBSize.ISize(aWM) -
+                                                 aPadding.ISize(aWM) -
+                                                 aBorder.ISize(aWM) -
+                                                 aMargin.ISize(aWM));
+      }
+    }
   }
 
   // Flex items ignore their min & max sizing properties in their
   // flex container's main-axis.  (Those properties get applied later in
   // the flexbox algorithm.)
   const nsStyleCoord& maxISizeCoord = stylePos->MaxISize(aWM);
   nscoord maxISize = NS_UNCONSTRAINEDSIZE;
   if (maxISizeCoord.GetUnit() != eStyleUnit_None &&