[webkit-changes] [WebKit/WebKit] 0fd82d: [iOS] Selection shows in the wrong place while scr...
Wenson Hsieh
noreply at github.com
Fri Dec 6 16:34:07 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0fd82dd1a7ef0bc8f9c79c1b908cfa721870e21a
https://github.com/WebKit/WebKit/commit/0fd82dd1a7ef0bc8f9c79c1b908cfa721870e21a
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2024-12-06 (Fri, 06 Dec 2024)
Changed paths:
A LayoutTests/editing/selection/ios/hide-selection-in-separate-overflow-scrollers-expected.txt
A LayoutTests/editing/selection/ios/hide-selection-in-separate-overflow-scrollers.html
M Source/WebKit/Shared/EditorState.h
M Source/WebKit/Shared/EditorState.serialization.in
M Source/WebKit/UIProcess/ios/UIKitUtilities.h
M Source/WebKit/UIProcess/ios/UIKitUtilities.mm
M Source/WebKit/UIProcess/ios/WKContentView.mm
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
M Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.h
M Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm
M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Log Message:
-----------
[iOS] Selection shows in the wrong place while scrolling if endpoints are in different subscrollable containers
https://bugs.webkit.org/show_bug.cgi?id=284168
rdar://140934400
Reviewed by Richard Robinson and Abrar Rahman Protyasha.
When "Selection Honors Overflow Scrolling" is enabled, there's a remaining scenario where the
selection may show up in the wrong place while overflow scrolling — when one of the selection
endpoints is in a different scroller (compared to the scrollable container of the selection's common
ancestor), and this selection endpoint's container is scrolled separately from the rest of the
selection. In this case, selection UI will still be hosted in the compositing view above the common
ancestor, which means the selection rects in the nested overflow container won't be able to scroll
properly (i.e. detached from the rest of the selection).
To address this issue for now, fall back to the long-standing behavior of hiding the selection
during overflow scrolling, but only in this scenario where one part of the selection is being
scrolled separately from the rest of the selection; in practice, this should be rare enough of a
corner case, where most users would be unlikely to ever see this old behavior.
See below for more details.
* LayoutTests/editing/selection/ios/hide-selection-in-separate-overflow-scrollers-expected.txt: Added.
* LayoutTests/editing/selection/ios/hide-selection-in-separate-overflow-scrollers.html: Added.
Add a layout test to verify that the selection is still hidden while scrolling in this scenario,
even when `Selection Honors Overflow Scrolling` is enabled.
* Source/WebKit/Shared/EditorState.h:
* Source/WebKit/Shared/EditorState.serialization.in:
Add optional `ScrollingNodeID`s representing the innermost scrollable containers of the selection
start and end positions. Notably, this may differ from the `enclosingScrollingNodeID` in this
scenario where one of the endpoints exists in a nested subscrollable container.
* Source/WebKit/UIProcess/ios/UIKitUtilities.h:
* Source/WebKit/UIProcess/ios/UIKitUtilities.mm:
(-[UIView _wk_isAncestorOf:]):
Add a helper method to compute whether or not a view is a ancestor of another view.
* Source/WebKit/UIProcess/ios/WKContentView.mm:
(-[WKContentView _didExitStableState]):
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView shouldHideSelectionInFixedPositionWhenScrolling]):
Rename `shouldHideSelectionWhenScrolling` to `shouldHideSelectionInFixedPositionWhenScrolling`, to
more accurately reflect that this is just about hiding selection UI in fixed-position containers
when scrolling. This renaming is important to distinguish between the new method below that
determines whether we should hide the selection during overflow scrolling.
(-[WKContentView _scrollingNodeScrollingWillBegin:]):
Pass the target scroll view into `-willStartScrollingOverflow:`.
(-[WKContentView _scrollingNodeScrollingDidEnd:]):
Deploy `-_scrollViewForScrollingNodeID:` here to avoid duplicating some code.
(-[WKContentView _didCommitLoadForMainFrame]):
Stop suppressing the edit menu (and/or selection interaction) when navigating.
(-[WKContentView _reconcileEnclosingScrollViewContentOffset:]):
(-[WKContentView _scrollViewForScrollingNodeID:]):
(-[WKContentView _updateTargetedPreviewScrollViewUsingContainerScrollingNodeID:]):
(-[WKContentView _restoreEditMenuIfNeeded]):
Drive-by fix: rename `-didEndScrollingOverflow` to `-didConcludeDrop` and remove a FIXME.
(-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]):
Drive-by fix: rename `-willStartScrollingOverflow` to `-willBeginDragLift` and remove a FIXME.
(-[WKContentView _shouldHideSelectionDuringOverflowScroll:]):
Add a new helper method that determines whether we should hide the selection when scrolling an
overflow container:
- If "Selection Honors Overflow Scrolling" is disabled, we always hide the selection.
- Otherwise, if scrolling will cause one of the selection endpoints to (visually) detach from the
rest of the selection, we'll hide the selection (this is the fallback described above).
- Otherwise, don't hide the selection.
(-[WKContentView shouldHideSelectionWhenScrolling]): Deleted.
* Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.h:
* Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm:
(WebKit::HideEditMenuScope::HideEditMenuScope):
(WebKit::HideEditMenuScope::~HideEditMenuScope):
Clean up logic to temporarily hide the selection during overflow scrolling, or when performing a
drag, using a new RAII object — `HideEditMenuScope`.
(-[WKTextInteractionWrapper view]):
(-[WKTextInteractionWrapper willBeginDragLift]):
(-[WKTextInteractionWrapper didConcludeDrop]):
(-[WKTextInteractionWrapper willStartScrollingOverflow:]):
(-[WKTextInteractionWrapper didEndScrollingOverflow]):
(-[WKTextInteractionWrapper reset]):
Add a helper method to reset state (currently, just `_hideEditMenuScope`) when committing a
mainframe navigation. Note that we force `_shouldRestoreEditMenuAfterOverflowScrolling := NO` here
to avoid presenting the edit menu after navigating.
(-[WKTextInteractionWrapper willStartScrollingOrZooming]):
(-[WKTextInteractionWrapper didEndScrollingOrZooming]):
(-[WKTextInteractionWrapper asyncTextInteraction]):
(-[WKTextInteractionWrapper willStartScrollingOverflow]): Deleted.
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::computeEnclosingLayerID const):
Refactor this code to also compute `scrollingNodeIDAtStart` and `scrollingNodeIDAtEnd`.
Canonical link: https://commits.webkit.org/287477@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