Skip to content

Commit 990b83a

Browse files
committed
[css-flexbox] Remove free-space-focused flex resolution algorithm, per WG resolution, in preparation for LC republication.
1 parent c758e67 commit 990b83a

3 files changed

Lines changed: 22 additions & 277 deletions

File tree

css-flexbox/Overview.bs

Lines changed: 2 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,133 +2585,6 @@ Cross-Axis Alignment</h3>
25852585
<h3 id='resolve-flexible-lengths'>
25862586
Resolving Flexible Lengths</h3>
25872587

2588-
Note: These two algorithms should give the same result.
2589-
We will delete the "LC" version in favor of the "CR" version
2590-
immediately before publishing our next LC.
2591-
For now we are maintaining both
2592-
to aid in finding any discrepancies in behavior between the two,
2593-
as those are bugs we'll need to fix.
2594-
2595-
<h4 id="resolve-flexible-lengths-desired-free-space">
2596-
Free Space Focused Algorithm (LC version)</h4>
2597-
2598-
<p>
2599-
To resolve the flexible lengths of the items within a flex line:
2600-
2601-
<ol>
2602-
<li>
2603-
<strong>Determine the used flex factor.</strong>
2604-
Sum the outer <i>hypothetical main sizes</i> of all items on the line.
2605-
If the sum is less than or equal to the flex container's inner main size,
2606-
use the <i>flex grow factor</i> for the rest of this algorithm;
2607-
otherwise, use the <i>flex shrink factor</i>.
2608-
2609-
<li>
2610-
<strong>Size inflexible items.</strong>
2611-
Freeze,
2612-
setting its <i>target main size</i>
2613-
to its <i>hypothetical main size</i>&hellip;
2614-
<ul>
2615-
<li>
2616-
any item that has a flex factor of zero
2617-
2618-
<li>
2619-
if using the <i>flex grow factor</i>:
2620-
any item that has a <a>flex base size</a> greater than its <a>hypothetical main size</a>
2621-
2622-
<li>
2623-
if using the <i>flex shrink factor</i>:
2624-
any item that has a <a>flex base size</a> smaller than its <a>hypothetical main size</a>
2625-
</ul>
2626-
2627-
<li>
2628-
<strong>Calculate initial <dfn>free space</dfn>.</strong>
2629-
Sum the outer sizes of all items on the line,
2630-
and subtract this from the flex container's inner main size.
2631-
For frozen items, use their outer <i>target main size</i>;
2632-
for other items, use their outer <a>flex base size</a>.
2633-
2634-
<li>
2635-
<strong>Calculate each unfrozen item’s <dfn>desired free space</dfn>.</strong>
2636-
2637-
If the initial <i>free space</i> is zero or positive,
2638-
each <i>flex item</i>’s <i>desired free space</i> is
2639-
the initial <i>free space</i> multiplied by the item’s <i>flex grow factor</i>.
2640-
2641-
If the initial <i>free space</i> is negative,
2642-
first find the <dfn>scaled flex factor sum</dfn>,
2643-
<code>max(1, &sum;unfrozen flex factors)</code>.
2644-
Then, for each unfrozen flex item,
2645-
find its <dfn>scaled flex factor</dfn> by multipling its <i>flex shrink factor</i> by its <a>flex base size</a>
2646-
and normalizing so that the sum of these <i>scaled flex factors</i> equals the <var>scaled flex factor sum</var>.
2647-
Then, multiply each item’s <i>flex shrink factor</i> by the initial <i>free space</i>,
2648-
and let the result be its <i>desired free space</i>.
2649-
2650-
<li>
2651-
<strong>Distribute <i>free space</i>.</strong>
2652-
<ol type=a>
2653-
<li>
2654-
<strong>Check for flexible items.</strong>
2655-
If all the <i>flex items</i> on the line are frozen,
2656-
free space has been distributed;
2657-
exit this step.
2658-
2659-
<li>
2660-
<strong>Calculate the remaining <i>free space</i></strong>
2661-
as for initial <i>free space</i>, above.
2662-
2663-
<li>
2664-
<strong>Find each unfrozen item’s <dfn>normalized free space</dfn>.</strong>
2665-
If the remaining <i>free space</i> is non-zero,
2666-
and its magnitude is less than that of the sum of the non-frozen <i>flex items</i><i>desired free space</i>,
2667-
multiply each item’s <i>desired free space</i>
2668-
by the ratio (<var>remaining free space</var>/<var>initial free space</var>).
2669-
This is the item’s <i>normalized free space</i>.
2670-
Otherwise, use each item’s <i>desired free space</i> as its <i>normalized free space</i>.
2671-
2672-
<li>
2673-
<strong>Calculate each item’s <i>target main size</i>.</strong>
2674-
Set each non-frozen flex item's <i>target main size</i>
2675-
to the sum of its <a>flex base size</a> and its <var>normalized free space</var>.
2676-
Note: This may result in a negative main size temporarily.
2677-
2678-
<li>
2679-
<strong>Fix min/max violations.</strong>
2680-
Clamp each non-frozen item's <i>target main size</i> by its min and max main size properties.
2681-
If the item's main size was made smaller by this, it's a max violation.
2682-
If the item's main size was made larger by this, it's a min violation.
2683-
2684-
<li>
2685-
<strong>Freeze over-flexed items.</strong>
2686-
The total violation is the sum of the adjustments from the previous step,
2687-
<code>&sum;(<var>clamped size</var> - <var>unclamped size</var></code>).
2688-
If the total violation is:
2689-
2690-
<dl>
2691-
<dt>Zero
2692-
<dd>
2693-
Freeze all items.
2694-
2695-
<dt>Positive
2696-
<dd>
2697-
Freeze all the items with min violations to their clamped size.
2698-
2699-
<dt>Negative
2700-
<dd>
2701-
Freeze all the items with max violations to their clamped size.
2702-
</dl>
2703-
<li>
2704-
<strong>Loop:</strong>
2705-
Return to the first step, “Distribute free space.”
2706-
</ol>
2707-
<li>
2708-
<strong>Set each item’s used main size to its <i>target main size</i>.</strong>
2709-
Note: All items should be frozen at this point.
2710-
</ol>
2711-
2712-
<h4 id="resolve-flexible-lengths-flex-factors">
2713-
Flex Factor Focused Algorithm (CR version)</h4>
2714-
27152588
<p>
27162589
To resolve the flexible lengths of the items within a flex line:
27172590

@@ -2895,7 +2768,7 @@ Intrinsic Sizes</h3>
28952768
For each <a>flex item</a>,
28962769
subtract its <a>flex basis</a> from its <a>max-content contribution</a> size,
28972770
then divide by its <a>flex grow factor</a>, floored at 1,
2898-
or by its <a>scaled flex factor</a> (if the result was negative, flooring the <a>flex shrink factor</a> at 1 if necessary).
2771+
or by its <a>scaled flex shrink factor</a> (if the result was negative, flooring the <a>flex shrink factor</a> at 1 if necessary).
28992772
This is the item's <var>max-content flex fraction</var>.
29002773

29012774
<li>
@@ -2907,7 +2780,7 @@ Intrinsic Sizes</h3>
29072780
among all the <a>flex items</a>.
29082781
Add each item’s <a>flex basis</a>
29092782
to the product of its <a>flex grow factor</a>
2910-
(or <a>scaled flex factor</a>, if the chosen <var>max-content flex fraction</var> was negative)
2783+
(or <a>scaled flex shrink factor</a>, if the chosen <var>max-content flex fraction</var> was negative)
29112784
and the chosen <var>max-content flex fraction</var>,
29122785
then clamp that result by the <a>max main size property</a>.
29132786

0 commit comments

Comments
 (0)