Bug 1315383 part 2 - [css-grid] Make Automatic Minimum Size clamping preserve the intrinsic ratio, unless either axis has 'stretch'. r=dholbert
authorMats Palmgren <mats@mozilla.com>
Fri, 11 Nov 2016 18:28:43 +0100
changeset 352307 54aa92ad290b119b8a95f4fcf832b019e6ab92ec
parent 352306 5c299f308a1dc2d30e07a85bc3b9ba9313b2f237
child 352308 cffc5238b6a0c5e89f5cfc7e695a86b598c302d9
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1315383
milestone52.0a1
Bug 1315383 part 2 - [css-grid] Make Automatic Minimum Size clamping preserve the intrinsic ratio, unless either axis has 'stretch'. r=dholbert
layout/generic/nsFrame.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -5164,32 +5164,36 @@ nsFrame::ComputeSizeWithIntrinsicDimensi
         tentISize = NSCoordMulDiv(intrinsicBSize, logicalRatio.ISize(aWM), logicalRatio.BSize(aWM));
       } else if (logicalRatio.ISize(aWM) > 0) {
         tentISize = aCBSize.ISize(aWM) - boxSizingToMarginEdgeISize; // XXX scrollbar?
         if (tentISize < 0) tentISize = 0;
       } else {
         tentISize = nsPresContext::CSSPixelsToAppUnits(300);
       }
 
+      // If we need to clamp the inline size to fit the CB, we use the 'stretch'
+      // or 'normal' codepath.  We use the ratio-preserving 'normal' codepath
+      // unless we have 'stretch' in the other axis.
       if ((aFlags & ComputeSizeFlags::eIClampMarginBoxMinSize) &&
-          tentISize > iSize) {
-        stretchI = eStretch;
+          stretchI != eStretch && tentISize > iSize) {
+        stretchI = (stretchB == eStretch ? eStretch : eStretchPreservingRatio);
       }
 
       if (hasIntrinsicBSize) {
         tentBSize = intrinsicBSize;
       } else if (logicalRatio.ISize(aWM) > 0) {
         tentBSize = NSCoordMulDiv(tentISize, logicalRatio.BSize(aWM), logicalRatio.ISize(aWM));
       } else {
         tentBSize = nsPresContext::CSSPixelsToAppUnits(150);
       }
 
+      // (ditto the comment about clamping the inline size above)
       if ((aFlags & ComputeSizeFlags::eBClampMarginBoxMinSize) &&
-          tentBSize > bSize) {
-        stretchB = eStretch;
+          stretchB != eStretch && tentBSize > bSize) {
+        stretchB = (stretchI == eStretch ? eStretch : eStretchPreservingRatio);
       }
 
       if (aIntrinsicRatio != nsSize(0, 0)) {
         if (stretchI == eStretch) {
           tentISize = iSize;  // * / 'stretch'
           if (stretchB == eStretch) {
             tentBSize = bSize;  // 'stretch' / 'stretch'
           } else if (stretchB == eStretchPreservingRatio && logicalRatio.ISize(aWM) > 0) {