Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1e0a8f21db25c527d049ed36604c90d679f63ad5
https://github.com/WebKit/WebKit/commit/1e0a8f21db25c527d049ed36604c90d679f63ad5
Author: Wenson Hsieh <[email protected]>
Date: 2024-11-13 (Wed, 13 Nov 2024)
Changed paths:
M Source/WebCore/platform/ios/SelectionGeometry.cpp
M Source/WebCore/platform/ios/SelectionGeometry.h
M Source/WebCore/rendering/RenderLayerScrollableArea.h
M Source/WebKit/Shared/EditorState.cpp
M Source/WebKit/Shared/EditorState.h
M Source/WebKit/Shared/EditorState.serialization.in
M Source/WebKit/UIProcess/PageClient.h
M Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/WebPageProxy.h
M Source/WebKit/UIProcess/ios/PageClientImplIOS.h
M Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
M Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Log Message:
-----------
[iOS] Selection in overflow scroller is sometimes offset from selected
content while scrolling
https://bugs.webkit.org/show_bug.cgi?id=283018
Reviewed by Aditya Keerthi.
When `SelectionHonorsOverflowScrolling` is enabled, the selection sometimes
(visually) lags behind
the selected content in an overflow scrolling container. This can happen if:
1. The editor state (which contains selection rects relative to the root view)
is computed in the
web process and sent to the UI process.
2. While the editor state IPC is being sent via remote layer tree commit, the
subscrollable area
containing selection UI is scrolled (i.e. the content offset changes).
3. The editor state arrives in the UI process, and we use the stale geometry
data from (1) when
generating selection drawing info.
To fix this, we add logic in the web process to send the scroll position of the
enclosing scrollable
area over to the UI process, along with the rest of the editor state's visual
data. In the UI
process, we then use this information to reconcile the enclosing composited
scroll view's scroll
position with the (possibly stale) scroll position when we computed the editor
state. If the
difference in scroll offset is more than a tiny delta (1 px), we shift the
entire editor state's
geometry by the necessary amount (mapped to root view coordinates) to ensure
that the selection UI
doesn't get out of sync with its enclosing scroller.
* Source/WebCore/platform/ios/SelectionGeometry.cpp:
(WebCore::SelectionGeometry::move):
Add a helper method to shift the entire `SelectionGeometry` by a given offset.
* Source/WebCore/platform/ios/SelectionGeometry.h:
* Source/WebCore/rendering/RenderLayerScrollableArea.h:
* Source/WebKit/Shared/EditorState.cpp:
(WebKit::EditorState::move):
Add a helper method to shift all owned rects and quads in the `EditorState` by
a given offset. Note
that we call `clipOwnedRectExtentsToNumericLimits()` afterwards, to ensure that
the editor state
geometry is still robust against underflow / overflow.
* Source/WebKit/Shared/EditorState.h:
* Source/WebKit/Shared/EditorState.serialization.in:
Add `ScrollingNodeID` and `ScrollPosition` to the editor state's visual data.
* Source/WebKit/UIProcess/PageClient.h:
(WebKit::PageClient::reconcileEnclosingScrollViewContentOffset):
See above for more details.
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTreeTransaction):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::editorStateChanged):
(WebKit::WebPageProxy::updateEditorState):
Make these take an `EditorState&&` rvalue reference instead of a const
reference, so that we can
call into the new `PageClient` hook to reconcile the incoming editor state with
subscrollers if
needed.
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::reconcileEnclosingScrollViewContentOffset):
Implement the main fix here — check if the enclosing scroller has scrolled
since the editor state
was computed, and adjust incoming selection rects.
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _reconcileEnclosingScrollViewContentOffset:]):
(-[WKContentView _scrollViewForScrollingNodeID:]):
Pull logic to map a `ScrollingNodeID` to `UIScrollView` out into a separate
helper method, so that
we can call it from multiple places.
(-[WKContentView
_updateTargetedPreviewScrollViewUsingContainerScrollingNodeID:]):
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::interpretKeyEvent):
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::computeEnclosingLayerID const):
Additionally compute the enclosing `ScrollingNodeID` and its corresponding
scroll position, and send
it through the editor state update.
Canonical link: https://commits.webkit.org/286537@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes