@@ -2322,8 +2322,9 @@ Resolving Flexible Lengths</h3>
23222322 <li>
23232323 <strong> Size inflexible items.</strong>
23242324 For any items that have a flex factor of zero,
2325- set their used main size
2326- to their <i> hypothetical main size</i> .
2325+ set their <i> target main size</i>
2326+ to their <i> hypothetical main size</i>
2327+ and freeze them.
23272328
23282329 If the <i> flex grow factor</i> is being used for this algorithm,
23292330 if any flexible items have a <a>flex base size</a> greater than their <a>hypothetical main size</a> ,
@@ -2336,107 +2337,90 @@ Resolving Flexible Lengths</h3>
23362337 and freeze them.
23372338
23382339 <li>
2339- <strong> Calculate free space.</strong>
2340- Sum the sizes of all items on the line:
2341- for frozen items,
2342- use their outer main size;
2343- for all other items,
2344- both flexible and inflexible,
2345- use their outer <a>flex base size</a> .
2346- Subtract this sum from the flex container's inner main size.
2347- This is the free space.
2340+ <strong> Calculate initial <dfn>free space</dfn> .</strong>
2341+ Sum the outer sizes of all items on the line,
2342+ and subtract this from the flex container's inner main size.
2343+ For frozen items, use their used main size;
2344+ for other items, use their <a>flex base size</a> .
2345+ This is the initial <i> free space</i> .
23482346
23492347 <li>
2350- <strong> Calculate desired free space.</strong>
2351- If the free space is zero or positive,
2352- then for each <a>flex item</a> on the line,
2353- its <var> originally desired free space</var>
2354- is the free space multiplied by the flex grow factor.
2355-
2356- Otherwise, if the free space is negative,
2357- then first sum the flex shrink factors of all the flex items on the line.
2358- If this number is greater than 1, set it to 1.
2359- Let this result be the <var> scaled flex factor sum</var> .
2360- For each flex item, multiply its flex shrink factor by its <a>flex base size</a> .
2361- Then, renormalize each flex shrink factor so that their sum is the <var> scaled flex factor sum</var> .
2362- Then, multiply the flex shrink factor by the free space,
2363- and let the result be the <var> originally desired free space</var> .
2348+ <strong> Calculate each item‘s <dfn>desired free space</dfn> .</strong>
2349+ <li>
2350+ If the initial <i> free space</i> is zero or positive,
2351+ each <i> flex item</i> ’s <i> desired free space</i> is
2352+ the initial <i> free space</i> multiplied by the item’s <i> flex grow factor</i> .
2353+ <li>
2354+ If the initial <i> free space</i> is negative,
2355+ then first sum the flex shrink factors of all the flex items on the line.
2356+ If this number is greater than 1, set it to 1.
2357+ Let this result be the <var> scaled flex factor sum</var> .
2358+ For each flex item, multiply its flex shrink factor by its <a>flex base size</a> .
2359+ Then, normalize each <i> flex shrink factor</i> so that their sum is the <var> scaled flex factor sum</var> .
2360+ Then, multiply the <i> flex shrink factor</i> by the initial <i> free space</i> ,
2361+ and let the result be the <i> desired free space</var> .
2362+ </dl>
23642363
23652364 <li>
2366- Loop:
2367-
2368- <ol>
2365+ <strong> Distribute <i> free space</i> .</strong>
2366+ <ol type=a>
23692367 <li>
2370- <strong> Check that you can distribute any space.</strong>
2371- If all the non-frozen flex items on the line have a flex factor of zero,
2372- exit the algorithm.
2368+ <strong> Check for flexible items.</strong>
2369+ If all the <i> flex items</i> on the line are frozen,
2370+ free space has been distributed;
2371+ exit this step.
23732372
23742373 <li>
2375- <strong> Reset desired free space.</strong>
2376- For each non-frozen flex item on the line,
2377- set its <var> desired free space</var>
2378- to its <var> originally desired free space</var> .
2374+ <strong> Calculate the remaining <i> free space</i></strong>
2375+ as for initial <i> free space</i> , above.
23792376
23802377 <li>
2381- <strong> Recalculate free space.</strong>
2382- Calculate the free space again,
2383- according to the “Calculate free space” step before this loop.
2384- <span class='note'> Note that this does not alter the desired free space of the items.</span>
2378+ <strong> Find each unfrozen item’s <dfn>normalized free space</dfn> .</strong>
2379+ If the remaining <i> free space</i> is non-zero,
2380+ and its magnitude is less than that of the sum of the non-frozen <i> flex items</i> ’ <i> desired free space</i> ,
2381+ multiply each item’s <i> desired free space</i>
2382+ by the ratio (<var> remaining free space</var> /<var> initial free space</var> ).
2383+ This is the item’s <i> normalized free space</i> .
2384+ Otherwise, use each item’s <i> desired free space</i> as its <i> normalized free space</i> .
23852385
23862386 <li>
2387- <strong> Normalize desired free space if necessary.</strong>
2388- If the free space is positive,
2389- and the sum of the <var> desired free spaces</var> of all the non-frozen flex items on the line
2390- is greater than the free space,
2391- normalize all the <var> desired free spaces</var> so that they sum exactly to the free space
2392- while maintaining their magnitudes relative to each other.
2393-
2394- Otherwise, if the free space is negative,
2395- and the sum of the <var> desired free spaces</var> of all the non-frozen flex items on the line
2396- is less than the free space,
2397- normalize all the <var> desired free spaces</var> so that they sum exactly to the free space
2398- while maintaining their magnitudes relative to each other.
2399-
2400- Otherwise, if the free space is zero,
2401- set the <var> desired free spaces</var> of all the non-frozen flex items on the line
2402- to zero.
2403-
2404- <li>
2405- <strong> Adjust main size.</strong>
2406- Set each non-frozen flex item's used main size
2407- to the sum of its <a>flex base size</a> and its <var> desired free space</var> .
2408-
2387+ <strong> Calculate each item’s <dfn>target main size</dfn> .</strong>
2388+ Set each non-frozen flex item's <i> target main size</i>
2389+ to the sum of its <a>flex base size</a> and its <var> normalized free space</var> .
24092390 Note: This may result in a negative main size temporarily.
24102391
24112392 <li>
24122393 <strong> Fix min/max violations.</strong>
2413- Clamp each non-frozen item's main size by its min and max main size properties.
2394+ Clamp each non-frozen item's <i> target main size</i> by its min and max main size properties.
24142395 If the item's main size was made smaller by this, it's a max violation.
24152396 If the item's main size was made larger by this, it's a min violation.
24162397
24172398 <li>
2418- The total violation is the sum of the adjustments from the previous step
2419- (<code><var> clamped size</var> - <var> unclamped size</var></code> ).
2399+ <strong> Freeze over-flexed items.</strong>
2400+ The total violation is the sum of the adjustments from the previous step,
2401+ <code> ∑(<var> clamped size</var> - <var> unclamped size</var></code> ).
24202402 If the total violation is:
24212403
24222404 <dl>
24232405 <dt> Zero
24242406 <dd>
2425- Exit the algorithm .
2407+ Do nothing .
24262408
24272409 <dt> Positive
24282410 <dd>
2429- Freeze all the items with min violations,
2430- reset all other items to their size upon entering this algorithm,
2431- and return to the start of this loop.
2411+ Freeze all the items with min violations to their clamped size.
24322412
24332413 <dt> Negative
24342414 <dd>
2435- Freeze all the items with max violations,
2436- reset all other items to their size upon entering this algorithm,
2437- and return to the start of this loop.
2415+ Freeze all the items with max violations to their clamped size.
24382416 </dl>
2417+ <li>
2418+ <strong> Loop:</strong>
2419+ Return to the first step, “Distribute free space.”
24392420 </ol>
2421+ <li>
2422+ <strong> Set each fozen item’s used size to its <i> target main size</i> .</strong>
2423+ Note: All items should be frozen at this point.
24402424 </ol>
24412425
24422426<h3 id='intrinsic-sizes'>
0 commit comments