Rename some wheel-event related functions
https://bugs.webkit.org/show_bug.cgi?id=209918

Reviewed by Zalan Bujtas.

Rename some functions to describe what they do, rather than being generic "platform" things, to make
the code easier to read.

Similarly, rename m_clearLatchingStateTimer for what it does.

* page/EventHandler.cpp:
(WebCore::EventHandler::EventHandler):
(WebCore::EventHandler::clearLatchedStateTimerFired):
(WebCore::EventHandler::determineWheelEventTarget):
(WebCore::EventHandler::recordWheelEventForDeltaFilter):
(WebCore::EventHandler::processWheelEventForScrolling):
(WebCore::EventHandler::processWheelEventForScrollSnap):
(WebCore::EventHandler::completeWidgetWheelEvent):
(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::platformPrepareForWheelEvents): Deleted.
(WebCore::EventHandler::platformRecordWheelEvent): Deleted.
(WebCore::EventHandler::platformCompleteWheelEvent): Deleted.
(WebCore::EventHandler::platformNotifyIfEndGesture): Deleted.
* page/EventHandler.h:
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::clearOrScheduleClearingLatchedStateIfNeeded):
(WebCore::EventHandler::determineWheelEventTarget):
(WebCore::EventHandler::recordWheelEventForDeltaFilter):
(WebCore::EventHandler::processWheelEventForScrolling):
(WebCore::EventHandler::processWheelEventForScrollSnap):
(WebCore::EventHandler::platformPrepareForWheelEvents): Deleted.
(WebCore::EventHandler::platformRecordWheelEvent): Deleted.
(WebCore::EventHandler::platformCompleteWheelEvent): Deleted.
(WebCore::EventHandler::platformNotifyIfEndGesture): Deleted.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@259416 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index f6261dc..a5cabaa 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,40 @@
+2020-04-02  Simon Fraser  <simon.fraser@apple.com>
+
+        Rename some wheel-event related functions
+        https://bugs.webkit.org/show_bug.cgi?id=209918
+
+        Reviewed by Zalan Bujtas.
+
+        Rename some functions to describe what they do, rather than being generic "platform" things, to make
+        the code easier to read.
+
+        Similarly, rename m_clearLatchingStateTimer for what it does.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::EventHandler):
+        (WebCore::EventHandler::clearLatchedStateTimerFired):
+        (WebCore::EventHandler::determineWheelEventTarget):
+        (WebCore::EventHandler::recordWheelEventForDeltaFilter):
+        (WebCore::EventHandler::processWheelEventForScrolling):
+        (WebCore::EventHandler::processWheelEventForScrollSnap):
+        (WebCore::EventHandler::completeWidgetWheelEvent):
+        (WebCore::EventHandler::handleWheelEvent):
+        (WebCore::EventHandler::platformPrepareForWheelEvents): Deleted.
+        (WebCore::EventHandler::platformRecordWheelEvent): Deleted.
+        (WebCore::EventHandler::platformCompleteWheelEvent): Deleted.
+        (WebCore::EventHandler::platformNotifyIfEndGesture): Deleted.
+        * page/EventHandler.h:
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::EventHandler::clearOrScheduleClearingLatchedStateIfNeeded):
+        (WebCore::EventHandler::determineWheelEventTarget):
+        (WebCore::EventHandler::recordWheelEventForDeltaFilter):
+        (WebCore::EventHandler::processWheelEventForScrolling):
+        (WebCore::EventHandler::processWheelEventForScrollSnap):
+        (WebCore::EventHandler::platformPrepareForWheelEvents): Deleted.
+        (WebCore::EventHandler::platformRecordWheelEvent): Deleted.
+        (WebCore::EventHandler::platformCompleteWheelEvent): Deleted.
+        (WebCore::EventHandler::platformNotifyIfEndGesture): Deleted.
+
 2020-04-02  Daniel Bates  <dabates@apple.com>
 
         Traverse float descendants when computing event and touch-action regions
diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp
index 6048f82..e742d6e 100644
--- a/Source/WebCore/page/EventHandler.cpp
+++ b/Source/WebCore/page/EventHandler.cpp
@@ -377,7 +377,7 @@
     , m_hoverTimer(*this, &EventHandler::hoverTimerFired)
     , m_cursorUpdateTimer(*this, &EventHandler::cursorUpdateTimerFired)
 #if PLATFORM(MAC)
-    , m_pendingMomentumWheelEventsTimer(*this, &EventHandler::clearLatchedState)
+    , m_clearLatchingStateTimer(*this, &EventHandler::clearLatchedStateTimerFired)
 #endif
     , m_autoscrollController(makeUnique<AutoscrollController>())
 #if !ENABLE(IOS_TOUCH_EVENTS)
@@ -2711,19 +2711,25 @@
 
 #endif
 
+void EventHandler::clearLatchedStateTimerFired()
+{
+    LOG(ScrollLatching, "EventHandler %p clearLatchedStateTimerFired()", this);
+    clearLatchedState();
+}
+
 #if !PLATFORM(MAC)
 
-void EventHandler::platformPrepareForWheelEvents(const PlatformWheelEvent&, const HitTestResult&, RefPtr<Element>&, RefPtr<ContainerNode>&, WeakPtr<ScrollableArea>&, bool&)
+void EventHandler::determineWheelEventTarget(const PlatformWheelEvent&, const HitTestResult&, RefPtr<Element>&, RefPtr<ContainerNode>&, WeakPtr<ScrollableArea>&, bool&)
 {
 }
 
-void EventHandler::platformRecordWheelEvent(const PlatformWheelEvent& event)
+void EventHandler::recordWheelEventForDeltaFilter(const PlatformWheelEvent& event)
 {
     if (auto* page = m_frame.page())
         page->wheelEventDeltaFilter()->updateFromDelta(FloatSize(event.deltaX(), event.deltaY()));
 }
 
-bool EventHandler::platformCompleteWheelEvent(const PlatformWheelEvent& event, ContainerNode*, const WeakPtr<ScrollableArea>&)
+bool EventHandler::processWheelEventForScrolling(const PlatformWheelEvent& event, ContainerNode*, const WeakPtr<ScrollableArea>&)
 {
     Ref<Frame> protectedFrame(m_frame);
 
@@ -2740,7 +2746,7 @@
     return true;
 }
 
-void EventHandler::platformNotifyIfEndGesture(const PlatformWheelEvent&, const WeakPtr<ScrollableArea>&)
+void EventHandler::processWheelEventForScrollSnap(const PlatformWheelEvent&, const WeakPtr<ScrollableArea>&)
 {
 }
 
@@ -2801,7 +2807,7 @@
     if (scrollableArea)
         scrollableArea->setScrollShouldClearLatchedState(false);
 
-    platformNotifyIfEndGesture(event, scrollableArea);
+    processWheelEventForScrollSnap(event, scrollableArea);
 
     if (!widget->platformWidget())
         return true;
@@ -2848,7 +2854,7 @@
     RefPtr<ContainerNode> scrollableContainer;
     WeakPtr<ScrollableArea> scrollableArea;
     bool isOverWidget = result.isOverWidget();
-    platformPrepareForWheelEvents(event, result, element, scrollableContainer, scrollableArea, isOverWidget);
+    determineWheelEventTarget(event, result, element, scrollableContainer, scrollableArea, isOverWidget);
 
 #if ENABLE(WHEEL_EVENT_LATCHING)
     if (event.phase() == PlatformWheelEventPhaseNone && event.momentumPhase() == PlatformWheelEventPhaseNone && m_frame.page())
@@ -2858,7 +2864,7 @@
     // FIXME: It should not be necessary to do this mutation here.
     // Instead, the handlers should know convert vertical scrolls appropriately.
     PlatformWheelEvent adjustedEvent = shouldSwapScrollDirection(result, event) ? event.copySwappingDirection() : event;
-    platformRecordWheelEvent(adjustedEvent);
+    recordWheelEventForDeltaFilter(adjustedEvent);
 
     if (element) {
         if (isOverWidget) {
@@ -2876,7 +2882,7 @@
                 scrollableArea->setScrollShouldClearLatchedState(false);
             }
 
-            platformNotifyIfEndGesture(adjustedEvent, scrollableArea);
+            processWheelEventForScrollSnap(adjustedEvent, scrollableArea);
             return true;
         }
     }
@@ -2884,8 +2890,8 @@
     if (scrollableArea)
         scrollableArea->setScrollShouldClearLatchedState(false);
 
-    bool handledEvent = platformCompleteWheelEvent(adjustedEvent, scrollableContainer.get(), scrollableArea);
-    platformNotifyIfEndGesture(adjustedEvent, scrollableArea);
+    bool handledEvent = processWheelEventForScrolling(adjustedEvent, scrollableContainer.get(), scrollableArea);
+    processWheelEventForScrollSnap(adjustedEvent, scrollableArea);
     return handledEvent;
 }
 
diff --git a/Source/WebCore/page/EventHandler.h b/Source/WebCore/page/EventHandler.h
index 8cbaead..58fc9c5 100644
--- a/Source/WebCore/page/EventHandler.h
+++ b/Source/WebCore/page/EventHandler.h
@@ -209,11 +209,12 @@
     void defaultWheelEventHandler(Node*, WheelEvent&);
     bool handlePasteGlobalSelection(const PlatformMouseEvent&);
 
-    void platformPrepareForWheelEvents(const PlatformWheelEvent&, const HitTestResult&, RefPtr<Element>& eventTarget, RefPtr<ContainerNode>& scrollableContainer, WeakPtr<ScrollableArea>&, bool& isOverWidget);
-    void platformRecordWheelEvent(const PlatformWheelEvent&);
-    bool platformCompleteWheelEvent(const PlatformWheelEvent&, ContainerNode* scrollableContainer, const WeakPtr<ScrollableArea>&);
+    void determineWheelEventTarget(const PlatformWheelEvent&, const HitTestResult&, RefPtr<Element>& eventTarget, RefPtr<ContainerNode>& scrollableContainer, WeakPtr<ScrollableArea>&, bool& isOverWidget);
+    void recordWheelEventForDeltaFilter(const PlatformWheelEvent&);
+    bool processWheelEventForScrolling(const PlatformWheelEvent&, ContainerNode* scrollableContainer, const WeakPtr<ScrollableArea>&);
+    void processWheelEventForScrollSnap(const PlatformWheelEvent&, const WeakPtr<ScrollableArea>&);
+
     bool platformCompletePlatformWidgetWheelEvent(const PlatformWheelEvent&, const Widget&, ContainerNode* scrollableContainer);
-    void platformNotifyIfEndGesture(const PlatformWheelEvent&, const WeakPtr<ScrollableArea>&);
 
 #if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
     using TouchArray = Vector<RefPtr<Touch>>;
@@ -495,6 +496,7 @@
 #endif
 
     void clearOrScheduleClearingLatchedStateIfNeeded(const PlatformWheelEvent&);
+    void clearLatchedStateTimerFired();
     void clearLatchedState();
 
     bool shouldSendMouseEventsToInactiveWindows() const;
@@ -526,7 +528,7 @@
     Timer m_cursorUpdateTimer;
 
 #if PLATFORM(MAC)
-    Timer m_pendingMomentumWheelEventsTimer;
+    Timer m_clearLatchingStateTimer;
 #endif
 
     std::unique_ptr<AutoscrollController> m_autoscrollController;
diff --git a/Source/WebCore/page/mac/EventHandlerMac.mm b/Source/WebCore/page/mac/EventHandlerMac.mm
index 6442701..4ff375b 100644
--- a/Source/WebCore/page/mac/EventHandlerMac.mm
+++ b/Source/WebCore/page/mac/EventHandlerMac.mm
@@ -927,10 +927,10 @@
     // when handling wheel events.
     // Logic below installs a timer when non-momentum scrolling ends. If momentum scroll does not start within that interval,
     // reset the latched state. If it does, stop the timer, leaving the latched state untouched.
-    if (!m_pendingMomentumWheelEventsTimer.isActive()) {
+    if (!m_clearLatchingStateTimer.isActive()) {
         if (event.isEndOfNonMomentumScroll()) {
             LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::clearOrScheduleClearingLatchedStateIfNeeded() - event" << event << ", scheduling clear timer");
-            m_pendingMomentumWheelEventsTimer.startOneShot(resetLatchedStateTimeout);
+            m_clearLatchingStateTimer.startOneShot(resetLatchedStateTimeout);
         }
     } else {
         // If another wheel event scrolling starts, stop the timer manually, and reset the latched state immediately.
@@ -938,15 +938,15 @@
             LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::clearOrScheduleClearingLatchedStateIfNeeded() - event" << event << ", timer pending, another scroll starting");
             if (auto* page = m_frame.page())
                 page->resetLatchingState();
-            m_pendingMomentumWheelEventsTimer.stop();
+            m_clearLatchingStateTimer.stop();
         } else if (event.isTransitioningToMomentumScroll()) {
             // Wheel events machinary is transitioning to momentum scrolling, so no need to reset latched state. Stop the timer.
-            m_pendingMomentumWheelEventsTimer.stop();
+            m_clearLatchingStateTimer.stop();
         }
     }
 }
 
-void EventHandler::platformPrepareForWheelEvents(const PlatformWheelEvent& wheelEvent, const HitTestResult& result, RefPtr<Element>& wheelEventTarget, RefPtr<ContainerNode>& scrollableContainer, WeakPtr<ScrollableArea>& scrollableArea, bool& isOverWidget)
+void EventHandler::determineWheelEventTarget(const PlatformWheelEvent& wheelEvent, const HitTestResult& result, RefPtr<Element>& wheelEventTarget, RefPtr<ContainerNode>& scrollableContainer, WeakPtr<ScrollableArea>& scrollableArea, bool& isOverWidget)
 {
     clearOrScheduleClearingLatchedStateIfNeeded(wheelEvent);
 
@@ -971,7 +971,7 @@
                 scrollableArea = makeWeakPtr(static_cast<ScrollableArea&>(*view));
             }
 
-            LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::platformPrepareForWheelEvents() - event" << wheelEvent << " found scrollableContainer" << ValueOrNull(scrollableContainer.get()) << " scrollableArea " << (scrollableArea ? scrollableArea.get() : nullptr));
+            LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::determineWheelEventTarget() - event" << wheelEvent << " found scrollableContainer" << ValueOrNull(scrollableContainer.get()) << " scrollableArea " << (scrollableArea ? scrollableArea.get() : nullptr));
         }
     }
 
@@ -995,11 +995,11 @@
                 isOverWidget = result.isOverWidget();
             }
 
-            LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::platformPrepareForWheelEvents() - considering latching for " << wheelEvent << ", at scroll limit " << startingAtScrollLimit << ", latching state " << page->latchingStateStack());
+            LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::determineWheelEventTarget() - considering latching for " << wheelEvent << ", at scroll limit " << startingAtScrollLimit << ", latching state " << page->latchingStateStack());
         }
     } else if (wheelEvent.shouldResetLatching()) {
         clearLatchedState();
-        LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::platformPrepareForWheelEvents() - reset latching for event " << wheelEvent << " latching state " << page->latchingStateStack());
+        LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::determineWheelEventTarget() - reset latching for event " << wheelEvent << " latching state " << page->latchingStateStack());
     }
 
     if (!wheelEvent.shouldResetLatching() && latchingState && latchingState->wheelEventElement()) {
@@ -1020,7 +1020,7 @@
     }
 }
 
-void EventHandler::platformRecordWheelEvent(const PlatformWheelEvent& wheelEvent)
+void EventHandler::recordWheelEventForDeltaFilter(const PlatformWheelEvent& wheelEvent)
 {
     auto* page = m_frame.page();
     if (!page)
@@ -1047,9 +1047,9 @@
     return latchingState.frame() ? latchingState.frame()->view() : frame.view();
 }
 
-bool EventHandler::platformCompleteWheelEvent(const PlatformWheelEvent& wheelEvent, ContainerNode* scrollableContainer, const WeakPtr<ScrollableArea>& scrollableArea)
+bool EventHandler::processWheelEventForScrolling(const PlatformWheelEvent& wheelEvent, ContainerNode* scrollableContainer, const WeakPtr<ScrollableArea>& scrollableArea)
 {
-    LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::platformCompleteWheelEvent " << wheelEvent << " - scrollableContainer " << scrollableContainer << " scrollableArea " << scrollableArea.get() << " use latched element " << wheelEvent.useLatchedEventElement());
+    LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::processWheelEventForScrolling " << wheelEvent << " - scrollableContainer " << scrollableContainer << " scrollableArea " << scrollableArea.get() << " use latched element " << wheelEvent.useLatchedEventElement());
 
     Ref<Frame> protectedFrame(m_frame);
 
@@ -1068,7 +1068,7 @@
         // WebKit2 code path
         if (!frameHasPlatformWidget(m_frame) && !latchingState->startedGestureAtScrollLimit() && scrollableContainer == latchingState->scrollableContainer() && scrollableArea && view != scrollableArea) {
             // If we did not start at the scroll limit, do not pass the event on to be handled by enclosing scrollable regions.
-            LOG_WITH_STREAM(Scrolling, stream << "EventHandler " << this << " platformCompleteWheelEvent - latched to " << scrollableArea.get() << " and not propagating");
+            LOG_WITH_STREAM(Scrolling, stream << "EventHandler " << this << " processWheelEventForScrolling - latched to " << scrollableArea.get() << " and not propagating");
             return true;
         }
 
@@ -1112,7 +1112,7 @@
     return false;
 }
 
-void EventHandler::platformNotifyIfEndGesture(const PlatformWheelEvent& wheelEvent, const WeakPtr<ScrollableArea>& scrollableArea)
+void EventHandler::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent, const WeakPtr<ScrollableArea>& scrollableArea)
 {
     if (!scrollableArea)
         return;