OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_INPUT_SCROLL_ELASTICITY_CONTROLLER_IMPL_H_ |
| 6 #define CONTENT_RENDERER_INPUT_SCROLL_ELASTICITY_CONTROLLER_IMPL_H_ |
| 7 |
| 8 #include "cc/input/scroll_elasticity_controller.h" |
| 9 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 class InputScrollElasticityController |
| 14 : public cc::ScrollElasticityController { |
| 15 public: |
| 16 explicit InputScrollElasticityController(cc::ScrollElasticityControllerClien
t*); |
| 17 virtual ~InputScrollElasticityController(); |
| 18 |
| 19 // This method is responsible for both scrolling and rubber-banding. |
| 20 // |
| 21 // Events are passed by IPC from the embedder. Events on Mac are grouped |
| 22 // into "gestures". If this method returns 'true', then this object has |
| 23 // handled the event. It expects the embedder to continue to forward events |
| 24 // from the gesture. |
| 25 // |
| 26 // This method makes the assumption that there is only 1 input device being |
| 27 // used at a time. If the user simultaneously uses multiple input devices, |
| 28 // Cocoa does not correctly pass all the gestureBegin/End events. The state |
| 29 // of this class is guaranteed to become eventually consistent, once the |
| 30 // user stops using multiple input devices. |
| 31 bool handleWheelEvent(const blink::WebMouseWheelEvent&); |
| 32 |
| 33 // cc::ScrollElasticityController implementation: |
| 34 void WillShutdown() override; |
| 35 void Animate(base::TimeTicks time) override; |
| 36 |
| 37 private: |
| 38 |
| 39 void snapRubberBandTimerFired(); |
| 40 bool isRubberBandInProgress() const; |
| 41 |
| 42 void stopSnapRubberbandTimer(); |
| 43 void snapRubberBand(); |
| 44 |
| 45 // This method determines whether a given event should be handled. The |
| 46 // logic for control events of gestures (PhaseBegan, PhaseEnded) is handled |
| 47 // elsewhere. |
| 48 // |
| 49 // This class handles almost all wheel events. All of the following |
| 50 // conditions must be met for this class to ignore an event: |
| 51 // + No previous events in this gesture have caused any scrolling or rubber |
| 52 // banding. |
| 53 // + The event contains a horizontal component. |
| 54 // + The client's view is pinned in the horizontal direction of the event. |
| 55 // + The wheel event disallows rubber banding in the horizontal direction |
| 56 // of the event. |
| 57 bool shouldHandleEvent(const blink::WebMouseWheelEvent&); |
| 58 |
| 59 cc::ScrollElasticityControllerClient* m_client; |
| 60 |
| 61 // There is an active scroll gesture event. This parameter only gets set to |
| 62 // false after the rubber band has been snapped, and before a new gesture |
| 63 // has begun. A careful audit of the code may deprecate the need for this |
| 64 // parameter. |
| 65 bool m_inScrollGesture; |
| 66 // At least one event in the current gesture has been consumed and has |
| 67 // caused the view to scroll or rubber band. All future events in this |
| 68 // gesture will be consumed and overscrolls will cause rubberbanding. |
| 69 bool m_hasScrolled; |
| 70 bool m_momentumScrollInProgress; |
| 71 bool m_ignoreMomentumScrolls; |
| 72 |
| 73 base::Time m_lastMomentumScrollTimestamp; |
| 74 gfx::Vector2dF m_overflowScrollDelta; |
| 75 gfx::Vector2dF m_stretchScrollForce; |
| 76 gfx::Vector2dF m_momentumVelocity; |
| 77 |
| 78 // Rubber band state. |
| 79 base::Time m_startTime; |
| 80 gfx::Vector2dF m_startStretch; |
| 81 gfx::Vector2dF m_origOrigin; |
| 82 gfx::Vector2dF m_origVelocity; |
| 83 |
| 84 bool m_snapRubberbandTimerIsActive; |
| 85 }; |
| 86 |
| 87 } |
| 88 |
| 89 #endif // CONTENT_RENDERER_INPUT_SCROLL_ELASTICITY_CONTROLLER_IMPL_H_ |
OLD | NEW |