| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H_ |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 9 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
| 10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 12 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
| 13 #include "content/common/input/synthetic_web_input_event_builders.h" | 13 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 14 #include "third_party/WebKit/public/web/WebInputEvent.h" | 14 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 15 #include "ui/gfx/vector2d.h" | 15 #include "ui/gfx/vector2d.h" |
| 16 #include "ui/gfx/vector2d_f.h" | 16 #include "ui/gfx/vector2d_f.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class CONTENT_EXPORT SyntheticSmoothScrollGesture : public SyntheticGesture { | 20 class CONTENT_EXPORT SyntheticSmoothScrollGesture : public SyntheticGesture { |
| 21 public: | 21 public: |
| 22 explicit SyntheticSmoothScrollGesture( | 22 explicit SyntheticSmoothScrollGesture( |
| 23 const SyntheticSmoothScrollGestureParams& params); | 23 const SyntheticSmoothScrollGestureParams& params); |
| 24 virtual ~SyntheticSmoothScrollGesture(); | 24 virtual ~SyntheticSmoothScrollGesture(); |
| 25 | 25 |
| 26 virtual SyntheticGesture::Result ForwardInputEvents( | 26 virtual SyntheticGesture::Result ForwardInputEvents( |
| 27 const base::TimeDelta& interval, SyntheticGestureTarget* target) OVERRIDE; | 27 const base::TimeTicks& timestamp, |
| 28 SyntheticGestureTarget* target) OVERRIDE; |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 enum GestureState { | 31 enum GestureState { |
| 31 SETUP, | 32 SETUP, |
| 32 STARTED, | 33 STARTED, |
| 33 MOVING, | 34 MOVING, |
| 34 STOPPING, | 35 STOPPING, |
| 35 DONE | 36 DONE |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 void ForwardTouchInputEvents( | 39 void ForwardTouchInputEvents( |
| 39 const base::TimeDelta& interval, SyntheticGestureTarget* target); | 40 const base::TimeTicks& timestamp, SyntheticGestureTarget* target); |
| 40 void ForwardMouseInputEvents( | 41 void ForwardMouseInputEvents( |
| 41 const base::TimeDelta& interval, SyntheticGestureTarget* target); | 42 const base::TimeTicks& timestamp, SyntheticGestureTarget* target); |
| 42 | 43 |
| 43 void ForwardTouchEvent(SyntheticGestureTarget* target) const; | 44 void ForwardTouchEvent(SyntheticGestureTarget* target, |
| 45 const base::TimeTicks& timestamp); |
| 44 void ForwardMouseWheelEvent(SyntheticGestureTarget* target, | 46 void ForwardMouseWheelEvent(SyntheticGestureTarget* target, |
| 45 const gfx::Vector2dF& delta) const; | 47 const gfx::Vector2dF& delta, |
| 48 const base::TimeTicks& timestamp) const; |
| 46 | 49 |
| 47 void PressTouchPoint(SyntheticGestureTarget* target); | 50 void PressTouchPoint(SyntheticGestureTarget* target, |
| 48 void MoveTouchPoint(SyntheticGestureTarget* target); | 51 const base::TimeTicks& timestamp); |
| 49 void ReleaseTouchPoint(SyntheticGestureTarget* target); | 52 void MoveTouchPoint(SyntheticGestureTarget* target, |
| 53 const gfx::Vector2dF& delta, |
| 54 const base::TimeTicks& timestamp); |
| 55 void ReleaseTouchPoint(SyntheticGestureTarget* target, |
| 56 const base::TimeTicks& timestamp); |
| 50 | 57 |
| 51 void AddTouchSlopToDistance(SyntheticGestureTarget* target); | 58 void AddTouchSlopToDistance(SyntheticGestureTarget* target); |
| 52 gfx::Vector2dF GetPositionDelta(const base::TimeDelta& interval) const; | 59 gfx::Vector2dF GetPositionDeltaAtTime(const base::TimeTicks& timestamp) |
| 60 const; |
| 53 gfx::Vector2dF ProjectLengthOntoScrollDirection(float delta_length) const; | 61 gfx::Vector2dF ProjectLengthOntoScrollDirection(float delta_length) const; |
| 54 gfx::Vector2dF ComputeRemainingDelta() const; | 62 void ComputeAndSetStopScrollingTime(); |
| 55 bool HasScrolledEntireDistance() const; | 63 base::TimeTicks ClampTimestamp(const base::TimeTicks& timestamp) const; |
| 64 bool HasScrolledEntireDistance(const base::TimeTicks& timestamp) const; |
| 56 | 65 |
| 57 SyntheticSmoothScrollGestureParams params_; | 66 SyntheticSmoothScrollGestureParams params_; |
| 58 gfx::Vector2dF total_delta_; | |
| 59 gfx::Vector2d total_delta_discrete_; | 67 gfx::Vector2d total_delta_discrete_; |
| 60 SyntheticWebTouchEvent touch_event_; | 68 SyntheticWebTouchEvent touch_event_; |
| 61 SyntheticGestureParams::GestureSourceType gesture_source_type_; | 69 SyntheticGestureParams::GestureSourceType gesture_source_type_; |
| 62 GestureState state_; | 70 GestureState state_; |
| 63 base::TimeDelta total_stopping_wait_time_; | 71 base::TimeTicks start_time_; |
| 72 base::TimeTicks stop_scrolling_time_; |
| 64 | 73 |
| 65 DISALLOW_COPY_AND_ASSIGN(SyntheticSmoothScrollGesture); | 74 DISALLOW_COPY_AND_ASSIGN(SyntheticSmoothScrollGesture); |
| 66 }; | 75 }; |
| 67 | 76 |
| 68 } // namespace content | 77 } // namespace content |
| 69 | 78 |
| 70 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H
_ | 79 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H
_ |
| OLD | NEW |