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_GESTURE_CONTROLLER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <queue> | 9 #include <queue> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 16 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
17 #include "content/browser/renderer_host/input/synthetic_pointer_action.h" | |
tdresser
2016/05/13 13:58:04
Where is this used?
lanwei
2016/05/19 16:04:12
Deleted.
| |
17 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
19 #include "content/common/input/synthetic_gesture_packet.h" | |
tdresser
2016/05/13 13:58:04
Where is this used?
| |
18 #include "content/common/input/synthetic_gesture_params.h" | 20 #include "content/common/input/synthetic_gesture_params.h" |
21 #include "content/common/input/synthetic_pointer_action_params.h" | |
19 | 22 |
20 namespace content { | 23 namespace content { |
21 | 24 |
22 class SyntheticGestureTarget; | 25 class SyntheticGestureTarget; |
26 using blink::WebTouchEvent; | |
tdresser
2016/05/13 13:58:04
Where is this used?
| |
23 | 27 |
24 // Controls a synthetic gesture. | 28 // Controls a synthetic gesture. |
25 // Repeatedly invokes the gesture object's ForwardInputEvent method to send | 29 // Repeatedly invokes the gesture object's ForwardInputEvent method to send |
26 // input events to the platform until the gesture has finished. | 30 // input events to the platform until the gesture has finished. |
27 class CONTENT_EXPORT SyntheticGestureController { | 31 class CONTENT_EXPORT SyntheticGestureController { |
28 public: | 32 public: |
29 explicit SyntheticGestureController( | 33 explicit SyntheticGestureController( |
30 std::unique_ptr<SyntheticGestureTarget> gesture_target); | 34 std::unique_ptr<SyntheticGestureTarget> gesture_target); |
31 virtual ~SyntheticGestureController(); | 35 virtual ~SyntheticGestureController(); |
32 | 36 |
33 typedef base::Callback<void(SyntheticGesture::Result)> | 37 typedef base::Callback<void(SyntheticGesture::Result)> |
34 OnGestureCompleteCallback; | 38 OnGestureCompleteCallback; |
35 void QueueSyntheticGesture( | 39 void QueueSyntheticGesture( |
36 std::unique_ptr<SyntheticGesture> synthetic_gesture, | 40 std::unique_ptr<SyntheticGesture> synthetic_gesture, |
37 const OnGestureCompleteCallback& completion_callback); | 41 const OnGestureCompleteCallback& completion_callback); |
38 | 42 |
43 void QueueSyntheticPointerAction( | |
44 const SyntheticPointerActionParams& gesture_params, | |
45 const OnGestureCompleteCallback& completion_callback); | |
46 | |
39 // Forward input events of the currently processed gesture. | 47 // Forward input events of the currently processed gesture. |
40 void Flush(base::TimeTicks timestamp); | 48 void Flush(base::TimeTicks timestamp); |
41 | 49 |
42 // To be called when all events generated from the current gesture have been | 50 // To be called when all events generated from the current gesture have been |
43 // fully flushed from the input pipeline (i.e., sent, processed and ack'ed). | 51 // fully flushed from the input pipeline (i.e., sent, processed and ack'ed). |
44 void OnDidFlushInput(); | 52 void OnDidFlushInput(); |
45 | 53 |
54 void ResetSyntheticPointer(); | |
55 | |
56 // Only for tests in SyntheticGestureControllerTest. | |
57 int PointerIndex(int index) const; | |
tdresser
2016/05/13 13:58:04
Add this method in the test file by making instant
| |
58 | |
46 private: | 59 private: |
47 void StartGesture(const SyntheticGesture& gesture); | 60 void StartGesture(const SyntheticGesture& gesture); |
48 void StopGesture(const SyntheticGesture& gesture, | 61 void StopGesture(const SyntheticGesture& gesture, |
49 const OnGestureCompleteCallback& completion_callback, | 62 const OnGestureCompleteCallback& completion_callback, |
50 SyntheticGesture::Result result); | 63 SyntheticGesture::Result result); |
51 | 64 |
65 void SetSyntheticPointer(const SyntheticPointerActionParams& gesture_params); | |
66 | |
52 std::unique_ptr<SyntheticGestureTarget> gesture_target_; | 67 std::unique_ptr<SyntheticGestureTarget> gesture_target_; |
53 std::unique_ptr<SyntheticGesture::Result> pending_gesture_result_; | 68 std::unique_ptr<SyntheticGesture::Result> pending_gesture_result_; |
54 | 69 |
55 // A queue of gesture/callback pairs. Implemented as two queues to | 70 // A queue of gesture/callback pairs. Implemented as two queues to |
56 // simplify the ownership of SyntheticGesture pointers. | 71 // simplify the ownership of SyntheticGesture pointers. |
57 class GestureAndCallbackQueue { | 72 class GestureAndCallbackQueue { |
58 public: | 73 public: |
59 GestureAndCallbackQueue(); | 74 GestureAndCallbackQueue(); |
60 ~GestureAndCallbackQueue(); | 75 ~GestureAndCallbackQueue(); |
61 void Push(std::unique_ptr<SyntheticGesture> gesture, | 76 void Push(std::unique_ptr<SyntheticGesture> gesture, |
(...skipping 13 matching lines...) Expand all Loading... | |
75 } | 90 } |
76 bool IsEmpty() { | 91 bool IsEmpty() { |
77 CHECK(gestures_.empty() == callbacks_.empty()); | 92 CHECK(gestures_.empty() == callbacks_.empty()); |
78 return gestures_.empty(); | 93 return gestures_.empty(); |
79 } | 94 } |
80 private: | 95 private: |
81 ScopedVector<SyntheticGesture> gestures_; | 96 ScopedVector<SyntheticGesture> gestures_; |
82 std::queue<OnGestureCompleteCallback> callbacks_; | 97 std::queue<OnGestureCompleteCallback> callbacks_; |
83 } pending_gesture_queue_; | 98 } pending_gesture_queue_; |
84 | 99 |
100 std::vector<SyntheticPointerActionParams> action_param_list_; | |
tdresser
2016/05/13 13:58:04
We're going to be adding a bunch of state and logi
| |
101 std::unique_ptr<SyntheticPointer> synthetic_pointer_; | |
102 std::vector<int> index_map_; | |
tdresser
2016/05/13 13:58:04
If this is fixed size, use std::array.
Add a comme
lanwei
2016/05/19 16:04:12
Done.
| |
103 | |
85 DISALLOW_COPY_AND_ASSIGN(SyntheticGestureController); | 104 DISALLOW_COPY_AND_ASSIGN(SyntheticGestureController); |
86 }; | 105 }; |
87 | 106 |
88 } // namespace content | 107 } // namespace content |
89 | 108 |
90 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ | 109 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ |
OLD | NEW |