Title: [96663] trunk/Source/WebCore
Revision
96663
Author
ander...@apple.com
Date
2011-10-04 16:48:39 -0700 (Tue, 04 Oct 2011)

Log Message

Move code into ScrollElasticityController::beginScrollGesture()
https://bugs.webkit.org/show_bug.cgi?id=69383

Reviewed by John Sullivan.

* platform/mac/ScrollAnimatorMac.h:
Add new ScrollElasticityControllerClient member functions.

* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::isHorizontalScrollerPinnedToMinimumPosition):
(WebCore::ScrollAnimatorMac::isHorizontalScrollerPinnedToMaximumPosition):
(WebCore::ScrollAnimatorMac::stretchAmount):
(WebCore::ScrollAnimatorMac::startSnapRubberbandTimer):
(WebCore::ScrollAnimatorMac::stopSnapRubberbandTimer):
Implement the new ScrollElasticityControllerClient member functions.

(WebCore::ScrollAnimatorMac::beginScrollGesture):
Move code into ScrollElasticityController::beginScrollGesture and call it directly.

* platform/mac/ScrollElasticityController.h:
Add new ScrollElasticityControllerClient member functions.

* platform/mac/ScrollElasticityController.mm:
(WebCore::reboundDeltaForElasticDelta):
(WebCore::ScrollElasticityController::beginScrollGesture):
Set up the scroll gesture state.

(WebCore::ScrollElasticityController::stopSnapRubberbandTimer):
New helper function.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (96662 => 96663)


--- trunk/Source/WebCore/ChangeLog	2011-10-04 23:34:56 UTC (rev 96662)
+++ trunk/Source/WebCore/ChangeLog	2011-10-04 23:48:39 UTC (rev 96663)
@@ -1,3 +1,35 @@
+2011-10-04  Anders Carlsson  <ander...@apple.com>
+
+        Move code into ScrollElasticityController::beginScrollGesture()
+        https://bugs.webkit.org/show_bug.cgi?id=69383
+
+        Reviewed by John Sullivan.
+
+        * platform/mac/ScrollAnimatorMac.h:
+        Add new ScrollElasticityControllerClient member functions.
+
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::isHorizontalScrollerPinnedToMinimumPosition):
+        (WebCore::ScrollAnimatorMac::isHorizontalScrollerPinnedToMaximumPosition):
+        (WebCore::ScrollAnimatorMac::stretchAmount):
+        (WebCore::ScrollAnimatorMac::startSnapRubberbandTimer):
+        (WebCore::ScrollAnimatorMac::stopSnapRubberbandTimer):
+        Implement the new ScrollElasticityControllerClient member functions.
+
+        (WebCore::ScrollAnimatorMac::beginScrollGesture):
+        Move code into ScrollElasticityController::beginScrollGesture and call it directly.
+
+        * platform/mac/ScrollElasticityController.h:
+        Add new ScrollElasticityControllerClient member functions.
+
+        * platform/mac/ScrollElasticityController.mm:
+        (WebCore::reboundDeltaForElasticDelta):
+        (WebCore::ScrollElasticityController::beginScrollGesture):
+        Set up the scroll gesture state.
+
+        (WebCore::ScrollElasticityController::stopSnapRubberbandTimer):
+        New helper function.
+
 2011-10-04  Scott Graham  <scot...@chromium.org>
 
         Add GAMEPAD feature flag

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (96662 => 96663)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2011-10-04 23:34:56 UTC (rev 96662)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2011-10-04 23:48:39 UTC (rev 96663)
@@ -138,6 +138,13 @@
     FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const;
 
 #if ENABLE(RUBBER_BANDING)
+    /// ScrollElasticityControllerClient member functions.
+    virtual bool isHorizontalScrollerPinnedToMinimumPosition() OVERRIDE;
+    virtual bool isHorizontalScrollerPinnedToMaximumPosition() OVERRIDE;
+    virtual IntSize stretchAmount() OVERRIDE;
+    virtual void startSnapRubberbandTimer() OVERRIDE;
+    virtual void stopSnapRubberbandTimer() OVERRIDE;
+
     bool allowsVerticalStretching() const;
     bool allowsHorizontalStretching() const;
     bool pinnedInDirection(float deltaX, float deltaY);

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (96662 => 96663)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2011-10-04 23:34:56 UTC (rev 96662)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2011-10-04 23:48:39 UTC (rev 96663)
@@ -882,6 +882,31 @@
     return false;
 }
 
+bool ScrollAnimatorMac::isHorizontalScrollerPinnedToMinimumPosition()
+{
+    return m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition();
+}
+
+bool ScrollAnimatorMac::isHorizontalScrollerPinnedToMaximumPosition()
+{
+    return m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition();
+}
+
+IntSize ScrollAnimatorMac::stretchAmount()
+{
+    return m_scrollableArea->overhangAmount();
+}
+
+void ScrollAnimatorMac::startSnapRubberbandTimer()
+{
+    m_snapRubberBandTimer.startRepeating(1.0 / 60.0);
+}
+
+void ScrollAnimatorMac::stopSnapRubberbandTimer()
+{
+    m_snapRubberBandTimer.stop();
+}
+
 bool ScrollAnimatorMac::allowsVerticalStretching() const
 {
     switch (m_scrollableArea->verticalScrollElasticity()) {
@@ -1075,26 +1100,9 @@
 void ScrollAnimatorMac::beginScrollGesture()
 {
     didBeginScrollGesture();
-
     m_haveScrolledSincePageLoad = true;
-    m_scrollElasticityController.m_inScrollGesture = true;
-    m_scrollElasticityController.m_momentumScrollInProgress = false;
-    m_scrollElasticityController.m_ignoreMomentumScrolls = false;
-    m_scrollElasticityController.m_lastMomentumScrollTimestamp = 0;
-    m_scrollElasticityController.m_momentumVelocity = FloatSize();
-    m_scrollElasticityController.m_scrollerInitiallyPinnedOnLeft = m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition();
-    m_scrollElasticityController.m_scrollerInitiallyPinnedOnRight = m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition();
-    m_scrollElasticityController.m_cumulativeHorizontalScroll = 0;
-    m_scrollElasticityController.m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = false;
-    
-    IntSize stretchAmount = m_scrollableArea->overhangAmount();
-    m_scrollElasticityController.m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
-    m_scrollElasticityController.m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(stretchAmount.height()));
 
-    m_scrollElasticityController.m_overflowScrollDelta = FloatSize();
-    
-    m_snapRubberBandTimer.stop();
-    m_scrollElasticityController.m_snapRubberbandTimerIsActive = false;
+    m_scrollElasticityController.beginScrollGesture();
 }
 
 void ScrollAnimatorMac::endScrollGesture()

Modified: trunk/Source/WebCore/platform/mac/ScrollElasticityController.h (96662 => 96663)


--- trunk/Source/WebCore/platform/mac/ScrollElasticityController.h	2011-10-04 23:34:56 UTC (rev 96662)
+++ trunk/Source/WebCore/platform/mac/ScrollElasticityController.h	2011-10-04 23:48:39 UTC (rev 96663)
@@ -35,8 +35,17 @@
 namespace WebCore {
 
 class ScrollElasticityControllerClient {
+protected:
+    virtual ~ScrollElasticityControllerClient() { } 
+
 public:
-    virtual ~ScrollElasticityControllerClient() { } 
+    virtual bool isHorizontalScrollerPinnedToMinimumPosition() = 0;
+    virtual bool isHorizontalScrollerPinnedToMaximumPosition() = 0;
+
+    virtual IntSize stretchAmount() = 0;
+
+    virtual void startSnapRubberbandTimer() = 0;
+    virtual void stopSnapRubberbandTimer() = 0;
 };
 
 class ScrollElasticityController {
@@ -45,9 +54,13 @@
 public:
     explicit ScrollElasticityController(ScrollElasticityControllerClient*);
 
+    void beginScrollGesture();
+
 private:
     ScrollElasticityControllerClient* m_client;
 
+    void stopSnapRubberbandTimer();
+
     // FIXME: These member variables should be private. They are currently public as a stop-gap measure, while
     // the rubber-band related code from ScrollAnimatorMac is being moved over.
 public:

Modified: trunk/Source/WebCore/platform/mac/ScrollElasticityController.mm (96662 => 96663)


--- trunk/Source/WebCore/platform/mac/ScrollElasticityController.mm	2011-10-04 23:34:56 UTC (rev 96662)
+++ trunk/Source/WebCore/platform/mac/ScrollElasticityController.mm	2011-10-04 23:48:39 UTC (rev 96663)
@@ -30,6 +30,13 @@
 
 namespace WebCore {
 
+static const float rubberbandStiffness = 20;
+
+static float reboundDeltaForElasticDelta(float delta)
+{
+    return delta * rubberbandStiffness;
+}
+
 ScrollElasticityController::ScrollElasticityController(ScrollElasticityControllerClient* client)
     : m_client(client)
     , m_inScrollGesture(false)
@@ -45,6 +52,33 @@
 {
 }
 
+void ScrollElasticityController::beginScrollGesture()
+{
+    m_inScrollGesture = true;
+    m_momentumScrollInProgress = false;
+    m_ignoreMomentumScrolls = false;
+    m_lastMomentumScrollTimestamp = 0;
+    m_momentumVelocity = FloatSize();
+    m_scrollerInitiallyPinnedOnLeft = m_client->isHorizontalScrollerPinnedToMinimumPosition();
+    m_scrollerInitiallyPinnedOnRight = m_client->isHorizontalScrollerPinnedToMaximumPosition();
+    m_cumulativeHorizontalScroll = 0;
+    m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = false;
+    
+    IntSize stretchAmount = m_client->stretchAmount();
+    m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
+    m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(stretchAmount.height()));
+    
+    m_overflowScrollDelta = FloatSize();
+
+    stopSnapRubberbandTimer();
+}
+
+void ScrollElasticityController::stopSnapRubberbandTimer()
+{
+    m_client->stopSnapRubberbandTimer();
+    m_snapRubberbandTimerIsActive = false;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(RUBBER_BANDING)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to