[webkit-changes] [WebKit/WebKit] 6151ef: Implement the "only the first wheel event is cance...

Simon Fraser noreply at github.com
Thu Mar 30 16:49:37 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6151efcb38ffe83c8b60a84a9bc563fb5e2dfc8b
      https://github.com/WebKit/WebKit/commit/6151efcb38ffe83c8b60a84a9bc563fb5e2dfc8b
  Author: Simon Fraser <simon.fraser at apple.com>
  Date:   2023-03-30 (Thu, 30 Mar 2023)

  Changed paths:
    M Source/WebCore/page/scrolling/ScrollingTree.cpp
    M Source/WebCore/page/scrolling/ScrollingTree.h
    M Source/WebCore/page/scrolling/ThreadedScrollingTree.h
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h
    M Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h
    M Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteLayerTreeEventDispatcher.cpp
    M Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteLayerTreeEventDispatcher.h
    M Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingCoordinatorProxyMac.h
    M Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingCoordinatorProxyMac.mm
    M Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.h
    M Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h
    M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in

  Log Message:
  -----------
  Implement the "only the first wheel event is cancelable" behavior for UI-side compositing
https://bugs.webkit.org/show_bug.cgi?id=250236
rdar://103969246

Reviewed by Tim Horton.

In 232108 at main I implemented support for "only the first wheel event in a gesture should be cancelable",
which is an intervention to prevent laggy pages with active wheel event listeners from causing bad scrolling.
It works by measuring how long it takes for the main thread to handle the "began" wheel event, and, if that
takes over 50ms, making all events in the rest of the scroll gesture non-blocking (i.e. they can't call preventDefault,
and we can do async scrolling). This code lives in `ThreadedScrollingTree::waitForEventToBeProcessedByMainThread()`.

This patch implements the same thing with UI-side compositing. The core implementation lives in
`RemoteScrollingTreeMac::willSendEventForDefaultHandling()`/``waitForEventDefaultHandlingCompletion()`, as
called from `RemoteLayerTreeEventDispatcher::scrollingThreadHandleWheelEvent()`. This required refactoring
that function to not return a value, but instead dispatch the `continueWheelEventHandling()` to the main thread
to send the event to the web process for JS handling.

We need to get a response from the web process `HandleWheelEvent()` message which tells us if the first
event had `preventDefault()` called on it (which allows the gesture to become non-blocking). We also need
to know the ScrollingNodeID which sync scrolling identified as the node that should scroll, since we still
need to do the scroll for non-default-prevented events, which we do via
`RemoteScrollingCoordinatorProxyMac::wheelEventHandlingCompleted())`.

A followup patch will address history swipe interaction.

* Source/WebCore/page/scrolling/ScrollingTree.cpp: Logging
(WebCore::ScrollingTree::computeWheelProcessingSteps):
(WebCore::ScrollingTree::determineWheelEventProcessing):
* Source/WebCore/page/scrolling/ScrollingTree.h:
(WebCore::ScrollingTree::willSendEventToMainThread): Deleted. No need for this on the base class.
(WebCore::ScrollingTree::waitForEventToBeProcessedByMainThread): Deleted.
* Source/WebCore/page/scrolling/ThreadedScrollingTree.h:
* Source/WebKit/Scripts/webkit/messages.py:
(headers_for_type):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
(WebKit::RemoteScrollingCoordinatorProxy::wheelEventHandlingCompleted):
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h:
(WebKit::RemoteScrollingTree::willSendEventForDefaultHandling):
(WebKit::RemoteScrollingTree::waitForEventDefaultHandlingCompletion):
(WebKit::RemoteScrollingTree::wheelEventDefaultHandlingCompleted):
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteLayerTreeEventDispatcher.cpp:
(WebKit::RemoteLayerTreeEventDispatcher::handleWheelEvent):
(WebKit::RemoteLayerTreeEventDispatcher::scrollingThreadHandleWheelEvent):
(WebKit::RemoteLayerTreeEventDispatcher::continueWheelEventHandling):
(WebKit::RemoteLayerTreeEventDispatcher::determineWheelEventProcessing):
(WebKit::RemoteLayerTreeEventDispatcher::wheelEventHandlingCompleted):
(WebKit::RemoteLayerTreeEventDispatcher::wheelEventWasHandledByScrollingThread): Deleted.
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteLayerTreeEventDispatcher.h:
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingCoordinatorProxyMac.h:
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingCoordinatorProxyMac.mm:
(WebKit::RemoteScrollingCoordinatorProxyMac::wheelEventHandlingCompleted):
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.h:
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm:
(WebKit::RemoteScrollingTreeMac::willSendEventForDefaultHandling):
(WebKit::RemoteScrollingTreeMac::waitForEventDefaultHandlingCompletion):
(WebKit::RemoteScrollingTreeMac::wheelEventDefaultHandlingCompleted):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::sendWheelEvent):
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h:
(WebKit::RemoteScrollingCoordinator::create): Deleted.
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm:
(WebKit::RemoteScrollingCoordinator::handleWheelEventForScrolling):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::handleWheelEvent):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

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




More information about the webkit-changes mailing list