Skip to content

Commit cda2822

Browse files
committed
[css-flexbox-1] Fix intrinsic size algo to better match the layout algo. #7189
1 parent 3c620e8 commit cda2822

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

css-flexbox-1/Overview.bs

+28-18
Original file line numberDiff line numberDiff line change
@@ -2908,38 +2908,52 @@ Flex Container Intrinsic Main Sizes</h4>
29082908
For each <a>flex item</a>,
29092909
subtract its outer <a>flex base size</a> from its [[#intrinsic-item-contributions|max-content contribution]] size.
29102910
If that result is positive,
2911-
divide by its <a>flex grow factor</a> floored at 1;
2911+
divide by its <a>flex grow factor</a>;
29122912
if negative,
2913-
divide by its <a>scaled flex shrink factor</a>
2914-
having floored the <a>flex shrink factor</a> at 1.
2915-
This is the item's <var>max-content flex fraction</var>.
2913+
divide by its <a>scaled flex shrink factor</a>.
2914+
This is the item's <var>desired flex fraction</var>.
29162915

29172916
<li>
29182917
Place all <a>flex items</a> into lines of infinite length.
2919-
2920-
<li>
29212918
Within each line,
2922-
find the largest <var>max-content flex fraction</var>
2919+
find the greatest (most positive)
2920+
<var>desired flex fraction</var>
29232921
among all the <a>flex items</a>.
2922+
This is the line’s <var>chosen flex fraction</var>.
2923+
2924+
<li>
2925+
If the sum of the line’s <a>flex grow factors</a>
2926+
(<a>flex shrink factors</a>,
2927+
if the <var>chosen flex fraction</var> is negative)
2928+
is less than 1,
2929+
multiply the <var>chosen flex fraction</var> by that sum.
2930+
2931+
<li>
29242932
Add each item’s <a>flex base size</a>
29252933
to the product of its <a>flex grow factor</a>
2926-
(or <a>scaled flex shrink factor</a>, if the chosen <var>max-content flex fraction</var> was negative)
2927-
and the chosen <var>max-content flex fraction</var>,
2934+
(<a>scaled flex shrink factor</a>, if shrinking)
2935+
and the <var>chosen flex fraction</var>,
29282936
then clamp that result by the <a>max main size</a>
29292937
floored by the <a>min main size</a>.
29302938

29312939
<li>
2932-
The <a>flex container</a>’s <a>max-content size</a> is the
2933-
largest sum of the afore-calculated sizes of all items within a single line.
2940+
The <a>flex container</a>’s <a>max-content size</a> is
2941+
the largest sum (among all the lines)
2942+
of the afore-calculated sizes of all items within a single line.
29342943
</ol>
29352944

29362945
The <strong><a>min-content</a> <a>main size</a></strong> of a <em><a>single-line</a></em> flex container
29372946
is calculated identically to the <a>max-content</a> <a>main size</a>,
29382947
except that the <a>flex items</a>[[#intrinsic-item-contributions|min-content contributions]] are used
29392948
instead of their [[#intrinsic-item-contributions|max-content contributions]].
2949+
29402950
However, for a <em><a>multi-line</a></em> container,
2941-
it is simply the largest [[#intrinsic-item-contributions|min-content contribution]]
2951+
the [=min-content=] [=main size=] is simply the largest [[#intrinsic-item-contributions|min-content contribution]]
29422952
of all the non-[=collapsed=] <a>flex items</a> in the <a>flex container</a>.
2953+
For this purpose,
2954+
each item's contribution
2955+
is capped by the item’s [=flex base size=] if the item is not growable,
2956+
and floored by the item’s [=flex base size=] if the item is not shrinkable.
29432957

29442958
<details class=note>
29452959
<summary>Implications of this algorithm when the sum of flex is less than 1</summary>
@@ -3008,17 +3022,13 @@ Flex Item Intrinsic Size Contributions</h4>
30083022
is the larger of its <em>outer</em> <a>min-content size</a>
30093023
and outer <a>preferred size</a>
30103024
if that is not ''width/auto'',
3011-
clamped by its <a>flex base size</a> as a maximum (if it is not growable)
3012-
and/or as a minimum (if it is not shrinkable),
3013-
and then further clamped by its <a lt="min main size">min</a>/<a>max main size</a>.
3025+
clamped by its <a lt="min main size">min</a>/<a>max main size</a>.
30143026

30153027
The <strong>main-size <a>max-content contribution</a> of a <a>flex item</a></strong>
30163028
is the larger of its <em>outer</em> <a>max-content size</a>
30173029
and outer <a>preferred size</a>
30183030
if that is not ''width/auto'',
3019-
clamped by its <a>flex base size</a> as a maximum (if it is not growable)
3020-
and/or as a minimum (if it is not shrinkable),
3021-
and then further clamped by its <a lt="min main size">min</a>/<a>max main size</a>.
3031+
clamped by its <a lt="min main size">min</a>/<a>max main size</a>.
30223032

30233033
<!--
30243034
████████ ████████ ███ ██████ ██ ██ ████████ ██ ██ ████████ ████ ██ ██ ██████

0 commit comments

Comments
 (0)