Skip to content

Commit 5c66e72

Browse files
committed
[css-flexbox][css-grid] Fix calculation of intrinsic sizes of grid/flex containers when tracks/items flex factors sum to less than one. #1735
1 parent 5de1675 commit 5c66e72

File tree

3 files changed

+53
-11
lines changed

3 files changed

+53
-11
lines changed

css-flexbox/Overview.bs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,9 +2809,18 @@ Flex Container Intrinsic Main Sizes</h4>
28092809
Within each line,
28102810
find the largest <var>max-content flex fraction</var>
28112811
among all the <a>flex items</a>.
2812+
If the sum of the <a>flex grow factors</a>
2813+
(<a>flex shrink factors</a>,
2814+
if the largest <var>max-content flex fraction</var> was negative)
2815+
on that line is less than one,
2816+
divide each <a>flex grow factor</a> (<a>flex shrink factor</a>)
2817+
by that sum to rescale their total to one.
2818+
2819+
<li>
28122820
Add each item’s <a>flex base size</a>
2813-
to the product of its <a>flex grow factor</a>
2814-
(or <a>scaled flex shrink factor</a>, if the chosen <var>max-content flex fraction</var> was negative)
2821+
to the product of its <em>rescaled</em> <a>flex grow factor</a>
2822+
(or <em>rescaled</em> <a>scaled flex shrink factor</a>,
2823+
if the chosen <var>max-content flex fraction</var> was negative)
28152824
and the chosen <var>max-content flex fraction</var>,
28162825
then clamp that result by the <a>max main size property</a>
28172826
floored by the <a>min main size property</a>.

css-flexbox/issues-cr-20160526.bsi

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,10 @@ Issue 42.
392392
Summary: Intrinsic sizing with ∑flex < 1 is broken
393393
From: fantasai
394394
Comment: https://github.com/w3c/csswg-drafts/issues/1735
395-
Open: =WG= Resolve.
395+
Response: https://github.com/w3c/csswg-drafts/issues/1735#issuecomment-329218845
396+
Open: Accepted
396397
Resolved: Bugfix
398+
Verified: =dholbert= Review.
397399
----
398400
Issue 43.
399401
Summary: Rename “Implied Minimum Size” section to “Automatic Minimum Size”
@@ -408,5 +410,13 @@ Summary: Confusion over content size vs transferred size of images.
408410
From: AmeliaBR
409411
Comment: https://github.com/w3c/csswg-drafts/issues/694
410412
Response: https://github.com/w3c/csswg-drafts/issues/694#issuecomment-315920507
411-
Closed: OutOfScope, refiled as https://github.com/w3c/csswg-drafts/issues/1609
413+
Closed: OutOfScope
414+
Note: Refiled as https://github.com/w3c/csswg-drafts/issues/1609
415+
----
416+
Issue 45.
417+
Summary: Clarify sentence construction in finding max-content flex fraction
418+
From: Alan Stearns
419+
Comment: https://github.com/w3c/csswg-drafts/issues/1803
420+
Response: https://github.com/w3c/csswg-drafts/issues/1803#issuecomment-329247658
421+
Closed: Editorial
412422
----

css-grid/Overview.bs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -905,15 +905,16 @@ Sizing Grid Containers</h3>
905905
<span class="note">The block layout spec should probably define this,
906906
but it isn't written yet.</span>
907907

908-
The <a>max-content size</a> of a <a>grid container</a> is
908+
The <a>max-content size</a> (<a>min-content size</a>) of a <a>grid container</a> is
909909
the sum of the <a>grid container’s</a> track sizes (including gutters)
910910
in the appropriate axis,
911-
when the grid is sized under a <a>max-content constraint</a>.
912-
913-
The <a>min-content size</a> of a <a>grid container</a> is
914-
the sum of the <a>grid container’s</a> track sizes (including gutters)
915-
in the appropriate axis,
916-
when the grid is sized under a <a>min-content constraint</a>.
911+
when the grid is sized under a <a>max-content constraint</a> (<a>min-content constraint</a>).
912+
However, if the sum of the <a>flex factors</a> of the <a>flexible tracks</a>
913+
is less than one,
914+
then instead calculate the flexible tracks’ sizes
915+
using <em>rescaled</em> flex factors--
916+
each track’s <a>flex factor</a> divided by the sum of all the tracks’ flex factors</a>--
917+
in place of their actual flex factors.
917918

918919

919920
<!--
@@ -1692,6 +1693,9 @@ Flexible Lengths: the ''fr'' unit</h4>
16921693
A <dfn export>flexible length</dfn> or <dfn><<flex>></dfn> is a dimension
16931694
with the <dfn value for="<flex>" lt="fr|fr unit">fr</dfn> unit,
16941695
which represents a fraction of the <a>leftover space</a> in the <a>grid container</a>.
1696+
Tracks sized with ''fr'' units are called <dfn>flexible tracks</dfn>
1697+
as they flex in response to <a>leftover space</a>
1698+
similar to how <a>flex items</a> fill space in a <a>flex container</a>.
16951699

16961700
Note: <<flex>> values are not <<length>>s
16971701
(nor are they compatible with <<length>>s, like some <<percentage>> values),
@@ -4254,6 +4258,25 @@ Major Changes</h4>
42544258
Significant Adjustments and Fixes</h4>
42554259

42564260
<ul>
4261+
<li id="change-2016-flex-max-content">
4262+
Corrected max-content contributions of flexible tracks
4263+
to handle cases where the sum of the flex factors is less than one.
4264+
(<a href="https://github.com/w3c/csswg-drafts/issues/1735">Issue 1735</a>)
4265+
<blockquote>
4266+
<p>
4267+
The <a>max-content size</a> (<a>min-content size</a>) of a <a>grid container</a> is
4268+
the sum of the <a>grid container’s</a> track sizes (including gutters)
4269+
in the appropriate axis,
4270+
when the grid is sized under a <a>max-content constraint</a> (<a>min-content constraint</a>).
4271+
<ins>However, if the sum of the <a>flex factors</a> of the <a>flexible tracks</a>
4272+
is less than one,
4273+
then instead calculate the flexible tracks’ sizes
4274+
using <em>rescaled</em> flex factors--
4275+
each track’s <a>flex factor</a> divided by the sum of all the tracks’ flex factors</a>--
4276+
in place of their actual flex factors.</ins>
4277+
</p>
4278+
</blockquote>
4279+
42574280
<li id="change-2016-flex-clamping-indefinite">
42584281
Applied flex factor clamping to 1 also to indefinite case
42594282
(<a href="https://drafts.csswg.org/css-grid-1/issues-cr-2016#issue-26">Issue 26</a>,

0 commit comments

Comments
 (0)