ScrollElasticityController should keep track of the rubberband timer state
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 22:14:49 +0000 (22:14 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 22:14:49 +0000 (22:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69381

Reviewed by Sam Weinig.

Add a m_snapRubberbandTimerIsActive member variable to ScrollElasticityController
and use it instead of checking whether the m_snapRubberbandTimer is active.

Eventually, ScrollElasticityControllerClient will have two member functions for starting
and stopping the timer, and the ScrollElasticityController will call them at the appropriate times.

* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::handleWheelEvent):
(WebCore::ScrollAnimatorMac::beginScrollGesture):
It's OK to stop the timer unconditionally.

(WebCore::ScrollAnimatorMac::snapRubberBand):
(WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
* platform/mac/ScrollElasticityController.h:
* platform/mac/ScrollElasticityController.mm:
(WebCore::ScrollElasticityController::ScrollElasticityController):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/platform/mac/ScrollElasticityController.h
Source/WebCore/platform/mac/ScrollElasticityController.mm

index 2a7c5a4..14c8b75 100644 (file)
@@ -1,5 +1,29 @@
 2011-10-04  Anders Carlsson  <andersca@apple.com>
 
+        ScrollElasticityController should keep track of the rubberband timer state
+        https://bugs.webkit.org/show_bug.cgi?id=69381
+
+        Reviewed by Sam Weinig.
+
+        Add a m_snapRubberbandTimerIsActive member variable to ScrollElasticityController
+        and use it instead of checking whether the m_snapRubberbandTimer is active.
+
+        Eventually, ScrollElasticityControllerClient will have two member functions for starting
+        and stopping the timer, and the ScrollElasticityController will call them at the appropriate times.
+
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::handleWheelEvent):
+        (WebCore::ScrollAnimatorMac::beginScrollGesture):
+        It's OK to stop the timer unconditionally.
+
+        (WebCore::ScrollAnimatorMac::snapRubberBand):
+        (WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
+        * platform/mac/ScrollElasticityController.h:
+        * platform/mac/ScrollElasticityController.mm:
+        (WebCore::ScrollElasticityController::ScrollElasticityController):
+
+2011-10-04  Anders Carlsson  <andersca@apple.com>
+
         Move all rubber-banding related member variables to ScrollElasticityController
         https://bugs.webkit.org/show_bug.cgi?id=69379
 
index 121534b..e9aabdd 100644 (file)
@@ -836,7 +836,7 @@ bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
     }
 
     bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone);
-    if (m_scrollElasticityController.m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberBandTimer.isActive())) {
+    if (m_scrollElasticityController.m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_scrollElasticityController.m_snapRubberbandTimerIsActive)) {
         if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) {
             m_scrollElasticityController.m_ignoreMomentumScrolls = false;
             return true;
@@ -1093,8 +1093,8 @@ void ScrollAnimatorMac::beginScrollGesture()
 
     m_scrollElasticityController.m_overflowScrollDelta = FloatSize();
     
-    if (m_snapRubberBandTimer.isActive())
-        m_snapRubberBandTimer.stop();
+    m_snapRubberBandTimer.stop();
+    m_scrollElasticityController.m_snapRubberbandTimerIsActive = false;
 }
 
 void ScrollAnimatorMac::endScrollGesture()
@@ -1112,7 +1112,7 @@ void ScrollAnimatorMac::snapRubberBand()
 
     m_scrollElasticityController.m_inScrollGesture = false;
 
-    if (m_snapRubberBandTimer.isActive())
+    if (m_scrollElasticityController.m_snapRubberbandTimerIsActive)
         return;
 
     m_scrollElasticityController.m_startTime = [NSDate timeIntervalSinceReferenceDate];
@@ -1121,6 +1121,7 @@ void ScrollAnimatorMac::snapRubberBand()
     m_scrollElasticityController.m_origVelocity = FloatSize();
 
     m_snapRubberBandTimer.startRepeating(1.0/60.0);
+    m_scrollElasticityController.m_snapRubberbandTimerIsActive = true;
 }
 
 static inline float roundTowardZero(float num)
@@ -1146,11 +1147,13 @@ void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*)
             m_scrollElasticityController.m_startStretch = m_scrollableArea->overhangAmount();
             if (m_scrollElasticityController.m_startStretch == FloatSize()) {    
                 m_snapRubberBandTimer.stop();
+
                 m_scrollElasticityController.m_stretchScrollForce = FloatSize();
                 m_scrollElasticityController.m_startTime = 0;
                 m_scrollElasticityController.m_startStretch = FloatSize();
                 m_scrollElasticityController.m_origOrigin = FloatPoint();
                 m_scrollElasticityController.m_origVelocity = FloatSize();
+                m_scrollElasticityController.m_snapRubberbandTimerIsActive = false;
 
                 return;
             }
@@ -1195,12 +1198,13 @@ void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*)
             m_scrollableArea->didCompleteRubberBand(roundedIntSize(m_scrollElasticityController.m_startStretch));
 
             m_snapRubberBandTimer.stop();
+
             m_scrollElasticityController.m_stretchScrollForce = FloatSize();
-            
             m_scrollElasticityController.m_startTime = 0;
             m_scrollElasticityController.m_startStretch = FloatSize();
             m_scrollElasticityController.m_origOrigin = FloatPoint();
             m_scrollElasticityController.m_origVelocity = FloatSize();
+            m_scrollElasticityController.m_snapRubberbandTimerIsActive = false;
         }
     } else {
         m_scrollElasticityController.m_startTime = [NSDate timeIntervalSinceReferenceDate];
index bc773ac..73b343b 100644 (file)
@@ -70,6 +70,8 @@ public:
     FloatSize m_startStretch;
     FloatPoint m_origOrigin;
     FloatSize m_origVelocity;
+
+    bool m_snapRubberbandTimerIsActive;
 };
 
 } // namespace WebCore
index 460e16c..607087e 100644 (file)
@@ -41,6 +41,7 @@ ScrollElasticityController::ScrollElasticityController(ScrollElasticityControlle
     , m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin(false)
     , m_lastMomentumScrollTimestamp(0)
     , m_startTime(0)
+    , m_snapRubberbandTimerIsActive(false)
 {
 }