Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fd843afddf6f891ee6c2d287b7c6a6b4ab44762d
      
https://github.com/WebKit/WebKit/commit/fd843afddf6f891ee6c2d287b7c6a6b4ab44762d
  Author: Tim Horton <[email protected]>
  Date:   2026-03-29 (Sun, 29 Mar 2026)

  Changed paths:
    M Source/WebKit/SourcesCocoa.txt
    M Source/WebKit/UIProcess/ViewGestureController.cpp
    M Source/WebKit/UIProcess/ViewGestureController.h
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp
    M Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm
    A Source/WebKit/UIProcess/mac/SwipeProgressTrackerMac.h
    A Source/WebKit/UIProcess/mac/SwipeProgressTrackerMac.mm
    M Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm
    M Source/WebKit/UIProcess/mac/WKAppKitGestureController.mm
    M Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj

  Log Message:
  -----------
  macOS: Wheel events with no backing platform event can't start a swipe
https://bugs.webkit.org/show_bug.cgi?id=310869
rdar://171300135

Reviewed by Richard Robinson, Aditya Keerthi, and Abrar Rahman Protyasha.

Wheel events that have no backing platform event can't make use of AppKit's
"trackSwipeWithEvent" method, and thus need a different path to make swiping 
work.
Take matters into our own hands with a custom (and async) swipe tracker and 
animator.

* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/ViewGestureController.cpp:
(WebKit::ViewGestureController::ViewGestureController):
(WebKit::ViewGestureController::controllerForPage):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
(WebKit::ViewGestureController::platformEventShouldCancelSwipe):
Allow the platform implementations to override `deltaShouldCancelSwipe` with 
richer
information from the platform event. If they decide not to, fall back to the 
existing behavior.

* Source/WebKit/UIProcess/ViewGestureController.h:
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp:
(WebKit::ViewGestureController::platformInitialize):
* Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::platformInitialize):
* Source/WebKit/UIProcess/mac/SwipeProgressTrackerMac.h: Added.
* Source/WebKit/UIProcess/mac/SwipeProgressTrackerMac.mm: Added.
Emulate "trackSwipeWithEvent" behavior.

(WebKit::easeOutCubic):
(WebKit::SwipeProgressTracker::SwipeProgressTracker):
(WebKit::SwipeProgressTracker::~SwipeProgressTracker):
(WebKit::SwipeProgressTracker::startTracking):
(WebKit::SwipeProgressTracker::reset):
(WebKit::SwipeProgressTracker::totalSwipeDistance const):
(WebKit::SwipeProgressTracker::handleEvent):
As events come in, progress through the m_state state machine. "Swiping" is the
fingers-down phase, and may result in either cancellation or completion of the 
swipe,
both of which usually (unless swiped all the way in one direction or the other)
progress to a snap animation (in either direction).

(WebKit::SwipeProgressTracker::shouldCancel):
Decide whether or not the swipe should be cancelled based on the current 
velocity
estimation and some thresholding.

(WebKit::SwipeProgressTracker::startAnimation):
(WebKit::SwipeProgressTracker::animationTimerFired):
(WebKit::SwipeProgressTracker::endAnimation):
(WebKit::SwipeProgressTracker::displayLinkFired):
(WebKit::SwipeProgressTracker::startDisplayLinkObserver):
(WebKit::SwipeProgressTracker::stopDisplayLinkObserver):
Implement the snap animation with a custom display link at full display 
framerate.

* Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::platformInitialize):
(WebKit::ViewGestureController::platformTeardown):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanStartSwipe):
(WebKit::ViewGestureController::handleScrollWheelEvent):
(WebKit::ViewGestureController::trackSwipeGesture):
For now, decide whether to use the existing implementation or not based on the 
existence
of an underlying platform event.

(WebKit::ViewGestureController::platformEventShouldCancelSwipe):
(WebKit::ViewGestureController::resetState):
Interrupt any ongoing MomentumEventDispatcher-driven momentum scrolling when 
cancelling a swipe,
so that a hard swipe doesn't result in the page scrolling from synthetic 
momentum events
after the swipe completes. trackSwipeWithEvent handles this for us normally, but
not in the new path.

* Source/WebKit/UIProcess/mac/WKAppKitGestureController.mm:
(-[WKAppKitGestureController interruptMomentumIfNeeded]):
* Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::interruptSyntheticMomentumScrolling):
Factor this interruption code out of one existing caller.

* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/310189@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to