Index: content/renderer/input/input_scroll_elasticity_controller.h |
diff --git a/content/renderer/input/input_scroll_elasticity_controller.h b/content/renderer/input/input_scroll_elasticity_controller.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..be16ce7e428db37c81d7a4fb40a0e26edb0287c7 |
--- /dev/null |
+++ b/content/renderer/input/input_scroll_elasticity_controller.h |
@@ -0,0 +1,89 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_RENDERER_INPUT_SCROLL_ELASTICITY_CONTROLLER_IMPL_H_ |
+#define CONTENT_RENDERER_INPUT_SCROLL_ELASTICITY_CONTROLLER_IMPL_H_ |
+ |
+#include "cc/input/scroll_elasticity_controller.h" |
+#include "third_party/WebKit/public/web/WebInputEvent.h" |
+ |
+namespace content { |
+ |
+class InputScrollElasticityController |
+ : public cc::ScrollElasticityController { |
+public: |
+ explicit InputScrollElasticityController(cc::ScrollElasticityControllerClient*); |
+ virtual ~InputScrollElasticityController(); |
+ |
+ // This method is responsible for both scrolling and rubber-banding. |
+ // |
+ // Events are passed by IPC from the embedder. Events on Mac are grouped |
+ // into "gestures". If this method returns 'true', then this object has |
+ // handled the event. It expects the embedder to continue to forward events |
+ // from the gesture. |
+ // |
+ // This method makes the assumption that there is only 1 input device being |
+ // used at a time. If the user simultaneously uses multiple input devices, |
+ // Cocoa does not correctly pass all the gestureBegin/End events. The state |
+ // of this class is guaranteed to become eventually consistent, once the |
+ // user stops using multiple input devices. |
+ bool handleWheelEvent(const blink::WebMouseWheelEvent&); |
+ |
+ // cc::ScrollElasticityController implementation: |
+ void WillShutdown() override; |
+ void Animate(base::TimeTicks time) override; |
+ |
+private: |
+ |
+ void snapRubberBandTimerFired(); |
+ bool isRubberBandInProgress() const; |
+ |
+ void stopSnapRubberbandTimer(); |
+ void snapRubberBand(); |
+ |
+ // This method determines whether a given event should be handled. The |
+ // logic for control events of gestures (PhaseBegan, PhaseEnded) is handled |
+ // elsewhere. |
+ // |
+ // This class handles almost all wheel events. All of the following |
+ // conditions must be met for this class to ignore an event: |
+ // + No previous events in this gesture have caused any scrolling or rubber |
+ // banding. |
+ // + The event contains a horizontal component. |
+ // + The client's view is pinned in the horizontal direction of the event. |
+ // + The wheel event disallows rubber banding in the horizontal direction |
+ // of the event. |
+ bool shouldHandleEvent(const blink::WebMouseWheelEvent&); |
+ |
+ cc::ScrollElasticityControllerClient* m_client; |
+ |
+ // There is an active scroll gesture event. This parameter only gets set to |
+ // false after the rubber band has been snapped, and before a new gesture |
+ // has begun. A careful audit of the code may deprecate the need for this |
+ // parameter. |
+ bool m_inScrollGesture; |
+ // At least one event in the current gesture has been consumed and has |
+ // caused the view to scroll or rubber band. All future events in this |
+ // gesture will be consumed and overscrolls will cause rubberbanding. |
+ bool m_hasScrolled; |
+ bool m_momentumScrollInProgress; |
+ bool m_ignoreMomentumScrolls; |
+ |
+ base::Time m_lastMomentumScrollTimestamp; |
+ gfx::Vector2dF m_overflowScrollDelta; |
+ gfx::Vector2dF m_stretchScrollForce; |
+ gfx::Vector2dF m_momentumVelocity; |
+ |
+ // Rubber band state. |
+ base::Time m_startTime; |
+ gfx::Vector2dF m_startStretch; |
+ gfx::Vector2dF m_origOrigin; |
+ gfx::Vector2dF m_origVelocity; |
+ |
+ bool m_snapRubberbandTimerIsActive; |
+}; |
+ |
+} |
+ |
+#endif // CONTENT_RENDERER_INPUT_SCROLL_ELASTICITY_CONTROLLER_IMPL_H_ |