Expand test infrastructure to support scrolling tests
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Apr 2015 21:32:59 +0000 (21:32 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Apr 2015 21:32:59 +0000 (21:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143383

Reviewed by Darin Adler.

No new tests: No change in behavior.

This is an initial set of changes that clean up a few things I noticed while extending testing support
for scroll animations and wheel event gestures.
1. Reduce the amount of #ifdef code in EventHandler{Mac}.
2. Consolidate the idea of an "End Gesture" in the PlatformWheelEvent class.
3. Remove a number of unneeded null checks in EventHandler.
4. ScrollController must always have a client, so hold a reference instead of using a pointer.

* page/EventHandler.cpp:
(WebCore::EventHandler::platformNotifyIfEndGesture): Renamed from 'platformNotifySnapIfNecessary'.
(WebCore::EventHandler::handleWheelEvent): Call 'platformNotifySnapIfNecessary' at method exit points.
(WebCore::EventHandler::platformNotifySnapIfNecessary): Deleted.
* page/EventHandler.h:
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::platformCompleteWheelEvent):  Remove unneeded null checks for 'view'. Remove
CSS_SNAP-specific call to 'platformNotifySnapIfNecessary'. This logic is now handled in the new
'platformNotifyIfEndGesture' method.
(WebCore::EventHandler::platformNotifyIfEndGesture): Renamed from 'platformNotifySnapIfNecessary'.
(WebCore::EventHandler::platformNotifySnapIfNecessary): Deleted.
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::ScrollingTreeFrameScrollingNodeMac): Pass 'this' as
reference to ScrollController constructor.
* platform/PlatformWheelEvent.h:
(WebCore::PlatformWheelEvent::shouldResetLatching): Call new 'isEndGesture' method.
(WebCore::PlatformWheelEvent::isEndGesture): Added method to encapsulate some code that was duplicated
in a number of places.
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::ScrollAnimator): Pass 'this' as reference to ScrollController constructor.
* platform/cocoa/ScrollController.h:
* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::ScrollController): Update to reflect m_client is now a reference.
(WebCore::ScrollController::handleWheelEvent): Ditto.
(WebCore::ScrollController::snapRubberBandTimerFired): Ditto. Also, a drive-by fix for ending rubberband
snapping. This end-state wasn't deactivating the timer (even when the animation finished). This isn't a
huge problem, but I (will) rely on the state of the animation timer in a future patch to decide if
tests should run or continue waiting.
(WebCore::ScrollController::isRubberBandInProgress): Ditto.
(WebCore::ScrollController::startSnapRubberbandTimer): Ditto.
(WebCore::ScrollController::stopSnapRubberbandTimer): Ditto.
(WebCore::ScrollController::shouldRubberBandInHorizontalDirection): Ditto.
(WebCore::ScrollController::processWheelEventForScrollSnapOnAxis): Ditto.
(WebCore::ScrollController::startScrollSnapTimer): Ditto.
(WebCore::ScrollController::stopScrollSnapTimer): Ditto.
(WebCore::ScrollController::scrollSnapAnimationUpdate): Ditto.
(WebCore::ScrollController::beginScrollSnapAnimation): Ditto.
(WebCore::ScrollController::computeSnapDelta): Ditto.
(WebCore::ScrollController::computeGlideDelta): Ditto.
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::gestureShouldBeginSnap): Use new PlatformWheelEvent::isEndGesture() method.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182334 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/page/mac/EventHandlerMac.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
Source/WebCore/platform/PlatformWheelEvent.h
Source/WebCore/platform/ScrollAnimator.cpp
Source/WebCore/platform/cocoa/ScrollController.h
Source/WebCore/platform/cocoa/ScrollController.mm
Source/WebCore/platform/mac/ScrollAnimatorMac.mm

index 33dffbd..0d4f069 100644 (file)
@@ -1,3 +1,61 @@
+2015-04-03  Brent Fulgham  <bfulgham@apple.com>
+
+        Expand test infrastructure to support scrolling tests
+        https://bugs.webkit.org/show_bug.cgi?id=143383
+
+        Reviewed by Darin Adler.
+
+        No new tests: No change in behavior.
+
+        This is an initial set of changes that clean up a few things I noticed while extending testing support
+        for scroll animations and wheel event gestures.
+        1. Reduce the amount of #ifdef code in EventHandler{Mac}.
+        2. Consolidate the idea of an "End Gesture" in the PlatformWheelEvent class.
+        3. Remove a number of unneeded null checks in EventHandler.
+        4. ScrollController must always have a client, so hold a reference instead of using a pointer.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::platformNotifyIfEndGesture): Renamed from 'platformNotifySnapIfNecessary'.
+        (WebCore::EventHandler::handleWheelEvent): Call 'platformNotifySnapIfNecessary' at method exit points.
+        (WebCore::EventHandler::platformNotifySnapIfNecessary): Deleted.
+        * page/EventHandler.h:
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::EventHandler::platformCompleteWheelEvent):  Remove unneeded null checks for 'view'. Remove
+        CSS_SNAP-specific call to 'platformNotifySnapIfNecessary'. This logic is now handled in the new
+        'platformNotifyIfEndGesture' method.
+        (WebCore::EventHandler::platformNotifyIfEndGesture): Renamed from 'platformNotifySnapIfNecessary'.
+        (WebCore::EventHandler::platformNotifySnapIfNecessary): Deleted.
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::ScrollingTreeFrameScrollingNodeMac): Pass 'this' as
+        reference to ScrollController constructor.
+        * platform/PlatformWheelEvent.h:
+        (WebCore::PlatformWheelEvent::shouldResetLatching): Call new 'isEndGesture' method.
+        (WebCore::PlatformWheelEvent::isEndGesture): Added method to encapsulate some code that was duplicated
+        in a number of places.
+        * platform/ScrollAnimator.cpp:
+        (WebCore::ScrollAnimator::ScrollAnimator): Pass 'this' as reference to ScrollController constructor.
+        * platform/cocoa/ScrollController.h:
+        * platform/cocoa/ScrollController.mm:
+        (WebCore::ScrollController::ScrollController): Update to reflect m_client is now a reference.
+        (WebCore::ScrollController::handleWheelEvent): Ditto.
+        (WebCore::ScrollController::snapRubberBandTimerFired): Ditto. Also, a drive-by fix for ending rubberband
+        snapping. This end-state wasn't deactivating the timer (even when the animation finished). This isn't a
+        huge problem, but I (will) rely on the state of the animation timer in a future patch to decide if
+        tests should run or continue waiting.
+        (WebCore::ScrollController::isRubberBandInProgress): Ditto.
+        (WebCore::ScrollController::startSnapRubberbandTimer): Ditto.
+        (WebCore::ScrollController::stopSnapRubberbandTimer): Ditto.
+        (WebCore::ScrollController::shouldRubberBandInHorizontalDirection): Ditto.
+        (WebCore::ScrollController::processWheelEventForScrollSnapOnAxis): Ditto.
+        (WebCore::ScrollController::startScrollSnapTimer): Ditto.
+        (WebCore::ScrollController::stopScrollSnapTimer): Ditto.
+        (WebCore::ScrollController::scrollSnapAnimationUpdate): Ditto.
+        (WebCore::ScrollController::beginScrollSnapAnimation): Ditto.
+        (WebCore::ScrollController::computeSnapDelta): Ditto.
+        (WebCore::ScrollController::computeGlideDelta): Ditto.
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::gestureShouldBeginSnap): Use new PlatformWheelEvent::isEndGesture() method.
+
 2015-04-03  Chris Fleizach  <cfleizach@apple.com>
 
         AX: Toggling check box state not speaking using plain space, not VO space.
index ae94bf6..46051c6 100644 (file)
@@ -2627,11 +2627,9 @@ bool EventHandler::platformCompletePlatformWidgetWheelEvent(const PlatformWheelE
     return true;
 }
 
-#if ENABLE(CSS_SCROLL_SNAP)
-void EventHandler::platformNotifySnapIfNecessary(const PlatformWheelEvent&, ScrollableArea&)
+void EventHandler::platformNotifyIfEndGesture(const PlatformWheelEvent&, ScrollableArea*)
 {
 }
-#endif
 
 #endif
 
@@ -2682,6 +2680,7 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event)
                     m_isHandlingWheelEvent = false;
                     if (scrollableArea)
                         scrollableArea->setScrolledProgrammatically(false);
+                    platformNotifyIfEndGesture(adjustedEvent, scrollableArea);
                     if (!widget->platformWidget())
                         return true;
                     return platformCompletePlatformWidgetWheelEvent(event, *widget, scrollableContainer.get());
@@ -2697,10 +2696,7 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event)
                 scrollableArea->setScrolledProgrammatically(false);
             }
 
-#if ENABLE(CSS_SCROLL_SNAP)
-            if (scrollableArea)
-                platformNotifySnapIfNecessary(adjustedEvent, *scrollableArea);
-#endif
+            platformNotifyIfEndGesture(adjustedEvent, scrollableArea);
             return true;
         }
     }
@@ -2708,7 +2704,9 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event)
     if (scrollableArea)
         scrollableArea->setScrolledProgrammatically(false);
 
-    return platformCompleteWheelEvent(event, scrollableContainer.get(), scrollableArea);
+    bool handledEvent = platformCompleteWheelEvent(event, scrollableContainer.get(), scrollableArea);
+    platformNotifyIfEndGesture(adjustedEvent, scrollableArea);
+    return handledEvent;
 }
 
 void EventHandler::clearLatchedState()
index 5f104a0..d510057 100644 (file)
@@ -210,10 +210,7 @@ public:
     void platformRecordWheelEvent(const PlatformWheelEvent&);
     bool platformCompleteWheelEvent(const PlatformWheelEvent&, ContainerNode* scrollableContainer, ScrollableArea*);
     bool platformCompletePlatformWidgetWheelEvent(const PlatformWheelEvent&, const Widget&, ContainerNode* scrollableContainer);
-
-#if ENABLE(CSS_SCROLL_SNAP)
-    void platformNotifySnapIfNecessary(const PlatformWheelEvent&, ScrollableArea&);
-#endif
+    void platformNotifyIfEndGesture(const PlatformWheelEvent&, ScrollableArea*);
 
 #if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
     typedef Vector<RefPtr<Touch>> TouchArray;
index 89a7cec..6caa169 100644 (file)
@@ -938,6 +938,7 @@ static FrameView* frameViewForLatchingState(Frame& frame, ScrollLatchingState* l
 bool EventHandler::platformCompleteWheelEvent(const PlatformWheelEvent& wheelEvent, ContainerNode* scrollableContainer, ScrollableArea* scrollableArea)
 {
     // We do another check on the frame view because the event handler can run JS which results in the frame getting destroyed.
+    ASSERT(m_frame.view());
     FrameView* view = m_frame.view();
 
     ScrollLatchingState* latchingState = m_frame.mainFrame().latchingState();
@@ -954,7 +955,9 @@ bool EventHandler::platformCompleteWheelEvent(const PlatformWheelEvent& wheelEve
         if (!latchingState->startedGestureAtScrollLimit())
             view = frameViewForLatchingState(m_frame, latchingState);
 
-        bool didHandleWheelEvent = view && view->wheelEvent(wheelEvent);
+        ASSERT(view);
+
+        bool didHandleWheelEvent = view->wheelEvent(wheelEvent);
         if (scrollableContainer == latchingState->scrollableContainer()) {
             // If we are just starting a scroll event, and have nowhere left to scroll, allow
             // the enclosing frame to handle the scroll.
@@ -962,20 +965,14 @@ bool EventHandler::platformCompleteWheelEvent(const PlatformWheelEvent& wheelEve
         }
 
         // If the platform widget is handling the event, we always want to return false.
-        if (view && scrollableArea == view && view->platformWidget())
+        if (scrollableArea == view && view->platformWidget())
             didHandleWheelEvent = false;
         
         return didHandleWheelEvent;
     }
     
-    bool didHandleEvent = view ? view->wheelEvent(wheelEvent) : false;
+    bool didHandleEvent = view->wheelEvent(wheelEvent);
     m_isHandlingWheelEvent = false;
-
-#if ENABLE(CSS_SCROLL_SNAP)
-    if (scrollableArea)
-        platformNotifySnapIfNecessary(wheelEvent, *scrollableArea);
-#endif
-
     return didHandleEvent;
 }
 
@@ -995,16 +992,19 @@ bool EventHandler::platformCompletePlatformWidgetWheelEvent(const PlatformWheelE
     return false;
 }
 
-#if ENABLE(CSS_SCROLL_SNAP)
-void EventHandler::platformNotifySnapIfNecessary(const PlatformWheelEvent& wheelEvent, ScrollableArea& scrollableArea)
+void EventHandler::platformNotifyIfEndGesture(const PlatformWheelEvent& wheelEvent, ScrollableArea* scrollableArea)
 {
+    if (!scrollableArea)
+        return;
+
     // Special case handling for ending wheel gesture to activate snap animation:
     if (wheelEvent.phase() != PlatformWheelEventPhaseEnded && wheelEvent.momentumPhase() != PlatformWheelEventPhaseEnded)
         return;
 
-    if (ScrollAnimator* scrollAnimator = scrollableArea.existingScrollAnimator())
+#if ENABLE(CSS_SCROLL_SNAP)
+    if (ScrollAnimator* scrollAnimator = scrollableArea->existingScrollAnimator())
         scrollAnimator->processWheelEventForScrollSnap(wheelEvent);
-}
 #endif
+}
 
 }
index f90d2be..94d157c 100644 (file)
@@ -55,7 +55,7 @@ PassRefPtr<ScrollingTreeFrameScrollingNode> ScrollingTreeFrameScrollingNodeMac::
 
 ScrollingTreeFrameScrollingNodeMac::ScrollingTreeFrameScrollingNodeMac(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
     : ScrollingTreeFrameScrollingNode(scrollingTree, nodeID)
-    , m_scrollController(this)
+    , m_scrollController(*this)
     , m_verticalScrollbarPainter(0)
     , m_horizontalScrollbarPainter(0)
     , m_lastScrollHadUnfilledPixels(false)
index 3c622ea..bdc19c4 100644 (file)
@@ -162,26 +162,10 @@ namespace WebCore {
         unsigned scrollCount() const { return m_scrollCount; }
         float unacceleratedScrollingDeltaX() const { return m_unacceleratedScrollingDeltaX; }
         float unacceleratedScrollingDeltaY() const { return m_unacceleratedScrollingDeltaY; }
-        bool useLatchedEventElement() const
-        {
-            return m_phase == PlatformWheelEventPhaseBegan || m_phase == PlatformWheelEventPhaseChanged
-                || m_momentumPhase == PlatformWheelEventPhaseBegan || m_momentumPhase == PlatformWheelEventPhaseChanged
-                || (m_phase == PlatformWheelEventPhaseEnded && m_momentumPhase == PlatformWheelEventPhaseNone);
-        }
-        bool shouldConsiderLatching() const
-        {
-            return m_phase == PlatformWheelEventPhaseBegan || m_phase == PlatformWheelEventPhaseMayBegin;
-        }
-        bool shouldResetLatching() const
-        {
-            if (m_phase == PlatformWheelEventPhaseCancelled || m_phase == PlatformWheelEventPhaseMayBegin)
-                return true;
-            
-            if (m_phase == PlatformWheelEventPhaseNone && m_momentumPhase == PlatformWheelEventPhaseEnded)
-                return true;
-            
-            return false;
-        }
+        bool useLatchedEventElement() const;
+        bool shouldConsiderLatching() const;
+        bool shouldResetLatching() const;
+        bool isEndGesture() const;
 #else
         bool useLatchedEventElement() const { return false; }
 #endif
@@ -210,6 +194,31 @@ namespace WebCore {
 #endif
     };
 
+#if PLATFORM(COCOA)
+    inline bool PlatformWheelEvent::useLatchedEventElement() const
+    {
+        return m_phase == PlatformWheelEventPhaseBegan || m_phase == PlatformWheelEventPhaseChanged
+        || m_momentumPhase == PlatformWheelEventPhaseBegan || m_momentumPhase == PlatformWheelEventPhaseChanged
+        || (m_phase == PlatformWheelEventPhaseEnded && m_momentumPhase == PlatformWheelEventPhaseNone);
+    }
+    
+    inline bool PlatformWheelEvent::shouldConsiderLatching() const
+    {
+        return m_phase == PlatformWheelEventPhaseBegan || m_phase == PlatformWheelEventPhaseMayBegin;
+    }
+    
+    inline bool PlatformWheelEvent::shouldResetLatching() const
+    {
+        return m_phase == PlatformWheelEventPhaseCancelled || m_phase == PlatformWheelEventPhaseMayBegin || isEndGesture();
+    }
+    
+    inline bool PlatformWheelEvent::isEndGesture() const
+    {
+        return m_phase == PlatformWheelEventPhaseNone && m_momentumPhase == PlatformWheelEventPhaseEnded;
+    }
+
+#endif
+
 } // namespace WebCore
 
 #endif // PlatformWheelEvent_h
index 28aa826..f73bc7f 100644 (file)
@@ -50,7 +50,7 @@ std::unique_ptr<ScrollAnimator> ScrollAnimator::create(ScrollableArea& scrollabl
 ScrollAnimator::ScrollAnimator(ScrollableArea& scrollableArea)
     : m_scrollableArea(scrollableArea)
 #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
-    , m_scrollController(this)
+    , m_scrollController(*this)
 #endif
     , m_currentPosX(0)
     , m_currentPosY(0)
index ba918de..7d5816d 100644 (file)
@@ -99,7 +99,7 @@ class ScrollController {
     WTF_MAKE_NONCOPYABLE(ScrollController);
 
 public:
-    explicit ScrollController(ScrollControllerClient*);
+    explicit ScrollController(ScrollControllerClient&);
 
     bool handleWheelEvent(const PlatformWheelEvent&);
 
@@ -141,7 +141,7 @@ private:
     const ScrollSnapAnimatorState& scrollSnapPointState(ScrollEventAxis) const;
 #endif
 
-    ScrollControllerClient* m_client;
+    ScrollControllerClient& m_client;
     
     CFTimeInterval m_lastMomentumScrollTimestamp;
     FloatSize m_overflowScrollDelta;
index b25df87..5d42b6e 100644 (file)
@@ -120,7 +120,7 @@ static float scrollWheelMultiplier()
     return multiplier;
 }
 
-ScrollController::ScrollController(ScrollControllerClient* client)
+ScrollController::ScrollController(ScrollControllerClient& client)
     : m_client(client)
     , m_lastMomentumScrollTimestamp(0)
     , m_startTime(0)
@@ -144,7 +144,7 @@ bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 #endif
     if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) {
         // First, check if we should rubber-band at all.
-        if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0))
+        if (m_client.pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0))
             && !shouldRubberBandInHorizontalDirection(wheelEvent))
             return false;
 
@@ -154,7 +154,7 @@ bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
         m_lastMomentumScrollTimestamp = 0;
         m_momentumVelocity = FloatSize();
 
-        IntSize stretchAmount = m_client->stretchAmount();
+        IntSize stretchAmount = m_client.stretchAmount();
         m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
         m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(stretchAmount.height()));
         m_overflowScrollDelta = FloatSize();
@@ -184,7 +184,7 @@ bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
     // Reset overflow values because we may decide to remove delta at various points and put it into overflow.
     m_overflowScrollDelta = FloatSize();
 
-    IntSize stretchAmount = m_client->stretchAmount();
+    IntSize stretchAmount = m_client.stretchAmount();
     bool isVerticallyStretched = stretchAmount.height();
     bool isHorizontallyStretched = stretchAmount.width();
 
@@ -228,7 +228,7 @@ bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
         }
 
         if (isVerticallyStretched) {
-            if (!isHorizontallyStretched && m_client->pinnedInDirection(FloatSize(deltaX, 0))) {
+            if (!isHorizontallyStretched && m_client.pinnedInDirection(FloatSize(deltaX, 0))) {
                 // Stretching only in the vertical.
                 if (deltaY && (fabsf(deltaX / deltaY) < rubberbandDirectionLockStretchRatio))
                     deltaX = 0;
@@ -240,7 +240,7 @@ bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
             }
         } else if (isHorizontallyStretched) {
             // Stretching only in the horizontal.
-            if (m_client->pinnedInDirection(FloatSize(0, deltaY))) {
+            if (m_client.pinnedInDirection(FloatSize(0, deltaY))) {
                 if (deltaX && (fabsf(deltaY / deltaX) < rubberbandDirectionLockStretchRatio))
                     deltaY = 0;
                 else if (fabsf(deltaY) < rubberbandMinimumRequiredDeltaBeforeStretch) {
@@ -251,7 +251,7 @@ bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
             }
         } else {
             // Not stretching at all yet.
-            if (m_client->pinnedInDirection(FloatSize(deltaX, deltaY))) {
+            if (m_client.pinnedInDirection(FloatSize(deltaX, deltaY))) {
                 if (fabsf(deltaY) >= fabsf(deltaX)) {
                     if (fabsf(deltaX) < rubberbandMinimumRequiredDeltaBeforeStretch) {
                         m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
@@ -268,37 +268,37 @@ bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
         if (!(shouldStretch || isVerticallyStretched || isHorizontallyStretched)) {
             if (deltaY) {
                 deltaY *= scrollWheelMultiplier();
-                m_client->immediateScrollBy(FloatSize(0, deltaY));
+                m_client.immediateScrollBy(FloatSize(0, deltaY));
             }
             if (deltaX) {
                 deltaX *= scrollWheelMultiplier();
-                m_client->immediateScrollBy(FloatSize(deltaX, 0));
+                m_client.immediateScrollBy(FloatSize(deltaX, 0));
             }
         } else {
-            if (!m_client->allowsHorizontalStretching(wheelEvent)) {
+            if (!m_client.allowsHorizontalStretching(wheelEvent)) {
                 deltaX = 0;
                 eventCoalescedDeltaX = 0;
-            } else if (deltaX && !isHorizontallyStretched && !m_client->pinnedInDirection(FloatSize(deltaX, 0))) {
+            } else if (deltaX && !isHorizontallyStretched && !m_client.pinnedInDirection(FloatSize(deltaX, 0))) {
                 deltaX *= scrollWheelMultiplier();
 
-                m_client->immediateScrollByWithoutContentEdgeConstraints(FloatSize(deltaX, 0));
+                m_client.immediateScrollByWithoutContentEdgeConstraints(FloatSize(deltaX, 0));
                 deltaX = 0;
             }
 
-            if (!m_client->allowsVerticalStretching(wheelEvent)) {
+            if (!m_client.allowsVerticalStretching(wheelEvent)) {
                 deltaY = 0;
                 eventCoalescedDeltaY = 0;
-            } else if (deltaY && !isVerticallyStretched && !m_client->pinnedInDirection(FloatSize(0, deltaY))) {
+            } else if (deltaY && !isVerticallyStretched && !m_client.pinnedInDirection(FloatSize(0, deltaY))) {
                 deltaY *= scrollWheelMultiplier();
 
-                m_client->immediateScrollByWithoutContentEdgeConstraints(FloatSize(0, deltaY));
+                m_client.immediateScrollByWithoutContentEdgeConstraints(FloatSize(0, deltaY));
                 deltaY = 0;
             }
 
-            IntSize stretchAmount = m_client->stretchAmount();
+            IntSize stretchAmount = m_client.stretchAmount();
 
             if (m_momentumScrollInProgress) {
-                if ((m_client->pinnedInDirection(FloatSize(eventCoalescedDeltaX, eventCoalescedDeltaY)) || (fabsf(eventCoalescedDeltaX) + fabsf(eventCoalescedDeltaY) <= 0)) && m_lastMomentumScrollTimestamp) {
+                if ((m_client.pinnedInDirection(FloatSize(eventCoalescedDeltaX, eventCoalescedDeltaY)) || (fabsf(eventCoalescedDeltaX) + fabsf(eventCoalescedDeltaY) <= 0)) && m_lastMomentumScrollTimestamp) {
                     m_ignoreMomentumScrolls = true;
                     m_momentumScrollInProgress = false;
                     snapRubberBand();
@@ -310,7 +310,7 @@ bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 
             FloatSize dampedDelta(ceilf(elasticDeltaForReboundDelta(m_stretchScrollForce.width())), ceilf(elasticDeltaForReboundDelta(m_stretchScrollForce.height())));
 
-            m_client->immediateScrollByWithoutContentEdgeConstraints(dampedDelta - stretchAmount);
+            m_client.immediateScrollByWithoutContentEdgeConstraints(dampedDelta - stretchAmount);
         }
     }
 
@@ -343,7 +343,7 @@ void ScrollController::snapRubberBandTimerFired()
         CFTimeInterval timeDelta = [NSDate timeIntervalSinceReferenceDate] - m_startTime;
 
         if (m_startStretch == FloatSize()) {
-            m_startStretch = m_client->stretchAmount();
+            m_startStretch = m_client.stretchAmount();
             if (m_startStretch == FloatSize()) {
                 stopSnapRubberbandTimer();
 
@@ -355,7 +355,7 @@ void ScrollController::snapRubberBandTimerFired()
                 return;
             }
 
-            m_origOrigin = m_client->absoluteScrollPosition() - m_startStretch;
+            m_origOrigin = m_client.absoluteScrollPosition() - m_startStretch;
             m_origVelocity = m_momentumVelocity;
 
             // Just like normal scrolling, prefer vertical rubberbanding
@@ -363,11 +363,11 @@ void ScrollController::snapRubberBandTimerFired()
                 m_origVelocity.setWidth(0);
 
             // Don't rubber-band horizontally if it's not possible to scroll horizontally
-            if (!m_client->canScrollHorizontally())
+            if (!m_client.canScrollHorizontally())
                 m_origVelocity.setWidth(0);
 
             // Don't rubber-band vertically if it's not possible to scroll vertically
-            if (!m_client->canScrollVertically())
+            if (!m_client.canScrollVertically())
                 m_origVelocity.setHeight(0);
         }
 
@@ -375,14 +375,14 @@ void ScrollController::snapRubberBandTimerFired()
             roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.height(), -m_origVelocity.height(), (float)timeDelta)));
 
         if (fabs(delta.x()) >= 1 || fabs(delta.y()) >= 1) {
-            m_client->immediateScrollByWithoutContentEdgeConstraints(FloatSize(delta.x(), delta.y()) - m_client->stretchAmount());
+            m_client.immediateScrollByWithoutContentEdgeConstraints(FloatSize(delta.x(), delta.y()) - m_client.stretchAmount());
 
-            FloatSize newStretch = m_client->stretchAmount();
+            FloatSize newStretch = m_client.stretchAmount();
 
             m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(newStretch.width()));
             m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(newStretch.height()));
         } else {
-            m_client->adjustScrollPositionToBoundsIfNecessary();
+            m_client.adjustScrollPositionToBoundsIfNecessary();
 
             stopSnapRubberbandTimer();
             m_stretchScrollForce = FloatSize();
@@ -394,6 +394,8 @@ void ScrollController::snapRubberBandTimerFired()
     } else {
         m_startTime = [NSDate timeIntervalSinceReferenceDate];
         m_startStretch = FloatSize();
+        if (!isRubberBandInProgress())
+            stopSnapRubberbandTimer();
     }
 }
 
@@ -402,18 +404,18 @@ bool ScrollController::isRubberBandInProgress() const
     if (!m_inScrollGesture && !m_momentumScrollInProgress && !m_snapRubberbandTimerIsActive)
         return false;
 
-    return !m_client->stretchAmount().isZero();
+    return !m_client.stretchAmount().isZero();
 }
 
 void ScrollController::startSnapRubberbandTimer()
 {
-    m_client->startSnapRubberbandTimer();
+    m_client.startSnapRubberbandTimer();
     m_snapRubberbandTimer.startRepeating(1.0 / 60.0);
 }
 
 void ScrollController::stopSnapRubberbandTimer()
 {
-    m_client->stopSnapRubberbandTimer();
+    m_client.stopSnapRubberbandTimer();
     m_snapRubberbandTimer.stop();
     m_snapRubberbandTimerIsActive = false;
 }
@@ -441,9 +443,9 @@ void ScrollController::snapRubberBand()
 bool ScrollController::shouldRubberBandInHorizontalDirection(const PlatformWheelEvent& wheelEvent)
 {
     if (wheelEvent.deltaX() > 0)
-        return m_client->shouldRubberBandInDirection(ScrollLeft);
+        return m_client.shouldRubberBandInDirection(ScrollLeft);
     if (wheelEvent.deltaX() < 0)
-        return m_client->shouldRubberBandInDirection(ScrollRight);
+        return m_client.shouldRubberBandInDirection(ScrollRight);
 
     return true;
 }
@@ -526,7 +528,7 @@ void ScrollController::processWheelEventForScrollSnapOnAxis(ScrollEventAxis axis
         // Begin tracking wheel deltas for glide prediction.
         endScrollSnapAnimation(axis, ScrollSnapState::UserInteraction);
         snapState.pushInitialWheelDelta(wheelDelta);
-        snapState.m_beginTrackingWheelDeltaOffset = m_client->scrollOffsetOnAxis(axis);
+        snapState.m_beginTrackingWheelDeltaOffset = m_client.scrollOffsetOnAxis(axis);
         break;
             
     case WheelEventStatus::InertialScrolling:
@@ -608,14 +610,14 @@ void ScrollController::startScrollSnapTimer(ScrollEventAxis axis)
 {
     RunLoop::Timer<ScrollController>& scrollSnapTimer = axis == ScrollEventAxis::Horizontal ? m_horizontalScrollSnapTimer : m_verticalScrollSnapTimer;
     if (!scrollSnapTimer.isActive()) {
-        m_client->startScrollSnapTimer(axis);
+        m_client.startScrollSnapTimer(axis);
         scrollSnapTimer.startRepeating(1.0 / 60.0);
     }
 }
 
 void ScrollController::stopScrollSnapTimer(ScrollEventAxis axis)
 {
-    m_client->stopScrollSnapTimer(axis);
+    m_client.stopScrollSnapTimer(axis);
     RunLoop::Timer<ScrollController>& scrollSnapTimer = axis == ScrollEventAxis::Horizontal ? m_horizontalScrollSnapTimer : m_verticalScrollSnapTimer;
     scrollSnapTimer.stop();
 }
@@ -645,7 +647,7 @@ void ScrollController::scrollSnapAnimationUpdate(ScrollEventAxis axis)
     ASSERT(snapState.m_currentState == ScrollSnapState::Gliding || snapState.m_currentState == ScrollSnapState::Snapping);
     float delta = snapState.m_currentState == ScrollSnapState::Snapping ? computeSnapDelta(axis) : computeGlideDelta(axis);
     if (delta)
-        m_client->immediateScrollOnAxis(axis, delta);
+        m_client.immediateScrollOnAxis(axis, delta);
     else
         endScrollSnapAnimation(axis, ScrollSnapState::DestinationReached);
 }
@@ -678,13 +680,13 @@ void ScrollController::beginScrollSnapAnimation(ScrollEventAxis axis, ScrollSnap
     
     ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
 
-    LayoutUnit offset = m_client->scrollOffsetOnAxis(axis);
+    LayoutUnit offset = m_client.scrollOffsetOnAxis(axis);
     float initialWheelDelta = newState == ScrollSnapState::Gliding ? snapState.averageInitialWheelDelta() : 0;
     LayoutUnit projectedScrollDestination = newState == ScrollSnapState::Gliding ? snapState.m_beginTrackingWheelDeltaOffset + LayoutUnit(projectedInertialScrollDistance(initialWheelDelta)) : offset;
     if (snapState.m_snapOffsets.isEmpty())
         return;
 
-    float scaleFactor = m_client->pageScaleFactor();
+    float scaleFactor = m_client.pageScaleFactor();
     
     projectedScrollDestination = std::min(std::max(LayoutUnit(projectedScrollDestination / scaleFactor), snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
     snapState.m_initialOffset = offset;
@@ -743,7 +745,7 @@ float ScrollController::computeSnapDelta(ScrollEventAxis axis) const
 {
     const ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
 
-    LayoutUnit offset = m_client->scrollOffsetOnAxis(axis);
+    LayoutUnit offset = m_client.scrollOffsetOnAxis(axis);
     bool canComputeSnap =  (snapState.m_initialOffset <= offset && offset < snapState.m_targetOffset) || (snapState.m_targetOffset < offset && offset <= snapState.m_initialOffset);
     if (snapState.m_currentState != ScrollSnapState::Snapping || !canComputeSnap)
         return 0;
@@ -790,7 +792,7 @@ float ScrollController::computeGlideDelta(ScrollEventAxis axis) const
 {
     const ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
 
-    LayoutUnit offset = m_client->scrollOffsetOnAxis(axis);
+    LayoutUnit offset = m_client.scrollOffsetOnAxis(axis);
     bool canComputeGlide = (snapState.m_initialOffset <= offset && offset < snapState.m_targetOffset) || (snapState.m_targetOffset < offset && offset <= snapState.m_initialOffset);
     if (snapState.m_currentState != ScrollSnapState::Gliding || !canComputeGlide)
         return 0;
index 1e667d4..9a8a983 100644 (file)
@@ -1154,10 +1154,8 @@ static bool gestureShouldBeginSnap(const PlatformWheelEvent& wheelEvent, const V
     if (!snapOffsets)
         return false;
     
-    if ((wheelEvent.phase() != PlatformWheelEventPhaseEnded)
-        && !(wheelEvent.phase() == PlatformWheelEventPhaseNone && wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded)) {
+    if (wheelEvent.phase() != PlatformWheelEventPhaseEnded && !wheelEvent.isEndGesture())
         return false;
-    }
 
     return true;
 }