From 1563c1e3a851d13982c2e9a0c2eabb8287823b35 Mon Sep 17 00:00:00 2001 From: Andreu Botella Date: Fri, 4 Oct 2024 16:39:40 -0700 Subject: [PATCH] [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 https://github.com/w3c/csswg-drafts/issues/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 Commit-Queue: Andreu Botella Cr-Commit-Position: refs/heads/main@{#1364495} --- .../line-clamp-auto-011.tentative.html | 2 +- .../line-clamp-auto-025.tentative.html | 7 +-- .../line-clamp-auto-026.tentative.html | 40 --------------- .../line-clamp-auto-032.tentative.html | 50 ------------------- .../line-clamp-auto-034.tentative.html | 11 ++-- .../line-clamp-auto-037.tentative.html | 2 +- .../reference/line-clamp-auto-011-ref.html | 5 +- .../reference/line-clamp-auto-025-ref.html | 27 ---------- .../reference/line-clamp-auto-026-ref.html | 32 ------------ .../reference/line-clamp-auto-032-ref.html | 34 ------------- .../reference/line-clamp-auto-034-ref.html | 23 --------- .../reference/line-clamp-auto-037-ref.html | 15 ++++++ 12 files changed, 30 insertions(+), 218 deletions(-) delete mode 100644 css/css-overflow/line-clamp/line-clamp-auto-026.tentative.html delete mode 100644 css/css-overflow/line-clamp/line-clamp-auto-032.tentative.html delete mode 100644 css/css-overflow/line-clamp/reference/line-clamp-auto-025-ref.html delete mode 100644 css/css-overflow/line-clamp/reference/line-clamp-auto-026-ref.html delete mode 100644 css/css-overflow/line-clamp/reference/line-clamp-auto-032-ref.html delete mode 100644 css/css-overflow/line-clamp/reference/line-clamp-auto-034-ref.html create mode 100644 css/css-overflow/line-clamp/reference/line-clamp-auto-037-ref.html diff --git a/css/css-overflow/line-clamp/line-clamp-auto-011.tentative.html b/css/css-overflow/line-clamp/line-clamp-auto-011.tentative.html index 00076a5336e890..50513516cc9daa 100644 --- a/css/css-overflow/line-clamp/line-clamp-auto-011.tentative.html +++ b/css/css-overflow/line-clamp/line-clamp-auto-011.tentative.html @@ -4,7 +4,7 @@ - + - -
-
-
Line 1 -Line 2 -Line 3 -Line 4 -
-
-
Line 5 -Line 6
-
-
diff --git a/css/css-overflow/line-clamp/line-clamp-auto-032.tentative.html b/css/css-overflow/line-clamp/line-clamp-auto-032.tentative.html deleted file mode 100644 index 17c6981ae33f11..00000000000000 --- a/css/css-overflow/line-clamp/line-clamp-auto-032.tentative.html +++ /dev/null @@ -1,50 +0,0 @@ - - -CSS Overflow: `line-clamp: auto` margin collapsing accounts for self-collapsing boxes - - - - - - - - -
-
Line 1 -Line 2 -Line 3 -Line 4
-
-
-
Line 5 -Line 6 -Line 7 -Line 8
-
diff --git a/css/css-overflow/line-clamp/line-clamp-auto-034.tentative.html b/css/css-overflow/line-clamp/line-clamp-auto-034.tentative.html index ebb676dfd8e0fa..96fe675d1b10c7 100644 --- a/css/css-overflow/line-clamp/line-clamp-auto-034.tentative.html +++ b/css/css-overflow/line-clamp/line-clamp-auto-034.tentative.html @@ -1,10 +1,10 @@ -CSS Overflow: `line-clamp: auto` clamp between IFCs +CSS Overflow: `line-clamp: auto` clamp height after IFC - - + + -
+
Line 1…

Following content.

diff --git a/css/css-overflow/line-clamp/reference/line-clamp-auto-025-ref.html b/css/css-overflow/line-clamp/reference/line-clamp-auto-025-ref.html deleted file mode 100644 index a76468d6d546e1..00000000000000 --- a/css/css-overflow/line-clamp/reference/line-clamp-auto-025-ref.html +++ /dev/null @@ -1,27 +0,0 @@ - - -CSS Reference - - -
-
Line 1 -Line 2 -Line 3 -Line 4… -
-
-
diff --git a/css/css-overflow/line-clamp/reference/line-clamp-auto-026-ref.html b/css/css-overflow/line-clamp/reference/line-clamp-auto-026-ref.html deleted file mode 100644 index 44d503a05220fd..00000000000000 --- a/css/css-overflow/line-clamp/reference/line-clamp-auto-026-ref.html +++ /dev/null @@ -1,32 +0,0 @@ - - -CSS Reference - - -
-
-
Line 1 -Line 2 -Line 3 -Line 4… -
-
-
-
diff --git a/css/css-overflow/line-clamp/reference/line-clamp-auto-032-ref.html b/css/css-overflow/line-clamp/reference/line-clamp-auto-032-ref.html deleted file mode 100644 index 4768c77ddabc93..00000000000000 --- a/css/css-overflow/line-clamp/reference/line-clamp-auto-032-ref.html +++ /dev/null @@ -1,34 +0,0 @@ - - -CSS Reference - - -
-
Line 1 -Line 2 -Line 3 -Line 4
-
-
-
diff --git a/css/css-overflow/line-clamp/reference/line-clamp-auto-034-ref.html b/css/css-overflow/line-clamp/reference/line-clamp-auto-034-ref.html deleted file mode 100644 index 8fae3b278c124d..00000000000000 --- a/css/css-overflow/line-clamp/reference/line-clamp-auto-034-ref.html +++ /dev/null @@ -1,23 +0,0 @@ - - -CSS Reference - - -
Line 1 -Line 2 -Line 3 -Line 4 -
Line 5 -Line 6
diff --git a/css/css-overflow/line-clamp/reference/line-clamp-auto-037-ref.html b/css/css-overflow/line-clamp/reference/line-clamp-auto-037-ref.html new file mode 100644 index 00000000000000..eeb9543554d996 --- /dev/null +++ b/css/css-overflow/line-clamp/reference/line-clamp-auto-037-ref.html @@ -0,0 +1,15 @@ + + +CSS Reference + +
Line 1…
+

Following content.