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_MOVE_GESTURE_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_MOVE_GESTURE_H_ |
7 | |
8 #include <vector> | |
7 | 9 |
8 #include "base/time/time.h" | 10 #include "base/time/time.h" |
9 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 11 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 12 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
11 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
12 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | |
13 #include "content/common/input/synthetic_web_input_event_builders.h" | 14 #include "content/common/input/synthetic_web_input_event_builders.h" |
14 #include "third_party/WebKit/public/web/WebInputEvent.h" | 15 #include "third_party/WebKit/public/web/WebInputEvent.h" |
15 #include "ui/gfx/geometry/vector2d.h" | 16 #include "ui/gfx/geometry/vector2d.h" |
16 #include "ui/gfx/geometry/vector2d_f.h" | 17 #include "ui/gfx/geometry/vector2d_f.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 // Simulates scrolling given a sequence of scroll distances as a continuous | 21 // This class is used as helper class for simulation of scroll and drag. |
21 // gestures (i.e. when synthesizing touch events, the touch pointer is not | 22 // Simulates scrolling/dragging given a sequence of distances as a continuous |
22 // lifted when changing scroll direction). | 23 // gestures (i.e. when synthesizing touch or mouse drag events, the pointer is |
24 // not lifted when changing scroll direction). | |
23 // If no distance is provided or the first one is 0, no touch events are | 25 // If no distance is provided or the first one is 0, no touch events are |
24 // generated. | 26 // generated. |
25 // When synthesizing touch events, the first distance is extended to compensate | 27 // When synthesizing touch events for scrolling, the first distance is extended |
26 // for the touch slop. | 28 // to compensate for the touch slop. |
27 class CONTENT_EXPORT SyntheticSmoothScrollGesture : public SyntheticGesture { | 29 class CONTENT_EXPORT SyntheticSmoothMoveGesture : public SyntheticGesture { |
28 public: | 30 public: |
29 explicit SyntheticSmoothScrollGesture( | 31 enum InputType { |
30 const SyntheticSmoothScrollGestureParams& params); | 32 TOUCH_INPUT, |
31 ~SyntheticSmoothScrollGesture() override; | 33 MOUSE_CLICK, |
34 MOUSE_WHEEL | |
35 }; | |
36 | |
37 SyntheticSmoothMoveGesture( | |
38 InputType gesture_source_type, | |
39 gfx::PointF start_point, | |
40 std::vector<gfx::Vector2d> distances, | |
41 int speed_in_pixels_s, | |
42 bool prevent_fling); | |
43 ~SyntheticSmoothMoveGesture() override; | |
32 | 44 |
33 SyntheticGesture::Result ForwardInputEvents( | 45 SyntheticGesture::Result ForwardInputEvents( |
34 const base::TimeTicks& timestamp, | 46 const base::TimeTicks& timestamp, |
35 SyntheticGestureTarget* target) override; | 47 SyntheticGestureTarget* target) override; |
36 | 48 |
37 private: | 49 private: |
38 enum GestureState { | 50 enum GestureState { |
39 SETUP, | 51 SETUP, |
40 STARTED, | 52 STARTED, |
41 MOVING, | 53 MOVING, |
42 STOPPING, | 54 STOPPING, |
43 DONE | 55 DONE |
44 }; | 56 }; |
45 | 57 |
58 | |
ssid
2015/02/18 17:57:35
Will remove.
| |
46 void ForwardTouchInputEvents( | 59 void ForwardTouchInputEvents( |
47 const base::TimeTicks& timestamp, SyntheticGestureTarget* target); | 60 const base::TimeTicks& timestamp, SyntheticGestureTarget* target); |
48 void ForwardMouseInputEvents( | 61 void ForwardMouseWheelInputEvents( |
62 const base::TimeTicks& timestamp, SyntheticGestureTarget* target); | |
63 void ForwardMouseClickInputEvents( | |
49 const base::TimeTicks& timestamp, SyntheticGestureTarget* target); | 64 const base::TimeTicks& timestamp, SyntheticGestureTarget* target); |
50 | 65 |
51 void ForwardTouchEvent(SyntheticGestureTarget* target, | 66 void ForwardTouchEvent(SyntheticGestureTarget* target, |
52 const base::TimeTicks& timestamp); | 67 const base::TimeTicks& timestamp); |
53 void ForwardMouseWheelEvent(SyntheticGestureTarget* target, | 68 void ForwardMouseWheelEvent(SyntheticGestureTarget* target, |
54 const gfx::Vector2dF& delta, | 69 const gfx::Vector2dF& delta, |
55 const base::TimeTicks& timestamp) const; | 70 const base::TimeTicks& timestamp) const; |
56 | 71 |
57 void PressTouchPoint(SyntheticGestureTarget* target, | 72 void PressTouchPoint(SyntheticGestureTarget* target, |
58 const base::TimeTicks& timestamp); | 73 const base::TimeTicks& timestamp); |
59 void MoveTouchPoint(SyntheticGestureTarget* target, | 74 void MoveTouchPoint(SyntheticGestureTarget* target, |
60 const gfx::Vector2dF& delta, | 75 const gfx::Vector2dF& delta, |
61 const base::TimeTicks& timestamp); | 76 const base::TimeTicks& timestamp); |
62 void ReleaseTouchPoint(SyntheticGestureTarget* target, | 77 void ReleaseTouchPoint(SyntheticGestureTarget* target, |
63 const base::TimeTicks& timestamp); | 78 const base::TimeTicks& timestamp); |
64 | 79 |
80 void PressMousePoint(SyntheticGestureTarget* target, | |
81 const base::TimeTicks& timestamp); | |
82 void ReleaseMousePoint(SyntheticGestureTarget* target, | |
83 const base::TimeTicks& timestamp); | |
84 void MoveMousePoint(SyntheticGestureTarget* target, | |
85 const gfx::Vector2dF& delta, | |
86 const base::TimeTicks& timestamp); | |
87 | |
65 void AddTouchSlopToFirstDistance(SyntheticGestureTarget* target); | 88 void AddTouchSlopToFirstDistance(SyntheticGestureTarget* target); |
66 gfx::Vector2dF GetPositionDeltaAtTime(const base::TimeTicks& timestamp) | 89 gfx::Vector2dF GetPositionDeltaAtTime(const base::TimeTicks& timestamp) const; |
67 const; | 90 void ComputeNextMoveSegment(); |
68 void ComputeNextScrollSegment(); | |
69 base::TimeTicks ClampTimestamp(const base::TimeTicks& timestamp) const; | 91 base::TimeTicks ClampTimestamp(const base::TimeTicks& timestamp) const; |
70 bool FinishedCurrentScrollSegment(const base::TimeTicks& timestamp) const; | 92 bool FinishedCurrentMoveSegment(const base::TimeTicks& timestamp) const; |
71 bool IsLastScrollSegment() const; | 93 bool IsLastMoveSegment() const; |
72 bool ScrollIsNoOp() const; | 94 bool MoveIsNoOp() const; |
73 | 95 |
74 SyntheticSmoothScrollGestureParams params_; | |
75 // Used for mouse input. | 96 // Used for mouse input. |
76 gfx::Vector2d current_scroll_segment_total_delta_discrete_; | 97 gfx::Vector2d current_move_segment_total_delta_discrete_; |
77 // Used for touch input. | 98 // Used for touch input. |
78 gfx::Point current_scroll_segment_start_position_; | 99 gfx::PointF current_move_segment_start_position_; |
79 SyntheticWebTouchEvent touch_event_; | 100 SyntheticWebTouchEvent touch_event_; |
80 SyntheticGestureParams::GestureSourceType gesture_source_type_; | 101 InputType gesture_source_type_; |
81 GestureState state_; | 102 GestureState state_; |
82 int current_scroll_segment_; | 103 int current_move_segment_; |
83 base::TimeTicks current_scroll_segment_start_time_; | 104 base::TimeTicks current_move_segment_start_time_; |
84 base::TimeTicks current_scroll_segment_stop_time_; | 105 base::TimeTicks current_move_segment_stop_time_; |
106 std::vector<gfx::Vector2d> move_distances_; | |
107 int speed_in_pixels_s_; | |
108 bool prevent_fling_; | |
85 | 109 |
86 DISALLOW_COPY_AND_ASSIGN(SyntheticSmoothScrollGesture); | 110 DISALLOW_COPY_AND_ASSIGN(SyntheticSmoothMoveGesture); |
87 }; | 111 }; |
88 | 112 |
89 } // namespace content | 113 } // namespace content |
90 | 114 |
91 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H _ | 115 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_MOVE_GESTURE_H_ |
OLD | NEW |