OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "content/browser/renderer_host/input/synthetic_pointer_action.h" | 5 #include "content/browser/renderer_host/input/synthetic_pointer_action.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/WebKit/public/web/WebInputEvent.h" | 8 #include "third_party/WebKit/public/web/WebInputEvent.h" |
9 #include "ui/events/latency_info.h" | 9 #include "ui/events/latency_info.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 SyntheticPointerAction::SyntheticPointerAction( | 13 SyntheticPointerAction::SyntheticPointerAction( |
14 const SyntheticPointerActionParams& params) | 14 const SyntheticPointerActionListParams& params) |
15 : params_(params) {} | 15 : params_(params) {} |
16 | 16 |
17 SyntheticPointerAction::SyntheticPointerAction( | 17 SyntheticPointerAction::SyntheticPointerAction( |
18 std::unique_ptr<std::vector<SyntheticPointerActionParams>> param_list, | 18 const SyntheticPointerActionListParams& params, |
19 SyntheticPointer* synthetic_pointer, | 19 SyntheticPointer* synthetic_pointer, |
20 IndexMap* index_map) | 20 IndexMap* index_map) |
21 : param_list_(std::move(param_list)), | 21 : params_(params), |
22 synthetic_pointer_(synthetic_pointer), | 22 synthetic_pointer_(synthetic_pointer), |
23 index_map_(index_map) {} | 23 index_map_(index_map) {} |
24 | 24 |
25 SyntheticPointerAction::~SyntheticPointerAction() {} | 25 SyntheticPointerAction::~SyntheticPointerAction() {} |
26 | 26 |
27 SyntheticGesture::Result SyntheticPointerAction::ForwardInputEvents( | 27 SyntheticGesture::Result SyntheticPointerAction::ForwardInputEvents( |
28 const base::TimeTicks& timestamp, | 28 const base::TimeTicks& timestamp, |
29 SyntheticGestureTarget* target) { | 29 SyntheticGestureTarget* target) { |
30 DCHECK(synthetic_pointer_); | 30 DCHECK(synthetic_pointer_); |
| 31 DCHECK_NE(synthetic_pointer_->SourceType(), |
| 32 SyntheticGestureParams::DEFAULT_INPUT); |
31 return ForwardTouchOrMouseInputEvents(timestamp, target); | 33 return ForwardTouchOrMouseInputEvents(timestamp, target); |
32 } | 34 } |
33 | 35 |
34 SyntheticGesture::Result SyntheticPointerAction::ForwardTouchOrMouseInputEvents( | 36 SyntheticGesture::Result SyntheticPointerAction::ForwardTouchOrMouseInputEvents( |
35 const base::TimeTicks& timestamp, | 37 const base::TimeTicks& timestamp, |
36 SyntheticGestureTarget* target) { | 38 SyntheticGestureTarget* target) { |
37 int point_index; | 39 int point_index; |
38 for (const SyntheticPointerActionParams& params : *param_list_) { | 40 for (const SyntheticPointerActionParams& params : params_.param_list) { |
39 if (!UserInputCheck(params)) | 41 if (!UserInputCheck(params)) |
40 return POINTER_ACTION_INPUT_INVALID; | 42 return POINTER_ACTION_INPUT_INVALID; |
41 | 43 |
42 switch (params.pointer_action_type()) { | 44 switch (params.pointer_action_type()) { |
43 case SyntheticPointerActionParams::PointerActionType::PRESS: | 45 case SyntheticPointerActionParams::PointerActionType::PRESS: |
44 point_index = synthetic_pointer_->Press( | 46 point_index = synthetic_pointer_->Press( |
45 params.position().x(), params.position().y(), target, timestamp); | 47 params.position().x(), params.position().y(), target, timestamp); |
46 SetPointIndex(params.index(), point_index); | 48 SetPointIndex(params.index(), point_index); |
47 break; | 49 break; |
48 case SyntheticPointerActionParams::PointerActionType::MOVE: | 50 case SyntheticPointerActionParams::PointerActionType::MOVE: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 88 |
87 if (params.pointer_action_type() == | 89 if (params.pointer_action_type() == |
88 SyntheticPointerActionParams::PointerActionType::RELEASE && | 90 SyntheticPointerActionParams::PointerActionType::RELEASE && |
89 GetPointIndex(params.index()) < 0) { | 91 GetPointIndex(params.index()) < 0) { |
90 return false; | 92 return false; |
91 } | 93 } |
92 return true; | 94 return true; |
93 } | 95 } |
94 | 96 |
95 } // namespace content | 97 } // namespace content |
OLD | NEW |