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_controlle r.h" | |
17 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
18 #include "content/common/input/synthetic_gesture_params.h" | 19 #include "content/common/input/synthetic_gesture_params.h" |
20 #include "content/common/input/synthetic_pointer_action_params.h" | |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 | 23 |
22 class SyntheticGestureTarget; | 24 class SyntheticGestureTarget; |
23 | 25 |
24 // Controls a synthetic gesture. | 26 // Controls a synthetic gesture. |
25 // Repeatedly invokes the gesture object's ForwardInputEvent method to send | 27 // Repeatedly invokes the gesture object's ForwardInputEvent method to send |
26 // input events to the platform until the gesture has finished. | 28 // input events to the platform until the gesture has finished. |
27 class CONTENT_EXPORT SyntheticGestureController { | 29 class CONTENT_EXPORT SyntheticGestureController { |
28 public: | 30 public: |
29 explicit SyntheticGestureController( | 31 explicit SyntheticGestureController( |
30 std::unique_ptr<SyntheticGestureTarget> gesture_target); | 32 std::unique_ptr<SyntheticGestureTarget> gesture_target); |
31 virtual ~SyntheticGestureController(); | 33 virtual ~SyntheticGestureController(); |
32 | 34 |
33 typedef base::Callback<void(SyntheticGesture::Result)> | 35 typedef base::Callback<void(SyntheticGesture::Result)> |
34 OnGestureCompleteCallback; | 36 OnGestureCompleteCallback; |
35 void QueueSyntheticGesture( | 37 void QueueSyntheticGesture( |
36 std::unique_ptr<SyntheticGesture> synthetic_gesture, | 38 std::unique_ptr<SyntheticGesture> synthetic_gesture, |
37 const OnGestureCompleteCallback& completion_callback); | 39 const OnGestureCompleteCallback& completion_callback); |
38 | 40 |
41 void QueueSyntheticPointerAction( | |
42 const SyntheticGestureParams& gesture_params, | |
43 const OnGestureCompleteCallback& completion_callback); | |
tdresser
2016/09/30 13:24:30
Why are we passing raw Params here? Couldn't we ma
lanwei
2016/10/21 21:53:07
Done.
| |
44 | |
39 // Forward input events of the currently processed gesture. | 45 // Forward input events of the currently processed gesture. |
40 void Flush(base::TimeTicks timestamp); | 46 void Flush(base::TimeTicks timestamp); |
41 | 47 |
42 // To be called when all events generated from the current gesture have been | 48 // 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). | 49 // fully flushed from the input pipeline (i.e., sent, processed and ack'ed). |
44 void OnDidFlushInput(); | 50 void OnDidFlushInput(); |
45 | 51 |
46 private: | 52 private: |
47 void StartGesture(const SyntheticGesture& gesture); | 53 void StartGesture(const SyntheticGesture& gesture); |
48 void StopGesture(const SyntheticGesture& gesture, | 54 void StopGesture(const SyntheticGesture& gesture, |
49 const OnGestureCompleteCallback& completion_callback, | 55 const OnGestureCompleteCallback& completion_callback, |
50 SyntheticGesture::Result result); | 56 SyntheticGesture::Result result); |
51 | 57 |
52 std::unique_ptr<SyntheticGestureTarget> gesture_target_; | 58 std::unique_ptr<SyntheticGestureTarget> gesture_target_; |
53 std::unique_ptr<SyntheticGesture::Result> pending_gesture_result_; | 59 std::unique_ptr<SyntheticGesture::Result> pending_gesture_result_; |
60 SyntheticPointerActionController pointer_action_controller_; | |
54 | 61 |
55 // A queue of gesture/callback pairs. Implemented as two queues to | 62 // A queue of gesture/callback pairs. Implemented as two queues to |
56 // simplify the ownership of SyntheticGesture pointers. | 63 // simplify the ownership of SyntheticGesture pointers. |
57 class GestureAndCallbackQueue { | 64 class GestureAndCallbackQueue { |
58 public: | 65 public: |
59 GestureAndCallbackQueue(); | 66 GestureAndCallbackQueue(); |
60 ~GestureAndCallbackQueue(); | 67 ~GestureAndCallbackQueue(); |
61 void Push(std::unique_ptr<SyntheticGesture> gesture, | 68 void Push(std::unique_ptr<SyntheticGesture> gesture, |
62 const OnGestureCompleteCallback& callback) { | 69 const OnGestureCompleteCallback& callback) { |
63 gestures_.push_back(std::move(gesture)); | 70 gestures_.push_back(std::move(gesture)); |
(...skipping 17 matching lines...) Expand all Loading... | |
81 ScopedVector<SyntheticGesture> gestures_; | 88 ScopedVector<SyntheticGesture> gestures_; |
82 std::queue<OnGestureCompleteCallback> callbacks_; | 89 std::queue<OnGestureCompleteCallback> callbacks_; |
83 } pending_gesture_queue_; | 90 } pending_gesture_queue_; |
84 | 91 |
85 DISALLOW_COPY_AND_ASSIGN(SyntheticGestureController); | 92 DISALLOW_COPY_AND_ASSIGN(SyntheticGestureController); |
86 }; | 93 }; |
87 | 94 |
88 } // namespace content | 95 } // namespace content |
89 | 96 |
90 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ | 97 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ |
OLD | NEW |