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..5ddfe42276d2054915689d14e6c02fb8cc8467d8 |
--- /dev/null |
+++ b/content/browser/renderer_host/input/synthetic_pointer_action_controller.cc |
@@ -0,0 +1,71 @@ |
+// 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; |
+} |
+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 || |
+ gesture_params.pointer_action_type() == |
+ SyntheticPointerActionParams::PointerActionType::FINISH) { |
+ if (gesture_params.pointer_action_type() == |
tdresser
2016/05/19 17:57:04
Move this outside of the outer if. I think reducin
lanwei
2016/05/20 01:48:16
Done.
|
+ SyntheticPointerActionParams::PointerActionType::FINISH) { |
+ action_param_list_.push_back(gesture_params); |
+ } |
+ |
+ // TODO(lanwei): Will support multiple pointer types in the same stream |
+ // later. |
tdresser
2016/05/19 17:57:04
Add a bug link.
lanwei
2016/05/20 01:48:16
Done.
|
+ 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(); |
+ } |
+ } else |
tdresser
2016/05/19 17:57:03
Add {} here. In general if one clause of an if sta
|
+ action_param_list_.push_back(gesture_params); |
tdresser
2016/05/19 17:57:03
I'd invert this condition so the common, easy to f
lanwei
2016/05/20 01:48:16
Done.
|
+ 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; |
+} |
+ |
+int SyntheticPointerActionController::PointerIndex(int index) const { |
tdresser
2016/05/19 17:57:04
Do we need this method here? Could it be defined i
lanwei
2016/05/20 01:48:16
Done.
|
+ CHECK_GE(index, 0); |
+ CHECK_LT(index, WebTouchEvent::touchesLengthCap); |
+ return index_map_[index]; |
+} |
+ |
+} // namespace content |