From 4fd2a4467a3e1d5cdbf5792801140a1b4f38288a Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Tue, 15 Oct 2024 09:43:31 +0000 Subject: [PATCH] Bug 1922856 [wpt PR 48482] - [line-clamp] Always clamp immediately after a line box, a=testonly Automatic update from web-platform-tests [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} -- wpt-commits: 1563c1e3a851d13982c2e9a0c2eabb8287823b35 wpt-pr: 48482 UltraBlame original commit: 5751601c841de1f7d26475e22ebaa4d8ca71b474 --- .../line-clamp-auto-011.tentative.html | 18 +- .../line-clamp-auto-025.tentative.html | 59 ++- .../line-clamp-auto-026.tentative.html | 357 --------------- .../line-clamp-auto-032.tentative.html | 406 ------------------ .../line-clamp-auto-034.tentative.html | 62 ++- .../line-clamp-auto-037.tentative.html | 2 +- .../reference/line-clamp-auto-011-ref.html | 19 + .../reference/line-clamp-auto-025-ref.html | 126 ------ .../reference/line-clamp-auto-026-ref.html | 146 ------- .../reference/line-clamp-auto-032-ref.html | 168 -------- ...-ref.html => line-clamp-auto-037-ref.html} | 55 +-- 11 files changed, 91 insertions(+), 1327 deletions(-) delete mode 100644 testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-026.tentative.html delete mode 100644 testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-032.tentative.html delete mode 100644 testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-025-ref.html delete mode 100644 testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-026-ref.html delete mode 100644 testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-032-ref.html rename testing/web-platform/tests/css/css-overflow/line-clamp/reference/{line-clamp-auto-034-ref.html => line-clamp-auto-037-ref.html} (67%) diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-011.tentative.html b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-011.tentative.html index c6960596685b0..c2e978cf52233 100644 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-011.tentative.html +++ b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-011.tentative.html @@ -141,21 +141,11 @@ 0 it should -not +still show -any -lines -and -its -content -box -' -s -intrinsic -size -should -be -zero +the +first +line " > < diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-025.tentative.html b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-025.tentative.html index 344a5f829b12b..cceb2e112663a 100644 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-025.tentative.html +++ b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-025.tentative.html @@ -26,7 +26,7 @@ clamp point is -visible +hidden < / title @@ -99,13 +99,13 @@ " reference / +webkit +- line - clamp - -auto -- -025 +005 - ref . @@ -133,9 +133,10 @@ : auto is +at the last -one +line where the box @@ -145,38 +146,27 @@ t overflow . -Since -non -- -inline -abspos -have -a -clamp -point -after -them -and -they -don +An +immediately +following +box +even +if +it ' -t -take -up -any -space -in -the -container +s an abspos -right -at -the -boundary +that +takes +up +no +block +size should +still be -visible +hidden . " > @@ -205,6 +195,11 @@ 32px serif ; +padding +: +0 +4px +; background - color diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-026.tentative.html b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-026.tentative.html deleted file mode 100644 index c8ea7d2349f84..0000000000000 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-026.tentative.html +++ /dev/null @@ -1,357 +0,0 @@ -< -! -DOCTYPE -html -> -< -meta -charset -= -" -utf -- -8 -" -> -< -title -> -CSS -Overflow -: -abspos -exactly -at -the -clamp -point -is -visible -< -/ -title -> -< -link -rel -= -" -author -" -title -= -" -Andreu -Botella -" -href -= -" -mailto -: -abotella -igalia -. -com -" -> -< -link -rel -= -" -help -" -href -= -" -https -: -/ -/ -drafts -. -csswg -. -org -/ -css -- -overflow -- -4 -/ -# -line -- -clamp -" -> -< -link -rel -= -" -match -" -href -= -" -reference -/ -line -- -clamp -- -auto -- -026 -- -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 -. -If -there -' -s -bottom -padding -in -a -container -box -that -counts -as -effectively -shrinking -the -boundary -. -" -> -< -style -> -. -clamp -{ -line -- -clamp -: -auto -; -max -- -height -: -calc -( -4lh -+ -2 -* -2px -) -; -font -: -16px -/ -32px -serif -; -background -- -color -: -yellow -; -} -. -padding -{ -padding -: -2px -; -} -. -inner -{ -white -- -space -: -pre -- -wrap -; -} -. -abspos -{ -position -: -absolute -; -width -: -100px -; -height -: -100px -; -background -- -color -: -skyblue -; -} -< -/ -style -> -< -div -class -= -" -clamp -" -> -< -div -class -= -" -padding -" -> -< -div -class -= -" -inner -" -> -Line -1 -Line -2 -Line -3 -Line -4 -< -/ -div -> -< -div -class -= -" -abspos -" -> -< -/ -div -> -< -div -class -= -" -inner -" -> -Line -5 -Line -6 -< -/ -div -> -< -/ -div -> -< -/ -div -> diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-032.tentative.html b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-032.tentative.html deleted file mode 100644 index 3cb90748174a9..0000000000000 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-032.tentative.html +++ /dev/null @@ -1,406 +0,0 @@ -< -! -DOCTYPE -html -> -< -meta -charset -= -" -utf -- -8 -" -> -< -title -> -CSS -Overflow -: -line -- -clamp -: -auto -margin -collapsing -accounts -for -self -- -collapsing -boxes -< -/ -title -> -< -link -rel -= -" -author -" -title -= -" -Andreu -Botella -" -href -= -" -mailto -: -abotella -igalia -. -com -" -> -< -link -rel -= -" -help -" -href -= -" -https -: -/ -/ -drafts -. -csswg -. -org -/ -css -- -overflow -- -4 -/ -# -line -- -clamp -" -> -< -link -rel -= -" -match -" -href -= -" -reference -/ -line -- -clamp -- -auto -- -032 -- -ref -. -html -" -> -< -meta -name -= -" -assert -" -content -= -" -With -line -- -clamp -: -auto -if -a -clamp -point -might -fall -inside -a -box -its -margins -are -accounted -for -correctly -. -This -is -the -case -even -for -self -- -collapsing -boxes -before -the -clamp -point -. -" -> -< -style -> -. -clamp -{ -line -- -clamp -: -auto -; -max -- -height -: -calc -( -4lh -+ -2 -* -5px -) -; -font -: -16px -/ -32px -serif -; -background -- -color -: -orange -; -} -. -inner -{ -white -- -space -: -pre -; -margin -: -5px -; -background -- -color -: -yellow -; -} -. -collapse -- -through -{ -margin -: -5px -; -} -. -abspos -{ -position -: -absolute -; -right -: -0 -; -height -: -100px -; -width -: -100px -; -background -- -color -: -skyblue -; -} -< -/ -style -> -< -! -- -- -The -bottom -margins -of -both -the -first -. -inner -and -of -. -collapse -- -through -end -at -the -clamp -boundary -since -the -bottom -margin -of -. -inner -collapses -through -. -collapse -- -through -. -This -also -puts -the -static -position -of -. -abspos -at -the -clamp -boundary -which -means -it -will -be -visible -. -- -- -> -< -div -class -= -" -clamp -" -> -< -div -class -= -" -inner -" -> -Line -1 -Line -2 -Line -3 -Line -4 -< -/ -div -> -< -div -class -= -" -collapse -- -through -" -> -< -/ -div -> -< -div -class -= -" -abspos -" -> -< -/ -div -> -< -div -class -= -" -inner -" -> -Line -5 -Line -6 -Line -7 -Line -8 -< -/ -div -> -< -/ -div -> diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-034.tentative.html b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-034.tentative.html index a363d1234f659..519705e199b0b 100644 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-034.tentative.html +++ b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-034.tentative.html @@ -25,8 +25,9 @@ : auto clamp -between -IFCs +height +after +IFC < / title @@ -99,13 +100,13 @@ " reference / +webkit +- line - clamp - -auto -- -034 +005 - ref . @@ -128,25 +129,26 @@ clamp : auto -there -can -be -a +if +the +clamp +height +is +after +an +IFC +the clamp point -between -two -IFCs -. -In -that -case -no -line will -have -an -ellipsis +be +set +after +the +last +line +before +that . " > @@ -251,6 +253,7 @@ = " ifc +red " > Line @@ -261,25 +264,8 @@ / div > -< -div -class -= -" -ifc -red -" -> Line 7 -Line -8 -< -/ -div -> -Line -9 < / div diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-037.tentative.html b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-037.tentative.html index 0a74311e8e23e..6d03151cf3268 100644 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-037.tentative.html +++ b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-auto-037.tentative.html @@ -116,7 +116,7 @@ - auto - -011 +037 - ref . diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-011-ref.html b/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-011-ref.html index d5a4c5c037ab1..25ee63a45cd13 100644 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-011-ref.html +++ b/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-011-ref.html @@ -28,6 +28,23 @@ . clamp { +height +: +0 +; +font +: +16px +/ +32px +serif +; +white +- +space +: +pre +; background - color @@ -57,6 +74,8 @@ clamp " > +Line +1 < / div diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-025-ref.html b/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-025-ref.html deleted file mode 100644 index 47f5401e05b6e..0000000000000 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-025-ref.html +++ /dev/null @@ -1,126 +0,0 @@ -< -! -DOCTYPE -html -> -< -meta -charset -= -" -utf -- -8 -" -> -< -title -> -CSS -Reference -< -/ -title -> -< -style -> -. -clamp -{ -font -: -16px -/ -32px -serif -; -background -- -color -: -yellow -; -} -. -inner -{ -white -- -space -: -pre -- -wrap -; -} -. -abspos -{ -position -: -absolute -; -width -: -100px -; -height -: -100px -; -background -- -color -: -skyblue -; -} -< -/ -style -> -< -div -class -= -" -clamp -" -> -< -div -class -= -" -inner -" -> -Line -1 -Line -2 -Line -3 -Line -4 -< -/ -div -> -< -div -class -= -" -abspos -" -> -< -/ -div -> -< -/ -div -> diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-026-ref.html b/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-026-ref.html deleted file mode 100644 index faabf50530266..0000000000000 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-026-ref.html +++ /dev/null @@ -1,146 +0,0 @@ -< -! -DOCTYPE -html -> -< -meta -charset -= -" -utf -- -8 -" -> -< -title -> -CSS -Reference -< -/ -title -> -< -style -> -. -clamp -{ -font -: -16px -/ -32px -serif -; -background -- -color -: -yellow -; -} -. -padding -{ -padding -: -2px -; -} -. -inner -{ -white -- -space -: -pre -- -wrap -; -} -. -abspos -{ -position -: -absolute -; -width -: -100px -; -height -: -100px -; -background -- -color -: -skyblue -; -} -< -/ -style -> -< -div -class -= -" -clamp -" -> -< -div -class -= -" -padding -" -> -< -div -class -= -" -inner -" -> -Line -1 -Line -2 -Line -3 -Line -4 -< -/ -div -> -< -div -class -= -" -abspos -" -> -< -/ -div -> -< -/ -div -> -< -/ -div -> diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-032-ref.html b/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-032-ref.html deleted file mode 100644 index f377329d4c316..0000000000000 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-032-ref.html +++ /dev/null @@ -1,168 +0,0 @@ -< -! -DOCTYPE -html -> -< -meta -charset -= -" -utf -- -8 -" -> -< -title -> -CSS -Reference -< -/ -title -> -< -style -> -. -clamp -{ -display -: -flow -- -root -; -font -: -16px -/ -32px -serif -; -background -- -color -: -orange -; -} -. -inner -{ -white -- -space -: -pre -; -margin -: -5px -; -background -- -color -: -yellow -; -} -. -collapse -- -through -{ -margin -: -5px -; -} -. -abspos -{ -position -: -absolute -; -right -: -0 -; -height -: -100px -; -width -: -100px -; -background -- -color -: -skyblue -; -} -< -/ -style -> -< -div -class -= -" -clamp -" -> -< -div -class -= -" -inner -" -> -Line -1 -Line -2 -Line -3 -Line -4 -< -/ -div -> -< -div -class -= -" -collapse -- -through -" -> -< -/ -div -> -< -div -class -= -" -abspos -" -> -< -/ -div -> -< -/ -div -> diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-034-ref.html b/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-037-ref.html similarity index 67% rename from testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-034-ref.html rename to testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-037-ref.html index 9e5b585167d2f..046cc8f7307af 100644 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-034-ref.html +++ b/testing/web-platform/tests/css/css-overflow/line-clamp/reference/line-clamp-auto-037-ref.html @@ -28,11 +28,11 @@ . clamp { -display +height : -flow -- -root +0 +. +5lh ; font : @@ -47,32 +47,21 @@ : pre ; -padding -: -0 -4px -; background - color : yellow ; -} -. -ifc -{ -display +border : -flow -- -root +1px +solid +black ; -background -- -color +padding : -orange +4px ; } < @@ -89,29 +78,17 @@ > Line 1 -Line -2 -Line -3 -Line -4 < +/ div -class -= -" -ifc -" > -Line -5 -Line -6 < -/ -div +p > +Following +content +. < / -div +p >