WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
292563
text-wrap balance doesn't work correctly with non-zero word-spacing
https://bugs.webkit.org/show_bug.cgi?id=292563
Summary
text-wrap balance doesn't work correctly with non-zero word-spacing
Sage Fennel
Reported
2025-05-05 14:47:47 PDT
Created
attachment 475142
[details]
Minimal reproduction HTML file, open in Safari and compare with results in Firefox or Chrome The use of word-spacing (other than the value 0) causes text-wrap: balance to line wrap every word. The attached HTML file should render as: "Line Wrap" But in Safari it renders as: "Line Wrap" --- Version 18.4 (20621.1.15.11.10) macOS 15.4.1 (24E263)
Attachments
Minimal reproduction HTML file, open in Safari and compare with results in Firefox or Chrome
(335 bytes, text/html)
2025-05-05 14:47 PDT
,
Sage Fennel
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Sage Fennel
Comment 1
2025-05-05 15:17:40 PDT
FYI, apparently this bug doesn't happen with text-wrap: pretty; in Safari TP.
Karl Dubost
Comment 2
2025-05-07 17:33:16 PDT
@sage thanks for the report. Does it happen on a live website too? If I set a longer line data:text/html,<h1%20style="text-wrap:balance;%20word-spacing:1px;">Line%20Wrap%20for%20every%20words</h1> The last word is being sent to the next line.
Radar WebKit Bug Importer
Comment 3
2025-05-07 17:33:31 PDT
<
rdar://problem/150893603
>
Karl Dubost
Comment 4
2025-05-07 17:45:04 PDT
The difference in between pretty and balance.
https://searchfox.org/wubkat/rev/dd5fe1011df7e3438ac4889356abcab7681df46d/Source/WebCore/layout/formattingContexts/inline/InlineContentConstrainer.cpp#322-332
```cpp if (wrapStyle == TextWrapStyle::Balance) { const InlineLayoutUnit idealLineWidth = totalWidth / chunkSize; if (m_numberOfLinesInOriginalLayout <= maximumLinesToBalanceWithLineRequirement) return balanceRangeWithLineRequirement(rangeToConstrain, idealLineWidth, chunkSize, isFirstChunk); return balanceRangeWithNoLineRequirement(rangeToConstrain, idealLineWidth, isFirstChunk); } if (wrapStyle == TextWrapStyle::Pretty) { const InlineLayoutUnit idealLineWidth = m_maximumLineWidthConstraint - textWrapPrettyStretchability * textWrapPrettyMaxStretch; return prettifyRange(rangeToConstrain, idealLineWidth, isFirstChunk); } ```
Karl Dubost
Comment 5
2025-05-07 17:51:32 PDT
Maybe word-spacing makes the line width bigger but it is not taken into account in the computation for textwrap ?
Sage Fennel
Comment 6
2025-05-07 19:21:53 PDT
@Karl Happy to report it. I disabled the offending rule (word-spacing) on main site, but I spun up a preview deployment with it re-enabled, so you can see the bug in context. I have word-spacing added to h1,h2 on my site.
https://deploy-preview-134--wavebeem-com.netlify.app/
Source code here if you'd like to see anything else:
https://github.com/wavebeem/wavebeem.com/pull/134/files
Karl Dubost
Comment 7
2025-05-07 19:24:00 PDT
Thanks a lot for the additional context!
Yulun Wu
Comment 8
2025-05-14 17:24:23 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/45408
EWS
Comment 9
2025-05-16 15:18:05 PDT
Committed
295034@main
(fd6ce0109386): <
https://commits.webkit.org/295034@main
> Reviewed commits have been landed. Closing PR #45408 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug