[webkit-changes] [WebKit/WebKit] 3af28e: Tapping at the start of RTL text in bidi text sele...
Wenson Hsieh
noreply at github.com
Mon Oct 7 07:13:25 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3af28efca18605efc95068f0c3c7aaa2b010f0e6
https://github.com/WebKit/WebKit/commit/3af28efca18605efc95068f0c3c7aaa2b010f0e6
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2024-10-07 (Mon, 07 Oct 2024)
Changed paths:
A LayoutTests/editing/caret/caret-at-start-of-bidi-rtl-text-expected.txt
A LayoutTests/editing/caret/caret-at-start-of-bidi-rtl-text.html
R LayoutTests/platform/ios/imported/blink/editing/selection/offset-from-point-complex-scripts-expected.txt
M Source/WebCore/rendering/RenderText.cpp
Log Message:
-----------
Tapping at the start of RTL text in bidi text selects the visual end (logical start) of the text
https://bugs.webkit.org/show_bug.cgi?id=280950
rdar://137395868
Reviewed by Ryosuke Niwa.
On iOS, attempting to place the selection at the start of an RTL text run within LTR bidi text
(using any of floating text cursor, tap gesture, or clicking with a trackpad on iPadOS) causes the
selection to be placed at the logical start of the RTL text (visually, at the right edge) instead of
where you tapped/clicked.
This happens because of this iOS-specific codepath used to map coordinates to a rendered DOM
position, in `RenderText::positionForPoint`:
```
if (pointLineDirection != run->logicalLeftIgnoringInlineDirection() && point.x() < run->visualRectIgnoringBlockDirection().x() + run->logicalWidth()) {
auto half = LayoutUnit { run->visualRectIgnoringBlockDirection().x() + run->logicalWidth() / 2.f };
auto affinity = point.x() < half ? Affinity::Downstream : Affinity::Upstream;
return createVisiblePosition(offsetForPositionInRun(*run, pointLineDirection) + run->start(), affinity);
}
```
This codepath doesn't attempt to take bidi text into account at the edges of the bidi container,
causing the max and min caret offsets to be visually flipped at bidi level boundaries. To fix this,
we adopt `createVisiblePositionAfterAdjustingOffsetForBiDi` for consistency with the nearby
(platform-agnostic) return values.
* LayoutTests/editing/caret/caret-at-start-of-bidi-rtl-text-expected.txt: Added.
* LayoutTests/editing/caret/caret-at-start-of-bidi-rtl-text.html: Added.
Add a layout test to exercise the change.
* LayoutTests/platform/ios/imported/blink/editing/selection/offset-from-point-complex-scripts-expected.txt: Removed.
Remove this iOS-specific baseline, now that iOS behavior aligns with all other platforms.
* Source/WebCore/rendering/RenderText.cpp:
(WebCore::RenderText::positionForPoint):
Canonical link: https://commits.webkit.org/284760@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list