tor-browser

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

commit b0c19969cb2713eb64d96726286173b0979d5a41
parent 055836804e701a7f6f6dfd3c3f222cf0f7f98ab9
Author: Andreu Botella <abotella@igalia.com>
Date:   Fri, 31 Oct 2025 08:55:14 +0000

Bug 1996844 [wpt PR 55711] - Let spaces hang before collapsed whitespace in a different item, a=testonly

Automatic update from web-platform-tests
Let spaces hang before collapsed whitespace in a different item

Certain kinds of preserved whitespace and other space separators at
the end of a line can hang, i.e. are allowed to overflow the edge of a
line box even if there are previous break opportunities, and are
ignored for alignment and justification. The conditions for this are
given in [CSS-TEXT]'s white space processing rules part II step 4.

This step of the spec, however, comes after step 3, which says that a
sequence of collapsible spaces at the end of the line gets removed.
This means that if a hangable space sequence is followed by a sequence
of collapsible spaces, breaking after the collapsible spaces should
cause the collapsible spaces to be removed, and the hangable spaces to
hang.

In Chromium, however, if there are hangable spaces in an inline item,
and they are followed by collapsible spaces in a different item (e.g.
separated by an open or close tag), the hangable spaces will not hang.
The reason for this is that the handling of collapsible spaces sets
`trailing_whitespace_` to `kCollapsed`, but only `kPreserved` (by
setting `LineInfo::HasTrailingSpaces()`) will cause the effects that
hanging has on alignment and justification. So we fixed this by making
sure that a `trailing_whitespace_` value of `kPreserved` is not
changed to `kCollapsed` in this case.

Note that `LineBreaker::HandleTrailingSpaces` does sometimes set
`trailing_whitespace_` to `kCollapsible`, but that can't cause this
issue, because then `RemoveTrailingCollapsibleSpace` will set the
proper `trailing_whitespace_`.

Bug: 447954818
Change-Id: Idb18811ff884fa20324ae6541dbc05e58a34a17d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7080407
Reviewed-by: Koji Ishii <kojii@chromium.org>
Reviewed-by: Andreu Botella <abotella@igalia.com>
Commit-Queue: Andreu Botella <abotella@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1536610}

--

wpt-commits: 04948e19b63acb896dd7c4c5bb2929cda1e03018
wpt-pr: 55711

Diffstat:
Atesting/web-platform/tests/css/css-text/white-space/hanging-whitespace-004.html | 39+++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)

diff --git a/testing/web-platform/tests/css/css-text/white-space/hanging-whitespace-004.html b/testing/web-platform/tests/css/css-text/white-space/hanging-whitespace-004.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Text Level 3: Collapsible spaces at the end of the line don't prevent previous whitespace from hanging</title> +<link rel="author" title="Andreu Botella" href="mailto:abotella@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-text-3/#hanging"> +<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2"> +<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="Phase II of the white space processing rules first removes collapsible spaces at the end of a line (step 3), and then a remaining sequence of white space can hang (step 4). Therefore, collapsible spaces at the end of the line shouldn't block previous whitespaces from hanging."> + +<style> + #square { + font: 25px/1 Ahem; + width: 4ch; + height: 4ch; + background: + linear-gradient(green, green) 1ch 0 / 1ch 1ch no-repeat, + linear-gradient(green, green) 3ch 0 / 1ch 1ch no-repeat, + linear-gradient(green, green) 0 2ch / 1ch 1ch no-repeat, + linear-gradient(green, green) 2ch 2ch / 1ch 1ch no-repeat, + red; + + white-space: normal; + color: green; + } + .right { + text-align: right; + } + .pre-wrap { + white-space: pre-wrap; + } +</style> + +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> + +<div id="square"> + <div>X X<span class="pre-wrap"> </span> XXXX</div> + <div class="right">X X<span class="pre-wrap"> </span> XXXX</div> +</div>