Bug 291495

Summary: Misses word-break opportunity and overflows
Product: WebKit Reporter: Johannes Odland <johannes.odland>
Component: Layout and RenderingAssignee: alan <zalan>
Status: RESOLVED FIXED    
Severity: Normal CC: ahmad.saleem792, bfulgham, fantasai.bugs, karlcow, koivisto, simon.fraser, vitor.roriz, webkit-bug-importer, zalan
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 18   
Hardware: All   
OS: All   
Attachments:
Description Flags
[fast-cq]Patch none

Johannes Odland
Reported 2025-04-13 12:28:45 PDT
There's a small bug in how WebKit breaks overflowing content with inline boxes. The bug occurs when it can fit the content but not the end side padding and border of an inline box inside the available width. Expected behavior: It should break at an earlier point if possible, moving the remaining content, padding and border to a new line. Current behavior: WebKit breaks the line at a later point, making the border and padding overflowing its container. Reduced test case: https://johannesodland.github.io/browserbugs/2025/safari-word-break-before-inline-box-end.html processOverflowingContentWithText
Attachments
[fast-cq]Patch (6.13 KB, patch)
2025-04-25 09:03 PDT, alan
no flags
Ahmad Saleem
Comment 1 2025-04-13 13:36:59 PDT
Firefox Nightly 139 (20250413095036) and Chrome Canary 137.0.7123.0 (Official Build) canary (arm64) matches each other and split in two lines. While Safari 18.4 and WebKit ToT (293648@main) remain in one line.
Johannes Odland
Comment 2 2025-04-14 01:03:40 PDT
Here's my current understanding of the issue: In `InlineContentBreaker::processOverflowingContentWithText()` webkit notices that the InlineBoxEnd item will cause overflow, and stores the index of the inline box end as `overflowingRunIndex`. Later, it tries to run `InlineContentBreaker::tryBreakingPreviousNonOverflowingRuns()`. There it will try to break the previous text run, but the entire run fits. It then includes the trailing InlineBoxEnd, which overflows.
Johannes Odland
Comment 3 2025-04-14 03:17:35 PDT
Maybe the width of any trailing InlineBoxEnds should be subtracted from the available space before trying to break preceding text runs?
Radar WebKit Bug Importer
Comment 4 2025-04-20 12:29:17 PDT
alan
Comment 5 2025-04-25 09:03:24 PDT
Created attachment 475049 [details] [fast-cq]Patch
EWS
Comment 6 2025-04-25 15:31:35 PDT
Committed 294132@main (7953222aee54): <https://commits.webkit.org/294132@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 475049 [details].
Note You need to log in before you can comment on or make changes to this bug.