Bug 1228455 - [css-grid] Update the 'used flex fraction' for indefinite sizes to clamp flex factors less than 1 before dividing the base size (due to CSS Grid spec change). r=dholbert
authorMats Palmgren <mats@mozilla.com>
Thu, 27 Oct 2016 10:32:00 -0400
changeset 319973 c9847c40b56c88a4dad6c5d43db002b597dd694b
parent 319972 35b7ac956b896839e669a1a8aecc1ff063449aa3
child 319974 e22d4c0e0f9dfa9e20f6452276c14d5faa84d2ef
push id83287
push userryanvm@gmail.com
push dateFri, 28 Oct 2016 19:33:32 +0000
treeherdermozilla-inbound@f4459d4ba9ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1228455
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 1228455 - [css-grid] Update the 'used flex fraction' for indefinite sizes to clamp flex factors less than 1 before dividing the base size (due to CSS Grid spec change). r=dholbert CSS Grid spec change: https://hg.csswg.org/drafts/rev/42427088d71f
layout/generic/nsGridContainerFrame.cpp
layout/reftests/css-grid/grid-max-sizing-flex-007.html
layout/reftests/css-grid/grid-max-sizing-flex-008-ref.html
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -4666,23 +4666,25 @@ nsGridContainerFrame::Tracks::FindUsedFl
 {
   if (aAvailableSize != NS_UNCONSTRAINEDSIZE) {
     // Use all of the grid tracks and a 'space to fill' of the available space.
     const TranslatedLineRange range(0, mSizes.Length());
     return FindFrUnitSize(range, aFlexTracks, aFunctions, aAvailableSize);
   }
 
   // The used flex fraction is the maximum of:
-  // ... each flexible track's base size divided by its flex factor
+  // ... each flexible track's base size divided by its flex factor (which is
+  // floored at 1).
   float fr = 0.0f;
   for (uint32_t track : aFlexTracks) {
     float flexFactor = aFunctions.MaxSizingFor(track).GetFlexFractionValue();
-    if (flexFactor > 0.0f) {
-      fr = std::max(fr, mSizes[track].mBase / flexFactor);
-    }
+    float possiblyDividedBaseSize = (flexFactor > 1.0f)
+      ? mSizes[track].mBase / flexFactor
+      : mSizes[track].mBase;
+    fr = std::max(fr, possiblyDividedBaseSize);
   }
   WritingMode wm = aState.mWM;
   nsRenderingContext* rc = &aState.mRenderingContext;
   GridItemCSSOrderIterator& iter = aState.mIter;
   iter.Reset();
   // ... the result of 'finding the size of an fr' for each item that spans
   // a flex track with its max-content contribution as 'space to fill'
   for (; !iter.AtEnd(); iter.Next()) {
--- a/layout/reftests/css-grid/grid-max-sizing-flex-007.html
+++ b/layout/reftests/css-grid/grid-max-sizing-flex-007.html
@@ -12,22 +12,22 @@
   <style type="text/css">
 .grid {
    display: grid;
    border:1px dashed;
    margin: 3px;
 }
 .rows {
    float: left;
-   grid: minmax(10px, 0.5fr) minmax(10px, 2fr) / 50px;
+   grid: minmax(10px, 1fr) minmax(10px, 4fr) / 50px;
    grid-row-gap: 33px;
 }
 .cols {
    display: inline-grid;
-   grid: 50px / minmax(10px, 0.5fr) minmax(10px, 2fr);
+   grid: 50px / minmax(10px, 1fr) minmax(10px, 4fr);
    grid-column-gap: 33px;
 }
 
 .item:nth-child(1) { background-color: purple; }
 .item:nth-child(2) { background-color: blue; }
 
 </style>
 
--- a/layout/reftests/css-grid/grid-max-sizing-flex-008-ref.html
+++ b/layout/reftests/css-grid/grid-max-sizing-flex-008-ref.html
@@ -53,17 +53,17 @@
 </div>
 </div>
 <div style="height:100px; margin-bottom:-100px">
   <div class="grid rows">
     <div class="item"></div>
     <div class="item"></div>
   </div>
 </div>
-<div style="display:inline-block; width:100px; margin-right:-9px">
+<div style="display:inline-block; width:73px; margin-right:-2px">
   <div class="grid cols">
     <div class="item"></div>
     <div class="item"></div>
   </div>
 </div>
 <div class="grid cols-min" style="width:53px">
   <div class="item"></div>
   <div class="item"></div>