Chromium Code Reviews| Index: Source/platform/mac/ScrollElasticityController.mm |
| diff --git a/Source/platform/mac/ScrollElasticityController.mm b/Source/platform/mac/ScrollElasticityController.mm |
| index 0ab305b6ab91823e3ff09e4e30feebf082a77ac4..65a9ea82db70f24657cf5dd78b7f19f7179b6a95 100644 |
| --- a/Source/platform/mac/ScrollElasticityController.mm |
| +++ b/Source/platform/mac/ScrollElasticityController.mm |
| @@ -110,9 +110,7 @@ ScrollElasticityController::ScrollElasticityController(ScrollElasticityControlle |
| bool ScrollElasticityController::handleWheelEvent(const PlatformWheelEvent& wheelEvent) |
| { |
| if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) { |
| - // First, check if we should rubber-band at all. |
| - if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0)) && |
| - !shouldRubberBandInHorizontalDirection(wheelEvent)) |
| + if (!shouldStartRubberBanding(wheelEvent)) |
| return false; |
| m_inScrollGesture = true; |
| @@ -185,6 +183,9 @@ bool ScrollElasticityController::handleWheelEvent(const PlatformWheelEvent& whee |
| // If we are starting momentum scrolling then do some setup. |
| if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhaseBegan || momentumPhase == PlatformWheelEventPhaseChanged)) { |
| + if (!shouldStartRubberBanding(wheelEvent)) |
| + return false; |
| + |
| m_momentumScrollInProgress = true; |
| // Start the snap rubber band timer if it's not running. This is needed to |
| // snap back from the over scroll caused by momentum events. |
| @@ -413,12 +414,22 @@ void ScrollElasticityController::snapRubberBand() |
| m_snapRubberbandTimerIsActive = true; |
| } |
| -bool ScrollElasticityController::shouldRubberBandInHorizontalDirection(const PlatformWheelEvent& wheelEvent) |
| +bool ScrollElasticityController::shouldStartRubberBanding(const PlatformWheelEvent& wheelEvent) |
| { |
| - if (wheelEvent.deltaX() > 0) |
| - return m_client->shouldRubberBandInDirection(ScrollLeft); |
| - if (wheelEvent.deltaX() < 0) |
| - return m_client->shouldRubberBandInDirection(ScrollRight); |
| + if (wheelEvent.deltaX() > 0) { |
| + if (!wheelEvent.canRubberbandLeft()) |
| + return false; |
| + if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0)) && !m_client->shouldRubberBandInDirection(ScrollLeft)) |
|
Alexei Svitkine (slow)
2014/03/20 18:38:09
Could the pinnedInDirection() check be made inside
erikchen
2014/03/24 22:12:04
I've reworked the logic of this method to be much
|
| + return false; |
| + return true; |
| + } |
| + if (wheelEvent.deltaX() < 0) { |
| + if (!wheelEvent.canRubberbandRight()) |
| + return false; |
| + if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0)) && !m_client->shouldRubberBandInDirection(ScrollRight)) |
| + return false; |
| + return true; |
| + } |
| return true; |
| } |