From 611a3f1c8b2d4c1d84c7e94c9acbd55f3c96fc0e Mon Sep 17 00:00:00 2001 From: "andersca@apple.com" Date: Thu, 26 Jan 2012 22:33:49 +0000 Subject: [PATCH] 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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106046 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 14 ++++++++++++++ Source/WebCore/platform/mac/ScrollAnimatorMac.mm | 20 ++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 9369488..3169ec0 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,17 @@ +2012-01-26 Anders Carlsson + + 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 Fix include path in gyp file for V8InternalSettings.h diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm index 973f570..c0fa822 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm @@ -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(); -- 2.7.4