Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5d309c9d1cb5cb215cf9764e1aad513afaf7c6ba
https://github.com/WebKit/WebKit/commit/5d309c9d1cb5cb215cf9764e1aad513afaf7c6ba
Author: Charlie Wolfe <[email protected]>
Date: 2026-07-22 (Wed, 22 Jul 2026)
Changed paths:
M Source/WebCore/editing/TextManipulationController.cpp
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextManipulation.mm
Log Message:
-----------
Text translated from an RTL language keeps RTL selection behavior
https://bugs.webkit.org/show_bug.cgi?id=320005
rdar://182944889
Reviewed by Wenson Hsieh.
Translation replaces an element's text via TextManipulationController without
touching its writing
direction. Since caret and selection direction come from the enclosing block's
direction (not the
script of the characters), text translated from Arabic (RTL) to English (LTR)
stayed in an RTL
block, so the caret moved backwards and selection extended the wrong way.
After a replacement, update the enclosing block's direction to match the base
direction of the new
text when they disagree, mirroring how pasted content updates its direction in
ReplaceSelectionCommand. dir=auto blocks are left alone since they already
recompute direction from
content.
Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextManipulation.mm
* Source/WebCore/editing/TextManipulationController.cpp:
(WebCore::updateEnclosingBlockDirectionAfterReplacement):
(WebCore::TextManipulationController::replace):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextManipulation.mm:
(TestWebKitAPI::selectionDirectionProbe):
(TestWebKitAPI::TEST(TextManipulation,
CompleteTextManipulationTranslatedRTLParagraphUsesStaleSelectionDirection)):
Canonical link: https://commits.webkit.org/317745@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications