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 using blink::WebTouchEvent; | |
14 | |
13 SyntheticPointerAction::SyntheticPointerAction( | 15 SyntheticPointerAction::SyntheticPointerAction( |
14 const SyntheticPointerActionParams& params) | 16 const SyntheticPointerActionParams& params) |
15 : params_(params) {} | 17 : params_(params) {} |
16 | 18 |
17 SyntheticPointerAction::SyntheticPointerAction( | 19 SyntheticPointerAction::SyntheticPointerAction( |
18 const SyntheticPointerActionParams& params, | 20 const std::vector<SyntheticPointerActionParams>& param_list, |
19 SyntheticPointer* synthetic_pointer) | 21 SyntheticPointer* synthetic_pointer, |
20 : params_(params), synthetic_pointer_(synthetic_pointer) {} | 22 int* index_map) |
23 : param_list_(param_list), | |
24 synthetic_pointer_(synthetic_pointer), | |
25 index_map_(index_map) {} | |
21 | 26 |
22 SyntheticPointerAction::~SyntheticPointerAction() {} | 27 SyntheticPointerAction::~SyntheticPointerAction() {} |
23 | 28 |
24 SyntheticGesture::Result SyntheticPointerAction::ForwardInputEvents( | 29 SyntheticGesture::Result SyntheticPointerAction::ForwardInputEvents( |
25 const base::TimeTicks& timestamp, | 30 const base::TimeTicks& timestamp, |
26 SyntheticGestureTarget* target) { | 31 SyntheticGestureTarget* target) { |
32 LOG(ERROR) << "SyntheticPointerAction::ForwardInputEvents "; | |
27 if (params_.gesture_source_type == SyntheticGestureParams::DEFAULT_INPUT) | 33 if (params_.gesture_source_type == SyntheticGestureParams::DEFAULT_INPUT) |
28 params_.gesture_source_type = | 34 params_.gesture_source_type = |
29 target->GetDefaultSyntheticGestureSourceType(); | 35 target->GetDefaultSyntheticGestureSourceType(); |
30 | 36 |
31 DCHECK_NE(params_.gesture_source_type, SyntheticGestureParams::DEFAULT_INPUT); | 37 DCHECK_NE(params_.gesture_source_type, SyntheticGestureParams::DEFAULT_INPUT); |
38 DCHECK(synthetic_pointer_); | |
32 | 39 |
33 ForwardTouchOrMouseInputEvents(timestamp, target); | 40 ForwardTouchOrMouseInputEvents(timestamp, target); |
34 return SyntheticGesture::GESTURE_FINISHED; | 41 return SyntheticGesture::GESTURE_FINISHED; |
35 } | 42 } |
36 | 43 |
37 void SyntheticPointerAction::ForwardTouchOrMouseInputEvents( | 44 void SyntheticPointerAction::ForwardTouchOrMouseInputEvents( |
38 const base::TimeTicks& timestamp, | 45 const base::TimeTicks& timestamp, |
39 SyntheticGestureTarget* target) { | 46 SyntheticGestureTarget* target) { |
40 switch (params_.pointer_action_type()) { | 47 LOG(ERROR) << "SyntheticPointerAction::ForwardTouchOrMouseInputEvents " |
41 case SyntheticPointerActionParams::PointerActionType::PRESS: | 48 << param_list_.size(); |
42 synthetic_pointer_->Press(params_.position().x(), params_.position().y(), | 49 if (param_list_.size() == 0) |
43 target, timestamp); | 50 return; |
44 break; | 51 |
45 case SyntheticPointerActionParams::PointerActionType::MOVE: | 52 for (auto iter = param_list_.begin(); iter != param_list_.end(); ++iter) { |
46 synthetic_pointer_->Move(params_.index(), params_.position().x(), | 53 SyntheticPointerActionParams params = (*iter); |
tdresser
2016/04/18 15:24:39
() aren't needed.
| |
47 params_.position().y(), target, timestamp); | 54 CHECK_GE(params.index(), 0); |
48 break; | 55 CHECK_LT(params.index(), WebTouchEvent::touchesLengthCap); |
49 case SyntheticPointerActionParams::PointerActionType::RELEASE: | 56 switch (params.pointer_action_type()) { |
50 synthetic_pointer_->Release(params_.index(), target, timestamp); | 57 case SyntheticPointerActionParams::PointerActionType::PRESS: { |
51 break; | 58 int index = synthetic_pointer_->Press( |
52 default: | 59 params.position().x(), params.position().y(), target, timestamp); |
53 NOTREACHED(); | 60 index_map_[params.index()] = index; |
tdresser
2016/04/18 15:24:39
Should we use a vector for index_map_? Somewhere w
lanwei
2016/04/19 19:05:32
Yes, I was thinking about which one to choose, I f
| |
54 break; | 61 break; |
62 } | |
63 case SyntheticPointerActionParams::PointerActionType::MOVE: | |
64 CHECK_GE(index_map_[params.index()], 0); | |
65 CHECK_LT(index_map_[params.index()], WebTouchEvent::touchesLengthCap); | |
66 synthetic_pointer_->Move(index_map_[params.index()], | |
67 params.position().x(), params.position().y(), | |
68 target, timestamp); | |
69 break; | |
70 case SyntheticPointerActionParams::PointerActionType::RELEASE: | |
71 CHECK_GE(index_map_[params.index()], 0); | |
72 CHECK_LT(index_map_[params.index()], WebTouchEvent::touchesLengthCap); | |
73 synthetic_pointer_->Release(index_map_[params.index()], target, | |
74 timestamp); | |
75 break; | |
76 default: | |
77 NOTREACHED(); | |
78 break; | |
79 } | |
55 } | 80 } |
56 synthetic_pointer_->DispatchEvent(target, timestamp); | 81 synthetic_pointer_->DispatchEvent(target, timestamp); |
57 } | 82 } |
58 | 83 |
59 } // namespace content | 84 } // namespace content |
OLD | NEW |