tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ca74ac45cbf9776aaf381a9ac7ff89cfb7525127
parent bef81873c5a04e139433841098e006bbaa8d21b4
Author: Andreu Botella <abotella@igalia.com>
Date:   Fri, 19 Dec 2025 09:13:47 +0000

Bug 2006151 [wpt PR 56747] - [line-clamp] Don't count phantom/empty lines when choosing to relayout, a=testonly

Automatic update from web-platform-tests
[line-clamp] Don't count phantom/empty lines when choosing to relayout

The CSS-INLINE spec defines a concept called "phantom line boxes"
(previously also known as "invisible line boxes"), which Chromium
refers to as "empty lines" (e.g. `LineInfo::IsEmptyLine`). Such line
boxes and their in-flow content must be treated as non-existing for
any purpose other than determining the position of their OOF
descendants, and for `line-clamp` they are indeed not counted when
clamping by lines.

Line-clamping should only have any effect when there is any content
after the clamp point; and in https://crrev.com/c/7009807 we fixed a
bug where lineless blocks and IFCs were ignored after the clamp point
by having them decrease the number of lines until clamp if the current
number is zero. However, this code only checked whether an in-flow
fragment did not decrease the number of lines, and assumed that it
must then be either a lineless block or an IFC.

As it turns out, however, phantom/empty line boxes are also in-flow
fragments that don't decrease the number of lines, but which are not
lineless blocks or IFCs. This change then made the presence of a
phantom/empty line box not be treated as non-existent if it is the
only content between the clamp point and the end of the line-clamp
container. To fix this, we added the condition that the fragment must
not be a line box.

Additionally, when writing tests, we also noticed that the DCHECK
inside this condition, which makes sure that there has been a previous
clamp point that we've previously chosen, would not hold if the
current block box starts immediately after the clamp point, since the
initial value of the number of lines until clamp would be zero. We
fixed this by removing this assertion, which in this case is harmless.

Bug: 467448802, 40336192
Change-Id: I4ab2fba137d1a2f5ca8f13991bf377ca64ae6fe6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7253151
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1558875}

--

wpt-commits: 29cea3325fdcef29ed4b9483d8eaa770da244003
wpt-pr: 56747

Diffstat:
Atesting/web-platform/tests/css/css-overflow/line-clamp/line-clamp-037.html | 23+++++++++++++++++++++++
Atesting/web-platform/tests/css/css-overflow/line-clamp/line-clamp-038.html | 29+++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-037.html b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-037.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Overflow: a phantom line box after the last non-phantom line box in a container doesn't introduce a clamp point</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="help" href="https://drafts.csswg.org/css-inline-3/#invisible-line-boxes"> +<link rel="match" href="reference/webkit-line-clamp-001-ref.html"> +<meta name="assert" content="Phantom line boxes are defined to be treated as not existing for any layout or rendering purpose other than determining the positions of any descendant, so if a regular line box is followed by a phantom line box, there's not a clamp point between them."> +<style> +.clamp { + line-clamp: 5; + font: 16px / 32px serif; + background-color: yellow; +} +</style> +<div class="clamp"> + Line 1 <br> + Line 2 <br> + Line 3 <br> + Line 4 <br> + Line 5 <br> + <span></span> <!-- phantom line box --> +</div> diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-038.html b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-038.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Overflow: a phantom line box after the last non-phantom line box in a container doesn't introduce a clamp point</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="help" href="https://drafts.csswg.org/css-inline-3/#invisible-line-boxes"> +<link rel="match" href="reference/webkit-line-clamp-001-ref.html"> +<meta name="assert" content="Phantom line boxes are defined to be treated as not existing for any layout or rendering purpose other than determining the positions of any descendant, so if a regular line box is followed by a phantom line box, there's not a clamp point between them. This is also the case if the phantom line box is created as a result of block-in-inline splitting."> +<style> +.clamp { + line-clamp: 5; + font: 16px / 32px serif; + background-color: yellow; +} +.clamp p { + margin: 0; +} +</style> +<div class="clamp"> + <span> + <div> + <p>Line 1</p> + <p>Line 2</p> + <p>Line 3</p> + <p>Line 4</p> + <p>Line 5</p> + </div> + </span> +</div>