@@ -3730,36 +3730,44 @@ Aligning the Grid: the 'justify-content' and 'align-content' properties</h3>
37303730<h3 id='grid-baselines'>
37313731Grid Container Baselines</h3>
37323732
3733- The first (last) baselines of a <a>grid container</a>
3734- are determined as follows:
3733+ The first [=baseline set=] of a [=grid container=]
3734+ is taken from the first available of:
3735+
3736+ 1. If any [=grid items=] intersecting the first ([=block-start=] –most) non-empty [=track=]
3737+ participate in first [=baseline alignment=] along the relevant axis,
3738+ <a lt="generate baselines">generate</a> a [=baseline set=] from their shared [=alignment baseline=]
3739+ and the [=grid container=] ’s [=first available font=] ,
3740+ after alignment has been performed.
3741+
3742+ 2. Otherwise, if any [=grid items=] intersecting that track participate in
3743+ last [=baseline alignment=] along the relevant axis,
3744+ <a lt="generate baselines">generate</a> from <em> that</em> [=alignment baseline=] .
3745+
3746+ 3. Otherwise, if any [=grid items=] intersecting that track
3747+ have a [=baseline set=] in the relevant axis at all,
3748+ take the [=baseline set=] from the [=grid item=]
3749+ with the <em> highest</em> ([=block-start=] –most) baseline
3750+ corresponding to the [=grid container=] 's [=alignment baseline=] ,
3751+ preferring the first in [=grid order=]
3752+ if multiple items are tied.
3753+
3754+ 4. Otherwise, if there are any [=grid items=] at all,
3755+ <a lt="synthesize baselines">synthesize</a> a [=baseline set=]
3756+ from the first [=grid item=] in [=grid order=] .
3757+
3758+ 5. Otherwise, the [=grid container=] has no first <a>baseline set</a> in the relevant axis.
3759+ (One is <a lt="synthesize baselines">synthesized</a>
3760+ from the [=grid container=] itself if needed,
3761+ according to the rules of its <a>alignment context</a> .)
37353762
3736- <ol>
3737- <li>
3738- Find the first (last) row of the [=grid container=]
3739- containing at least one [=grid item=] .
3740-
3741- If any of the [=grid items=] intersecting this row
3742- participate in [=baseline alignment=] in that row,
3743- the grid container's <a>baseline set</a>
3744- is <a lt="generate baselines">generated</a> from
3745- the shared <a>alignment baseline</a> of those <a>grid items</a> .
3746-
3747- Otherwise,
3748- the grid container's first (last) baseline set
3749- is <a lt="generate baselines">generated</a> from
3750- the <a>alignment baseline</a> of the first (last) <a>grid item</a>
3751- in row-major <a>grid order</a> (according to the <a>writing mode</a> of the <a>grid container</a> ).
3752- If the [=grid item=] has no <a>alignment baseline</a> in the grid's inline axis,
3753- then one is first <a lt="synthesize baselines">synthesized</a>
3754- from its border edges.
3763+ For this purpose,
3764+ any [=grid item=] that spans multiple tracks
3765+ is ignored if it’s span does not start in the indicated track;
3766+ except that for step 2,
3767+ it's ignored if its span does not <em> end</em> in the track.
37553768
3756- <li>
3757- If the [=grid container=] does not contain any [=grid items=] ,
3758- the grid container has no first (last) <a>baseline set</a> ,
3759- and one is <a lt="synthesize baselines">synthesized</a> if needed
3760- according to the rules of its <a>alignment context</a> .
3761- Exit from this algorithm.
3762- </ol>
3769+ Last baselines are analogous
3770+ (with “first”/“last” and “start”/“end” inverted).
37633771
37643772 <dfn export lt="grid order|grid-modified document order">Grid-modified document order (grid order)</dfn>
37653773 is the order in which <a>grid items</a> are encountered
0 commit comments