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..63a703c09185bf81d59adf00b2fcf45ad8be6ac4 |
--- /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_impl.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; |
sadrul
2013/11/04 19:26:42
a new line after the #include block
kouhei (in TOK)
2013/11/05 01:32:26
Done.
|
+using WebKit::WebMouseWheelEvent; |
+ |
+namespace content { |
+ |
+SyntheticGestureTargetAura::SyntheticGestureTargetAura( |
+ RenderWidgetHostImpl* host) |
+ : SyntheticGestureTargetBase(host) { |
+} |
+ |
+void SyntheticGestureTargetAura::QueueWebTouchEventToPlatform( |
+ const WebTouchEvent& web_touch, |
+ const ui::LatencyInfo& latency_info) { |
+ aura::Window* window = render_widget_host()->GetView()->GetNativeView(); |
+ aura::RootWindow* root_window = |
+ static_cast<aura::RootWindow*>(window->GetRootWindow()); |
+ 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 size_t num_touches = touch_with_latency.event.touchesLength; |
+ for (size_t 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); |
sadrul
2013/11/04 19:26:42
Use aura::client::ScreenPositionClient::ConvertPoi
kouhei (in TOK)
2013/11/05 01:32:26
Done.
|
+ point->screenPosition.x = position.x(); |
+ point->screenPosition.y = position.y(); |
+ } |
+ |
+ ScopedVector<ui::TouchEvent> events; |
+ bool conversionSucceed = MakeUITouchEventsFromWebTouchEvents( |
sadrul
2013/11/04 19:26:42
conversion_success
kouhei (in TOK)
2013/11/05 01:32:26
Done.
|
+ touch_with_latency, &events, SCREEN_COORDINATES); |
+ DCHECK(conversionSucceed); |
+ |
+ for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), |
+ end = events.end(); iter != end; ++iter) { |
+ root_window_host_delegate->OnHostTouchEvent(*iter); |
sadrul
2013/11/04 19:26:42
If Queue*<> expects events to be dispatched asynch
kouhei (in TOK)
2013/11/05 01:32:26
IIUC, QueueWebTouchEventToPlatform can either asyn
Dominik Grewe
2013/11/05 10:32:48
Good question. Afaict synchronous dispatch is fine
sadrul
2013/11/05 17:53:25
OK. Perhaps 'Dispatch' would be a better name. 'Qu
kouhei (in TOK)
2013/11/06 03:24:22
To be addressed in the later CL.
|
+ } |
+} |
+ |
+SyntheticGestureParams::GestureSourceType |
+SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { |
+ return SyntheticGestureParams::TOUCH_INPUT; |
sadrul
2013/11/04 19:26:42
I am not so sure if TOUCH_ is the default for aura
kouhei (in TOK)
2013/11/05 01:32:26
Ack. I'll fix this in new CL once I have aura-nati
sadrul
2013/11/05 17:53:25
OK. Please add a TODO (and reference the bug# if t
kouhei (in TOK)
2013/11/06 03:24:22
Done.
|
+} |
+ |
+bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType( |
+ SyntheticGestureParams::GestureSourceType gesture_source_type) const { |
+ return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT |
sadrul
2013/11/04 19:26:42
|| at the end of the first line
kouhei (in TOK)
2013/11/05 01:32:26
Done.
|
+ || gesture_source_type == SyntheticGestureParams::MOUSE_INPUT; |
+} |
+ |
+} // namespace content |