Chromium Code Reviews| Index: content/browser/renderer_host/input/synthetic_pointer_action_controller.cc |
| diff --git a/content/browser/renderer_host/input/synthetic_pointer_action_controller.cc b/content/browser/renderer_host/input/synthetic_pointer_action_controller.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9dac7768cd96a32a6667cd1ff81fc1e7d205a2e9 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/input/synthetic_pointer_action_controller.cc |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/renderer_host/input/synthetic_pointer_action_controller.h" |
| + |
| +namespace content { |
| + |
| +SyntheticPointerActionController::SyntheticPointerActionController() { |
| + for (size_t i = 0; i < index_map_.size(); ++i) |
| + index_map_[i] = -1; |
|
tdresser
2016/05/20 14:24:31
std::fill
lanwei
2016/05/23 16:40:51
Done.
|
| +} |
| +SyntheticPointerActionController::~SyntheticPointerActionController() {} |
| + |
| +std::unique_ptr<SyntheticGesture> |
| +SyntheticPointerActionController::CreateSyntheticPointerAction( |
| + const SyntheticPointerActionParams& gesture_params) { |
| + DCHECK(gesture_params.pointer_action_type() != |
| + SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED); |
| + std::unique_ptr<SyntheticGesture> synthetic_gesture; |
| + if (gesture_params.pointer_action_type() != |
| + SyntheticPointerActionParams::PointerActionType::PROCESS) |
|
tdresser
2016/05/20 14:24:31
This isn't technically required by the style guide
lanwei
2016/05/23 16:40:51
Done.
|
| + action_param_list_.push_back(gesture_params); |
|
tdresser
2016/05/20 14:24:31
Should we push back the gesture params if the type
lanwei
2016/05/23 16:40:51
The reason I push the 'FINISH' action into the par
|
| + |
| + if (gesture_params.pointer_action_type() == |
| + SyntheticPointerActionParams::PointerActionType::PROCESS || |
| + gesture_params.pointer_action_type() == |
| + SyntheticPointerActionParams::PointerActionType::FINISH) { |
| + // TODO(lanwei): Will support multiple pointer types in the same stream |
| + // later, see https://crbug.com/613303. |
| + if (!action_param_list_.empty()) { |
| + if (!synthetic_pointer_) |
| + SetSyntheticPointer(gesture_params); |
| + |
| + synthetic_gesture = |
| + std::unique_ptr<SyntheticGesture>(new SyntheticPointerAction( |
| + action_param_list_, synthetic_pointer_.get(), &index_map_)); |
| + action_param_list_.clear(); |
| + } |
| + } |
| + return synthetic_gesture; |
| +} |
| + |
| +void SyntheticPointerActionController::SetSyntheticPointer( |
| + const SyntheticPointerActionParams& gesture_params) { |
| + SyntheticGestureParams::GestureSourceType gesture_source_type = |
| + gesture_params.gesture_source_type; |
| + if (gesture_source_type == SyntheticGestureParams::DEFAULT_INPUT) |
| + gesture_source_type = default_type_; |
| + DCHECK_NE(gesture_source_type, SyntheticGestureParams::DEFAULT_INPUT); |
| + synthetic_pointer_ = SyntheticPointer::Create(gesture_source_type); |
| +} |
| + |
| +void SyntheticPointerActionController::ResetSyntheticPointer() { |
| + synthetic_pointer_.reset(); |
| +} |
| + |
| +void SyntheticPointerActionController::SetDefaultGestureSourceType( |
| + SyntheticGestureParams::GestureSourceType default_type) { |
| + default_type_ = default_type; |
| +} |
| + |
| +} // namespace content |