Bug 277203 - Extra wrap when table and different white-spaces are involved
Summary: Extra wrap when table and different white-spaces are involved
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari 17
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL: data:text/html,<table><td><span style...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2024-07-27 02:47 PDT by Ebrahim Byagowi
Modified: 2024-07-30 13:52 PDT (History)
5 users (show)

See Also:


Attachments
Test reduction (211 bytes, text/html)
2024-07-27 11:14 PDT, zalan
no flags Details
Screenshot after fix is applied (105.16 KB, image/png)
2024-07-27 11:24 PDT, zalan
no flags Details
Patch (16.35 KB, patch)
2024-07-28 16:43 PDT, zalan
no flags Details | Formatted Diff | Diff
Patch (16.35 KB, patch)
2024-07-28 18:42 PDT, zalan
no flags Details | Formatted Diff | Diff
Patch (16.46 KB, patch)
2024-07-28 20:30 PDT, zalan
no flags Details | Formatted Diff | Diff
Patch (7.72 KB, patch)
2024-07-29 13:30 PDT, zalan
no flags Details | Formatted Diff | Diff
[fast-cq]Patch (21.38 KB, patch)
2024-07-30 08:41 PDT, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ebrahim Byagowi 2024-07-27 02:47:45 PDT
Steps to repro:
Open the following
data:text/html;charset=utf8,<style>li { display: inline; word-spacing: -0.125em; } li:after { content: " • "; } li:last-child:after { content: none; } li span { white-space: normal; } ul { white-space: nowrap }</style><table><tr><td><ul><li>a</li><li><span>b </span></li><li><span>c</span></li></ul></td></tr></table>

Expected:
Have all of them in one line, like Firefox and Chrome

Actual:
There is an extra wrap and this has turned into two lines

This is reduction of a Wikipedia page https://fa.wikipedia.org/wiki/الگو:الکترومغناطیس and actually I'm seeing this there very frequently.
Comment 1 Ebrahim Byagowi 2024-07-27 03:02:44 PDT
Simpler testcast:

data:text/html;charset=utf8,<table><td><span style="white-space: nowrap"><span style="word-spacing: -0.125em;">a • </span><span style="word-spacing: -0.125em;"><span style="white-space: normal;">b </span> • </span><span style="word-spacing: -0.125em;">c</span></span></td></table>
Comment 2 Ebrahim Byagowi 2024-07-27 03:10:02 PDT
Simpler testcase:

data:text/html,<table><td><span style="word-spacing: -0.125em; white-space: nowrap"><span style="white-space: normal;">a </span> - </span>b</td></table>
Comment 3 Ebrahim Byagowi 2024-07-27 03:25:42 PDT
Happens with WebKit ToT, cfab25f0bf96f64c1e6ad30979788cabaa4a4f4f
Comment 4 Ebrahim Byagowi 2024-07-27 03:26:06 PDT
(in addition to the stable Safari)
Comment 5 Radar WebKit Bug Importer 2024-07-27 05:38:14 PDT
<rdar://problem/132633448>
Comment 6 zalan 2024-07-27 05:43:09 PDT
:( alright, let's get this fixed.

Thank you for reporting it!
Comment 7 zalan 2024-07-27 11:14:54 PDT
Created attachment 471983 [details]
Test reduction

This bug is not specific to tables. Any shrink-to-fit content fails.
Comment 8 zalan 2024-07-27 11:22:57 PDT
Line wrap is caused by not accounting for negative word-space when probing if content fits the line.
Comment 9 zalan 2024-07-27 11:24:16 PDT
Created attachment 471984 [details]
Screenshot after fix is applied

this looks to be fixed. will post patch soon.
Comment 10 zalan 2024-07-28 16:43:47 PDT
Created attachment 471992 [details]
Patch
Comment 11 zalan 2024-07-28 18:42:23 PDT
Created attachment 471994 [details]
Patch
Comment 12 zalan 2024-07-28 20:30:31 PDT
Created attachment 471996 [details]
Patch
Comment 13 zalan 2024-07-29 13:30:31 PDT
Created attachment 472007 [details]
Patch
Comment 14 Ebrahim Byagowi 2024-07-30 06:08:04 PDT
I just built WebKit with patch 472007 here locally and can confirm it now works locally including on the original page I spotted the issue. Thank you for the fix! 😊
Comment 15 zalan 2024-07-30 08:41:47 PDT
Created attachment 472017 [details]
[fast-cq]Patch
Comment 16 zalan 2024-07-30 08:42:09 PDT
(In reply to Ebrahim Byagowi from comment #14)
> I just built WebKit with patch 472007 here locally and can confirm it now
> works locally including on the original page I spotted the issue. Thank you
> for the fix! 😊
Excellent! Thank you for verifying it!
Comment 17 EWS 2024-07-30 13:52:54 PDT
Committed 281600@main (0bf7c728f0c7): <https://commits.webkit.org/281600@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 472017 [details].