Closed Bug 1955899 Opened 5 months ago Closed 5 months ago

[wpt-sync] Sync PR 51539 - [line-clamp] Fix bug with line-breaking ellipsis inserted in last line

Categories

(Core :: CSS Parsing and Computation, task, P4)

task

Tracking

()

RESOLVED FIXED
138 Branch
Tracking Status
firefox138 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 51539 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/51539
Details from upstream follow.

Andreu Botella <abotella@igalia.com> wrote:

[line-clamp] Fix bug with line-breaking ellipsis inserted in last line

With line-clamp, if the line that would have the ellipsis happens to
be the last line in the line-clamp container, then it must not have
the ellipsis. In the spec's terms, there cannot be a region break (or
a clamp point) at the end of the container. The way this was
implemented was by laying out first with the ellipsis, and then doing
a relayout without ellipsizing if we detected that there were no lines
after it.

However, this was implemented when the ellipsis simply hid content
from the line. With the line breaking ellipsis the spec requires,
which we are implementing under the CSSLineClampLineBreakingEllipsis
flag, the presence of the ellipsis can push content to the next line,
which can make a line no longer the last line.

The behavior that is almost certainly expected is that in such cases,
the line would not have the ellipsis. To implement this, we detect
whether an ellipsized line would be the last line of its IFC if it
didn't have the ellipsis. We implement this in
InlineLayoutAlgorithm::DoesRemainderFitInLineWithoutEllipsis, which
tries to compute that based on item metrics, and it returns nullopt
to indicate that this cannot be computed without LineBreaker. Then,
the LayoutResult::WouldBeLastLineIfNotForEllipsis flag is set.

In the block layout algorithm's BlockLineClampData, if we're
clamping by a number of lines, and we've just laid out a line box with
the WouldBeLastLineIfNotForEllipsis, then we set a flag that will
make any further calls to BlockLineClampData::UpdateAfterLayout
ignore any further lines for the purposes of decreasing the number of
lines until clamp. This will mean that any remaining lines in the same
IFC will not be counted when determining whether we should relayout
without ellipsizing.

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

Component: web-platform-tests → CSS Parsing and Computation
Product: Testing → Core

CI Results

Ran 7 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 2 tests

Status Summary

Firefox

PASS: 1
FAIL: 1

Chrome

PASS: 1
FAIL: 1

Safari

FAIL: 2

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Pushed by wptsync@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a25e6e1bb5ee [wpt PR 51539] - [line-clamp] Fix bug with line-breaking ellipsis inserted in last line, a=testonly https://hg.mozilla.org/integration/autoland/rev/08263cd19fc5 [wpt PR 51539] - Update wpt metadata, a=testonly
Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 138 Branch
You need to log in before you can comment on or make changes to this bug.