8000 [css-grid-1][css-grid-2] Allow non-intrinsic tracks to absorb space w… · xfq/csswg-drafts@a159883 · GitHub
Skip to content

Commit a159883

Browse files
committed
[css-grid-1][css-grid-2] Allow non-intrinsic tracks to absorb space when possible/needed. w3c#3648
1 parent 639aa60 commit a159883

2 files changed

Lines changed: 269 additions & 209 deletions

File tree

css-grid-1/Overview.bs

Lines changed: 133 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -4166,9 +4166,10 @@ Resolve Intrinsic Track Sizes</h3>
41664166
<ol>
41674167
<li id="track-size-intrinsic-min">
41684168
<strong>For intrinsic minimums:</strong>
4169-
First increase the <a>base size</a> of tracks with
4170-
an <a lt="intrinsic sizing function">intrinsic</a> <a>min track sizing function</a>
4171-
by [[#extra-space|distributing extra space]] as needed
4169+
First [=distribute extra space=]
4170+
to <a>base sizes</a> of all tracks,
4171+
preferring those with
4172+
an <a lt="intrinsic sizing function">intrinsic</a> <a>min track sizing function</a>,
41724173
to accommodate these items’ <a>minimum contributions</a>.
41734174

41744175
If the grid container is being sized under a
@@ -4185,36 +4186,40 @@ Resolve Intrinsic Track Sizes</h3>
41854186

41864187
<li id="track-size-content-min">
41874188
<strong>For content-based minimums:</strong>
4188-
Next continue to increase the <a>base size</a> of tracks with
4189-
a <a>min track sizing function</a> of ''min-content'' or ''max-content''
4190-
by [[#extra-space|distributing extra space]] as needed
4191-
to account for these items' <a>min-content contributions</a>.
4189+
Next continue to [=distribute extra space=]
4190+
to the [=base sizes=] of all tracks,
4191+
preferring those with
4192+
a <a>min track sizing function</a> of ''min-content'' or ''max-content'',
4193+
to accommodate these items' <a>min-content contributions</a>.
41924194

41934195
<li id="track-size-max-content-min">
41944196
<strong>For max-content minimums:</strong>
41954197
Next, if the grid container is being sized
41964198
under a <a>max-content constraint</a>,
4197-
continue to increase the <a>base size</a> of tracks with
4199+
continue to [=distribute extra space=]
4200+
to the [=base sizes=] of all tracks,
4201+
preferring those with
41984202
a <a>min track sizing function</a> of
4199-
''grid-template-columns/auto'' or ''max-content''
4200-
by [[#extra-space|distributing extra space]] as needed
4201-
to account for these items' <a>limited max-content contributions</a>.
4203+
''grid-template-columns/auto'' or ''max-content'',
4204+
to accommodate these items' <a>limited max-content contributions</a>.
42024205

42034206
In all cases,
4204-
continue to increase the <a>base size</a> of tracks with
4205-
a <a>min track sizing function</a> of ''max-content''
4206-
by [[#extra-space|distributing extra space]] as needed
4207-
to account for these items' <a>max-content contributions</a>.
4207+
continue to [=distribute extra space=]
4208+
to the [=base sizes=] of all tracks,
4209+
preferring those with
4210+
a <a>min track sizing function</a> of ''max-content'',
4211+
to accommodate these items' <a>max-content contributions</a>.
4212+
42084213
<li>
42094214
If at this point any track’s <a>growth limit</a> is now less than its <a>base size</a>,
42104215
increase its <a>growth limit</a> to match its <a>base size</a>.
42114216

42124217
<li>
42134218
<strong>For intrinsic maximums:</strong>
4214-
Next increase the <a>growth limit</a> of tracks with
4215-
an <a lt="intrinsic sizing function">intrinsic</a> <a>max track sizing function</a>
4216-
by [[#extra-space|distributing extra space]] as needed
4217-
to account for these items' <a>min-content contributions</a>.
4219+
Next [=distribute extra space=]
4220+
to the [=growth limits=] of tracks with
4221+
<a lt="intrinsic sizing function">intrinsic</a> <a>max track sizing function</a>,
4222+
to accommodate these items' <a>min-content contributions</a>.
42184223
Mark any tracks whose <a>growth limit</a> changed
42194224
from infinite to finite in this step
42204225
as <dfn>infinitely growable</dfn> for the next step.
@@ -4261,10 +4266,10 @@ Resolve Intrinsic Track Sizes</h3>
42614266

42624267
<li>
42634268
<strong>For max-content maximums:</strong>
4264-
Lastly continue to increase the <a>growth limit</a> of tracks with
4265-
a <a>max track sizing function</a> of ''max-content''
4266-
by [[#extra-space|distributing extra space]] as needed
4267-
to account for these items' <a>max-content contributions</a>.
4269+
Lastly continue to [=distribute extra space=]
4270+
to the [=growth limits=] of tracks with
4271+
a <a>max track sizing function</a> of ''max-content'',
4272+
to accommodate these items' <a>max-content contributions</a>.
42684273
However, limit the growth of any ''fit-content()'' tracks
42694274
by their ''fit-content()'' argument.
42704275
</ol>
@@ -4313,97 +4318,122 @@ Resolve Intrinsic Track Sizes</h3>
43134318
<h4 id="extra-space">
43144319
Distributing Extra Space Across Spanned Tracks</h4>
43154320

4316-
To <dfn noexport>distribute extra space</dfn>
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):
4321+
<div algorithm>
4322+
To <dfn noexport>distribute extra space</dfn>
4323+
to the [=base sizes=] or [=growth limits=] (the |affected size|s)
4324+
of a set of tracks (the |affected track|s)
4325+
to accommodate specific intrinsic size contributions (the |size contribution|s)
4326+
of a set of grid items spanning those tracks (the |item|s),
4327+
potentially preferring a subset of those tracks
4328+
(the optional |preferred track|s,
4329+
defaulting to all |affected track|s):
43214330

4322-
<ol>
4323-
<li>
4324-
Maintain separately for each |affected track|
4325-
a |planned increase|,
4326-
initially set to 0.
4327-
(This prevents the size increases from becoming order-dependent.)
4331+
<ol>
4332+
<li>
4333+
Maintain separately for each |affected track|
4334+
a |planned increase|,
4335+
initially set to 0.
4336+
(This prevents the size increases from becoming order-dependent.)
43284337

4329-
<li>
4330-
[=list/For each=] accommodated |item|,
4338+
<li>
4339+
[=list/For each=] accommodated |item|,
4340+
considering only tracks the item spans:
43314341

4332-
<ol>
4333-
<li>
4334-
<strong>Find the space to distribute:</strong>
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.
4339-
(For infinite <a>growth limits</a>, substitute the track's <a>base size</a>.)
4340-
This remaining size contribution is the |space| to distribute.
4342+
<ol>
4343+
<li>
4344+
<strong>Find the space to distribute:</strong>
4345+
Subtract the |affected size| of every spanned track
4346+
(not just the |affected track|s)
4347+
from the item's |size contribution|,
4348+
flooring it at zero.
4349+
(For infinite <a>growth limits</a>, substitute the track's <a>base size</a>.)
4350+
This remaining size contribution is the |space| to distribute.
43414351

4342-
<pre><var>space</var> = max(0, <var>size contribution</var> - ∑<var>track-sizes</var>)</pre>
4352+
<pre><var>space</var> = max(0, <var>size contribution</var> - ∑<var>track-sizes</var>)</pre>
43434353

4344-
<li>
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,
4348-
freezing a track’s |item-incurred increase|
4349-
as its |affected size| + |item-incurred increase|
4350-
reaches its |limit|
4351-
(and continuing to grow the unfrozen tracks as needed).
4352-
4353-
For [=base sizes=],
4354-
the |limit| is its [=growth limit=].
4355-
For [=growth limits=],
4356-
the |limit| is infinity if it is marked as [=infinitely growable=],
4357-
and equal to the [=growth limit=] otherwise.
4358-
4359-
Note: If the |affected size| was a <a>growth limit</a>
4360-
and the track is not marked [=infinitely growable=],
4361-
then each |item-incurred increase| will be zero.
4354+
<li>
4355+
<strong>Distribute |space| to |preferred track|s up to limits:</strong>
4356+
4357+
If the item spans any |preferred track|s,
4358+
find the |item-incurred increase| for each such track by:
4359+
distributing the space equally among these tracks,
4360+
freezing a track’s |item-incurred increase|
4361+
as its |affected size| + |item-incurred increase|
4362+
reaches its |limit|
4363+
(and continuing to grow the unfrozen tracks as needed).
4364+
4365+
For [=base sizes=],
4366+
the |limit| is its [=growth limit=].
4367+
For [=growth limits=],
4368+
the |limit| is infinity if it is marked as [=infinitely growable=],
4369+
and equal to the [=growth limit=] otherwise.
4370+
4371+
Note: If the affected size was a <a>growth limit</a>
4372+
and the track is not marked [=infinitely growable=],
4373+
then each |item-incurred increase| will be zero.
43624374

4363-
<li>
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…
4375+
<li>
4376+
<strong>Distribute |space| to non-preferred tracks up to limits:</strong>
43674377

4368-
<ul>
4369-
<li>
4370-
when <a href=#track-size-intrinsic-min>accommodating minimum contributions</a>
4371-
or <a href=#track-size-content-min>accommodating min-content contributions</a>:
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.
4374-
<li>
4375-
when <a href=#track-size-max-content-min>accommodating max-content contributions</a>:
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.
4378-
<li>
4379-
when handling any intrinsic <a>growth limit</a>:
4380-
all |affected track|s.
4381-
</ul>
4378+
If extra |space| remains at this point
4379+
and the item spans any non-preferred |affected track|s,
4380+
then continue distributing |space| as defined in the previous step
4381+
to these |affected track|s,
4382+
skipping any tracks with a [=min-content=] [=max track sizing function=]
4383+
when accommodating [=max-content contributions=].
4384+
4385+
Note: This step only affects [=base sizes=],
4386+
because this algorithm is never invoked on [=growth limits=]
4387+
with any non-preferred |affected tracks|.
43824388

4383-
For this purpose,
4384-
the [=max track sizing function=] of a ''fit-content()'' track
4385-
is treated as ''max-content''
4386-
until it reaches the limit specified as the ''fit-content()'' argument,
4387-
after which it is treated as having a <a>fixed sizing function</a> of that argument.
4389+
<li>
4390+
<strong>Distribute |space| beyond limits:</strong>
43884391

4389-
Note: This step prioritizes the distribution of space
4390-
for accommodating |size contribution|s
4391-
beyond the tracks' current growth limits
4392-
based on the types of their [=max track sizing functions=].
4392+
If extra |space| remains at this point,
4393+
unfreeze the |preferred track|s (if any)
4394+
or else the |affected track|s (if not),
4395+
then continue to distribute |space| to the |item-incurred increase| of…
43934396

4394-
<li>
4395-
For each |affected track|,
4396-
if the track’s |item-incurred increase| is larger than the track’s |planned increase|
4397-
set the track’s |planned increase| to that value.
4397+
<ul>
4398+
<li>
4399+
when <a href=#track-size-intrinsic-min>accommodating minimum contributions</a>
4400+
or <a href=#track-size-content-min>accommodating min-content contributions</a>:
4401+
any unfrozen |affected track| that happens to also have an intrinsic <a>max track sizing function</a>;
4402+
if there are no such tracks, then all unfrozen |affected track|s.
4403+
<li>
4404+
when <a href=#track-size-max-content-min>accommodating max-content contributions</a>:
4405+
any unfrozen |affected track| that happens to also have a ''max-content'' <a>max track sizing function</a>;
4406+
if there are no such tracks, then all unfrozen |affected track|s.
4407+
<li>
4408+
when handling any intrinsic <a>growth limit</a>:
4409+
all unfrozen |affected track|s.
4410+
</ul>
43984411

4399-
</ol>
4400-
<li>
4401-
<strong>Update the tracks' |affected size|s</strong>
4402-
by adding in the |planned increase|,
4403-
so that the next round of space distribution will account for the increase.
4404-
(If the affected size is an infinite <a>growth limit</a>,
4405-
set it to the track's <a>base size</a> plus the |planned increase|.)
4406-
</ol>
4412+
For this purpose,
4413+
the [=max track sizing function=] of a ''fit-content()'' track
4414+
is treated as ''max-content''
4415+
until it reaches the limit specified as the ''fit-content()'' argument,
4416+
after which it is treated as having a <a>fixed sizing function</a> of that argument.
4417+
4418+
Note: This step prioritizes the distribution of space
4419+
for accommodating |size contribution|s
4420+
beyond the tracks' current growth limits
4421+
based on the types of their [=max track sizing functions=].
4422+
4423+
<li>
4424+
For each |affected track|,
4425+
if the track’s |item-incurred increase| is larger than the track’s |planned increase|
4426+
set the track’s |planned increase| to that value.
4427+
4428+
</ol>
4429+
<li>
4430+
<strong>Update the tracks' |affected size|s</strong>
4431+
by adding in the |planned increase|,
4432+
so that the next round of space distribution will account for the increase.
4433+
(If the affected size is an infinite <a>growth limit</a>,
4434+
set it to the track's <a>base size</a> plus the |planned increase|.)
4435+
</ol>
4436+
</div>
44074437

44084438

44094439
<h3 id="algo-grow-tracks">

0 commit comments

Comments
 (0)