Title: [270389] trunk/Source/WebCore
Revision
270389
Author
[email protected]
Date
2020-12-02 23:58:44 -0800 (Wed, 02 Dec 2020)

Log Message

Determine the WheelScrollGestureState on the main thread before passing it to ScrollingCoordinator
https://bugs.webkit.org/show_bug.cgi?id=219481

Reviewed by Tim Horton.

Fixing webkit.org/b/218764 requires that we store state for a given series of wheel events
related to whether the "begin" event had preventDefault() called on it (i.e. was canceled).
Previously code was designed to propagate OptionSet<EventHandling> around, and use it to compute
WheelScrollGestureState in both EventHandler and ScrollingTree code. However, we can
compute WheelScrollGestureState just once in EventHandler, and pass it to ScrollingCoordinator.

To achieve this, add a bottleneck in the form of EventHandler::handleWheelEventInScrollableArea()
and before calling the ScrollableArea function (implementation of which can call ScrollingCoordinator),
compute WheelScrollGestureState from OptionSet<EventHandling>. This required making
handleWheelEventInAppropriateEnclosingBox() a member function.

* page/EventHandler.cpp:
(WebCore::EventHandler::processWheelEventForScrolling):
(WebCore::EventHandler::handleWheelEvent):
(WebCore::handleWheelEventPhaseInScrollableArea):
(WebCore::didScrollInScrollableArea):
(WebCore::EventHandler::handleWheelEventInAppropriateEnclosingBox):
(WebCore::EventHandler::handleWheelEventInScrollableArea):
(WebCore::EventHandler::updateWheelGestureState):
(WebCore::EventHandler::defaultWheelEventHandler):
(WebCore::handleWheelEventInAppropriateEnclosingBox): Deleted.
* page/EventHandler.h:
* page/FrameView.cpp:
(WebCore::FrameView::handleWheelEventForScrolling):
* page/FrameView.h:
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::wheelEvent):
(WebCore::EventHandler::processWheelEventForScrolling):
(WebCore::EventHandler::wheelEventWasProcessedByMainThread):
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollingCoordinator::handleWheelEventForScrolling):
(WebCore::ScrollingCoordinator::wheelEventWasProcessedByMainThread):
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::handleWheelEventAfterMainThread):
(WebCore::ThreadedScrollingTree::wheelEventWasProcessedByMainThread):
* page/scrolling/ThreadedScrollingTree.h:
* page/scrolling/mac/ScrollingCoordinatorMac.h:
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::handleWheelEventForScrolling):
(WebCore::ScrollingCoordinatorMac::wheelEventWasProcessedByMainThread):
* page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp:
(WebCore::ScrollingCoordinatorNicosia::handleWheelEventForScrolling):
(WebCore::ScrollingCoordinatorNicosia::wheelEventWasProcessedByMainThread):
* page/scrolling/nicosia/ScrollingCoordinatorNicosia.h:
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::handleWheelEventForScrolling):
* platform/ScrollableArea.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::handleWheelEventForScrolling):
* rendering/RenderLayer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (270388 => 270389)


--- trunk/Source/WebCore/ChangeLog	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/ChangeLog	2020-12-03 07:58:44 UTC (rev 270389)
@@ -1,3 +1,61 @@
+2020-12-02  Simon Fraser  <[email protected]>
+
+        Determine the WheelScrollGestureState on the main thread before passing it to ScrollingCoordinator
+        https://bugs.webkit.org/show_bug.cgi?id=219481
+
+        Reviewed by Tim Horton.
+
+        Fixing webkit.org/b/218764 requires that we store state for a given series of wheel events
+        related to whether the "begin" event had preventDefault() called on it (i.e. was canceled).
+        Previously code was designed to propagate OptionSet<EventHandling> around, and use it to compute
+        WheelScrollGestureState in both EventHandler and ScrollingTree code. However, we can
+        compute WheelScrollGestureState just once in EventHandler, and pass it to ScrollingCoordinator.
+
+        To achieve this, add a bottleneck in the form of EventHandler::handleWheelEventInScrollableArea()
+        and before calling the ScrollableArea function (implementation of which can call ScrollingCoordinator),
+        compute WheelScrollGestureState from OptionSet<EventHandling>. This required making
+        handleWheelEventInAppropriateEnclosingBox() a member function.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::processWheelEventForScrolling):
+        (WebCore::EventHandler::handleWheelEvent):
+        (WebCore::handleWheelEventPhaseInScrollableArea):
+        (WebCore::didScrollInScrollableArea):
+        (WebCore::EventHandler::handleWheelEventInAppropriateEnclosingBox):
+        (WebCore::EventHandler::handleWheelEventInScrollableArea):
+        (WebCore::EventHandler::updateWheelGestureState):
+        (WebCore::EventHandler::defaultWheelEventHandler):
+        (WebCore::handleWheelEventInAppropriateEnclosingBox): Deleted.
+        * page/EventHandler.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::handleWheelEventForScrolling):
+        * page/FrameView.h:
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::EventHandler::wheelEvent):
+        (WebCore::EventHandler::processWheelEventForScrolling):
+        (WebCore::EventHandler::wheelEventWasProcessedByMainThread):
+        * page/scrolling/ScrollingCoordinator.h:
+        (WebCore::ScrollingCoordinator::handleWheelEventForScrolling):
+        (WebCore::ScrollingCoordinator::wheelEventWasProcessedByMainThread):
+        * page/scrolling/ThreadedScrollingTree.cpp:
+        (WebCore::ThreadedScrollingTree::handleWheelEventAfterMainThread):
+        (WebCore::ThreadedScrollingTree::wheelEventWasProcessedByMainThread):
+        * page/scrolling/ThreadedScrollingTree.h:
+        * page/scrolling/mac/ScrollingCoordinatorMac.h:
+        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+        (WebCore::ScrollingCoordinatorMac::handleWheelEventForScrolling):
+        (WebCore::ScrollingCoordinatorMac::wheelEventWasProcessedByMainThread):
+        * page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp:
+        (WebCore::ScrollingCoordinatorNicosia::handleWheelEventForScrolling):
+        (WebCore::ScrollingCoordinatorNicosia::wheelEventWasProcessedByMainThread):
+        * page/scrolling/nicosia/ScrollingCoordinatorNicosia.h:
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::handleWheelEventForScrolling):
+        * platform/ScrollableArea.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::handleWheelEventForScrolling):
+        * rendering/RenderLayer.h:
+
 2020-12-02  Rob Buis  <[email protected]>
 
         Remove m_reversedOrderIteratorForHitTesting

Modified: trunk/Source/WebCore/page/EventHandler.cpp (270388 => 270389)


--- trunk/Source/WebCore/page/EventHandler.cpp	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2020-12-03 07:58:44 UTC (rev 270389)
@@ -291,76 +291,6 @@
     }
 }
 
-static void handleWheelEventPhaseInScrollableArea(ScrollableArea& scrollableArea, const WheelEvent& wheelEvent)
-{
-#if PLATFORM(MAC)
-    if (wheelEvent.phase() == PlatformWheelEventPhase::MayBegin || wheelEvent.phase() == PlatformWheelEventPhase::Cancelled)
-        scrollableArea.scrollAnimator().handleWheelEventPhase(wheelEvent.phase());
-#else
-    UNUSED_PARAM(scrollableArea);
-    UNUSED_PARAM(wheelEvent);
-#endif
-}
-
-static bool didScrollInScrollableArea(ScrollableArea& scrollableArea, const WheelEvent& wheelEvent)
-{
-    ScrollGranularity scrollGranularity = wheelGranularityToScrollGranularity(wheelEvent.deltaMode());
-    bool didHandleWheelEvent = false;
-    if (float absoluteDelta = std::abs(wheelEvent.deltaX()))
-        didHandleWheelEvent |= scrollableArea.scroll(wheelEvent.deltaX() > 0 ? ScrollRight : ScrollLeft, scrollGranularity, absoluteDelta);
-    
-    if (float absoluteDelta = std::abs(wheelEvent.deltaY()))
-        didHandleWheelEvent |= scrollableArea.scroll(wheelEvent.deltaY() > 0 ? ScrollDown : ScrollUp, scrollGranularity, absoluteDelta);
-    
-    return didHandleWheelEvent;
-}
-
-static bool handleWheelEventInAppropriateEnclosingBox(Node* startNode, const WheelEvent& wheelEvent, const FloatSize& filteredPlatformDelta, const FloatSize& filteredVelocity, OptionSet<EventHandling> eventHandling)
-{
-    bool shouldHandleEvent = wheelEvent.deltaX() || wheelEvent.deltaY();
-#if ENABLE(WHEEL_EVENT_LATCHING)
-    shouldHandleEvent |= wheelEvent.phase() == PlatformWheelEventPhase::Ended;
-#if ENABLE(CSS_SCROLL_SNAP)
-    shouldHandleEvent |= wheelEvent.momentumPhase() == PlatformWheelEventPhase::Ended;
-#endif
-#endif
-    if (!startNode->renderer())
-        return false;
-
-    RenderBox& initialEnclosingBox = startNode->renderer()->enclosingBox();
-
-    // RenderListBox is special because it's a ScrollableArea that the scrolling tree doesn't know about.
-    if (is<RenderListBox>(initialEnclosingBox))
-        handleWheelEventPhaseInScrollableArea(downcast<RenderListBox>(initialEnclosingBox), wheelEvent);
-
-    if (!shouldHandleEvent)
-        return false;
-
-    if (is<RenderListBox>(initialEnclosingBox))
-        return didScrollInScrollableArea(downcast<RenderListBox>(initialEnclosingBox), wheelEvent);
-
-    RenderBox* currentEnclosingBox = &initialEnclosingBox;
-    while (currentEnclosingBox) {
-        if (RenderLayer* boxLayer = currentEnclosingBox->layer()) {
-            auto platformEvent = wheelEvent.underlyingPlatformEvent();
-            bool scrollingWasHandled;
-            if (platformEvent) {
-                auto copiedEvent = platformEvent->copyWithDeltasAndVelocity(filteredPlatformDelta.width(), filteredPlatformDelta.height(), filteredVelocity);
-                scrollingWasHandled = boxLayer->handleWheelEventForScrolling(copiedEvent, eventHandling);
-            } else
-                scrollingWasHandled = didScrollInScrollableArea(*boxLayer, wheelEvent);
-
-            if (scrollingWasHandled)
-                return true;
-        }
-
-        currentEnclosingBox = currentEnclosingBox->containingBlock();
-        if (!currentEnclosingBox || currentEnclosingBox->isRenderView())
-            return false;
-    }
-    return false;
-}
-
 #if (ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS_FAMILY))
 static bool shouldGesturesTriggerActive()
 {
@@ -2787,7 +2717,7 @@
     // We do another check on the frame view because the event handler can run JS which results in the frame getting destroyed.
     FrameView* view = m_frame.view();
     
-    bool didHandleEvent = view ? view->handleWheelEventForScrolling(event, eventHandling) : false;
+    bool didHandleEvent = view ? handleWheelEventInScrollableArea(event, *view, eventHandling) : false;
     m_isHandlingWheelEvent = false;
     return didHandleEvent;
 }
@@ -2865,12 +2795,17 @@
     return platformCompletePlatformWidgetWheelEvent(event, *widget.get(), scrollableArea);
 }
 
-bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event, OptionSet<WheelEventProcessingSteps> processingSteps)
+bool EventHandler::handleWheelEvent(const PlatformWheelEvent& wheelEvent, OptionSet<WheelEventProcessingSteps> processingSteps)
 {
+#if ENABLE(KINETIC_SCROLLING)
+    if (wheelEvent.isGestureStart())
+        m_wheelScrollGestureState = WTF::nullopt;
+#endif
+
     OptionSet<EventHandling> handling;
-    bool handled = handleWheelEventInternal(event, processingSteps, handling);
+    bool handled = handleWheelEventInternal(wheelEvent, processingSteps, handling);
     // wheelEventWasProcessedByMainThread() may have already been called via performDefaultWheelEventHandling(), but this ensures that it's always called if that code path doesn't run.
-    wheelEventWasProcessedByMainThread(event, handling);
+    wheelEventWasProcessedByMainThread(wheelEvent, handling);
     return handled;
 }
 
@@ -2974,6 +2909,97 @@
     return handledEvent;
 }
 
+static void handleWheelEventPhaseInScrollableArea(ScrollableArea& scrollableArea, const WheelEvent& wheelEvent)
+{
+#if PLATFORM(MAC)
+    if (wheelEvent.phase() == PlatformWheelEventPhase::MayBegin || wheelEvent.phase() == PlatformWheelEventPhase::Cancelled)
+        scrollableArea.scrollAnimator().handleWheelEventPhase(wheelEvent.phase());
+#else
+    UNUSED_PARAM(scrollableArea);
+    UNUSED_PARAM(wheelEvent);
+#endif
+}
+
+static bool didScrollInScrollableArea(ScrollableArea& scrollableArea, const WheelEvent& wheelEvent)
+{
+    ScrollGranularity scrollGranularity = wheelGranularityToScrollGranularity(wheelEvent.deltaMode());
+    bool didHandleWheelEvent = false;
+    if (float absoluteDelta = std::abs(wheelEvent.deltaX()))
+        didHandleWheelEvent |= scrollableArea.scroll(wheelEvent.deltaX() > 0 ? ScrollRight : ScrollLeft, scrollGranularity, absoluteDelta);
+
+    if (float absoluteDelta = std::abs(wheelEvent.deltaY()))
+        didHandleWheelEvent |= scrollableArea.scroll(wheelEvent.deltaY() > 0 ? ScrollDown : ScrollUp, scrollGranularity, absoluteDelta);
+
+    return didHandleWheelEvent;
+}
+
+bool EventHandler::handleWheelEventInAppropriateEnclosingBox(Node* startNode, const WheelEvent& wheelEvent, const FloatSize& filteredPlatformDelta, const FloatSize& filteredVelocity, OptionSet<EventHandling> eventHandling)
+{
+    bool shouldHandleEvent = wheelEvent.deltaX() || wheelEvent.deltaY();
+#if ENABLE(WHEEL_EVENT_LATCHING)
+    shouldHandleEvent |= wheelEvent.phase() == PlatformWheelEventPhase::Ended;
+#if ENABLE(CSS_SCROLL_SNAP)
+    shouldHandleEvent |= wheelEvent.momentumPhase() == PlatformWheelEventPhase::Ended;
+#endif
+#endif
+    if (!startNode->renderer())
+        return false;
+
+    RenderBox& initialEnclosingBox = startNode->renderer()->enclosingBox();
+
+    // RenderListBox is special because it's a ScrollableArea that the scrolling tree doesn't know about.
+    if (is<RenderListBox>(initialEnclosingBox))
+        handleWheelEventPhaseInScrollableArea(downcast<RenderListBox>(initialEnclosingBox), wheelEvent);
+
+    if (!shouldHandleEvent)
+        return false;
+
+    if (is<RenderListBox>(initialEnclosingBox))
+        return didScrollInScrollableArea(downcast<RenderListBox>(initialEnclosingBox), wheelEvent);
+
+    RenderBox* currentEnclosingBox = &initialEnclosingBox;
+    while (currentEnclosingBox) {
+        if (RenderLayer* boxLayer = currentEnclosingBox->layer()) {
+            auto platformEvent = wheelEvent.underlyingPlatformEvent();
+            bool scrollingWasHandled;
+            if (platformEvent) {
+                auto copiedEvent = platformEvent->copyWithDeltasAndVelocity(filteredPlatformDelta.width(), filteredPlatformDelta.height(), filteredVelocity);
+                scrollingWasHandled = handleWheelEventInScrollableArea(copiedEvent, *boxLayer, eventHandling);
+            } else
+                scrollingWasHandled = didScrollInScrollableArea(*boxLayer, wheelEvent);
+
+            if (scrollingWasHandled)
+                return true;
+        }
+
+        currentEnclosingBox = currentEnclosingBox->containingBlock();
+        if (!currentEnclosingBox || currentEnclosingBox->isRenderView())
+            return false;
+    }
+    return false;
+}
+
+bool EventHandler::handleWheelEventInScrollableArea(const PlatformWheelEvent& wheelEvent, ScrollableArea& scrollableArea, OptionSet<EventHandling> eventHandling)
+{
+    auto gestureState = updateWheelGestureState(wheelEvent, eventHandling);
+    LOG_WITH_STREAM(Scrolling, stream << "EventHandler::handleWheelEventInScrollableArea() - eventHandling " << eventHandling << " -> gesture state " << gestureState);
+    return scrollableArea.handleWheelEventForScrolling(wheelEvent, gestureState);
+}
+
+Optional<WheelScrollGestureState> EventHandler::updateWheelGestureState(const PlatformWheelEvent& wheelEvent, OptionSet<EventHandling> eventHandling)
+{
+#if ENABLE(KINETIC_SCROLLING)
+    if (!m_wheelScrollGestureState && wheelEvent.isGestureStart() && eventHandling.contains(EventHandling::DispatchedToDOM))
+        m_wheelScrollGestureState = eventHandling.contains(EventHandling::DefaultPrevented) ? WheelScrollGestureState::Blocking : WheelScrollGestureState::NonBlocking;
+
+    return m_wheelScrollGestureState;
+#else
+    UNUSED_PARAM(wheelEvent);
+    UNUSED_PARAM(eventHandling);
+    return WTF::nullopt;
+#endif
+}
+
 void EventHandler::clearLatchedState()
 {
     auto* page = m_frame.page();
@@ -3032,7 +3058,7 @@
         auto platformEvent = wheelEvent.underlyingPlatformEvent();
         if (platformEvent) {
             auto copiedEvent = platformEvent->copyWithDeltasAndVelocity(filteredPlatformDelta.width(), filteredPlatformDelta.height(), filteredVelocity);
-            if (latchedScroller->handleWheelEventForScrolling(copiedEvent, eventHandling))
+            if (handleWheelEventInScrollableArea(copiedEvent, *latchedScroller, eventHandling))
                 wheelEvent.setDefaultHandled();
             return;
         }

Modified: trunk/Source/WebCore/page/EventHandler.h (270388 => 270389)


--- trunk/Source/WebCore/page/EventHandler.h	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/EventHandler.h	2020-12-03 07:58:44 UTC (rev 270389)
@@ -464,6 +464,11 @@
     void processWheelEventForScrollSnap(const PlatformWheelEvent&, const WeakPtr<ScrollableArea>&);
     bool completeWidgetWheelEvent(const PlatformWheelEvent&, const WeakPtr<Widget>&, const WeakPtr<ScrollableArea>&);
 
+    bool handleWheelEventInAppropriateEnclosingBox(Node* startNode, const WheelEvent&, const FloatSize& filteredPlatformDelta, const FloatSize& filteredVelocity, OptionSet<EventHandling>);
+
+    bool handleWheelEventInScrollableArea(const PlatformWheelEvent&, ScrollableArea&, OptionSet<EventHandling>);
+    Optional<WheelScrollGestureState> updateWheelGestureState(const PlatformWheelEvent&, OptionSet<EventHandling>);
+
     bool platformCompletePlatformWidgetWheelEvent(const PlatformWheelEvent&, const Widget&, const WeakPtr<ScrollableArea>&);
 
     void defaultSpaceEventHandler(KeyboardEvent&);
@@ -584,6 +589,10 @@
     bool m_hasActiveGesture { false };
 #endif
 
+#if ENABLE(KINETIC_SCROLLING)
+    Optional<WheelScrollGestureState> m_wheelScrollGestureState;
+#endif
+
 #if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
     using TouchTargetMap = HashMap<int, RefPtr<EventTarget>>;
     TouchTargetMap m_originatingTouchPointTargets;
@@ -614,7 +623,6 @@
 
 #if PLATFORM(COCOA)
     NSView *m_mouseDownView { nullptr };
-    Optional<WheelScrollGestureState> m_wheelScrollGestureState;
     bool m_sendingEventToSubview { false };
 #endif
 

Modified: trunk/Source/WebCore/page/FrameView.cpp (270388 => 270389)


--- trunk/Source/WebCore/page/FrameView.cpp	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/FrameView.cpp	2020-12-03 07:58:44 UTC (rev 270389)
@@ -5098,7 +5098,7 @@
     ScrollView::removeChild(widget);
 }
 
-bool FrameView::handleWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, OptionSet<EventHandling> eventHandling)
+bool FrameView::handleWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, Optional<WheelScrollGestureState> gestureState)
 {
     // Note that to allow for rubber-band over-scroll behavior, even non-scrollable views
     // should handle wheel events.
@@ -5128,11 +5128,11 @@
 #if ENABLE(ASYNC_SCROLLING)
     if (auto scrollingCoordinator = this->scrollingCoordinator()) {
         if (scrollingCoordinator->coordinatesScrollingForFrameView(*this))
-            return scrollingCoordinator->handleWheelEventForScrolling(wheelEvent, scrollingNodeID(), eventHandling);
+            return scrollingCoordinator->handleWheelEventForScrolling(wheelEvent, scrollingNodeID(), gestureState);
     }
 #endif
 
-    return ScrollableArea::handleWheelEventForScrolling(wheelEvent, eventHandling);
+    return ScrollableArea::handleWheelEventForScrolling(wheelEvent, gestureState);
 }
 
 bool FrameView::isVerticalDocument() const

Modified: trunk/Source/WebCore/page/FrameView.h (270388 => 270389)


--- trunk/Source/WebCore/page/FrameView.h	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/FrameView.h	2020-12-03 07:58:44 UTC (rev 270389)
@@ -565,7 +565,7 @@
     // This function exists for ports that need to handle wheel events manually.
     // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms
     // we need this function in order to do the scroll ourselves.
-    bool handleWheelEventForScrolling(const PlatformWheelEvent&, OptionSet<EventHandling>) final;
+    bool handleWheelEventForScrolling(const PlatformWheelEvent&, Optional<WheelScrollGestureState>) final;
 
     WEBCORE_EXPORT void setScrollingPerformanceLoggingEnabled(bool);
 

Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (270388 => 270389)


--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2020-12-03 07:58:44 UTC (rev 270389)
@@ -150,10 +150,8 @@
     auto wheelEvent = PlatformEventFactory::createPlatformWheelEvent(event, page->chrome().platformPageClient());
     OptionSet<WheelEventProcessingSteps> processingSteps = { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch };
 
-    if (wheelEvent.isGestureStart())
-        m_wheelScrollGestureState = WTF::nullopt;
-    else if (wheelEvent.phase() == PlatformWheelEventPhase::Changed || wheelEvent.momentumPhase() == PlatformWheelEventPhase::Changed) {
-        if (m_frame.settings().wheelEventGesturesBecomeNonBlocking() && m_wheelScrollGestureState && *m_wheelScrollGestureState == WheelScrollGestureState::NonBlocking)
+    if (wheelEvent.phase() == PlatformWheelEventPhase::Changed || wheelEvent.momentumPhase() == PlatformWheelEventPhase::Changed) {
+        if (m_frame.settings().wheelEventGesturesBecomeNonBlocking() && m_wheelScrollGestureState.valueOr(WheelScrollGestureState::Blocking) == WheelScrollGestureState::NonBlocking)
             processingSteps = { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForNonBlockingDOMEventDispatch };
     }
     return handleWheelEvent(wheelEvent, processingSteps);
@@ -948,7 +946,7 @@
 
         LOG_WITH_STREAM(ScrollLatching, stream << " sending to view " << *view);
 
-        bool didHandleWheelEvent = view->handleWheelEventForScrolling(wheelEvent, eventHandling);
+        bool didHandleWheelEvent = handleWheelEventInScrollableArea(wheelEvent, *view, eventHandling);
         // If the platform widget is handling the event, we always want to return false.
         if (view->platformWidget())
             didHandleWheelEvent = false;
@@ -957,7 +955,7 @@
         return didHandleWheelEvent;
     }
     
-    bool didHandleEvent = view->handleWheelEventForScrolling(wheelEvent, eventHandling);
+    bool didHandleEvent = handleWheelEventInScrollableArea(wheelEvent, *view, eventHandling);
     m_isHandlingWheelEvent = false;
     return didHandleEvent;
 }
@@ -972,13 +970,12 @@
     if (!view)
         return;
 
+    updateWheelGestureState(wheelEvent, eventHandling);
+
     if (auto scrollingCoordinator = m_frame.page()->scrollingCoordinator()) {
         if (scrollingCoordinator->coordinatesScrollingForFrameView(*view))
-            scrollingCoordinator->wheelEventWasProcessedByMainThread(wheelEvent, eventHandling);
+            scrollingCoordinator->wheelEventWasProcessedByMainThread(wheelEvent, m_wheelScrollGestureState);
     }
-
-    if (wheelEvent.isGestureStart() && eventHandling.contains(EventHandling::DispatchedToDOM))
-        m_wheelScrollGestureState = eventHandling.contains(EventHandling::DefaultPrevented) ? WheelScrollGestureState::Blocking : WheelScrollGestureState::NonBlocking;
 #else
     UNUSED_PARAM(wheelEvent);
     UNUSED_PARAM(eventHandling);

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h (270388 => 270389)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2020-12-03 07:58:44 UTC (rev 270389)
@@ -127,8 +127,8 @@
     // These virtual functions are currently unique to the threaded scrolling architecture. 
     virtual void commitTreeStateIfNeeded() { }
     virtual bool requestScrollPositionUpdate(ScrollableArea&, const IntPoint&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped) { return false; }
-    virtual bool handleWheelEventForScrolling(const PlatformWheelEvent&, ScrollingNodeID, OptionSet<EventHandling>) { return false; }
-    virtual void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>) { }
+    virtual bool handleWheelEventForScrolling(const PlatformWheelEvent&, ScrollingNodeID, Optional<WheelScrollGestureState>) { return false; }
+    virtual void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, Optional<WheelScrollGestureState>) { }
 
     // Create an unparented node.
     virtual ScrollingNodeID createNode(ScrollingNodeType, ScrollingNodeID newNodeID) { return newNodeID; }

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeGestureState.cpp (270388 => 270389)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeGestureState.cpp	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeGestureState.cpp	2020-12-03 07:58:44 UTC (rev 270389)
@@ -41,7 +41,7 @@
 
 void ScrollingTreeGestureState::receivedWheelEvent(const PlatformWheelEvent& event)
 {
-    if (event.isGestureBegin()) {
+    if (event.isGestureStart()) {
         clearAllNodes();
         return;
     }

Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (270388 => 270389)


--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp	2020-12-03 07:58:44 UTC (rev 270389)
@@ -64,7 +64,7 @@
     return ScrollingTree::handleWheelEvent(wheelEvent, processingSteps);
 }
 
-bool ThreadedScrollingTree::handleWheelEventAfterMainThread(const PlatformWheelEvent& wheelEvent, ScrollingNodeID targetNodeID, OptionSet<EventHandling>)
+bool ThreadedScrollingTree::handleWheelEventAfterMainThread(const PlatformWheelEvent& wheelEvent, ScrollingNodeID targetNodeID, Optional<WheelScrollGestureState>)
 {
     LOG_WITH_STREAM(Scrolling, stream << "ThreadedScrollingTree::handleWheelEventAfterMainThread " << wheelEvent << " node " << targetNodeID);
 
@@ -76,7 +76,7 @@
     return result.wasHandled;
 }
 
-void ThreadedScrollingTree::wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>)
+void ThreadedScrollingTree::wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, Optional<WheelScrollGestureState>)
 {
     // FIXME: Set state based on EventHandling flags.
 }

Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h (270388 => 270389)


--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h	2020-12-03 07:58:44 UTC (rev 270389)
@@ -47,8 +47,8 @@
 
     WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&, OptionSet<WheelEventProcessingSteps>) override;
 
-    bool handleWheelEventAfterMainThread(const PlatformWheelEvent&, ScrollingNodeID, OptionSet<EventHandling>);
-    void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>);
+    bool handleWheelEventAfterMainThread(const PlatformWheelEvent&, ScrollingNodeID, Optional<WheelScrollGestureState>);
+    void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, Optional<WheelScrollGestureState>);
 
     void invalidate() override;
 

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h (270388 => 270389)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h	2020-12-03 07:58:44 UTC (rev 270389)
@@ -41,8 +41,8 @@
     void commitTreeStateIfNeeded() final;
 
     // Handle the wheel event on the scrolling thread. Returns whether the event was handled or not.
-    bool handleWheelEventForScrolling(const PlatformWheelEvent&, ScrollingNodeID, OptionSet<EventHandling>) final;
-    void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>) final;
+    bool handleWheelEventForScrolling(const PlatformWheelEvent&, ScrollingNodeID, Optional<WheelScrollGestureState>) final;
+    void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, Optional<WheelScrollGestureState>) final;
 
 private:
     void scheduleTreeStateCommit() final;

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (270388 => 270389)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm	2020-12-03 07:58:44 UTC (rev 270389)
@@ -73,7 +73,7 @@
     });
 }
 
-bool ScrollingCoordinatorMac::handleWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, ScrollingNodeID targetNodeID, OptionSet<EventHandling> eventHandling)
+bool ScrollingCoordinatorMac::handleWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, ScrollingNodeID targetNodeID, Optional<WheelScrollGestureState> gestureState)
 {
     ASSERT(isMainThread());
     ASSERT(m_page);
@@ -81,11 +81,11 @@
     if (scrollingTree()->willWheelEventStartSwipeGesture(wheelEvent))
         return false;
 
-    LOG_WITH_STREAM(Scrolling, stream << "ScrollingCoordinatorMac::handleWheelEventForScrolling - sending event to scrolling thread, node " << targetNodeID);
+    LOG_WITH_STREAM(Scrolling, stream << "ScrollingCoordinatorMac::handleWheelEventForScrolling - sending event to scrolling thread, node " << targetNodeID << " gestureState " << gestureState);
     
     RefPtr<ThreadedScrollingTree> threadedScrollingTree = downcast<ThreadedScrollingTree>(scrollingTree());
-    ScrollingThread::dispatch([threadedScrollingTree, wheelEvent, targetNodeID, eventHandling] {
-        threadedScrollingTree->handleWheelEventAfterMainThread(wheelEvent, targetNodeID, eventHandling);
+    ScrollingThread::dispatch([threadedScrollingTree, wheelEvent, targetNodeID, gestureState] {
+        threadedScrollingTree->handleWheelEventAfterMainThread(wheelEvent, targetNodeID, gestureState);
     });
     return true;
 }
@@ -96,13 +96,13 @@
     return ++deferIdentifier;
 }
 
-void ScrollingCoordinatorMac::wheelEventWasProcessedByMainThread(const PlatformWheelEvent& wheelEvent, OptionSet<EventHandling> defaultHandling)
+void ScrollingCoordinatorMac::wheelEventWasProcessedByMainThread(const PlatformWheelEvent& wheelEvent, Optional<WheelScrollGestureState> gestureState)
 {
     auto deferrer = WheelEventTestMonitorCompletionDeferrer { m_page->wheelEventTestMonitor().get(), reinterpret_cast<WheelEventTestMonitor::ScrollableAreaIdentifier>(nextDeferIdentifier()), WheelEventTestMonitor::ReportDOMEventHandling };
 
     RefPtr<ThreadedScrollingTree> threadedScrollingTree = downcast<ThreadedScrollingTree>(scrollingTree());
-    ScrollingThread::dispatch([threadedScrollingTree, wheelEvent, defaultHandling, deferrer = WTFMove(deferrer)] {
-        threadedScrollingTree->wheelEventWasProcessedByMainThread(wheelEvent, defaultHandling);
+    ScrollingThread::dispatch([threadedScrollingTree, wheelEvent, gestureState, deferrer = WTFMove(deferrer)] {
+        threadedScrollingTree->wheelEventWasProcessedByMainThread(wheelEvent, gestureState);
     });
 }
 

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp (270388 => 270389)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp	2020-12-03 07:58:44 UTC (rev 270389)
@@ -69,22 +69,22 @@
     m_scrollingStateTreeCommitterTimer.stop();
 }
 
-bool ScrollingCoordinatorNicosia::handleWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, ScrollingNodeID targetNode, OptionSet<EventHandling> eventHandling)
+bool ScrollingCoordinatorNicosia::handleWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, ScrollingNodeID targetNode, Optional<WheelScrollGestureState> gestureState)
 {
     ASSERT(isMainThread());
     ASSERT(m_page);
     ASSERT(scrollingTree());
 
-    ScrollingThread::dispatch([threadedScrollingTree = makeRef(downcast<ThreadedScrollingTree>(*scrollingTree())), wheelEvent, targetNode, eventHandling] {
-        threadedScrollingTree->handleWheelEventAfterMainThread(wheelEvent, targetNode, eventHandling);
+    ScrollingThread::dispatch([threadedScrollingTree = makeRef(downcast<ThreadedScrollingTree>(*scrollingTree())), wheelEvent, targetNode, gestureState] {
+        threadedScrollingTree->handleWheelEventAfterMainThread(wheelEvent, targetNode, gestureState);
     });
     return true;
 }
 
-void ScrollingCoordinatorNicosia::wheelEventWasProcessedByMainThread(const PlatformWheelEvent& wheelEvent, OptionSet<EventHandling> eventHandling)
+void ScrollingCoordinatorNicosia::wheelEventWasProcessedByMainThread(const PlatformWheelEvent& wheelEvent, Optional<WheelScrollGestureState> gestureState)
 {
-    ScrollingThread::dispatch([threadedScrollingTree = makeRef(downcast<ThreadedScrollingTree>(*scrollingTree())), wheelEvent, eventHandling] {
-        threadedScrollingTree->wheelEventWasProcessedByMainThread(wheelEvent, eventHandling);
+    ScrollingThread::dispatch([threadedScrollingTree = makeRef(downcast<ThreadedScrollingTree>(*scrollingTree())), wheelEvent, gestureState] {
+        threadedScrollingTree->wheelEventWasProcessedByMainThread(wheelEvent, gestureState);
     });
 }
 

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.h (270388 => 270389)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.h	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.h	2020-12-03 07:58:44 UTC (rev 270389)
@@ -44,8 +44,8 @@
 
     void commitTreeStateIfNeeded() override;
 
-    bool handleWheelEventForScrolling(const PlatformWheelEvent&, ScrollingNodeID, OptionSet<EventHandling>) override;
-    void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>) override;
+    bool handleWheelEventForScrolling(const PlatformWheelEvent&, ScrollingNodeID, Optional<WheelScrollGestureState>) override;
+    void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, Optional<WheelScrollGestureState>) override;
 
 private:
     void scheduleTreeStateCommit() override;

Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.h (270388 => 270389)


--- trunk/Source/WebCore/platform/PlatformWheelEvent.h	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.h	2020-12-03 07:58:44 UTC (rev 270389)
@@ -150,7 +150,6 @@
 
 #if ENABLE(ASYNC_SCROLLING)
     bool useLatchedEventElement() const;
-    bool isGestureStart() const;
     bool isGestureContinuation() const; // The fingers-down part of the gesture excluding momentum.
     bool shouldResetLatching() const;
     bool isNonGestureEvent() const;
@@ -163,7 +162,7 @@
     PlatformWheelEventPhase phase() const { return m_phase; }
     PlatformWheelEventPhase momentumPhase() const { return m_momentumPhase; }
 
-    bool isGestureBegin() const;
+    bool isGestureStart() const;
     bool isGestureCancel() const;
 
     bool isEndOfNonMomentumScroll() const;
@@ -212,11 +211,6 @@
         || (m_phase == PlatformWheelEventPhase::Ended && m_momentumPhase == PlatformWheelEventPhase::None);
 }
 
-inline bool PlatformWheelEvent::isGestureStart() const
-{
-    return m_phase == PlatformWheelEventPhase::Began || m_phase == PlatformWheelEventPhase::MayBegin;
-}
-
 inline bool PlatformWheelEvent::isGestureContinuation() const
 {
     return m_phase == PlatformWheelEventPhase::Changed;
@@ -241,10 +235,9 @@
 
 #if ENABLE(KINETIC_SCROLLING)
 
-inline bool PlatformWheelEvent::isGestureBegin() const
+inline bool PlatformWheelEvent::isGestureStart() const
 {
-    return m_phase == PlatformWheelEventPhase::MayBegin
-        || m_phase == PlatformWheelEventPhase::Began;
+    return m_phase == PlatformWheelEventPhase::Began || m_phase == PlatformWheelEventPhase::MayBegin;
 }
 
 inline bool PlatformWheelEvent::isGestureCancel() const

Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (270388 => 270389)


--- trunk/Source/WebCore/platform/ScrollableArea.cpp	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp	2020-12-03 07:58:44 UTC (rev 270389)
@@ -203,7 +203,7 @@
         scrollAnimator().notifyContentAreaScrolled(scrollPosition() - oldPosition);
 }
 
-bool ScrollableArea::handleWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, OptionSet<EventHandling>)
+bool ScrollableArea::handleWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, Optional<WheelScrollGestureState>)
 {
     if (!isScrollableOrRubberbandable())
         return false;

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (270388 => 270389)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2020-12-03 07:58:44 UTC (rev 270389)
@@ -48,7 +48,7 @@
 class GraphicsLayer;
 class TiledBacking;
 
-enum class EventHandling : uint8_t;
+enum class WheelScrollGestureState : uint8_t;
 
 inline int offsetForOrientation(ScrollOffset offset, ScrollbarOrientation orientation)
 {
@@ -84,7 +84,7 @@
     // expect it to happen sometime in the future.
     virtual bool requestScrollPositionUpdate(const ScrollPosition&, ScrollType = ScrollType::User, ScrollClamping = ScrollClamping::Clamped) { return false; }
 
-    WEBCORE_EXPORT virtual bool handleWheelEventForScrolling(const PlatformWheelEvent&, OptionSet<EventHandling>);
+    WEBCORE_EXPORT virtual bool handleWheelEventForScrolling(const PlatformWheelEvent&, Optional<WheelScrollGestureState>);
 
     bool usesScrollSnap() const;
 

Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (270388 => 270389)


--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2020-12-03 07:58:44 UTC (rev 270389)
@@ -764,7 +764,7 @@
 
 void ScrollController::updateGestureInProgressState(const PlatformWheelEvent& wheelEvent)
 {
-    if (wheelEvent.isGestureBegin() || wheelEvent.isTransitioningToMomentumScroll())
+    if (wheelEvent.isGestureStart() || wheelEvent.isTransitioningToMomentumScroll())
         m_inScrollGesture = true;
     else if (wheelEvent.isEndOfNonMomentumScroll() || wheelEvent.isGestureCancel() || wheelEvent.isEndOfMomentumScroll())
         m_inScrollGesture = false;

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (270388 => 270389)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2020-12-03 07:58:44 UTC (rev 270389)
@@ -3165,7 +3165,7 @@
     return backing()->scrollingNodeIDForRole(ScrollCoordinationRole::Scrolling);
 }
 
-bool RenderLayer::handleWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, OptionSet<EventHandling> eventHandling)
+bool RenderLayer::handleWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, Optional<WheelScrollGestureState> gestureState)
 {
     if (!isScrollableOrRubberbandable())
         return false;
@@ -3173,11 +3173,11 @@
 #if ENABLE(ASYNC_SCROLLING)
     if (usesAsyncScrolling() && scrollingNodeID()) {
         if (auto* scrollingCoordinator = page().scrollingCoordinator())
-            return scrollingCoordinator->handleWheelEventForScrolling(wheelEvent, scrollingNodeID(), eventHandling);
+            return scrollingCoordinator->handleWheelEventForScrolling(wheelEvent, scrollingNodeID(), gestureState);
     }
 #endif
 
-    return ScrollableArea::handleWheelEventForScrolling(wheelEvent, eventHandling);
+    return ScrollableArea::handleWheelEventForScrolling(wheelEvent, gestureState);
 }
 
 IntRect RenderLayer::visibleContentRectInternal(VisibleContentRectIncludesScrollbars scrollbarInclusion, VisibleContentRectBehavior) const

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (270388 => 270389)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2020-12-03 07:38:58 UTC (rev 270388)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2020-12-03 07:58:44 UTC (rev 270389)
@@ -493,7 +493,7 @@
     Scrollbar* verticalScrollbar() const final { return m_vBar.get(); }
     ScrollableArea* enclosingScrollableArea() const final;
 
-    bool handleWheelEventForScrolling(const PlatformWheelEvent&, OptionSet<EventHandling>) final;
+    bool handleWheelEventForScrolling(const PlatformWheelEvent&, Optional<WheelScrollGestureState>) final;
     bool isScrollableOrRubberbandable() final;
     bool hasScrollableOrRubberbandableAncestor() final;
     bool useDarkAppearance() const final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to