[webkit-changes] [WebKit/WebKit] fc02c9: [iOS] Add a (off-by-default) setting to make bidi ...
Wenson Hsieh
noreply at github.com
Wed Oct 9 11:08:22 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: fc02c970c4f7dd90289db2a822a60e38581556aa
https://github.com/WebKit/WebKit/commit/fc02c970c4f7dd90289db2a822a60e38581556aa
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2024-10-09 (Wed, 09 Oct 2024)
Changed paths:
A LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-expected.txt
A LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection.html
M LayoutTests/resources/ui-helper.js
M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
M Source/WebCore/platform/ios/SelectionGeometry.cpp
M Source/WebCore/platform/ios/SelectionGeometry.h
M Source/WebCore/rendering/RenderObject.cpp
M Source/WebCore/rendering/RenderObject.h
M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
M Source/WebKit/UIProcess/Cocoa/WKTextSelectionRect.mm
Log Message:
-----------
[iOS] Add a (off-by-default) setting to make bidi text selections appear visually contiguous
https://bugs.webkit.org/show_bug.cgi?id=281100
Reviewed by Richard Robinson.
Adjust some iOS text selection codepaths to allow for visually-contiguous selection views (that
appear logically discontiguous); guard this new behavior behind a feature flag, which is off by
default. This is work towards implementing a more intuitive selection behaviors for bidi text, by
ensuring visual stability while the user is interacting with selection handles.
In a subsequent patch, we'll extend the selection to ensure both logical and visual contiguity after
the user is done selecting text.
* LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-expected.txt: Added.
* LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection.html: Added.
Add a basic layout test to ensure that selection UI remains stable while the user is in the process
of selecting text.
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
Add the new internal feature flag.
* Source/WebCore/platform/ios/SelectionGeometry.cpp:
(WebCore::SelectionGeometry::SelectionGeometry):
(WebCore::operator<<):
* Source/WebCore/platform/ios/SelectionGeometry.h:
(WebCore::SelectionGeometry::mayAppearLogicallyDiscontiguous const):
(WebCore::SelectionGeometry::setMayAppearLogicallyDiscontiguous):
Add a new boolean flag to indicate that the `SelectionGeometry` may have a logically discontiguous
appearance.
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::areOnSameLine):
(WebCore::makeBidiSelectionVisuallyContiguousIfNeeded):
Implement the main heuristic to ensure visual contiguity here. At a high level, this post-processes
coalesced selection geometries such that:
- Interior selection geometries (neither the start nor end) are unaltered.
- Geometries that contain the start are all coalesced into a single selection that extends from
the selection start caret rect, to the end of the line containing the start position.
- Likewise, geometries that contain the end are coalesced into a selection that extends from the
start of the line containing the end position, to the end caret rect.
If all of the selected text is left-to-right, we simply skip the steps above. For now, we also only
support horizontal bidi text (i.e. bail from this codepath if there are any vertical selections).
(WebCore::RenderObject::collectSelectionGeometriesInternal):
(WebCore::RenderObject::collectSelectionGeometries):
* Source/WebCore/rendering/RenderObject.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/Cocoa/WKTextSelectionRect.mm:
(-[WKTextSelectionRect writingDirection]):
Canonical link: https://commits.webkit.org/284907@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