OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/browser/renderer_host/input/synthetic_pointer_action_controlle r.h" | |
6 | |
7 namespace content { | |
8 | |
9 SyntheticPointerActionController::SyntheticPointerActionController() | |
10 : action_param_list_(new std::vector<SyntheticPointerActionParams>()) { | |
11 std::fill(index_map_.begin(), index_map_.end(), -1); | |
12 } | |
13 SyntheticPointerActionController::~SyntheticPointerActionController() {} | |
14 | |
15 std::unique_ptr<SyntheticGesture> | |
16 SyntheticPointerActionController::CreateSyntheticPointerAction( | |
17 const SyntheticPointerActionParams& gesture_params) { | |
18 DCHECK(gesture_params.pointer_action_type() != | |
19 SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED); | |
20 DCHECK(action_param_list_.get()); | |
21 std::unique_ptr<SyntheticGesture> synthetic_gesture; | |
22 if (gesture_params.pointer_action_type() != | |
23 SyntheticPointerActionParams::PointerActionType::PROCESS) { | |
24 action_param_list_->push_back(gesture_params); | |
25 } | |
26 | |
27 if (gesture_params.pointer_action_type() == | |
28 SyntheticPointerActionParams::PointerActionType::PROCESS || | |
29 gesture_params.pointer_action_type() == | |
30 SyntheticPointerActionParams::PointerActionType::FINISH) { | |
31 // TODO(lanwei): Will support multiple pointer types in the same stream | |
32 // later, see https://crbug.com/613303. | |
33 if (!action_param_list_->empty()) { | |
34 if (!synthetic_pointer_) | |
35 SetSyntheticPointer(gesture_params); | |
36 | |
37 synthetic_gesture = std::unique_ptr<SyntheticGesture>( | |
tdresser
2016/05/31 13:44:26
You can replace = std::unique_ptr<SyntheticGesture
lanwei
2016/06/02 13:26:27
Yes, thanks!
| |
38 new SyntheticPointerAction(std::move(action_param_list_), | |
39 synthetic_pointer_.get(), &index_map_)); | |
40 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | |
41 } | |
42 } | |
43 return synthetic_gesture; | |
44 } | |
45 | |
46 void SyntheticPointerActionController::SetSyntheticPointer( | |
47 const SyntheticPointerActionParams& gesture_params) { | |
48 SyntheticGestureParams::GestureSourceType gesture_source_type = | |
49 gesture_params.gesture_source_type; | |
50 if (gesture_source_type == SyntheticGestureParams::DEFAULT_INPUT) | |
51 gesture_source_type = default_type_; | |
52 DCHECK_NE(gesture_source_type, SyntheticGestureParams::DEFAULT_INPUT); | |
53 synthetic_pointer_ = SyntheticPointer::Create(gesture_source_type); | |
54 } | |
55 | |
56 void SyntheticPointerActionController::ResetSyntheticPointer() { | |
57 synthetic_pointer_.reset(); | |
58 } | |
59 | |
60 void SyntheticPointerActionController::SetDefaultGestureSourceType( | |
61 SyntheticGestureParams::GestureSourceType default_type) { | |
62 default_type_ = default_type; | |
63 } | |
64 | |
65 } // namespace content | |
OLD | NEW |