Skip to content

Commit ab4d234

Browse files
andreubotellafrivoaltabatkins
authored
[css-overflow-4] Draft spec for continue: collapse (#7708) (#10816)
* [css-overflow-4] Draft spec for `continue: collapse` (#7708) * Clarification about float clearance in the automatic block size * Update to only allow clamping after a line * Apply suggestions from code review Co-authored-by: Florian Rivoal <[email protected]> * Update css-overflow-4/Overview.bs Co-authored-by: Florian Rivoal <[email protected]> * Update css-overflow-4/Overview.bs * Update css-overflow-4/Overview.bs * Update css-overflow-4/Overview.bs * Update css-overflow-4/Overview.bs * Update css-overflow-4/Overview.bs * Update for #10439 * Update for #11962 * Update for #10868 --------- Co-authored-by: Florian Rivoal <[email protected]> Co-authored-by: Tab Atkins Jr. <[email protected]>
1 parent 65ab9cb commit ab4d234

File tree

1 file changed

+122
-29
lines changed

1 file changed

+122
-29
lines changed

css-overflow-4/Overview.bs

Lines changed: 122 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -707,12 +707,14 @@ Indicating Block-Axis Overflow: the 'block-ellipsis' property</h3>
707707
</pre>
708708

709709
This property allows inserting content into the last line box
710-
before a (forced <em>or</em> unforced) <a>region break</a>
711-
to indicate the continuity of truncated/interrupted content.
710+
before a (forced <em>or</em> unforced) <a>region break</a> or a [=clamp point=]
711+
to indicate the continuity of truncated / interrupted content.
712712
It only affects line boxes contained directly by the <a>block container</a> itself,
713713
but as it inherits, will have an effect on descendants’ line boxes unless overridden.
714-
If the box contains no line box immediately preceding a <a>region break</a>,
715-
then this property has no effect.
714+
715+
This property only affects a line box
716+
if it immediately precedes eiher a [=region break=]
717+
or a [=clamp point=] in the [=block formatting context=].
716718

717719
Note: See [[css-overflow-4#fragmentation]] for a way to generate boxes with such a [=region break=].
718720

@@ -777,10 +779,13 @@ Indicating Block-Axis Overflow: the 'block-ellipsis' property</h3>
777779
The [=block overflow ellipsis=] must not be included
778780
in either the ''::first-letter'' nor the ''::first-line'' pseudo-elements.
779781

780-
If there is a subsequent <a>fragmentation container</a> in the [=fragmentation context=]
782+
If the [=block overflow ellipsis=] is placed before a [=region break=] and
783+
there is a subsequent <a>fragmentation container</a> in the [=fragmentation context=]
781784
that would receive subsequent content,
782785
then the content displaced by the <a>block overflow ellipsis</a>
783786
must be pushed to that <a>fragmentation container</a>.
787+
If it is placed before a [=clamp point=],
788+
then the displaced content must be pushed to the remainder of the [=inline formatting context=].
784789

785790
The UA must treat the <a>block overflow ellipsis</a> as an unbreakable string,
786791
If any part of the [=block overflow ellipsis=] overflows,
@@ -810,7 +815,7 @@ Limiting Visible Lines: the 'line-clamp' shorthand property</h3>
810815

811816
<pre class="propdef shorthand">
812817
Name: line-clamp
813-
Value: none | <<integer [1,∞]>> || <<'block-ellipsis'>>
818+
Value: none | [<<integer [1,∞]>> || <<'block-ellipsis'>>] ''-webkit-legacy''?
814819
Initial: none
815820
Percentages: N/A
816821
</pre>
@@ -844,14 +849,21 @@ Limiting Visible Lines: the 'line-clamp' shorthand property</h3>
844849
<dt><dfn><<integer [1,∞]>></dfn>
845850
<dt><dfn><'block-ellipsis'></dfn>
846851
<dd>
847-
Sets 'continue' to ''discard''
848-
if either or both values ares specified.
852+
853+
Issue(7708): Whether this should imply ''discard'' or ''collapse'' is an unresolved question.
854+
855+
Sets 'continue' to ''collapse''
856+
if either or both values are specified,
857+
unless the ''line-clamp/-webkit-legacy'' keyword is also specified.
849858

850859
Sets 'max-lines' to the specified <<integer>>
851860
or to ''max-lines/none'' if omitted,
852861
and 'block-ellipsis' to other component of the value if specified
853862
or to ''block-ellipsis/auto'' if omitted.
854863

864+
<dt><dfn>-webkit-legacy</dfn>
865+
<dd>Sets 'continue' to ''continue/-webkit-legacy''.
866+
855867
</dl>
856868

857869
See the corresponding longhand properties for details
@@ -901,7 +913,7 @@ Legacy compatibility</h4>
901913

902914
For compatibility with legacy content,
903915
UAs that support 'line-clamp' must also support the '-webkit-line-clamp' property
904-
and the additional ''-webkit-discard'' value for the 'continue' property.
916+
and the additional ''continue/-webkit-legacy'' value for the 'continue' property.
905917

906918
<pre class="propdef shorthand">
907919
Name: -webkit-line-clamp
@@ -912,17 +924,18 @@ Legacy compatibility</h4>
912924

913925
<pre class="propdef partial">
914926
Name: continue
915-
New Values: -webkit-discard
927+
New Values: -webkit-legacy
916928
</pre>
917929

918930
Like 'line-clamp', '-webkit-line-clamp' is a shorthand of 'max-lines', 'continue', and 'block-ellipsis',
919931
except that:
920932

921933
* its syntax is ''line-clamp/none'' | <<integer [1,∞]>>
922-
* it sets 'continue' to ''-webkit-discard'' instead of ''discard''
934+
* it sets 'continue' to ''continue/-webkit-legacy'' instead of ''collapse''
935+
(as if the ''line-clamp/-webkit-legacy'' keyword was set on 'line-clamp')
923936
* it unconditionally sets 'block-ellipsis' to ''block-ellipsis/auto''
924937

925-
The <dfn value for=continue>-webkit-discard</dfn> value behaves identically to ''discard'',
938+
The <dfn value for=continue>-webkit-legacy</dfn> value behaves identically to ''collapse'',
926939
except that it only takes effect
927940
if the [=specified value=] of the 'display' property
928941
is ''-webkit-box'' or ''-webkit-inline-box''
@@ -947,28 +960,37 @@ Forcing a Break After a Set Number of Lines: the 'max-lines' property</h3>
947960
Name: max-lines
948961
Value: ''none'' | <<integer [1,∞]>>
949962
Initial: ''none''
950-
Applies to: <a>block containers</a> which are also [=fragmentation containers=] that capture [=region breaks=]
963+
Applies to: <a>block containers</a> which are also either [=fragmentation containers=] that capture [=region breaks=] or [=line-clamp containers=]
951964
Inherited: no
952965
Percentages: N/A
953966
Computed value: the keyword ''max-lines/none'' or an integer
954967
Animation type: by computed value type
955968
</pre>
956969

957-
This property only has an effect on boxes that are [=fragmentation containers=] that capture [=region breaks=].
958-
959-
Also, if the value of 'max-lines' is not <dfn for=max-lines dfn-type=value>none</dfn>,
960-
a <a>region break</a>
961-
is forced after its <var>N</var>th
962-
descendant <a>in-flow</a> <a>line box</a>,
963-
where <var>N</var> is the specified value of 'max-lines'.
964-
Only lines boxes in the same <a>Block Formatting Context</a>
970+
If the value of 'max-lines' is not <dfn for=max-lines dfn-type=value>none</dfn>,
971+
then, given a [=computed value=] of <var>N</var>:
972+
973+
- If the box is a [=fragmentation container=] that captures [=region breaks=],
974+
a <a>region break</a>
975+
is forced after its <var>N</var>th
976+
descendant <a>in-flow</a> <a>line box</a>.
977+
If fewer than <var>N</var> line boxes exist,
978+
then 'max-lines' introduces no <a>region break</a>.
979+
- If the box is a [=line-clamp container=],
980+
its [=clamp point=] is set
981+
to the first possible clamp point after
982+
its <var>N</var>th
983+
descendant <a>in-flow</a> <a>line box</a>.
984+
If fewer than <var>N</var> line boxes exist,
985+
or if there are no clamp points after it,
986+
then that line-clamp container has no clamp point.
987+
988+
989+
Only line boxes in the same <a>block formatting context</a>
965990
are counted:
966991
the contents of descendants that establish <a>independent formatting contexts</a>
967992
are skipped over while counting line boxes.
968993

969-
If fewer than <var>N</var> line boxes exist,
970-
then 'max-lines' introduces no <a>region break</a>.
971-
972994
Note: This implies that 'max-lines' has no effect when applied to [=multi-column containers=],
973995
since any line box they contain are nested into [=independent formatting contexts=].
974996

@@ -1004,7 +1026,7 @@ Fragmentation of Overflow: the 'continue' property</h3>
10041026

10051027
<pre class=propdef>
10061028
Name: continue
1007-
Value: auto | discard
1029+
Value: auto | discard | collapse
10081030
Initial: ''continue/auto''
10091031
Applies to: [=block containers=] and [=multicol containers=]
10101032
Inherited: no
@@ -1014,10 +1036,12 @@ Fragmentation of Overflow: the 'continue' property</h3>
10141036
</pre>
10151037

10161038
The 'continue' property gives authors the ability
1017-
to turn a box into a [=fragmentation container=] (see [[!CSS-BREAK-3]])
1018-
and to specify that content after the [=fragmentation break=] must be discarded.
1039+
to truncate/interrupt the content inside a box,
1040+
either by visually hiding the remaining content,
1041+
or by turning the box into a [=fragmentation container=] (see [[!CSS-BREAK-3]])
1042+
and discarding the content after the [=fragmentation break=].
10191043

1020-
Issue: This property is meant to generalize and replace the <code>region-fragment</code> property from [[CSS-REGIONS-1]].
1044+
Issue: ''continue: discard'' is meant to generalize and replace the <code>region-fragment</code> property from [[CSS-REGIONS-1]].
10211045
Once it is sufficiently stable in this specification,
10221046
<code>region-fragment</code> should be removed from the regions specification in favor of this.
10231047

@@ -1048,6 +1072,15 @@ Fragmentation of Overflow: the 'continue' property</h3>
10481072
Breaks applying to other [=fragmentation contexts=]
10491073
(such as pagination of this box itself)
10501074
do not cause any content to be discarded.
1075+
1076+
<dt><dfn>collapse</dfn>
1077+
<dd>
1078+
If the box is a [=block container=], then it must
1079+
[=establish an independent formatting context=] that also becomes a [=line-clamp container=].
1080+
This causes all content after the [=clamp point=] to be visually hidden, and to not be
1081+
taken into account for the box's [=automatic block size=].
1082+
1083+
This keyword has no effect on [=multicol containers=].
10511084
</dl>
10521085

10531086
<div class=example>
@@ -1114,6 +1147,9 @@ Fragmentation of Overflow: the 'continue' property</h3>
11141147
would cause intrinsic sizes to depend on layout, which would cause circularities.
11151148
-->
11161149

1150+
Note: This differs from the ''visibility: hidden''-like behavior
1151+
of content after the [=clamp point=] with ''continue: collapse''.
1152+
11171153
Note: In the case of <a href="https://www.w3.org/TR/css-break-3/#parallel-flows">parallel fragmentation flows</a>,
11181154
content occurring after the <a>fragmentation break</a> in the box tree
11191155
could still be rendered,
@@ -1122,7 +1158,7 @@ Fragmentation of Overflow: the 'continue' property</h3>
11221158

11231159
Additionaliy,
11241160
for compatibility (see [[#webkit-line-clamp]]),
1125-
when the [=computed value=] of the 'continue' property is ''discard''
1161+
when the [=computed value=] of the 'continue' property is ''collapse'', ''continue/-webkit-legacy'', or ''discard''
11261162
and the [=computed value=] of the '-webkit-box-orient' property is ''vertical'':
11271163
* If the [=specified value=] of the 'display' property is ''-webkit-box'',
11281164
the [=computed value=] becomes ''flow-root'' and
@@ -1139,6 +1175,63 @@ Fragmentation of Overflow: the 'continue' property</h3>
11391175
as the box would be a [=flex container=] rather than a [=block container=],
11401176
and thus the 'continue' property would not apply.
11411177

1178+
<h4 id=line-clamp-containers>Line-clamp containers</h4>
1179+
1180+
A <dfn export>line-clamp container</dfn> is an [=independent formatting context|independent=] [=block formatting context=]
1181+
that additionally follows the rules in this section.
1182+
Line-clamp containers can have a <dfn>clamp point</dfn>,
1183+
which is one of the following block-axis positions inside it:
1184+
1185+
- The start of the [=line-clamp container=].
1186+
- A point between two consecutive [=line boxes=]
1187+
in an [=inline formatting context=]
1188+
contained by the line-clamp container's [=block formatting context=].
1189+
- A point between two [=in-flow=] [=block-level=] sibling boxes
1190+
in the line-clamp container's [=block formatting context=].
1191+
1192+
If the [=line-clamp container=]'s [=block formatting context root=]
1193+
has a [=computed value=] of 'max-lines' other than ''max-lines/none'',
1194+
then that property will determine the [=clamp point=].
1195+
Otherwise, the clamp point will be set to the last possible clamp point
1196+
such that, for it and all previous possible clamp points,
1197+
the line-clamp container's [=automatic block size=]
1198+
(as determined below)
1199+
is not greater than the [=block size=] the box would have
1200+
if its automatic block size were infinite.
1201+
If the [=block size=] would be infinite,
1202+
then there is no clamp point.
1203+
1204+
Within a [=line-clamp container=],
1205+
the following boxes and line boxes become [=invisible boxes=]:
1206+
1207+
- Any [=in-flow=] or floating boxes
1208+
that follow the [=clamp point=] in the box tree.
1209+
This includes [=independent formatting contexts=]
1210+
and all of their descendants.
1211+
- Any [=line boxes=] that follow the [=clamp point=]
1212+
inside an [=inline formatting context=].
1213+
- Any [=absolutely positioned box=]
1214+
which has an invisible box within its [=containing block chain=],
1215+
and all of its descendants.
1216+
1217+
Any overflow such invisible boxes and line boxes might have
1218+
is always counted as [=ink overflow=] rather than [=scrollable overflow=].
1219+
1220+
NOTE: This differs from the ''display: none''-like behavior
1221+
of not rendered content with ''continue: discard''.
1222+
1223+
If a [=block container=] contains a [=clamp point=],
1224+
within itself or in any of its descendants,
1225+
its [=automatic block size=] will not take into account any invisible boxes.
1226+
This also applies for the [=line-clamp container=] itself.
1227+
1228+
NOTE: If there are any floats before the [=clamp point=],
1229+
the [=line-clamp container=]'s automatic size must grow to encompass the clearance,
1230+
just like it would if it were a regular [=block formatting context=] root
1231+
that only contained its contents before the [=clamp point=].
1232+
This is regardless of whether this would cause any content after the [=clamp point=]
1233+
to be within the container's bounds.
1234+
11421235
<h2 id=sbg-ext class=nonum>
11431236
Appendix A: Possible extensions for ''scrollbar-gutter''</h2>
11441237

0 commit comments

Comments
 (0)