Skip to content

Commit 3877c16

Browse files
committed
Rework baselines a bit. Things can have baselines in either axis, and we distinguish between 'natural' and 'synthetic' baselines.
1 parent 8bcd1a7 commit 3877c16

4 files changed

Lines changed: 47 additions & 26 deletions

File tree

css-align/Overview.bs

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -283,28 +283,32 @@ Baseline Alignment: the ''baseline'' and ''last-baseline'' keywords</h3>
283283
<dt><dfn>baseline</dfn>
284284
<dd>
285285
Indicates <dfn dfn for export>first-baseline alignment</dfn>:
286-
aligns one of baselines in the box's <a>first baseline set</a>
287-
in the appropriate axis
286+
If the box has a <a>natural baseline</a> in the appropriate axis,
287+
aligns one of the baselines in the box's <a>first baseline set</a>
288+
in that axis
288289
with the corresponding baseline
289290
in the <a>first baseline sets</a>
290291
of all the boxes in its <a>baseline-sharing group</a>.
291292

292293
If the <a>alignment subject</a>’s position is not fully determined by <a>baseline alignment</a>,
293-
the content is ''start''-aligned insofar as possible while preserving the baseline alignment.
294-
(Content that has no <a>first baselines</a> is thus start-aligned.)
294+
or the box has no <a>natural baseline</a> in the appropriate axis,
295+
the content is ''start''-aligned insofar as possible while preserving the <a>baseline alignment</a>.
296+
(<a>Alignment subjects</a> that have no inline-level content are thus ''start''-aligned.)
295297

296298
<dt><dfn>last-baseline</dfn>
297299
<dd>
298300
Indicates <dfn dfn for export>last-baseline alignment</dfn>:
299-
aligns one of baselines in the box's <a>last baseline set</a>
300-
in the appropriate axis
301+
If the box has a <a>natural baseline</a> in the appropriate axis,
302+
aligns one of the baselines in the box's <a>last baseline set</a>
303+
in that axis
301304
with the corresponding baseline
302305
in the <a>last baseline sets</a>
303306
of all the boxes in its <a>baseline-sharing group</a>.
304307

305308
If the <a>alignment subject</a>’s position is not fully determined by <a>baseline alignment</a>,
306-
the content is ''end''-aligned insofar as possible while preserving the baseline alignment.
307-
(Content that has no <a>last baselines</a> is thus end-aligned.)
309+
or the box has no <a>natural baseline</a> in the appropriate axis,
310+
the content is ''end''-aligned insofar as possible while preserving the <a>baseline alignment</a>.
311+
(<a>Alignment subjects</a> that have no inline-level content are thus ''end''-aligned.)
308312

309313
Issue: Should this ''end'' fallback be ''safe'' or ''unsafe''?
310314
</dl>
@@ -677,7 +681,7 @@ Baseline Content-Alignment</h3>
677681
<dt>Table Cells:
678682
<dd>
679683
A <a>table cell</a> participates in first (last) <a>baseline content-alignment</a>
680-
in either its row or column (whichever matches its <a>inline axis</a>)
684+
in either its row or column (whichever matches the axises of its <a>natural baselines</a>)
681685
if its computed 'align-content' is ''baseline'' (''last-baseline'').
682686

683687
<dt>Flex Items:
@@ -695,7 +699,7 @@ Baseline Content-Alignment</h3>
695699
<dt>Grid Items:
696700
<dd>
697701
A <a>grid item</a> participates in first (last) <a>baseline content-alignment</a>
698-
in either its row or column (whichever matches its <a>inline axis</a>)
702+
in either its row or column (whichever matches the axises of its <a>natural baselines</a>)
699703
if its computed 'align-content' is ''baseline'' (''last-baseline''),
700704
and its computed 'align-self' or 'justify-self' (whichever affects its <a>block axis</a>)
701705
is ''align-self/stretch'' or ''self-start'' (''self-end'').
@@ -1148,7 +1152,7 @@ Baseline Self-Alignment</h3>
11481152
<dt>Grid Items:
11491153
<dd>
11501154
A <a>grid item</a> participates in first (last) <a>baseline self-alignment</a>
1151-
in either its row or column (whichever matches its <a>inline axis</a>)
1155+
in either its row or column (whichever axises it has a <a>natural baseline</a> in)
11521156
if its 'justify-self' or 'align-self' property (whichever affects its <a>block axis</a>)
11531157
computes to ''baseline'' (''last-baseline'').
11541158
</dl>
@@ -1363,6 +1367,14 @@ Determining the Baselines of a Box</h2>
13631367

13641368
Note: The forthcoming Inline Layout Module will define synthesis rules for baselines other than alphabetic and central.
13651369

1370+
A box has a <dfn export>natural baseline</dfn>
1371+
if it derives its <a>baseline set</a>(s) from a font's baseline table
1372+
(whether or not the UA had to <a href="https://drafts.csswg.org/css-inline/#baseline-synthesis-fonts">synthesize that baseline table</a>,
1373+
e.g. due to it being missing from the font).
1374+
It has a <dfn export>synthesized baseline</dfn>
1375+
if its baselines are <a>synthesized</a> from the geometry of its box,
1376+
as described above.
1377+
13661378
<p class='issue'>
13671379
Maybe these things are wrong?
13681380
CSS 2.1 is really weird about baseline alignment.
@@ -1375,10 +1387,12 @@ Baseline Alignment Terminology</h3>
13751387
This is possible only if they
13761388

13771389
<ul>
1378-
<li>share an <a>alignment context</a> whose axis is parallel to their <a>inline axis</a>
1379-
<li>either have the same <a>block flow direction</a> and <a>baseline alignment preference</a>,
1380-
or have opposite <a>block flow direction</a> and opposite <a>baseline alignment preference</a>
1381-
(in other words, the baselines that want to align are on the same side of the alignment context).
1390+
<li>share an <a>alignment context</a> whose axis is parallel to an axis in which they have a baseline
1391+
<li>the baselines that want to align are on the same “side” of the alignment context,
1392+
e.g. the boxes in a vertical-axis <a>alignment context</a> all want to align their leftmost baseline
1393+
(whether that is the first baseline in a ''vertical-lr'' flow,
1394+
the last baseline in a ''vertical-rl'' flow,
1395+
or the first baseline of a ''vertical-lr'' flow that has been propagated to being the block-axis <a>first baseline</a> of a ''horizontal-tb'' ''ltr'' grid container)
13821396
</ul>
13831397

13841398
Boxes <dfn lt="shared alignment context|alignment context" export>share an alignment context</dfn> along a particular axis when they are:
@@ -1391,6 +1405,9 @@ Baseline Alignment Terminology</h3>
13911405
<li>flex items in the same flex line, along the flex container's main axis
13921406
</ul>
13931407

1408+
Note: The inline-level boxes on a line box also share an alignment context and participate in a baseline-sharing group;
1409+
however this is detailed in the CSS Inline Layout module, not here.
1410+
13941411
Boxes in a <a>baseline-sharing group</a> are aligned to each other
13951412
using their <dfn export>alignment baseline</dfn>.
13961413
This is the dominant baseline associated with
@@ -1400,6 +1417,9 @@ Baseline Alignment Terminology</h3>
14001417
specifying ''align-content: baseline'' on table cells in the same row
14011418
will align the alphabetic baselines of their <a>first formatted lines</a>.
14021419

1420+
Note: The 'alignment-baseline' property introduced in CSS Inline Layout Level 3
1421+
will allow changing which baseline is used for baseline alignment within a <a>baseline-sharing group</a>.
1422+
14031423
<h3 id='align-by-baseline'>
14041424
Aligning Boxes by Baseline</h3>
14051425

css-flexbox/Overview.bs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,8 +2007,8 @@ Cross-axis Alignment: the 'align-items' and 'align-self' properties</h3>
20072007

20082008
<dt><dfn>baseline</dfn>
20092009
<dd>
2010-
If the <a>flex item</a>’s inline axis is the same as the <a>cross axis</a>,
2011-
this value is identical to <a value for=align-self>flex-start</a>.
2010+
If the <a>flex item</a> has no <a>natural baselines</a> in its <a>main axis</a>,
2011+
this value is identical to ''align-self/flex-start''.
20122012

20132013
Otherwise,
20142014
it <dfn dfn id='baseline-participation'>participates in baseline alignment</dfn>:
@@ -2178,7 +2178,8 @@ Flex Container Baselines</h3>
21782178
is <a lt="generate baselines">generated</a> from
21792179
its <a>alignment baseline</a>.
21802180

2181-
3. Otherwise, the flex container's first/last <a>main-axis baseline set</a>
2181+
3. Otherwise, the flex container has no natural first/last main-axis <a>baseline set</a>,
2182+
and a synthesized first/last <a>baseline set</a>, if needed,
21822183
is <a lt="synthesize baselines">synthesized</a>
21832184
from the first/last item's content box,
21842185
or, failing that, from the flex container's content box.
@@ -2200,7 +2201,8 @@ Flex Container Baselines</h3>
22002201
the flex container's first/last <a>cross-axis baseline set</a>
22012202
is that baseline set.
22022203

2203-
2. Otherwise, the flex container's <a>cross-axis baseline set</a>
2204+
2. Otherwise, the flex container has no natural cross-axis <a>baseline set</a>,
2205+
and a synthesized first/last <a>baseline set</a>, if needed,
22042206
is <a lt="synthesize baselines">synthesized</a>
22052207
from the first/last item's content box,
22062208
or, failing that, from the flex container's content box.

css-grid/Overview.bs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,17 +3516,14 @@ Grid Container Baselines</h3>
35163516
that <a>grid item</a>’s <a>alignment baseline</a>.
35173517

35183518
<li>
3519-
Otherwise, the grid container's first (last) baseline set
3519+
Otherwise, the grid container has no natural first (last) <a>baseline set</a> in that axis,
3520+
and a synthesized first/last <a>baseline set</a>, if needed,
35203521
is <a lt="synthesize baselines">synthesized</a>
35213522
from the first (last) item's (in <a>grid order</a>) content box,
35223523
or, if there's no <a>grid item</a>,
35233524
from the grid container's content box.
35243525
</ol>
35253526

3526-
A <a>grid item</a> <dfn export id="baseline-participation">participates in baseline alignment</dfn> in a particular dimension
3527-
if its value for 'align-self' or 'justify-self', as appropriate, is ''baseline''
3528-
and its inline axis is parallel to that dimension.
3529-
35303527
<dfn export lt="grid order|grid-modified document order">'grid-modified document order (grid order)</dfn>
35313528
is the order in which <a>grid items</a> are encountered
35323529
when traversing the grid's <a>grid cells</a>,

css-inline/Overview.bs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ Alignment Point: 'alignment-baseline' longhand</h4>
160160
<p>Specifies what point of an inline-level box is aligned to what point in the parent.
161161
Values are defined below:
162162

163-
For the following definitions, the margin box is used for atomic inlines,
164-
and the leading box for non-replaced inlines:
163+
For the following definitions,
164+
the margin box is used for atomic inlines,
165+
the leading box for non-replaced inlines,
166+
and the baselines of the box are <a lt="synthesized baseline">synthesized</a> if missing in the line-box's inline axis:
165167

166168
<dl dfn-for=alignment-baseline dfn-type=value>
167169
<dt><dfn>baseline</dfn>

0 commit comments

Comments
 (0)