Skip to content

[line-clamp] Fix crash w/ tabs in DoesRemainderFitInLineWithoutEllipsis#58771

Merged
chromium-wpt-export-bot merged 1 commit intomasterfrom
chromium-export-cl-7689516
Mar 26, 2026
Merged

[line-clamp] Fix crash w/ tabs in DoesRemainderFitInLineWithoutEllipsis#58771
chromium-wpt-export-bot merged 1 commit intomasterfrom
chromium-export-cl-7689516

Conversation

@chromium-wpt-export-bot
Copy link
Copy Markdown
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Mar 26, 2026

With the CSSLineClampLineBreakingEllipsis feature flag on, the
line-clamp ellipsis takes up space when line breaking. This means that
if you're line-breaking with an ellipsis, you can't always know if
this line would be the last in the paragraph if the ellipsis wasn't
there.

This is why in https://crrev.com/c/6361775 the
InlineLayoutAlgorithm::DoesRemainderFitInLineWithoutEllipsis method
was added, which iterates through the remaining inline items in the
inline FC and adds up their width to figure that out; although in some
cases it doesn't have enough information, so it bails out and causes
the line breaker to run again without ellipsizing.

This method was assuming, however, that non-empty text or control
items (other than forced breaks) would always have an associated text
shape result. This is mostly the case, but it isn't for preserved
tabs, where the shape result is created when line shaping based on the
position in the line. This led to a crash in such cases.

This CL fixes this by testing whether the shape result is null, and if
so, it bails out of the algorithm causing the line breaker to run
again.

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

With the `CSSLineClampLineBreakingEllipsis` feature flag on, the
line-clamp ellipsis takes up space when line breaking. This means that
if you're line-breaking with an ellipsis, you can't always know if
this line would be the last in the paragraph if the ellipsis wasn't
there.

This is why in https://crrev.com/c/6361775 the
`InlineLayoutAlgorithm::DoesRemainderFitInLineWithoutEllipsis` method
was added, which iterates through the remaining inline items in the
inline FC and adds up their width to figure that out; although in some
cases it doesn't have enough information, so it bails out and causes
the line breaker to run again without ellipsizing.

This method was assuming, however, that non-empty text or control
items (other than forced breaks) would always have an associated text
shape result. This is mostly the case, but it isn't for preserved
tabs, where the shape result is created when line shaping based on the
position in the line. This led to a crash in such cases.

This CL fixes this by testing whether the shape result is null, and if
so, it bails out of the algorithm causing the line breaker to run
again.

Bug: 40336192, 494630376
Change-Id: I28e2d391c86419ff54f054a5b823c07a794f089d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7689516
Reviewed-by: Koji Ishii <kojii@chromium.org>
Commit-Queue: Andreu Botella <abotella@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1605427}
Copy link
Copy Markdown
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot merged commit f2a5186 into master Mar 26, 2026
27 checks passed
@chromium-wpt-export-bot chromium-wpt-export-bot deleted the chromium-export-cl-7689516 branch March 26, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants