tor-browser

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

commit 6948a1fcebd03f87d97b9ff071e01fd050b8b60a
parent 67999ac27a74acd2e5824309443f8fb96048944e
Author: Andreu Botella <abotella@igalia.com>
Date:   Wed, 15 Oct 2025 09:14:18 +0000

Bug 1994271 [wpt PR 55423] - [line-clamp] Count lineless content after clamp when choosing to relayout, a=testonly

Automatic update from web-platform-tests
[line-clamp] Count lineless content after clamp when choosing to relayout

Line-clamp should not happen if the clamp point is at the end of the
line-clamp container. Since this can't be determined ahead of time, in
`BlockLineClampData::ShouldRelayoutWithNoForcedTruncate` (which is
called from `BlockLayoutAlgorithm::FinishLayout`), we check if we have
clamped; and in that case, if the number of lines until clamp is zero
rather than negative, we abort and relayout without clamp.

However, checking the number of lines until clamp only takes into
account whether there are any lines after the clamp point. If the only
content after the clamp point are block boxes containing no lines, or
independent formatting contexts (whose lines don't count when clamping
by lines), then the number of lines until clamp remains at zero, which
will cause a relayout without clamping.

To fix this, we update `BlockLineClampData::UpdateAfterLayout` to
explicitly decrease the lines until clamp by one if it's currently at
zero and the layout we've just done does not change the number of
lines. This means the first in-flow box immediately after the clamp
point is treated as having at least one line. Since after clamp, the
number of lines is only ever used for this relayout check, this should
not affect any other part of the line-clamp machinery.

Bug: 40336192
Change-Id: Ib7bb5ba8958038caf0152f2e14e307e69400d932
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7009807
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Andreu Botella <abotella@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1529627}

--

wpt-commits: ecc3c067406871d614c1b926c258620f6639ba7d
wpt-pr: 55423

Diffstat:
Atesting/web-platform/tests/css/css-overflow/line-clamp/line-clamp-036.html | 37+++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+), 0 deletions(-)

diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-036.html b/testing/web-platform/tests/css/css-overflow/line-clamp/line-clamp-036.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Overflow: `line-clamp` with only lineless content after clamp</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="/css/reference/ref-filled-green-100px-square.xht"> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> +<meta name="assert" content="If there is content after the clamp point, but it has no lines (e.g. lineless blocks or IFCs), the line-clamp container will still clamp."> +<style> +.clamp { + line-clamp: 4; + font: 25px/1 Ahem; +} +.green { + color: green; +} +.red { + background-color: red; +} +.lineless { + height: 1lh; +} +.ifc { + display: flow-root; +} +</style> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div class="clamp"> + <div class="green"> + PASS<br> + PASS<br> + PASS<br> + PAS<br> <!-- intentionally misspelled so the ellipsis doesn't stick out of the square --> + </div> + <div class="red lineless"></div> + <div class="red ifc">FAIL</div> +</div>