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 347960 1354f15ccab53581cd3d6ce25d625f2a8b09ff01
parent 347959 fb521e9bf8f8adc6631ea272669bb43999658b0b
child 347961 5eed1210b69a03c364741fa7b35107703e1114c2
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1314206
milestone52.0a1
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 &&