WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
251313
Incorrect text caret placement when RTL text starts with whitespace
https://bugs.webkit.org/show_bug.cgi?id=251313
Summary
Incorrect text caret placement when RTL text starts with whitespace
Ebrahim Byagowi
Reported
2023-01-27 22:55:15 PST
This is a reduction of something that hits me on RTL websites and happens both in Safari 16.2 and tip of tree (5dc808f2): Steps to reproduce: Open data:text/html;charset=utf8,<textarea%20dir=rtl%20style="font-size:%20500%">%20شسی%20شسی%20شسی%20شسی%20شسی%20شسی%20شسی%20شسی</textarea><script>document.querySelector('textarea').focus()</script> (if caret didn't appear, click on the textarea, press Command+A, press the right arrow key button) Expected: The caret should go to right most position, start of the text in RTL. Actual: The caret goes after the first space, as can be seen in the attached screen cast.
Attachments
Caret
(643.43 KB, video/quicktime)
2023-01-27 22:55 PST
,
Ebrahim Byagowi
no flags
Details
Patch
(5.95 KB, patch)
2023-01-29 09:00 PST
,
zalan
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(4.54 KB, patch)
2023-01-30 07:49 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Patch
(4.54 KB, patch)
2023-02-01 14:16 PST
,
zalan
no flags
Details
Formatted Diff
Diff
overhanging trailing space
(56.43 KB, image/png)
2023-02-03 20:07 PST
,
zalan
no flags
Details
[fast-cq]Patch
(10.55 KB, patch)
2023-02-04 19:37 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Ebrahim Byagowi
Comment 1
2023-01-27 22:55:52 PST
Created
attachment 464698
[details]
Caret
zalan
Comment 2
2023-01-28 06:57:46 PST
This is about incorrect hanging whitespace handling in RTL context. When the textarea's style is changed from "white-space: pre-wrap" to 'white-space: pre", it starts working fine. Looking at the individual text run positions, the logically leading (visually trailing) whitespace on the first line is at -5px (this is logical x -5px, which essentially means whitespace is put outside the textarea).
Radar WebKit Bug Importer
Comment 3
2023-01-28 06:58:21 PST
<
rdar://problem/104781435
>
zalan
Comment 4
2023-01-29 09:00:12 PST
Created
attachment 464742
[details]
Patch
Ebrahim Byagowi
Comment 5
2023-01-29 11:06:09 PST
> Patch
Just tested the patch and works as expected, awesome. Thanks 😊
zalan
Comment 6
2023-01-29 21:10:41 PST
(In reply to Ebrahim Byagowi from
comment #5
)
> > Patch > > Just tested the patch and works as expected, awesome. Thanks 😊
Thank you so much! I decided to go with a more (RTL) focused approach though -will post a new patch soon (sorry about that, will use this patch as a more generic fix for pre-wrap vs. scrollable overflow under a different bug).
zalan
Comment 7
2023-01-30 07:49:51 PST
Created
attachment 464751
[details]
Patch
Ebrahim Byagowi
Comment 8
2023-01-30 11:31:02 PST
Tested the new patch also and it works great, this use of C++ lambdas to contain variables needed to calculate one value is an interesting pattern I found in these fixes, hopefully I will use it somewhere I had access to a C++ codebase, and, thanks again 😊
zalan
Comment 9
2023-01-30 20:05:36 PST
(In reply to Ebrahim Byagowi from
comment #8
)
> Tested the new patch also and it works great, this use of C++ lambdas to > contain variables needed to calculate one value is an interesting pattern I > found in these fixes, hopefully I will use it somewhere I had access to a > C++ codebase, and, thanks again 😊
I find it useful when I need to scope things for clarify (especially with this many lines of comment) but don't want to introduce a static helper function.
zalan
Comment 10
2023-02-01 14:16:42 PST
Created
attachment 464805
[details]
Patch
Ebrahim Byagowi
Comment 11
2023-02-03 06:03:43 PST
Is that underline behind hanging space on svg/compositing/outermost-svg-with-border-padding.html worrisome? Apparently other browsers do that also, data:text/html;charset=utf8,<u%20dir=rtl%20style="width:700px;display:block;font-size:%20500%;%20white-space:%20pre-wrap">%20%D8%B4%D8%B3%DB%8C%20%D8%B4%D8%B3%DB%8C%20%D8%B4%D8%B3%DB%8C%20%D8%B4%D8%B3%DB%8C%20%D8%B4%D8%B3%DB%8C%20%D8%B4%D8%B3%DB%8C%20%D8%B4%D8%B3%DB%8C%20%D8%B4%D8%B3%DB%8C</textarea><script>document.querySelector('textarea').focus()</u>
Ebrahim Byagowi
Comment 12
2023-02-03 06:48:42 PST
> Apparently other browsers do that also,
But it shouldn't happen beyond the element borders apparently, hmmm.
zalan
Comment 13
2023-02-03 20:07:06 PST
(In reply to Ebrahim Byagowi from
comment #12
)
> > Apparently other browsers do that also, > > But it shouldn't happen beyond the element borders apparently, hmmm.
Chrome overhangs that trailing space too (see attached screenshot). going to take a look at that failing test case and land this patch shortly.
zalan
Comment 14
2023-02-03 20:07:29 PST
Created
attachment 464830
[details]
overhanging trailing space
zalan
Comment 15
2023-02-03 20:21:39 PST
(this is with overflow: visible. the failing test has overflow auto/scroll. This is about whether the trailing hanging whitespace should contribute to scrollable or ink overflow -current behavior is ink, but with this patch we start contributing to scrollable overflow)
zalan
Comment 16
2023-02-04 19:37:44 PST
Created
attachment 464842
[details]
[fast-cq]Patch
Ebrahim Byagowi
Comment 17
2023-02-04 23:00:54 PST
> Patch
Applied the patch on top of tip of tree (6c4c9810) and things look great, thanks 😊
zalan
Comment 18
2023-02-05 06:35:44 PST
(In reply to Ebrahim Byagowi from
comment #17
)
> > Patch > > Applied the patch on top of tip of tree (6c4c9810) and things look great, > thanks 😊
Thank you! Very much appreciated!
EWS
Comment 19
2023-02-05 06:38:49 PST
Committed
259868@main
(f500d3412d93): <
https://commits.webkit.org/259868@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 464842
[details]
.
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