RESOLVED FIXED 220548
Hairline on selection when bidi text is involved
https://bugs.webkit.org/show_bug.cgi?id=220548
Summary Hairline on selection when bidi text is involved
Ebrahim Byagowi
Reported 2021-01-12 10:30:02 PST
Created attachment 417468 [details] hairline on selection Steps to reproduce: Open data:text/html;charset=utf8,<div>نوامبر%2020 select all of the text and zoom in with pinch to zoom to see the issue better Expected: A clear selection, like Firefox and Chrome Actual: Spotting a white hairline on selection More of different kinds of such hairlines can be easily spotted when opening https://fa.wikipedia.org/ and pressing ⌘+A perhaps we should reach to them one by one if they are not of the same root.
Attachments
hairline on selection (18.32 KB, image/png)
2021-01-12 10:30 PST, Ebrahim Byagowi
no flags
Hairlines (5.51 MB, video/quicktime)
2023-01-26 22:53 PST, Ebrahim Byagowi
no flags
no shrink selection rect (758.55 KB, image/png)
2023-01-27 07:48 PST, zalan
no flags
Patch (2.59 KB, patch)
2023-01-28 08:08 PST, zalan
no flags
Patch (2.65 KB, patch)
2023-01-28 10:27 PST, zalan
no flags
Patch (4.65 KB, patch)
2023-01-29 08:57 PST, zalan
ews-feeder: commit-queue-
Radar WebKit Bug Importer
Comment 1 2021-01-19 10:30:42 PST
Ebrahim Byagowi
Comment 2 2021-02-24 12:41:40 PST
This one doesn't involve bidi, data:text/html;charset=utf8,<span%20style="font-family:sans-serif"><span%20lang="ja">フレンズ</span>,
Ebrahim Byagowi
Comment 3 2022-10-08 00:14:35 PDT
This one still exists, just for the polishment worth to have a look I'd guess.
Ebrahim Byagowi
Comment 4 2023-01-26 22:53:08 PST
Created attachment 464685 [details] Hairlines @zalan, this will be a nice polish to have I believe, the screen cast shows how reliably one can see hairlines on Persian Wikipedia's homepage, https://fa.wikipedia.org other than minimal tests I've brought it.
zalan
Comment 5 2023-01-27 07:25:06 PST
(In reply to Ebrahim Byagowi from comment #4) > Created attachment 464685 [details] > Hairlines > > @zalan, this will be a nice polish to have I believe, the screen cast shows > how reliably one can see hairlines on Persian Wikipedia's homepage, > https://fa.wikipedia.org other than minimal tests I've brought it. :| this is an unfortunate side effect of how we measure text at soft wrap opportunity boundaries and happily join such "runs" without remeasuring them ignoring kerning (and ligature) adjustments. let's take the following example: <span>ンズ</span>text we form the following "runs" at soft wrap opportunities and measure them individually before line breaking [ン] -> 16px [ズ] -> 16px [text] -> 42px Later as we form the line, we merge [ン][ズ] into one run. This run now has the width of 32px but with potential kerning (and ligature) it may very well be (slightly) incorrect. When we get to selection painting (as background decoration) we have the following runs: [ンズ] -> left 0px, right 32px [text] -> left 32px, right 74px Now we want to be precise with the selection boundaries, so we call FontCascade::adjustSelectionRectForText() on these individual runs and due to kerning (and ligature) we may see a (slightly) different widths this time (note that we measure ンズ as one continuous run this time) [ンズ] -> 31.12px (and with directional pixel snapping -> 31.5px) [text] -> 42px and we paint selection at the following positions from 0px to 31.5px and from 42px to 74px which ends up producing a hairline gap. Now the correct fix is to never simply sum individual run widths when merging, but it has some performance (and line breaking cycle) implications afaict. The more practical fix may be to never shrink selection rect through this adjustment. Need to do some code reading first.
zalan
Comment 6 2023-01-27 07:48:13 PST
Created attachment 464688 [details] no shrink selection rect This is what the selection on the wiki page looks like after not letting the selection rect shrink.
Ebrahim Byagowi
Comment 7 2023-01-27 08:41:11 PST
> Need to do some code reading first. Oh, that just sounds fantastic, now that I know this problem had reached into good hands, I won't make any noise about it anymore as I indeed understand something to not happen in favor of performance given current infrastructure and code architecture. Thanks 😊
zalan
Comment 8 2023-01-28 08:08:40 PST
Ebrahim Byagowi
Comment 9 2023-01-28 09:17:07 PST
> Patch The patch works flawlessly when applied upon current tip of tree (ca0fcb99), and I'm hopeful it can be landed, thank you very much! 😊
zalan
Comment 10 2023-01-28 10:20:56 PST
(In reply to Ebrahim Byagowi from comment #9) > > Patch > > The patch works flawlessly when applied upon current tip of tree (ca0fcb99), > and I'm hopeful it can be landed, thank you very much! 😊 Thank you!
zalan
Comment 11 2023-01-28 10:27:39 PST
Ebrahim Byagowi
Comment 12 2023-01-28 21:16:31 PST
> Patch Just wanted to let you know I've tested the updated version of the patch also, awesome! 😊
zalan
Comment 13 2023-01-29 08:57:14 PST
zalan
Comment 14 2023-01-29 08:57:39 PST
Same patch (now with a test case)
EWS
Comment 15 2023-01-29 12:31:51 PST
Committed 259537@main (df25b495844d): <https://commits.webkit.org/259537@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 464741 [details].
Note You need to log in before you can comment on or make changes to this bug.