Title: [106051] trunk/Source/WebCore
Revision
106051
Author
[email protected]
Date
2012-01-26 15:06:01 -0800 (Thu, 26 Jan 2012)

Log Message

Move horizontal rubber-band checks to ScrollElasticityController::handleWheelEvent
https://bugs.webkit.org/show_bug.cgi?id=77147

Reviewed by Adam Roben.

* platform/mac/ScrollAnimatorMac.h:
(ScrollAnimatorMac):
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::handleWheelEvent):
Always call ScrollElasticityController::handleWheelEvent, and only call didBeginScrollGesture and
didEndScrollGesture if the event was actually handled.

(WebCore::ScrollAnimatorMac::shouldRubberBandInDirection):
Implement this.

* platform/mac/ScrollElasticityController.h:
* platform/mac/ScrollElasticityController.mm:
(WebCore::ScrollElasticityController::handleWheelEvent):
Check if we should rubber-band and return false if we shouldn't.

(WebCore::ScrollElasticityController::shouldRubberBandInHorizontalDirection):
Ask the client if we should rubber-band.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106050 => 106051)


--- trunk/Source/WebCore/ChangeLog	2012-01-26 22:58:21 UTC (rev 106050)
+++ trunk/Source/WebCore/ChangeLog	2012-01-26 23:06:01 UTC (rev 106051)
@@ -1,3 +1,28 @@
+2012-01-26  Anders Carlsson  <[email protected]>
+
+        Move horizontal rubber-band checks to ScrollElasticityController::handleWheelEvent
+        https://bugs.webkit.org/show_bug.cgi?id=77147
+
+        Reviewed by Adam Roben.
+
+        * platform/mac/ScrollAnimatorMac.h:
+        (ScrollAnimatorMac):
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::handleWheelEvent):
+        Always call ScrollElasticityController::handleWheelEvent, and only call didBeginScrollGesture and
+        didEndScrollGesture if the event was actually handled.
+
+        (WebCore::ScrollAnimatorMac::shouldRubberBandInDirection):
+        Implement this.
+
+        * platform/mac/ScrollElasticityController.h:
+        * platform/mac/ScrollElasticityController.mm:
+        (WebCore::ScrollElasticityController::handleWheelEvent):
+        Check if we should rubber-band and return false if we shouldn't.
+
+        (WebCore::ScrollElasticityController::shouldRubberBandInHorizontalDirection):
+        Ask the client if we should rubber-band.
+
 2012-01-19  James Robinson  <[email protected]>
 
         [chromium] Remove setLayerTreeHost nonsense on lost context

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (106050 => 106051)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2012-01-26 22:58:21 UTC (rev 106050)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2012-01-26 23:06:01 UTC (rev 106051)
@@ -125,6 +125,7 @@
     virtual bool pinnedInDirection(const FloatSize&) OVERRIDE;
     virtual bool canScrollHorizontally() OVERRIDE;
     virtual bool canScrollVertically() OVERRIDE;
+    virtual bool shouldRubberBandInDirection(ScrollDirection) OVERRIDE;
     virtual WebCore::IntPoint absoluteScrollPosition() OVERRIDE;
     virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) OVERRIDE;
     virtual void immediateScrollBy(const FloatSize&) OVERRIDE;

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (106050 => 106051)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2012-01-26 22:58:21 UTC (rev 106050)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2012-01-26 23:06:01 UTC (rev 106051)
@@ -888,17 +888,6 @@
 }
 
 #if ENABLE(RUBBER_BANDING)
-
-static bool shouldRubberBandInHorizontalDirection(const PlatformWheelEvent& wheelEvent, ScrollableArea* scrollableArea)
-{
-    if (wheelEvent.deltaX() > 0)
-        return scrollableArea->shouldRubberBandInDirection(ScrollLeft);
-    if (wheelEvent.deltaX() < 0)
-        return scrollableArea->shouldRubberBandInDirection(ScrollRight);
-
-    return true;
-}
-
 bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 {
     m_haveScrolledSincePageLoad = true;
@@ -918,16 +907,16 @@
             return ScrollAnimator::handleWheelEvent(wheelEvent);
     }
 
-    if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) {
-        if (pinnedInDirection(-wheelEvent.deltaX(), 0) &&
-            !shouldRubberBandInHorizontalDirection(wheelEvent, m_scrollableArea))
-            return false;
+    bool didHandleEvent = m_scrollElasticityController.handleWheelEvent(wheelEvent);
 
-        didBeginScrollGesture();
-    } else if (wheelEvent.phase() == PlatformWheelEventPhaseEnded)
-        didEndScrollGesture();
+    if (didHandleEvent) {
+        if (wheelEvent.phase() == PlatformWheelEventPhaseBegan)
+            didBeginScrollGesture();
+        else if (wheelEvent.phase() == PlatformWheelEventPhaseEnded)
+            didEndScrollGesture();
+    }
 
-    return m_scrollElasticityController.handleWheelEvent(wheelEvent);
+    return didHandleEvent;
 }
 
 bool ScrollAnimatorMac::pinnedInDirection(float deltaX, float deltaY)
@@ -1018,6 +1007,11 @@
     return scrollbar->enabled();
 }
 
+bool ScrollAnimatorMac::shouldRubberBandInDirection(ScrollDirection direction)
+{
+    return m_scrollableArea->shouldRubberBandInDirection(direction);
+}
+
 IntPoint ScrollAnimatorMac::absoluteScrollPosition()
 {
     return m_scrollableArea->visibleContentRect().location() + m_scrollableArea->scrollOrigin();

Modified: trunk/Source/WebCore/platform/mac/ScrollElasticityController.h (106050 => 106051)


--- trunk/Source/WebCore/platform/mac/ScrollElasticityController.h	2012-01-26 22:58:21 UTC (rev 106050)
+++ trunk/Source/WebCore/platform/mac/ScrollElasticityController.h	2012-01-26 23:06:01 UTC (rev 106051)
@@ -30,6 +30,7 @@
 
 #include "FloatPoint.h"
 #include "FloatSize.h"
+#include "ScrollTypes.h"
 #include <wtf/Noncopyable.h>
 
 namespace WebCore {
@@ -47,6 +48,7 @@
     virtual bool pinnedInDirection(const FloatSize&) = 0;
     virtual bool canScrollHorizontally() = 0;
     virtual bool canScrollVertically() = 0;
+    virtual bool shouldRubberBandInDirection(ScrollDirection) = 0;
 
     // Return the absolute scroll position, not relative to the scroll origin.
     virtual WebCore::IntPoint absoluteScrollPosition() = 0;
@@ -70,6 +72,8 @@
     void stopSnapRubberbandTimer();
     void snapRubberBand();
 
+    bool shouldRubberBandInHorizontalDirection(const PlatformWheelEvent&);
+
     ScrollElasticityControllerClient* m_client;
 
     bool m_inScrollGesture;

Modified: trunk/Source/WebCore/platform/mac/ScrollElasticityController.mm (106050 => 106051)


--- trunk/Source/WebCore/platform/mac/ScrollElasticityController.mm	2012-01-26 22:58:21 UTC (rev 106050)
+++ trunk/Source/WebCore/platform/mac/ScrollElasticityController.mm	2012-01-26 23:06:01 UTC (rev 106051)
@@ -117,16 +117,12 @@
 
 bool ScrollElasticityController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 {
-    bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone);
-    if (m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberbandTimerIsActive)) {
-        if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) {
-            m_ignoreMomentumScrolls = false;
-            return true;
-        }
-        return false;
-    }
+    if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) {
+        // First, check if we should rubber-band at all.
+        if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0)) &&
+            !shouldRubberBandInHorizontalDirection(wheelEvent))
+            return false;
 
-    if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) {
         m_inScrollGesture = true;
         m_momentumScrollInProgress = false;
         m_ignoreMomentumScrolls = false;
@@ -148,6 +144,15 @@
         return true;
     }
 
+    bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone);
+    if (m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberbandTimerIsActive)) {
+        if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) {
+            m_ignoreMomentumScrolls = false;
+            return true;
+        }
+        return false;
+    }
+
     float deltaX = m_overflowScrollDelta.width();
     float deltaY = m_overflowScrollDelta.height();
 
@@ -388,6 +393,16 @@
     m_snapRubberbandTimerIsActive = true;
 }
 
+bool ScrollElasticityController::shouldRubberBandInHorizontalDirection(const PlatformWheelEvent& wheelEvent)
+{
+    if (wheelEvent.deltaX() > 0)
+        return m_client->shouldRubberBandInDirection(ScrollLeft);
+    if (wheelEvent.deltaX() < 0)
+        return m_client->shouldRubberBandInDirection(ScrollRight);
+
+    return true;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(RUBBER_BANDING)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to