Title: [104846] trunk/Source/WebCore
Revision
104846
Author
ander...@apple.com
Date
2012-01-12 12:25:19 -0800 (Thu, 12 Jan 2012)

Log Message

Move snapRubberBand to ScrollElasticityController
https://bugs.webkit.org/show_bug.cgi?id=76200

Reviewed by Andreas Kling.

* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::smoothScrollWithEvent):
(WebCore::ScrollAnimatorMac::endScrollGesture):
* platform/mac/ScrollElasticityController.h:
* platform/mac/ScrollElasticityController.mm:
(systemUptime):
(WebCore::ScrollElasticityController::snapRubberBand):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (104845 => 104846)


--- trunk/Source/WebCore/ChangeLog	2012-01-12 20:21:51 UTC (rev 104845)
+++ trunk/Source/WebCore/ChangeLog	2012-01-12 20:25:19 UTC (rev 104846)
@@ -1,3 +1,19 @@
+2012-01-12  Anders Carlsson  <ander...@apple.com>
+
+        Move snapRubberBand to ScrollElasticityController
+        https://bugs.webkit.org/show_bug.cgi?id=76200
+
+        Reviewed by Andreas Kling.
+
+        * platform/mac/ScrollAnimatorMac.h:
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::smoothScrollWithEvent):
+        (WebCore::ScrollAnimatorMac::endScrollGesture):
+        * platform/mac/ScrollElasticityController.h:
+        * platform/mac/ScrollElasticityController.mm:
+        (systemUptime):
+        (WebCore::ScrollElasticityController::snapRubberBand):
+
 2012-01-12  Antti Koivisto  <an...@apple.com>
 
         REGRESSION(r104060): Setting user stylesheet may leave CSSStyleSelector with stale rule pointers 

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (104845 => 104846)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2012-01-12 20:21:51 UTC (rev 104845)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2012-01-12 20:25:19 UTC (rev 104846)
@@ -139,7 +139,6 @@
     bool allowsVerticalStretching() const;
     bool allowsHorizontalStretching() const;
     bool pinnedInDirection(float deltaX, float deltaY);
-    void snapRubberBand();
     void snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*);
     bool smoothScrollWithEvent(const PlatformWheelEvent&);
     void beginScrollGesture();

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (104845 => 104846)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2012-01-12 20:21:51 UTC (rev 104845)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2012-01-12 20:25:19 UTC (rev 104846)
@@ -40,20 +40,12 @@
 #include "ScrollbarTheme.h"
 #include "ScrollbarThemeMac.h"
 #include "WebCoreSystemInterface.h"
-#include <sys/time.h>
-#include <sys/sysctl.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/UnusedParam.h>
 
 using namespace WebCore;
 using namespace std;
 
-#ifdef BUILDING_ON_LEOPARD
-@interface NSProcessInfo (ScrollAnimatorMacExt)
-- (NSTimeInterval)systemUptime;
-@end
-#endif
-
 static bool supportsUIStateTransitionProgress()
 {
     // FIXME: This is temporary until all platforms that support ScrollbarPainter support this part of the API.
@@ -75,31 +67,6 @@
     return nil;
 }
 
-#if ENABLE(RUBBER_BANDING)
-static NSTimeInterval systemUptime()
-{
-    if ([[NSProcessInfo processInfo] respondsToSelector:@selector(systemUptime)])
-        return [[NSProcessInfo processInfo] systemUptime];
-
-    // Get how long system has been up. Found by looking getting "boottime" from the kernel.
-    static struct timeval boottime = {0, 0};
-    if (!boottime.tv_sec) {
-        int mib[2] = {CTL_KERN, KERN_BOOTTIME};
-        size_t size = sizeof(boottime);
-        if (-1 == sysctl(mib, 2, &boottime, &size, 0, 0))
-            boottime.tv_sec = 0;
-    }
-    struct timeval now;
-    if (boottime.tv_sec && -1 != gettimeofday(&now, 0)) {
-        struct timeval uptime;
-        timersub(&now, &boottime, &uptime);
-        NSTimeInterval result = uptime.tv_sec + (uptime.tv_usec / 1E+6);
-        return result;
-    }
-    return 0;
-}
-#endif
-
 @interface NSObject (ScrollAnimationHelperDetails)
 - (id)initWithDelegate:(id)delegate;
 - (void)_stopRun;
@@ -1256,7 +1223,7 @@
                 if ((pinnedInDirection(eventCoalescedDeltaX, eventCoalescedDeltaY) || (fabsf(eventCoalescedDeltaX) + fabsf(eventCoalescedDeltaY) <= 0)) && m_scrollElasticityController.m_lastMomentumScrollTimestamp) {
                     m_scrollElasticityController.m_ignoreMomentumScrolls = true;
                     m_scrollElasticityController.m_momentumScrollInProgress = false;
-                    snapRubberBand();
+                    m_scrollElasticityController.snapRubberBand();
                 }
             }
 
@@ -1295,29 +1262,9 @@
 {
     didEndScrollGesture();
 
-    snapRubberBand();
+    m_scrollElasticityController.snapRubberBand();
 }
 
-void ScrollAnimatorMac::snapRubberBand()
-{
-    CFTimeInterval timeDelta = systemUptime() - m_scrollElasticityController.m_lastMomentumScrollTimestamp;
-    if (m_scrollElasticityController.m_lastMomentumScrollTimestamp && timeDelta >= scrollVelocityZeroingTimeout)
-        m_scrollElasticityController.m_momentumVelocity = FloatSize();
-
-    m_scrollElasticityController.m_inScrollGesture = false;
-
-    if (m_scrollElasticityController.m_snapRubberbandTimerIsActive)
-        return;
-
-    m_scrollElasticityController.m_startTime = [NSDate timeIntervalSinceReferenceDate];
-    m_scrollElasticityController.m_startStretch = FloatSize();
-    m_scrollElasticityController.m_origOrigin = FloatPoint();
-    m_scrollElasticityController.m_origVelocity = FloatSize();
-
-    m_scrollElasticityController.m_client->startSnapRubberbandTimer();
-    m_scrollElasticityController.m_snapRubberbandTimerIsActive = true;
-}
-
 void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*)
 {
     m_scrollElasticityController.snapRubberBandTimerFired();

Modified: trunk/Source/WebCore/platform/mac/ScrollElasticityController.h (104845 => 104846)


--- trunk/Source/WebCore/platform/mac/ScrollElasticityController.h	2012-01-12 20:21:51 UTC (rev 104845)
+++ trunk/Source/WebCore/platform/mac/ScrollElasticityController.h	2012-01-12 20:25:19 UTC (rev 104846)
@@ -66,9 +66,11 @@
 private:
     void stopSnapRubberbandTimer();
 
-    // FIXME: These member variables should be private. They are currently public as a stop-gap measure, while
+    // FIXME: These members 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:
+    void snapRubberBand();
+
     ScrollElasticityControllerClient* m_client;
 
     bool m_inScrollGesture;

Modified: trunk/Source/WebCore/platform/mac/ScrollElasticityController.mm (104845 => 104846)


--- trunk/Source/WebCore/platform/mac/ScrollElasticityController.mm	2012-01-12 20:21:51 UTC (rev 104845)
+++ trunk/Source/WebCore/platform/mac/ScrollElasticityController.mm	2012-01-12 20:25:19 UTC (rev 104846)
@@ -26,10 +26,46 @@
 #include "config.h"
 #include "ScrollElasticityController.h"
 
+#include <sys/time.h>
+#include <sys/sysctl.h>
+
 #if ENABLE(RUBBER_BANDING)
 
+#ifdef BUILDING_ON_LEOPARD
+@interface NSProcessInfo (ScrollAnimatorMacExt)
+- (NSTimeInterval)systemUptime;
+@end
+#endif
+
+#if ENABLE(RUBBER_BANDING)
+static NSTimeInterval systemUptime()
+{
+    if ([[NSProcessInfo processInfo] respondsToSelector:@selector(systemUptime)])
+        return [[NSProcessInfo processInfo] systemUptime];
+
+    // Get how long system has been up. Found by looking getting "boottime" from the kernel.
+    static struct timeval boottime = {0, 0};
+    if (!boottime.tv_sec) {
+        int mib[2] = {CTL_KERN, KERN_BOOTTIME};
+        size_t size = sizeof(boottime);
+        if (-1 == sysctl(mib, 2, &boottime, &size, 0, 0))
+            boottime.tv_sec = 0;
+    }
+    struct timeval now;
+    if (boottime.tv_sec && -1 != gettimeofday(&now, 0)) {
+        struct timeval uptime;
+        timersub(&now, &boottime, &uptime);
+        NSTimeInterval result = uptime.tv_sec + (uptime.tv_usec / 1E+6);
+        return result;
+    }
+    return 0;
+}
+#endif
+
+
 namespace WebCore {
 
+static const float scrollVelocityZeroingTimeout = 0.10f;
 static const float rubberbandStiffness = 20;
 static const float rubberbandAmplitude = 0.31f;
 static const float rubberbandPeriod = 1.6f;
@@ -161,6 +197,26 @@
     m_snapRubberbandTimerIsActive = false;
 }
 
+void ScrollElasticityController::snapRubberBand()
+{
+    CFTimeInterval timeDelta = systemUptime() - m_lastMomentumScrollTimestamp;
+    if (m_lastMomentumScrollTimestamp && timeDelta >= scrollVelocityZeroingTimeout)
+        m_momentumVelocity = FloatSize();
+
+    m_inScrollGesture = false;
+
+    if (m_snapRubberbandTimerIsActive)
+        return;
+
+    m_startTime = [NSDate timeIntervalSinceReferenceDate];
+    m_startStretch = FloatSize();
+    m_origOrigin = FloatPoint();
+    m_origVelocity = FloatSize();
+
+    m_client->startSnapRubberbandTimer();
+    m_snapRubberbandTimerIsActive = true;
+}
+
 } // 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