[webkit-changes] [WebKit/WebKit] 965f70: Ensure visually contiguous boundaries when extendi...
Wenson Hsieh
noreply at github.com
Fri Dec 20 12:46:57 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 965f70e7b6c9145e2f9977f3087f42f7aa09a1ae
https://github.com/WebKit/WebKit/commit/965f70e7b6c9145e2f9977f3087f42f7aa09a1ae
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2024-12-20 (Fri, 20 Dec 2024)
Changed paths:
A LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-extending-expected.txt
A LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-extending.html
M Source/WebCore/editing/Editing.cpp
M Source/WebCore/editing/Editing.h
M Source/WebCore/editing/FrameSelection.cpp
M Source/WebCore/editing/FrameSelection.h
M Source/WebCore/editing/RenderedPosition.cpp
M Source/WebCore/editing/RenderedPosition.h
Log Message:
-----------
Ensure visually contiguous boundaries when extending selection using Shift+Arrow keys
https://bugs.webkit.org/show_bug.cgi?id=284981
rdar://141786406
Reviewed by Aditya Keerthi and Ryosuke Niwa.
Add support for snapping to the nearest bidi text boundary that results in a visually contiguous
selection on iOS, in the case where `VisuallyContiguousBidiTextSelectionEnabled` is turned on. To
achieve this, we refactor the existing utilities in `Editing.cpp` that are currently used to adjust
a selection to nearest visually-contiguous bidi text boundaries, and expose a new helper function
that's used in `FrameSelection` when performing user-triggered selection extension.
See below for more details.
* LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-extending-expected.txt: Added.
* LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-extending.html: Added.
Add a layout test to exercise this change by extending the selection by word granularity, through
LTR and RTL paragraphs containing bidi text.
* Source/WebCore/editing/Editing.cpp:
(WebCore::findBidiBoundary):
Add a `SelectionExtentMovement` enum argument to control whether we should pick the left or right
bidi boundary when determining the adjusted boundary point that maintains visual contiguity.
(WebCore::boxWithMinimumBidiLevelBetween):
Add a helper method to find the inline box with the minimum bidi level between two
`RenderedPosition`s, and use it in a couple places below.
(WebCore::primaryDirectionForSingleLineRange):
(WebCore::makeVisuallyContiguousIfNeeded):
Pull the existing logic in `adjustToVisuallyContiguousRange` into a static helper, that returns
a visually contiguous range for the given range (or `nullopt` if there's no adjustment needed).
(WebCore::adjustToVisuallyContiguousRange):
Reimplement this in terms of `makeVisuallyContiguousIfNeeded`.
(WebCore::adjustVisibleExtentPreservingVisualContiguity):
Expose a new helper function that takes a base and (mutable) extent, and adjusts the extent in order
to produce a visually contiguous selection across bidi text.
(WebCore::visuallyClosestBidiBoundary): Deleted.
* Source/WebCore/editing/Editing.h:
* Source/WebCore/editing/FrameSelection.cpp:
(WebCore::FrameSelection::adjustSelectionExtentIfNeeded):
In addition to adjusting the position for `user-select: all;`, we now also ensure that the new
selection extent will result in a visually contiguous selection using the above helper.
(WebCore::FrameSelection::modifyExtendingRight):
(WebCore::FrameSelection::modifyExtendingForward):
(WebCore::FrameSelection::modifyExtendingLeft):
(WebCore::FrameSelection::modifyExtendingBackward):
(WebCore::FrameSelection::modify):
Plumb the `UserTriggered` flag into `modifyExtending*`.
(WebCore::FrameSelection::updateAppearance):
(WebCore::adjustPositionForUserSelectAll): Deleted.
Rename this to `adjustSelectionExtentIfNeeded`, and make it a private method on `FrameSelection`.
* Source/WebCore/editing/FrameSelection.h:
(WebCore::RenderedPosition::boundaryPoint const):
* Source/WebCore/editing/RenderedPosition.h:
Add a helper to make a `BoundaryPoint` from the `RenderedPosition`.
Canonical link: https://commits.webkit.org/288183@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