Skip to content

Commit f490ebe

Browse files
committed
[css-text-decor] Switch to talking about 'considered text'. Add issue about line-through positioning, especially in elements without text.
1 parent 83b8296 commit f490ebe

File tree

2 files changed

+110
-41
lines changed

2 files changed

+110
-41
lines changed

css-text-decor/Overview.html

Lines changed: 62 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,59 +1043,85 @@ <h3 id=text-underline-position-property><span class=secno>2.6. </span> Text
10431043

10441044
<h3 id=line-position><span class=secno>2.7. </span> Determining the
10451045
Position and Thickness of Line Decorations</h3>
1046+
<!--
1047+
<p>Since line decorations can span elements with varying font sizes and
1048+
vertical alignments, the best position for a line decoration is not
1049+
necessarily the ideal position dictated by the <i>decorating box</i>.
1050+
In determining the position of text decoration lines within a given line box,
1051+
user agents must consider, for each <i>decorating box</i> on that line,
1052+
the “ideal” positions of such line decorations of each
1053+
run of text decorated by that <i>decorating box</i>
1054+
(each <dfn>considered run</dfn>).
1055+
However, descendants of the <i>decorating box</i>
1056+
that are skipped due to 'text-decoration-skip',
1057+
descendant inlines with ''text-decoration-skip: ink'',
1058+
and any descendants that do not participate in the <i>decorating box</i>’s inline formatting context
1059+
are excluded from the set of <i>considered fragments</i>.
1060+
1061+
<p>
1062+
<dfn>Decoration-affecting text</dfn> is any text decorated by a <i>decorating box</i>
1063+
that can affect the size and position of the decoration;
1064+
descendants that are skipped due to 'text-decoration-skip',
1065+
descendant inlines with ''text-decoration-skip: ink'',
1066+
and any descendants that do not participate in the <i>decorating box</i>’s inline formatting context
1067+
are not <i>considered fragments</i>.
1068+
The position and thickness of decorations on <i>considered fragments</i> are calculated by looking at sets of <i>considered fragments</i>:
1069+
each set is composed of all the <i>considered fragments</i> in a single line box
1070+
and decorated by the same <i>decorating box</i>.
1071+
-->
10461072

10471073
<p>Since line decorations can span elements with varying font sizes and
10481074
vertical alignments, the best position for a line decoration is not
10491075
necessarily the ideal position dictated by the <a
10501076
href="#decorating-box"><i>decorating box</i></a>. Instead, it's
10511077
calculated, per line, from all text decorated by the <a
1052-
href="#decorating-box"><i>decorating box</i></a> on that line, the
1053-
<i>considered text</i>. However, descendants of the <a
1078+
href="#decorating-box"><i>decorating box</i></a> on that line, the <dfn
1079+
id=considered-text>considered text</dfn>. However, descendants of the <a
10541080
href="#decorating-box"><i>decorating box</i></a> that are skipped due to
10551081
<a href="#text-decoration-skip"><code
10561082
class=property>text-decoration-skip</code></a>’, descendant inlines with
10571083
<code class=css>text-decoration-skip: ink</code>’, and any
10581084
descendants that do not participate in the <a
10591085
href="#decorating-box"><i>decorating box</i></a>’s inline formatting
1060-
context are excluded from the set of <i>considered text</i>.
1086+
context are excluded from the set of <a
1087+
href="#considered-text"><i>considered text</i></a>.
10611088

1062-
<p> The line decoration positions are then calculated per set of
1063-
<i>considered fragments</i> as follows (treating <a
1064-
href="#underline-left"><i>over</i>-positioned underlines</a> as
1065-
<i>over</i> lines and <a href="#underline-left"><i>under</i>-positioned
1089+
<p> The line decoration positions are then calculated per line as follows
1090+
(treating <a href="#underline-left"><i>over</i>-positioned underlines</a>
1091+
as <i>over</i> lines and <a href="#underline-left"><i>under</i>-positioned
10661092
overlines</a> as <i>under</i> lines):
10671093

10681094
<dl>
1069-
<dt><a
1070-
href="http://www.w3.org/TR/css3-writing-modes/#over"><i>over</i></a>
1095+
<dt><a href="http://www.w3.org/TR/css-writing-modes/#over"><i>over</i></a>
10711096
lines
10721097

10731098
<dd> Align the line decoration with respect to the highest
10741099
<!-- <i>text-over</i> baseline of the considered fragments. --> <a
1075-
href="http://www.w3.org/TR/css3-writing-modes/#over"><i>over</i></a> edge
1076-
of the <i>considered fragments</i>’ content boxes.
1100+
href="http://www.w3.org/TR/css-writing-modes/#over"><i>over</i></a>
1101+
EM-box edge of the <a href="#considered-text"><i>considered text</i></a>.
10771102

10781103
<dt><a href="#underline-alphabetic"><i>alphabetic</i></a> underlines
10791104

10801105
<dd>
10811106
<p>The alphabetic underline position is calculated by taking the ideal
1082-
offset (from the alphabetic baseline) of each <i>considered
1083-
fragment</i>, averaging those, and then using the lowest alphabetic
1084-
baseline to actually position the line. (Alphabetic baselines can differ
1085-
between ‘<code class=css>baseline</code>’-aligned boxes if the
1086-
dominant baseline is non-alphabetic.) To prevent superscripts and
1087-
subscripts from throwing this position off-kilter, an inline with a
1088-
non-initial computed ‘<code class=property>vertical-align</code>’ is
1089-
treated as having the ideal underline position of their parent.
1107+
offset (from the alphabetic baseline) of each run of <a
1108+
href="#considered-text"><i>considered text</i></a>, averaging those, and
1109+
then using the lowest alphabetic baseline to actually position the line.
1110+
(Alphabetic baselines can differ between ‘<code
1111+
class=css>baseline</code>’-aligned boxes if the dominant baseline is
1112+
non-alphabetic.) To prevent superscripts and subscripts from throwing
1113+
this position off-kilter, an inline with a non-initial computed ‘<code
1114+
class=property>vertical-align</code>’ is treated as having the ideal
1115+
underline position of its parent.
10901116

10911117
<dt>non-alphabetic <a
1092-
href="http://www.w3.org/TR/css3-writing-modes/#under"><i>under</i></a>
1118+
href="http://www.w3.org/TR/css-writing-modes/#under"><i>under</i></a>
10931119
lines
10941120

10951121
<dd> Position the line decoration with respect to the lowest
10961122
<!-- <i>text-under</i> baseline of the considered fragments. --> <a
1097-
href="http://www.w3.org/TR/css3-writing-modes/#under"><i>under</i></a>
1098-
edge of the <i>considered fragments</i>’ content boxes.
1123+
href="http://www.w3.org/TR/css-writing-modes/#under"><i>under</i></a>
1124+
EM-box edge of the <a href="#considered-text"><i>considered text</i></a>.
10991125

11001126
<dt>line-throughs
11011127

@@ -1104,12 +1130,20 @@ <h3 id=line-position><span class=secno>2.7. </span> Determining the
11041130
descendant with a different computed ‘<code
11051131
class=property>font-size</code>’. (This ensures that the text remains
11061132
effectively “crossed out” despite any font size changes.) For each
1107-
set of <i>considered fragments</i> with the same ‘<code
1108-
class=property>font-size</code>’, compute an ideal position averaged
1109-
from their direct contents and font metrics (assigning any fragment with
1110-
non-initial ‘<code class=property>vertical-align</code>’ the ideal
1111-
position of its parent). Position the portion of the line across each
1112-
decorated fragment at that position.
1133+
run of <a href="#considered-text"><i>considered text</i></a> with the
1134+
same ‘<code class=property>font-size</code>’, compute an ideal
1135+
position averaged from its font metrics. To prevent superscripts and
1136+
subscripts from throwing this position off-kilter, an inline with a
1137+
non-initial computed ‘<code class=property>vertical-align</code>’ is
1138+
treated as having the ideal underline position of its parent. Position
1139+
the portion of the line across each decorated fragment at that position.
1140+
<p class=issue> For simplicity, line-throughs should draw over each
1141+
element at that element's preferred/averaged position. This can produce
1142+
some undesirable jumpiness, but there doesn't appear to be any way to
1143+
avoid that which is correct in all instances, and all attempts are
1144+
worryingly complex. What position should line-throughts adopt over
1145+
elements that have a different font-size, but no <a
1146+
href="#considered-text"><i>considered text</i></a>?
11131147
</dl>
11141148

11151149
<p> CSS does not define the thickness of line decorations. In determining

css-text-decor/Overview.src.html

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,37 @@ <h3 id="text-underline-position-property">
683683

684684
<h3 id="line-position">
685685
Determining the Position and Thickness of Line Decorations</h3>
686+
<!--
687+
<p>Since line decorations can span elements with varying font sizes and
688+
vertical alignments, the best position for a line decoration is not
689+
necessarily the ideal position dictated by the <i>decorating box</i>.
690+
In determining the position of text decoration lines within a given line box,
691+
user agents must consider, for each <i>decorating box</i> on that line,
692+
the “ideal” positions of such line decorations of each
693+
run of text decorated by that <i>decorating box</i>
694+
(each <dfn>considered run</dfn>).
695+
However, descendants of the <i>decorating box</i>
696+
that are skipped due to 'text-decoration-skip',
697+
descendant inlines with ''text-decoration-skip: ink'',
698+
and any descendants that do not participate in the <i>decorating box</i>’s inline formatting context
699+
are excluded from the set of <i>considered fragments</i>.
686700
701+
<p>
702+
<dfn>Decoration-affecting text</dfn> is any text decorated by a <i>decorating box</i>
703+
that can affect the size and position of the decoration;
704+
descendants that are skipped due to 'text-decoration-skip',
705+
descendant inlines with ''text-decoration-skip: ink'',
706+
and any descendants that do not participate in the <i>decorating box</i>’s inline formatting context
707+
are not <i>considered fragments</i>.
708+
The position and thickness of decorations on <i>considered fragments</i> are calculated by looking at sets of <i>considered fragments</i>:
709+
each set is composed of all the <i>considered fragments</i> in a single line box
710+
and decorated by the same <i>decorating box</i>.
711+
-->
687712
<p>Since line decorations can span elements with varying font sizes and
688713
vertical alignments, the best position for a line decoration is not
689714
necessarily the ideal position dictated by the <i>decorating box</i>.
690715
Instead, it's calculated, per line, from all text decorated by the <i>decorating box</i> on that line,
691-
the <i>considered text</i>.
716+
the <dfn>considered text</dfn>.
692717
However, descendants of the <i>decorating box</i>
693718
that are skipped due to 'text-decoration-skip',
694719
descendant inlines with ''text-decoration-skip: ink'',
@@ -697,46 +722,56 @@ <h3 id="line-position">
697722

698723
<p>
699724
The line decoration positions are then calculated
700-
per set of <i>considered fragments</i>
725+
per line
701726
as follows
702727
(treating <a href="#underline-left"><i>over</i>-positioned underlines</a> as <i>over</i> lines
703728
and <a href="#underline-left"><i>under</i>-positioned overlines</a> as <i>under</i> lines):
704729

705730
<dl>
706-
<dt><a href="http://www.w3.org/TR/css3-writing-modes/#over"><i>over</i></a> lines
731+
<dt><a href="http://www.w3.org/TR/css-writing-modes/#over"><i>over</i></a> lines
707732
<dd>
708733
Align the line decoration with respect to the highest
709734
<!-- <i>text-over</i> baseline of the considered fragments. -->
710-
<a href="http://www.w3.org/TR/css3-writing-modes/#over"><i>over</i></a> edge
711-
of the <i>considered fragments</i>’ content boxes.
735+
<a href="http://www.w3.org/TR/css-writing-modes/#over"><i>over</i></a> EM-box edge
736+
of the <i>considered text</i>.
712737

713738
<dt><a href="#underline-alphabetic"><i>alphabetic</i></a> underlines
714739
<dd>
715740
<p>The alphabetic underline position is calculated by taking
716-
the ideal offset (from the alphabetic baseline) of each <i>considered fragment</i>,
741+
the ideal offset (from the alphabetic baseline) of each run of <i>considered text</i>,
717742
averaging those, and then using the lowest alphabetic baseline to actually position the line.
718743
(Alphabetic baselines can differ between ''baseline''-aligned boxes
719744
if the dominant baseline is non-alphabetic.)
720745
To prevent superscripts and subscripts from throwing this position off-kilter,
721746
an inline with a non-initial computed 'vertical-align'
722-
is treated as having the ideal underline position of their parent.
747+
is treated as having the ideal underline position of its parent.
723748

724-
<dt>non-alphabetic <a href="http://www.w3.org/TR/css3-writing-modes/#under"><i>under</i></a> lines
749+
<dt>non-alphabetic <a href="http://www.w3.org/TR/css-writing-modes/#under"><i>under</i></a> lines
725750
<dd>
726751
Position the line decoration with respect to the lowest
727752
<!-- <i>text-under</i> baseline of the considered fragments. -->
728-
<a href="http://www.w3.org/TR/css3-writing-modes/#under"><i>under</i></a> edge
729-
of the <i>considered fragments</i>’ content boxes.
753+
<a href="http://www.w3.org/TR/css-writing-modes/#under"><i>under</i></a> EM-box edge
754+
of the <i>considered text</i>.
730755

731756
<dt>line-throughs
732757
<dd>
733758
Line-throughs essentially use the same sort of averaging as for alphabetic underlines,
734759
but recompute the position when drawing across a descendant with a different computed 'font-size'.
735760
(This ensures that the text remains effectively “crossed out” despite any font size changes.)
736-
For each set of <i>considered fragments</i> with the same 'font-size',
737-
compute an ideal position averaged from their direct contents and font metrics
738-
(assigning any fragment with non-initial 'vertical-align' the ideal position of its parent).
761+
For each run of <i>considered text</i> with the same 'font-size',
762+
compute an ideal position averaged from its font metrics.
763+
To prevent superscripts and subscripts from throwing this position off-kilter,
764+
an inline with a non-initial computed 'vertical-align'
765+
is treated as having the ideal underline position of its parent.
739766
Position the portion of the line across each decorated fragment at that position.
767+
768+
<p class='issue'>
769+
For simplicity, line-throughs should draw over each element at that element's preferred/averaged position.
770+
This can produce some undesirable jumpiness,
771+
but there doesn't appear to be any way to avoid that which is correct in all instances,
772+
and all attempts are worryingly complex.
773+
What position should line-throughts adopt over elements that have a different font-size,
774+
but no <i>considered text</i>?
740775
</dl>
741776

742777
<p>

0 commit comments

Comments
 (0)