Move some member variables out of ScrollElasticityController
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Dec 2011 21:08:42 +0000 (21:08 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Dec 2011 21:08:42 +0000 (21:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=75115

Reviewed by Adam Roben.

Move a couple of member variables that aren't related to rubberbanding out from
ScrollElasticityController and back into ScrollAnimatorMac and remove now unneeded
ScrollElasticityControllerClient member functions as well.

* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::ScrollAnimatorMac):
(WebCore::ScrollAnimatorMac::handleWheelEvent):
(WebCore::ScrollAnimatorMac::beginScrollGesture):
* platform/mac/ScrollElasticityController.h:
* platform/mac/ScrollElasticityController.mm:
(WebCore::ScrollElasticityController::ScrollElasticityController):
(WebCore::ScrollElasticityController::beginScrollGesture):

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

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

index 0c17fe4..c4193b3 100644 (file)
@@ -1,3 +1,24 @@
+2011-12-22  Anders Carlsson  <andersca@apple.com>
+
+        Move some member variables out of ScrollElasticityController
+        https://bugs.webkit.org/show_bug.cgi?id=75115
+
+        Reviewed by Adam Roben.
+
+        Move a couple of member variables that aren't related to rubberbanding out from
+        ScrollElasticityController and back into ScrollAnimatorMac and remove now unneeded
+        ScrollElasticityControllerClient member functions as well.
+
+        * platform/mac/ScrollAnimatorMac.h:
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::ScrollAnimatorMac):
+        (WebCore::ScrollAnimatorMac::handleWheelEvent):
+        (WebCore::ScrollAnimatorMac::beginScrollGesture):
+        * platform/mac/ScrollElasticityController.h:
+        * platform/mac/ScrollElasticityController.mm:
+        (WebCore::ScrollElasticityController::ScrollElasticityController):
+        (WebCore::ScrollElasticityController::beginScrollGesture):
+
 2011-12-22  Balazs Kelemen  <kbalazs@webkit.org>
 
         Fix debug build with assertions disabled
index 9cdc0d2..914a949 100644 (file)
@@ -133,8 +133,6 @@ private:
 
 #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;
@@ -150,6 +148,11 @@ private:
 
     ScrollElasticityController m_scrollElasticityController;
     Timer<ScrollAnimatorMac> m_snapRubberBandTimer;
+
+    bool m_scrollerInitiallyPinnedOnLeft;
+    bool m_scrollerInitiallyPinnedOnRight;
+    int m_cumulativeHorizontalScroll;
+    bool m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin;
 #endif
 
     bool m_haveScrolledSincePageLoad;
index 107d783..e843a8b 100644 (file)
@@ -586,6 +586,10 @@ ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea)
 #if ENABLE(RUBBER_BANDING)
     , m_scrollElasticityController(this)
     , m_snapRubberBandTimer(this, &ScrollAnimatorMac::snapRubberBandTimerFired)
+    , m_scrollerInitiallyPinnedOnLeft(false)
+    , m_scrollerInitiallyPinnedOnRight(false)
+    , m_cumulativeHorizontalScroll(0)
+    , m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin(false)
 #endif
     , m_haveScrolledSincePageLoad(false)
     , m_needsScrollerStyleUpdate(false)
@@ -990,23 +994,23 @@ bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
             // in the opposite direction of the pin location, then we switch the
             // boolean, and rubber band. That is, if we were pinned to the left,
             // and we ended up scrolling to the right, we rubber band.
-            m_scrollElasticityController.m_cumulativeHorizontalScroll += wheelEvent.deltaX();
-            if (m_scrollElasticityController.m_scrollerInitiallyPinnedOnLeft && m_scrollElasticityController.m_cumulativeHorizontalScroll < 0)
-                m_scrollElasticityController.m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = true;
-            if (m_scrollElasticityController.m_scrollerInitiallyPinnedOnRight && m_scrollElasticityController.m_cumulativeHorizontalScroll > 0)
-                m_scrollElasticityController.m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = true;
+            m_cumulativeHorizontalScroll += wheelEvent.deltaX();
+            if (m_scrollerInitiallyPinnedOnLeft && m_cumulativeHorizontalScroll < 0)
+                m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = true;
+            if (m_scrollerInitiallyPinnedOnRight && m_cumulativeHorizontalScroll > 0)
+                m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = true;
         }
 
         // After a gesture begins, we go through:
         // 1+ PlatformWheelEventPhaseNone
         // 0+ PlatformWheelEventPhaseChanged
         // 1 PlatformWheelEventPhaseEnded if there was at least one changed event
-        if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseNone && !m_scrollElasticityController.m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin) {
+        if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseNone && !m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin) {
             if ((isScrollingLeftAndShouldNotRubberBand(wheelEvent, m_scrollableArea) &&
-                m_scrollElasticityController.m_scrollerInitiallyPinnedOnLeft &&
+                m_scrollerInitiallyPinnedOnLeft &&
                 m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition()) ||
                 (isScrollingRightAndShouldNotRubberBand(wheelEvent, m_scrollableArea) &&
-                m_scrollElasticityController.m_scrollerInitiallyPinnedOnRight &&
+                m_scrollerInitiallyPinnedOnRight &&
                 m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition())) {
                 return ScrollAnimator::handleWheelEvent(wheelEvent);
             }
@@ -1060,16 +1064,6 @@ bool ScrollAnimatorMac::pinnedInDirection(float deltaX, float deltaY)
     return false;
 }
 
-bool ScrollAnimatorMac::isHorizontalScrollerPinnedToMinimumPosition()
-{
-    return m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition();
-}
-
-bool ScrollAnimatorMac::isHorizontalScrollerPinnedToMaximumPosition()
-{
-    return m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition();
-}
-
 IntSize ScrollAnimatorMac::stretchAmount()
 {
     return m_scrollableArea->overhangAmount();
@@ -1278,7 +1272,12 @@ void ScrollAnimatorMac::smoothScrollWithEvent(const PlatformWheelEvent& wheelEve
 void ScrollAnimatorMac::beginScrollGesture()
 {
     didBeginScrollGesture();
+
+    m_scrollerInitiallyPinnedOnLeft = m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition();
+    m_scrollerInitiallyPinnedOnRight = m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition();
     m_haveScrolledSincePageLoad = true;
+    m_cumulativeHorizontalScroll = 0;
+    m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = false;
 
     m_scrollElasticityController.beginScrollGesture();
 }
index 3c5692c..486370b 100644 (file)
@@ -39,9 +39,6 @@ protected:
     virtual ~ScrollElasticityControllerClient() { } 
 
 public:
-    virtual bool isHorizontalScrollerPinnedToMinimumPosition() = 0;
-    virtual bool isHorizontalScrollerPinnedToMaximumPosition() = 0;
-
     virtual IntSize stretchAmount() = 0;
 
     virtual void startSnapRubberbandTimer() = 0;
@@ -67,12 +64,7 @@ public:
     bool m_inScrollGesture;
     bool m_momentumScrollInProgress;
     bool m_ignoreMomentumScrolls;
-    bool m_scrollerInitiallyPinnedOnLeft;
-    bool m_scrollerInitiallyPinnedOnRight;
     
-    int m_cumulativeHorizontalScroll;
-    bool m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin;
-
     CFTimeInterval m_lastMomentumScrollTimestamp;
     FloatSize m_overflowScrollDelta;
     FloatSize m_stretchScrollForce;
index ff66f6b..fa84133 100644 (file)
@@ -42,10 +42,6 @@ ScrollElasticityController::ScrollElasticityController(ScrollElasticityControlle
     , m_inScrollGesture(false)
     , m_momentumScrollInProgress(false)
     , m_ignoreMomentumScrolls(false)
-    , m_scrollerInitiallyPinnedOnLeft(false)
-    , m_scrollerInitiallyPinnedOnRight(false)
-    , m_cumulativeHorizontalScroll(0)
-    , m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin(false)
     , m_lastMomentumScrollTimestamp(0)
     , m_startTime(0)
     , m_snapRubberbandTimerIsActive(false)
@@ -59,10 +55,6 @@ void ScrollElasticityController::beginScrollGesture()
     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()));