Fix selection.modify() to use resolved text direction instead of inline base direction#357
Fix selection.modify() to use resolved text direction instead of inline base direction#357sambandaru wants to merge 1 commit into
Conversation
|
@rniwa Could you please review |
|
For normative changes, the following tasks have been completed:
|
|
Please file bugs for each browser and have this discussed at an editing WG meeting. |
|
Ack |
|
Are there WPT tests for this? |
I will add one. |
Tests to support the spec change PR - w3c/selection-api#357 Bug: 499819853 Change-Id: Ia827a90b9c12f64d04ea72cb2bee8f0535bedd6e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7848414 Reviewed-by: Kent Tamura <tkent@chromium.org> Reviewed-by: Pranav Modi <pranavmodi@microsoft.com> Commit-Queue: Sambamurthy Bandaru <sambamurthy.bandaru@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1631971}
Tests to support the spec change PR - w3c/selection-api#357 Bug: 499819853 Change-Id: Ia827a90b9c12f64d04ea72cb2bee8f0535bedd6e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7848414 Reviewed-by: Kent Tamura <tkent@chromium.org> Reviewed-by: Pranav Modi <pranavmodi@microsoft.com> Commit-Queue: Sambamurthy Bandaru <sambamurthy.bandaru@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1631971}
Tests to support the spec change PR - w3c/selection-api#357 Bug: 499819853 Change-Id: Ia827a90b9c12f64d04ea72cb2bee8f0535bedd6e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7848414 Reviewed-by: Kent Tamura <tkent@chromium.org> Reviewed-by: Pranav Modi <pranavmodi@microsoft.com> Commit-Queue: Sambamurthy Bandaru <sambamurthy.bandaru@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1631971}
Steps 7–8 of
Selection.modify()use the inline base direction (paragraph-level CSSdirection) to map"left"/"right"to forwards/backwards. This is wrong when the caret is inside a bidi run with a different direction.When the caret is inside "שלום" (an RTL run) and the user presses the Right arrow, the current spec maps Right to forwards, and moves the caret visually to the left. This is incorrect.
The spec should instead use the resolved text direction at the caret (rtl), which maps Right to backwards and moves the caret visually to the right.
Fix: Replace "inline base direction" with "resolved text direction at the focus" (bidi embedding level per UAX#9: even = LTR, odd = RTL).
Browser behavior: Firefox and Safari already use resolved text direction. Chromium currently matches the spec text; a fix is in progress. This change aligns the spec with majority interoperable behavior.
Preview | Diff