⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285992 in webkit


Ignore:
Timestamp:
Nov 18, 2021, 2:06:53 AM (5 years ago)
Author:
Chris Lord
Message:

[GLIB] twitch.tv forces synchronous scrolling
https://bugs.webkit.org/show_bug.cgi?id=232376
<rdar://problem/85247010>

Reviewed by Simon Fraser.

Source/WebCore:

Make sure to keep the userScrollInProgress flag in sync for scrolling
nodes in the nicosia backend and add a utility function to determine
if user scroll is in progress for a given wheel event. This lets
EventDispatcher dispatch events asynchronously in that case.

No new tests, exercised by existing tests.

  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::isUserScrollInProgressAtEventLocation):

  • page/scrolling/ScrollingTree.h:
  • page/scrolling/ScrollingTreeScrollingNode.cpp:

(WebCore::ScrollingTreeScrollingNode::isUserScrollInProgress const):
(WebCore::ScrollingTreeScrollingNode::isUserScrollProgress const): Deleted.

  • page/scrolling/ScrollingTreeScrollingNode.h:
  • page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp:

(WebCore::ScrollingTreeScrollingNodeDelegateNicosia::handleWheelEvent):

Source/WebKit:

Don't force synchronous wheel event delivery for scroll events when
a user scroll is in progress.

  • WebProcess/WebPage/EventDispatcher.cpp:

(WebKit::EventDispatcher::wheelEvent):

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r285991 r285992  
     12021-11-18  Chris Lord  <clord@igalia.com>
     2
     3        [GLIB] twitch.tv forces synchronous scrolling
     4        https://bugs.webkit.org/show_bug.cgi?id=232376
     5        <rdar://problem/85247010>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Make sure to keep the userScrollInProgress flag in sync for scrolling
     10        nodes in the nicosia backend and add a utility function to determine
     11        if user scroll is in progress for a given wheel event. This lets
     12        EventDispatcher dispatch events asynchronously in that case.
     13
     14        No new tests, exercised by existing tests.
     15
     16        * page/scrolling/ScrollingTree.cpp:
     17        (WebCore::ScrollingTree::isUserScrollInProgressAtEventLocation):
     18        * page/scrolling/ScrollingTree.h:
     19        * page/scrolling/ScrollingTreeScrollingNode.cpp:
     20        (WebCore::ScrollingTreeScrollingNode::isUserScrollInProgress const):
     21        (WebCore::ScrollingTreeScrollingNode::isUserScrollProgress const): Deleted.
     22        * page/scrolling/ScrollingTreeScrollingNode.h:
     23        * page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp:
     24        (WebCore::ScrollingTreeScrollingNodeDelegateNicosia::handleWheelEvent):
     25
    1262021-11-18  Carlos Garcia Campos  <cgarcia@igalia.com>
    227
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r285526 r285992  
    6464ScrollingTree::~ScrollingTree() = default;
    6565
     66bool ScrollingTree::isUserScrollInProgressAtEventLocation(const PlatformWheelEvent& wheelEvent)
     67{
     68    if (!m_rootNode)
     69        return false;
     70
     71    // This method is invoked by the event handling thread
     72    Locker locker { m_treeStateLock };
     73
     74    if (m_treeState.nodesWithActiveUserScrolls.isEmpty())
     75        return false;
     76
     77    FloatPoint position = wheelEvent.position();
     78    position.move(m_rootNode->viewToContentsOffset(m_treeState.mainFrameScrollPosition));
     79    if (auto node = scrollingNodeForPoint(position))
     80        return m_treeState.nodesWithActiveUserScrolls.contains(node->scrollingNodeID());
     81
     82    return false;
     83}
     84
    6685OptionSet<WheelEventProcessingSteps> ScrollingTree::computeWheelProcessingSteps(const PlatformWheelEvent& wheelEvent)
    6786{
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r285669 r285992  
    104104    void setMomentumScrollingAnimatorEnabled(bool value) { m_momentumScrollingAnimatorEnabled = value; }
    105105
     106    WEBCORE_EXPORT bool isUserScrollInProgressAtEventLocation(const PlatformWheelEvent&);
    106107    WEBCORE_EXPORT OptionSet<WheelEventProcessingSteps> determineWheelEventProcessing(const PlatformWheelEvent&);
    107108    WEBCORE_EXPORT virtual WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&, OptionSet<WheelEventProcessingSteps> = { });
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp

    r285669 r285992  
    206206}
    207207
    208 bool ScrollingTreeScrollingNode::isUserScrollProgress() const
     208bool ScrollingTreeScrollingNode::isUserScrollInProgress() const
    209209{
    210210    return scrollingTree().isUserScrollInProgressForNode(scrollingNodeID());
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h

    r285526 r285992  
    7070    RectEdges<bool> edgePinnedState() const;
    7171
    72     bool isUserScrollProgress() const;
     72    bool isUserScrollInProgress() const;
    7373    void setUserScrollInProgress(bool);
    7474
  • trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp

    r285161 r285992  
    8181WheelEventHandlingResult ScrollingTreeScrollingNodeDelegateNicosia::handleWheelEvent(const PlatformWheelEvent& wheelEvent, EventTargeting eventTargeting)
    8282{
    83     if (!scrollingNode().canHandleWheelEvent(wheelEvent, eventTargeting)
    84         || !m_scrollController.handleWheelEvent(wheelEvent))
    85         return WheelEventHandlingResult::unhandled();
     83    bool wasInUserScroll = m_scrollController.isUserScrollInProgress();
     84    bool handled = scrollingNode().canHandleWheelEvent(wheelEvent, eventTargeting) && m_scrollController.handleWheelEvent(wheelEvent);
     85    bool isInUserScroll = m_scrollController.isUserScrollInProgress();
    8686
    87     return WheelEventHandlingResult::handled();
     87    if (isInUserScroll != wasInUserScroll)
     88        scrollingNode().setUserScrollInProgress(isInUserScroll);
     89
     90    return handled ? WheelEventHandlingResult::handled() : WheelEventHandlingResult::unhandled();
    8891}
    8992
  • trunk/Source/WebKit/ChangeLog

    r285990 r285992  
     12021-11-18  Chris Lord  <clord@igalia.com>
     2
     3        [GLIB] twitch.tv forces synchronous scrolling
     4        https://bugs.webkit.org/show_bug.cgi?id=232376
     5        <rdar://problem/85247010>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Don't force synchronous wheel event delivery for scroll events when
     10        a user scroll is in progress.
     11
     12        * WebProcess/WebPage/EventDispatcher.cpp:
     13        (WebKit::EventDispatcher::wheelEvent):
     14
    1152021-11-18  Kimmo Kinnunen  <kkinnunen@apple.com>
    216
  • trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp

    r285953 r285992  
    4949#if ENABLE(SCROLLING_THREAD)
    5050#include <WebCore/ScrollingThread.h>
     51#include <WebCore/ScrollingTreeNode.h>
    5152#include <WebCore/ThreadedScrollingTree.h>
    5253#endif
     
    126127
    127128        auto processingSteps = scrollingTree->determineWheelEventProcessing(platformWheelEvent);
     129        bool useMainThreadForScrolling = processingSteps.contains(WheelEventProcessingSteps::MainThreadForScrolling);
     130
     131#if !PLATFORM(COCOA)
     132        // Deliver continuing scroll gestures directly to the scrolling thread.
     133        if (platformWheelEvent.phase() == PlatformWheelEventPhase::Changed && scrollingTree->isUserScrollInProgressAtEventLocation(platformWheelEvent))
     134            useMainThreadForScrolling = false;
     135#endif
    128136
    129137        scrollingTree->willProcessWheelEvent();
    130138
    131         ScrollingThread::dispatch([scrollingTree, wheelEvent, platformWheelEvent, processingSteps, pageID, protectedThis = Ref { *this }] {
    132             if (processingSteps.contains(WheelEventProcessingSteps::MainThreadForScrolling)) {
     139        ScrollingThread::dispatch([scrollingTree, wheelEvent, platformWheelEvent, processingSteps, useMainThreadForScrolling, pageID, protectedThis = Ref { *this }] {
     140            if (useMainThreadForScrolling) {
    133141                scrollingTree->willSendEventToMainThread(platformWheelEvent);
    134142                protectedThis->dispatchWheelEventViaMainThread(pageID, wheelEvent, processingSteps);
     
    136144                return;
    137145            }
    138        
     146
    139147            auto result = scrollingTree->handleWheelEvent(platformWheelEvent, processingSteps);
    140148
Note: See TracChangeset for help on using the changeset viewer.