[webkit-changes] [WebKit/WebKit] 5a67b6: [iPadOS] Unable to two-finger pan image carousels ...
Wenson Hsieh
noreply at github.com
Wed Dec 4 15:44:17 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5a67b636ca3a3ae0df1e746a4ad9e0c44c2f1ed3
https://github.com/WebKit/WebKit/commit/5a67b636ca3a3ae0df1e746a4ad9e0c44c2f1ed3
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2024-12-04 (Wed, 04 Dec 2024)
Changed paths:
M Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h
M Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.mm
M Source/WebCore/page/Quirks.cpp
M Source/WebCore/page/Quirks.h
M Source/WebKit/Shared/ios/InteractionInformationAtPosition.h
M Source/WebKit/Shared/ios/InteractionInformationAtPosition.serialization.in
M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h
M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
M Source/WebKit/UIProcess/PageClient.h
M Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h
M Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm
M Source/WebKit/UIProcess/ios/PageClientImplIOS.h
M Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
M Source/WebKit/UIProcess/ios/PointerTouchCompatibilitySimulator.h
M Source/WebKit/UIProcess/ios/PointerTouchCompatibilitySimulator.mm
M Source/WebKit/UIProcess/ios/WKBaseScrollView.h
M Source/WebKit/UIProcess/ios/WKBaseScrollView.mm
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Log Message:
-----------
[iPadOS] Unable to two-finger pan image carousels in Amazon app using trackpad
https://bugs.webkit.org/show_bug.cgi?id=284041
rdar://140800215
Reviewed by Abrar Rahman Protyasha.
Make some improvements to the pointer touch compatibility quirk introduced in 286150 at main, and
deploy it to fix horizontal swiping over image carousels on product pages in the Amazon app.
- Only activate the quirk when performing mouse hover over specific DOM subtrees on Amazon/Feedly.
- Make the simulated touches more responsive by locking in to dispatching simulated touches once
the hysteresis threshold is met.
- Fix an issue where the scroll view content offset would sometimes jump when simulating touches.
See below for more information.
* Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h:
* Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.mm:
(WTF::IOSApplication::isAmazon):
* Source/WebCore/page/Quirks.cpp:
(WebCore::Quirks::needsPointerTouchCompatibility const):
Add a heuristic that engages this pointer touch compatibility quirk only when hovering over specific
targets in a couple of native iOS apps — Feedly and Amazon.
* Source/WebCore/page/Quirks.h:
* Source/WebKit/Shared/ios/InteractionInformationAtPosition.h:
* Source/WebKit/Shared/ios/InteractionInformationAtPosition.serialization.in:
Add a position information flag that determines whether or not the touch simulation quirk should be
active.
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
Refactor `PointerTouchCompatibilitySimulator` so that it's now always instantiated on the web view,
but only intercepts wheel events if the quirk is activated (based on the position information state
above).
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView scrollView:handleScrollUpdate:completion:]):
Make `handleScrollUpdate` return a `bool` result indicating whether the event should be handled, and
prevent dispatching the wheel event if so. Note that the page will always still see the begin/end
wheel events even if the touch simulation quirk kicks in, since we only return `true` from
`handleScrollUpdate` in the case where the wheel event phase is already `Changed`, and we always
reset immediately upon observing the `Ended` phase.
(-[WKWebView _setPointerTouchCompatibilitySimulatorEnabled:]):
(-[WKWebView _isSimulatingCompatibilityPointerTouches]):
(-[WKWebView shouldAllowPanGestureRecognizerToReceiveTouchesInScrollView:]):
Don't allow simulated touches to trigger scrolling via the scroll view pan gesture; see below for
more detail.
* Source/WebKit/UIProcess/PageClient.h:
* Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:
* Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
(-[WKScrollingNodeScrollViewDelegate shouldAllowPanGestureRecognizerToReceiveTouchesInScrollView:]):
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::shouldAllowPanGestureRecognizerToReceiveTouches const):
* Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::isSimulatingCompatibilityPointerTouches const):
* Source/WebKit/UIProcess/ios/PointerTouchCompatibilitySimulator.h:
(WebKit::PointerTouchCompatibilitySimulator::isSimulatingTouches const):
* Source/WebKit/UIProcess/ios/PointerTouchCompatibilitySimulator.mm:
(WebKit::hasPredominantHorizontalAxis):
(WebKit::PointerTouchCompatibilitySimulator::handleScrollUpdate):
Rework how touch simulation works:
1. Accumulate a total wheel delta when beginning a trackpad swipe, and consider the cumulative
delta when checking for the predominant scrolling axis. This allows a slow-but-steady horizontal
swipe to reliably trigger the quirk.
2. Once the quirk is active, intercept all subsequent wheel events and just perform touch event
simulation. This helps prevent erroneous vertical scroll jittering when swiping horizontally.
3. Apply the initial touch move delta when beginning the simulated touches, so that we immediately
dispatch `touchstart` over the centroid and `touchmove` to the centroid offset by the initial
delta. This prevents the stream of simulated touches from being incorrectly handled as a tap
gesture, if the touch simulation ends right after it begins.
(WebKit::PointerTouchCompatibilitySimulator::resetState):
(WebKit::PointerTouchCompatibilitySimulator::locationInScreen const):
Rename `m_delta` to `m_touchDelta` to clarify that this tracks the overall touch delta once the
simulated touch event stream begins.
(WebKit::PointerTouchCompatibilitySimulator::setEnabled):
Add a method to enable/disable `PointerTouchCompatibilitySimulator` on the fly, now that we always
create this helper class but only activate it when the user hovers over specific DOM elements in a
couple of targeted native apps.
(WebKit::PointerTouchCompatibilitySimulator::requiresPointerTouchCompatibility): Deleted.
Move this logic into `WebCore::Quirks`, now that it additionally depends on the state of the DOM.
* Source/WebKit/UIProcess/ios/WKBaseScrollView.h:
Add a new delegate method that allows WebKit's managed scroll views to avoid recognizing pan
gestures due to simulated touches.
* Source/WebKit/UIProcess/ios/WKBaseScrollView.mm:
(-[WKBaseScrollView gestureRecognizer:shouldReceiveTouch:]):
Additionally override `-gestureRecognizer:shouldReceiveTouch:` and return `NO` when pointer touch
compatibility simulator is actively sending touches to avoid unwanted scrolling due to these
simulated touches.
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _updateLastPointerRegionIfNeeded:]):
Make this also update the enablement state of `PointerTouchCompatibilitySimulator`, based on
`needsPointerTouchCompatibilityQuirk` in the position information computed based on the cursor
location.
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::elementPositionInformation):
Populate the new `needsPointerTouchCompatibilityQuirk` member on position information, based the
hit-tested node and new heuristics in `Quirks`.
Canonical link: https://commits.webkit.org/287368@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