Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Unified Diff: content/browser/renderer_host/input/synthetic_gesture_controller.cc

Issue 1884883005: Prepare SyntheticPointerAction to handle touch actions for multiple fingers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move logic to controller Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/synthetic_gesture_controller.cc
diff --git a/content/browser/renderer_host/input/synthetic_gesture_controller.cc b/content/browser/renderer_host/input/synthetic_gesture_controller.cc
index 9e5bc84403eb18e01f09e43b26b9db51fbd20211..ebcae9b141f17962f3e19e474d869f50f6868a98 100644
--- a/content/browser/renderer_host/input/synthetic_gesture_controller.cc
+++ b/content/browser/renderer_host/input/synthetic_gesture_controller.cc
@@ -12,11 +12,15 @@
#include "content/common/input_messages.h"
#include "content/public/browser/render_widget_host.h"
+using blink::WebTouchEvent;
+
namespace content {
SyntheticGestureController::SyntheticGestureController(
std::unique_ptr<SyntheticGestureTarget> gesture_target)
- : gesture_target_(std::move(gesture_target)) {}
+ : gesture_target_(std::move(gesture_target)) {
+ index_map_ = std::vector<int>(WebTouchEvent::touchesLengthCap, -1);
+}
SyntheticGestureController::~SyntheticGestureController() {}
@@ -34,6 +38,52 @@ void SyntheticGestureController::QueueSyntheticGesture(
StartGesture(*pending_gesture_queue_.FrontGesture());
}
+void SyntheticGestureController::QueueSyntheticPointerAction(
+ const SyntheticPointerActionParams& gesture_params,
+ const OnGestureCompleteCallback& completion_callback) {
+ DCHECK(gesture_params.pointer_action_type() !=
+ SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED);
+
+ if (gesture_params.pointer_action_type() ==
+ SyntheticPointerActionParams::PointerActionType::PROCESS ||
+ gesture_params.pointer_action_type() ==
+ SyntheticPointerActionParams::PointerActionType::FINISH) {
+ if (gesture_params.pointer_action_type() ==
+ SyntheticPointerActionParams::PointerActionType::FINISH) {
+ action_param_list_.push_back(gesture_params);
+ }
+
+ // TODO(lanwei): Will support multiple pointer types in the same stream
+ // later.
+ if (!action_param_list_.empty()) {
+ if (!synthetic_pointer_)
+ SetSyntheticPointer(gesture_params);
+
+ std::unique_ptr<SyntheticGesture> synthetic_gesture =
+ std::unique_ptr<SyntheticGesture>(new SyntheticPointerAction(
+ action_param_list_, synthetic_pointer_.get(), &index_map_));
+ QueueSyntheticGesture(std::move(synthetic_gesture), completion_callback);
+ action_param_list_.clear();
+ }
+ } else
+ action_param_list_.push_back(gesture_params);
+}
+
+void SyntheticGestureController::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 =
+ gesture_target_->GetDefaultSyntheticGestureSourceType();
+ DCHECK_NE(gesture_source_type, SyntheticGestureParams::DEFAULT_INPUT);
+ synthetic_pointer_ = SyntheticPointer::Create(gesture_source_type);
+}
+
+void SyntheticGestureController::ResetSyntheticPointer() {
+ synthetic_pointer_.reset();
+}
+
void SyntheticGestureController::Flush(base::TimeTicks timestamp) {
TRACE_EVENT0("input", "SyntheticGestureController::Flush");
if (pending_gesture_queue_.IsEmpty())
@@ -93,6 +143,12 @@ void SyntheticGestureController::StopGesture(
completion_callback.Run(result);
}
+int SyntheticGestureController::PointerIndex(int index) const {
+ CHECK_GE(index, 0);
+ CHECK_LT(index, WebTouchEvent::touchesLengthCap);
+ return index_map_[index];
+}
+
SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() {
}

Powered by Google App Engine
This is Rietveld 408576698