Simplify checking of whether we should rubberband horizontally
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2012 22:33:49 +0000 (22:33 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2012 22:33:49 +0000 (22:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77141

Reviewed by Adam Roben.

Have a single check for horizontal rubber-banding in both directions. This is in preparation
for moving this code into ScrollElasticityController.

* platform/mac/ScrollAnimatorMac.mm:
(WebCore::shouldRubberBandInHorizontalDirection):
(WebCore::ScrollAnimatorMac::handleWheelEvent):

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

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

index 9369488..3169ec0 100644 (file)
@@ -1,3 +1,17 @@
+2012-01-26  Anders Carlsson  <andersca@apple.com>
+
+        Simplify checking of whether we should rubberband horizontally
+        https://bugs.webkit.org/show_bug.cgi?id=77141
+
+        Reviewed by Adam Roben.
+
+        Have a single check for horizontal rubber-banding in both directions. This is in preparation
+        for moving this code into ScrollElasticityController.
+
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::shouldRubberBandInHorizontalDirection):
+        (WebCore::ScrollAnimatorMac::handleWheelEvent):
+
 2012-01-26  Scott Graham  <scottmg@chomium.org>
 
         Fix include path in gyp file for V8InternalSettings.h
index 973f570..c0fa822 100644 (file)
@@ -889,14 +889,14 @@ void ScrollAnimatorMac::cancelAnimations()
 
 #if ENABLE(RUBBER_BANDING)
 
-static inline bool isScrollingLeftAndShouldNotRubberBand(const PlatformWheelEvent& wheelEvent, ScrollableArea* scrollableArea)
+static bool shouldRubberBandInHorizontalDirection(const PlatformWheelEvent& wheelEvent, ScrollableArea* scrollableArea)
 {
-    return wheelEvent.deltaX() > 0 && !scrollableArea->shouldRubberBandInDirection(ScrollLeft);
-}
+    if (wheelEvent.deltaX() > 0)
+        return scrollableArea->shouldRubberBandInDirection(ScrollLeft);
+    if (wheelEvent.deltaX() < 0)
+        return scrollableArea->shouldRubberBandInDirection(ScrollRight);
 
-static inline bool isScrollingRightAndShouldNotRubberBand(const PlatformWheelEvent& wheelEvent, ScrollableArea* scrollableArea)
-{
-    return wheelEvent.deltaX() < 0 && !scrollableArea->shouldRubberBandInDirection(ScrollRight);
+    return true;
 }
 
 bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
@@ -919,12 +919,8 @@ bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
     }
 
     if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) {
-        if (m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition() &&
-            isScrollingLeftAndShouldNotRubberBand(wheelEvent, m_scrollableArea))
-            return false;
-
-        if (m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition() &&
-            isScrollingRightAndShouldNotRubberBand(wheelEvent, m_scrollableArea))
+        if (pinnedInDirection(-wheelEvent.deltaX(), 0) &&
+            !shouldRubberBandInHorizontalDirection(wheelEvent, m_scrollableArea))
             return false;
 
         didBeginScrollGesture();