Skip to content

Commit 639aa60

Browse files
committed
[css-grid-1][css-grid-2][editorial] var-ification of the 'distribute extra space' algorithm, for clarity.
1 parent 5b04c96 commit 639aa60

2 files changed

Lines changed: 64 additions & 54 deletions

File tree

css-grid-1/Overview.bs

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4314,33 +4314,39 @@ Resolve Intrinsic Track Sizes</h3>
43144314
Distributing Extra Space Across Spanned Tracks</h4>
43154315

43164316
To <dfn noexport>distribute extra space</dfn>
4317-
by increasing the affected sizes of a set of tracks
4318-
as required by a set of intrinsic size contributions,
4317+
to the [=base sizes=] or [=growth limits=] (the |affected size|s)
4318+
of a set of tracks (the |affected track|s)
4319+
to accommodate specific intrinsic size contributions (the |size contribution|s)
4320+
of a set of grid items spanning those tracks (the |item|s):
43194321

43204322
<ol>
43214323
<li>
4322-
Maintain separately for each affected <a>base size</a> or <a>growth limit</a>
4324+
Maintain separately for each |affected track|
43234325
a |planned increase|,
43244326
initially set to 0.
43254327
(This prevents the size increases from becoming order-dependent.)
43264328

43274329
<li>
4328-
For each considered item,
4330+
[=list/For each=] accommodated |item|,
4331+
43294332
<ol>
43304333
<li>
43314334
<strong>Find the space to distribute:</strong>
4332-
Subtract the corresponding size (<a>base size</a> or <a>growth limit</a>) of <em>every</em> spanned track
4333-
from the item's size contribution to find the item's remaining size contribution.
4335+
Subtract the |affected size| of <em>every</em> track the item spans
4336+
(not just the |affected track|s)
4337+
from the item's |size contribution|,
4338+
flooring it at zero.
43344339
(For infinite <a>growth limits</a>, substitute the track's <a>base size</a>.)
4335-
This is the space to distribute. Floor it at zero.
4336-
<pre><var>extra-space</var> = max(0, <var>size-contribution</var> - ∑<var>track-sizes</var>)</pre>
4340+
This remaining size contribution is the |space| to distribute.
4341+
4342+
<pre><var>space</var> = max(0, <var>size contribution</var> - ∑<var>track-sizes</var>)</pre>
43374343

43384344
<li>
4339-
<strong>Distribute space up to limits:</strong>
4340-
Find the |item-incurred increase| for each spanned track with an affected size
4341-
by: distributing the space equally among such tracks,
4345+
<strong>Distribute |space| up to limits:</strong>
4346+
Find the |item-incurred increase| for each |affected track| by:
4347+
distributing the |space| equally among such tracks,
43424348
freezing a track’s |item-incurred increase|
4343-
as its affected size + |item-incurred increase|
4349+
as its |affected size| + |item-incurred increase|
43444350
reaches its |limit|
43454351
(and continuing to grow the unfrozen tracks as needed).
43464352

@@ -4350,28 +4356,28 @@ Distributing Extra Space Across Spanned Tracks</h4>
43504356
the |limit| is infinity if it is marked as [=infinitely growable=],
43514357
and equal to the [=growth limit=] otherwise.
43524358

4353-
Note: If the affected size was a <a>growth limit</a>
4359+
Note: If the |affected size| was a <a>growth limit</a>
43544360
and the track is not marked [=infinitely growable=],
43554361
then each |item-incurred increase| will be zero.
43564362

43574363
<li>
4358-
<strong>Distribute space beyond limits:</strong>
4359-
If space remains after all tracks are frozen,
4360-
unfreeze and continue to distribute space to the |item-incurred increase| of…
4364+
<strong>Distribute |space| beyond limits:</strong>
4365+
If |space| remains after all |affected tracks| are frozen,
4366+
unfreeze and continue to distribute |space| to the |item-incurred increase| of…
43614367

43624368
<ul>
43634369
<li>
43644370
when <a href=#track-size-intrinsic-min>accommodating minimum contributions</a>
43654371
or <a href=#track-size-content-min>accommodating min-content contributions</a>:
4366-
any affected track that happens to also have an intrinsic <a>max track sizing function</a>;
4367-
if there are no such tracks, then all affected tracks.
4372+
any |affected track| that happens to also have an intrinsic <a>max track sizing function</a>;
4373+
if there are no such tracks, then all |affected track|s.
43684374
<li>
43694375
when <a href=#track-size-max-content-min>accommodating max-content contributions</a>:
4370-
any affected track that happens to also have a ''max-content'' <a>max track sizing function</a>;
4371-
if there are no such tracks, then all affected tracks.
4376+
any |affected track| that happens to also have a ''max-content'' <a>max track sizing function</a>;
4377+
if there are no such tracks, then all |affected track|s.
43724378
<li>
43734379
when handling any intrinsic <a>growth limit</a>:
4374-
all affected tracks.
4380+
all |affected track|s.
43754381
</ul>
43764382

43774383
For this purpose,
@@ -4381,20 +4387,19 @@ Distributing Extra Space Across Spanned Tracks</h4>
43814387
after which it is treated as having a <a>fixed sizing function</a> of that argument.
43824388

43834389
Note: This step prioritizes the distribution of space
4384-
for accommodating space required
4385-
by the tracks’ [=min track sizing functions=]
4386-
beyond their current growth limits
4390+
for accommodating |size contribution|s
4391+
beyond the tracks' current growth limits
43874392
based on the types of their [=max track sizing functions=].
43884393

43894394
<li>
4390-
For each affected track,
4395+
For each |affected track|,
43914396
if the track’s |item-incurred increase| is larger than the track’s |planned increase|
43924397
set the track’s |planned increase| to that value.
43934398

43944399
</ol>
43954400
<li>
4396-
<strong>Update the tracks' affected sizes</strong>
4397-
by adding in the |planned increase|
4401+
<strong>Update the tracks' |affected size|s</strong>
4402+
by adding in the |planned increase|,
43984403
so that the next round of space distribution will account for the increase.
43994404
(If the affected size is an infinite <a>growth limit</a>,
44004405
set it to the track's <a>base size</a> plus the |planned increase|.)

css-grid-2/Overview.bs

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4991,33 +4991,39 @@ Resolve Intrinsic Track Sizes</h3>
49914991
Distributing Extra Space Across Spanned Tracks</h4>
49924992

49934993
To <dfn noexport>distribute extra space</dfn>
4994-
by increasing the affected sizes of a set of tracks
4995-
as required by a set of intrinsic size contributions,
4994+
to the [=base sizes=] or [=growth limits=] (the |affected size|s)
4995+
of a set of tracks (the |affected track|s)
4996+
to accommodate specific intrinsic size contributions (the |size contribution|s)
4997+
of a set of grid items spanning those tracks (the |item|s):
49964998

49974999
<ol>
49985000
<li>
4999-
Maintain separately for each affected <a>base size</a> or <a>growth limit</a>
5001+
Maintain separately for each |affected track|
50005002
a |planned increase|,
50015003
initially set to 0.
50025004
(This prevents the size increases from becoming order-dependent.)
50035005

50045006
<li>
5005-
For each considered item,
5007+
[=list/For each=] accommodated |item|,
5008+
50065009
<ol>
50075010
<li>
50085011
<strong>Find the space to distribute:</strong>
5009-
Subtract the corresponding size (<a>base size</a> or <a>growth limit</a>) of <em>every</em> spanned track
5010-
from the item's size contribution to find the item's remaining size contribution.
5012+
Subtract the |affected size| of <em>every</em> track the item spans
5013+
(not just the |affected track|s)
5014+
from the item's |size contribution|,
5015+
flooring it at zero.
50115016
(For infinite <a>growth limits</a>, substitute the track's <a>base size</a>.)
5012-
This is the space to distribute. Floor it at zero.
5013-
<pre><var>extra-space</var> = max(0, <var>size-contribution</var> - ∑<var>track-sizes</var>)</pre>
5017+
This remaining size contribution is the |space| to distribute.
5018+
5019+
<pre><var>space</var> = max(0, <var>size contribution</var> - ∑<var>track-sizes</var>)</pre>
50145020

50155021
<li>
5016-
<strong>Distribute space up to limits:</strong>
5017-
Find the |item-incurred increase| for each spanned track with an affected size
5018-
by: distributing the space equally among such tracks,
5022+
<strong>Distribute |space| up to limits:</strong>
5023+
Find the |item-incurred increase| for each |affected track| by:
5024+
distributing the |space| equally among such tracks,
50195025
freezing a track’s |item-incurred increase|
5020-
as its affected size + |item-incurred increase|
5026+
as its |affected size| + |item-incurred increase|
50215027
reaches its |limit|
50225028
(and continuing to grow the unfrozen tracks as needed).
50235029

@@ -5027,28 +5033,28 @@ Distributing Extra Space Across Spanned Tracks</h4>
50275033
the |limit| is infinity if it is marked as [=infinitely growable=],
50285034
and equal to the [=growth limit=] otherwise.
50295035

5030-
Note: If the affected size was a <a>growth limit</a>
5036+
Note: If the |affected size| was a <a>growth limit</a>
50315037
and the track is not marked [=infinitely growable=],
50325038
then each |item-incurred increase| will be zero.
50335039

50345040
<li>
5035-
<strong>Distribute space beyond limits:</strong>
5036-
If space remains after all tracks are frozen,
5037-
unfreeze and continue to distribute space to the |item-incurred increase| of…
5041+
<strong>Distribute |space| beyond limits:</strong>
5042+
If |space| remains after all |affected tracks| are frozen,
5043+
unfreeze and continue to distribute |space| to the |item-incurred increase| of…
50385044

50395045
<ul>
50405046
<li>
50415047
when <a href=#track-size-intrinsic-min>accommodating minimum contributions</a>
50425048
or <a href=#track-size-content-min>accommodating min-content contributions</a>:
5043-
any affected track that happens to also have an intrinsic <a>max track sizing function</a>;
5044-
if there are no such tracks, then all affected tracks.
5049+
any |affected track| that happens to also have an intrinsic <a>max track sizing function</a>;
5050+
if there are no such tracks, then all |affected track|s.
50455051
<li>
50465052
when <a href=#track-size-max-content-min>accommodating max-content contributions</a>:
5047-
any affected track that happens to also have a ''max-content'' <a>max track sizing function</a>;
5048-
if there are no such tracks, then all affected tracks.
5053+
any |affected track| that happens to also have a ''max-content'' <a>max track sizing function</a>;
5054+
if there are no such tracks, then all |affected track|s.
50495055
<li>
50505056
when handling any intrinsic <a>growth limit</a>:
5051-
all affected tracks.
5057+
all |affected track|s.
50525058
</ul>
50535059

50545060
For this purpose,
@@ -5058,20 +5064,19 @@ Distributing Extra Space Across Spanned Tracks</h4>
50585064
after which it is treated as having a <a>fixed sizing function</a> of that argument.
50595065

50605066
Note: This step prioritizes the distribution of space
5061-
for accommodating space required
5062-
by the tracks’ [=min track sizing functions=]
5063-
beyond their current growth limits
5067+
for accommodating |size contribution|s
5068+
beyond the tracks' current growth limits
50645069
based on the types of their [=max track sizing functions=].
50655070

50665071
<li>
5067-
For each affected track,
5072+
For each |affected track|,
50685073
if the track’s |item-incurred increase| is larger than the track’s |planned increase|
50695074
set the track’s |planned increase| to that value.
50705075

50715076
</ol>
50725077
<li>
5073-
<strong>Update the tracks' affected sizes</strong>
5074-
by adding in the |planned increase|
5078+
<strong>Update the tracks' |affected size|s</strong>
5079+
by adding in the |planned increase|,
50755080
so that the next round of space distribution will account for the increase.
50765081
(If the affected size is an infinite <a>growth limit</a>,
50775082
set it to the track's <a>base size</a> plus the |planned increase|.)

0 commit comments

Comments
 (0)