-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[line-clamp] Always clamp immediately after a line box
In our initial implementation of `line-clamp: auto`, we allowed clamping after lineless boxes, in order to better match the behavior of `line-clamp` as it follows from the spec's `continue: discard` model, even though our implementation uses a different model which is not yet in the specification (see w3c/csswg-drafts#7708). However, in hallway conversations in TPAC 2024, we agreed that it would be better for this model to instead only allow clamping immediately after a line. If the first line does not fit, we calmp at the first line even if that overflows the clamp height. If there are no lines, we do not clamp. This patch implements this. Additionally, a previous patch (https://crrev.com/c/5868971) had increased the memory size of `LineClampData` from 8 to 20 bytes, causing a memory regression. This patch shrinks it to 12 bytes, since `LineClampData` no longer needs to keep track of how many block boxes there are between the last line and the clmap point, and now OOFs after the clamped line behave the same when clamping by a number of lines or by a height, so there is no need for a flag to distinguish these behaviors. This patch also adds a size assertion for `LineClampData`. This patch also changes or removes some WPT tests that were written assuming the previous behavior. Bug: 40336192, 368114054 Change-Id: I8c8afebb5dc566de92112cee2fcf24a2e60b42c8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5904459 Reviewed-by: Ian Kilpatrick <[email protected]> Commit-Queue: Andreu Botella <[email protected]> Cr-Commit-Position: refs/heads/main@{#1364495}
- Loading branch information
1 parent
2bbd336
commit 1563c1e
Showing
12 changed files
with
30 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
<link rel="author" title="Andreu Botella" href="mailto:[email protected]"> | ||
<link rel="help" href="https://drafts.csswg.org/css-overflow-4/#line-clamp"> | ||
<link rel="match" href="reference/line-clamp-auto-011-ref.html"> | ||
<meta name="assert" content="When line-clamp: auto is used with max-height: 0, it should not show any lines and its content box's intrinsic size should be zero"> | ||
<meta name="assert" content="When line-clamp: auto is used with max-height: 0, it should still show the first line"> | ||
<style> | ||
.clamp { | ||
line-clamp: auto; | ||
|
7 changes: 4 additions & 3 deletions
7
css/css-overflow/line-clamp/line-clamp-auto-025.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>CSS Overflow: abspos exactly at the clamp point is visible</title> | ||
<title>CSS Overflow: abspos exactly at the clamp point is hidden</title> | ||
<link rel="author" title="Andreu Botella" href="mailto:[email protected]"> | ||
<link rel="help" href="https://drafts.csswg.org/css-overflow-4/#line-clamp"> | ||
<link rel="match" href="reference/line-clamp-auto-025-ref.html"> | ||
<meta name="assert" content="The chosen clamp point with line-clamp: auto is the last one where the box size doesn't overflow. Since non-inline abspos have a clamp point after them, and they don't take up any space in the container, an abspos right at the boundary should be visible."> | ||
<link rel="match" href="reference/webkit-line-clamp-005-ref.html"> | ||
<meta name="assert" content="The chosen clamp point with line-clamp: auto is at the last line where the box size doesn't overflow. An immediately following box, even if it's an abspos that takes up no block size, should still be hidden."> | ||
<style> | ||
.clamp { | ||
line-clamp: auto; | ||
max-height: 4lh; | ||
font: 16px / 32px serif; | ||
padding: 0 4px; | ||
background-color: yellow; | ||
} | ||
.inner { | ||
|
40 changes: 0 additions & 40 deletions
40
css/css-overflow/line-clamp/line-clamp-auto-026.tentative.html
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
css/css-overflow/line-clamp/line-clamp-auto-032.tentative.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>CSS Overflow: `line-clamp: auto` clamp between IFCs</title> | ||
<title>CSS Overflow: `line-clamp: auto` clamp height after IFC</title> | ||
<link rel="author" title="Andreu Botella" href="mailto:[email protected]"> | ||
<link rel="help" href="https://drafts.csswg.org/css-overflow-4/#line-clamp"> | ||
<link rel="match" href="reference/line-clamp-auto-034-ref.html"> | ||
<meta name="assert" content="With `line-clamp: auto`, there can be a clamp point between two IFCs. In that case, no line will have an ellipsis."> | ||
<link rel="match" href="reference/webkit-line-clamp-005-ref.html"> | ||
<meta name="assert" content="With `line-clamp: auto`, if the clamp height is after an IFC, the clamp point will be set after the last line before that."> | ||
<style> | ||
.clamp { | ||
line-clamp: auto; | ||
|
@@ -28,6 +28,5 @@ | |
Line 2 | ||
Line 3 | ||
Line 4 | ||
<div class="ifc">Line 5 | ||
Line 6</div><div class="ifc red">Line 7 | ||
Line 8</div>Line 9</div> | ||
<div class="ifc red">Line 5 | ||
Line 6</div>Line 7</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
<title>CSS Overflow: `line-clamp: auto` with non-zero max-height that doesn't fit any content</title> | ||
<link rel="author" title="Andreu Botella" href="mailto:[email protected]"> | ||
<link rel="help" href="https://drafts.csswg.org/css-overflow-4/#line-clamp"> | ||
<link rel="match" href="reference/line-clamp-auto-011-ref.html"> | ||
<link rel="match" href="reference/line-clamp-auto-037-ref.html"> | ||
<meta name="assert" content="When line-clamp: auto is used with a max-height that isn't enough for any contained boxes or line boxes, then it should not show any content and its content box's intrinsic size should be zero"> | ||
<style> | ||
.clamp { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
css/css-overflow/line-clamp/reference/line-clamp-auto-025-ref.html
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
css/css-overflow/line-clamp/reference/line-clamp-auto-026-ref.html
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
css/css-overflow/line-clamp/reference/line-clamp-auto-032-ref.html
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
css/css-overflow/line-clamp/reference/line-clamp-auto-034-ref.html
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
css/css-overflow/line-clamp/reference/line-clamp-auto-037-ref.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>CSS Reference</title> | ||
<style> | ||
.clamp { | ||
height: 0.5lh; | ||
font: 16px / 32px serif; | ||
white-space: pre; | ||
background-color: yellow; | ||
border: 1px solid black; | ||
padding: 4px; | ||
} | ||
</style> | ||
<div class="clamp">Line 1…</div> | ||
<p>Following content.</p> |