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

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

Issue 26664002: SyntheticGestureTarget implementation for injecting synthetic input events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile_err Created 7 years, 2 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_target_aura.cc
diff --git a/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc b/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc
new file mode 100644
index 0000000000000000000000000000000000000000..901b6e578037b6c644e93f934bcc94f2e5e6130c
--- /dev/null
+++ b/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc
@@ -0,0 +1,71 @@
+// Copyright 2013 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_gesture_target_aura.h"
+
+#include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/browser/renderer_host/ui_events_helper.h"
+#include "content/common/input/input_event.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+
+using WebKit::WebTouchEvent;
+using WebKit::WebMouseWheelEvent;
+
+namespace content {
+
+SyntheticGestureTargetAura::SyntheticGestureTargetAura(
+ RenderWidgetHostViewAura* render_view)
+ : SyntheticGestureTargetBase(render_view) {
+}
+
+void SyntheticGestureTargetAura::QueueWebTouchEventToPlatform(
+ const WebTouchEvent& web_touch,
+ const ui::LatencyInfo& latency_info) {
+ aura::Window* window = render_view_aura()->GetNativeView();
+ aura::RootWindow* root_window =
+ reinterpret_cast<aura::RootWindow*>(window->GetRootWindow());
aelias_OOO_until_Jul13 2013/10/31 01:47:48 Use static_cast for downcasts. reinterpret_cast i
kouhei (in TOK) 2013/10/31 04:26:36 Done.
+ if (!root_window)
+ return;
+
+ aura::RootWindowHostDelegate* root_window_host_delegate =
+ root_window->AsRootWindowHostDelegate();
+
+ TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info);
+
+ // SyntheticGesture may skip calculating screenPosition, so we will fill it
+ // in here. "screenPosition" is converted from "position".
+ const unsigned num_touches = touch_with_latency.event.touchesLength;
aelias_OOO_until_Jul13 2013/10/31 01:47:48 size_t is preferred to unsigned for counts.
kouhei (in TOK) 2013/10/31 04:26:36 Done.
+ for (unsigned i = 0; i < num_touches; ++ i) {
+ WebKit::WebTouchPoint* point = &touch_with_latency.event.touches[i];
+ gfx::Point position(point->position.x, point->position.y);
+ aura::Window::ConvertPointToTarget(window, root_window, &position);
+ root_window->ConvertPointToHost(&position);
+ point->screenPosition.x = position.x();
+ point->screenPosition.y = position.y();
+ }
+
+ ScopedVector<ui::TouchEvent> events;
+ if (!MakeUITouchEventsFromWebTouchEvents(touch_with_latency, &events,
+ SCREEN_COORDINATES))
+ return;
aelias_OOO_until_Jul13 2013/10/31 01:47:48 Should this ever happen? How about DCHECKing it i
kouhei (in TOK) 2013/10/31 04:26:36 Done.
+
+ for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
+ end = events.end(); iter != end; ++iter) {
+ root_window_host_delegate->OnHostTouchEvent(*iter);
+ }
+}
+
+SyntheticGestureParams::GestureSourceType
+SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const {
+ return SyntheticGestureParams::TOUCH_INPUT;
+}
+
+bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType(
+ SyntheticGestureParams::GestureSourceType gesture_source_type) const {
+ return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT
+ || gesture_source_type == SyntheticGestureParams::MOUSE_INPUT;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698