Skip to content

Commit c740cb6

Browse files
[line-clamp] Disable overflow-wrap in a line with the ellipsis
Per the specification of `block-ellipsis` (one of the unexposed longhands that `line-clamp` is a shorthand for in the spec), the line-clamp ellipsis is placed after the last soft wrap opportunity that still allows the ellipsis to fit in the line, where soft wrap opportunities added by `overflow-wrap` are ignored. A previous CL, https://crrev.com/c/6394977, tried to implement this, and added a WPT test for it (`block-ellipsis-016.html`). However, it only tested and handled the case where the line would have overflown because it had `text-wrap: nowrap`, which was also handled specially with the line-clamp ellipsis. It did not handle cases where the line overflows because it has no soft wrap opportunities. This CL fixes that by not setting `break_anywhere_if_overflow_` when the line has a line-clamp ellipsis. Bug: 40336192 Change-Id: I657bc4b4b252c6b4f1fa39b57ff20d1446b5d0b9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6654782 Commit-Queue: Andreu Botella <abotella@igalia.com> Reviewed-by: Koji Ishii <kojii@chromium.org> Cr-Commit-Position: refs/heads/main@{#1475729}
1 parent 9a82027 commit c740cb6

2 files changed

Lines changed: 25 additions & 9 deletions

File tree

css/css-overflow/line-clamp/block-ellipsis-016.html

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
<title>CSS Overflow: soft wrap opportunities created by overflow-wrap are ignored for inserting block-ellipsis</title>
44
<link rel="author" title="Andreu Botella" href="mailto:abotella@igalia.com">
55
<link rel="help" href="https://drafts.csswg.org/css-overflow-4/#block-ellipsis">
6-
<link rel="match" href="reference/block-ellipsis-001-ref.html">
7-
<meta name="assert" content="The block-ellipsis is placed after the last soft wrap opportunity in the line box that fits the ellipsis. This happens even with text-wrap: nowrap, since that only prevents line wrapping, rather than removing wrap opportunities.">
6+
<link rel="match" href="reference/block-ellipsis-016-ref.html">
7+
<meta name="assert" content="The block-ellipsis is placed after the last soft wrap opportunity in the line box that fits the ellipsis. `overflow-wrap: anywhere`, however, does not count as creating soft wrap opportunities. Therefore, if a line with the ellipsis has no breakpoints that would prevent it from overflowing, it gets entirely displaced by the ellipsis.">
88
<style>
99
.clamp {
10-
line-clamp: 2;
11-
width: 63.1ch;
10+
line-clamp: 3;
11+
width: 20.1ch;
1212
border: 1px solid black;
1313
font-family: monospace;
14-
white-space: pre;
1514
overflow-wrap: anywhere;
1615
}
1716
</style>
18-
<div class="clamp">This time, Mark, who had always been the center of attention in
19-
any social gathering, walked into the room uncharacteristically quietly, barely speaking as he settled into a chair.
20-
21-
When asked, he said that he was fine, when he wasn't really fine.</div>
17+
<div class="clamp">
18+
This time, Mark
19+
walked in
20+
uncharacteristically <!-- the ellipsis would cause this line to overflow -->
21+
quietly.
22+
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Reference</title>
4+
<style>
5+
.clamp {
6+
width: 20.1ch;
7+
border: 1px solid black;
8+
font-family: monospace;
9+
}
10+
</style>
11+
<div class="clamp">
12+
This time, Mark
13+
walked in <br>
14+
15+
</div>

0 commit comments

Comments
 (0)