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..dbdf7c6e3e43c4cdfc5b4e9f91a8c3e8bfd5c0a2 |
--- /dev/null |
+++ b/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc |
@@ -0,0 +1,94 @@ |
+// 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::WebInputEvent; |
+using WebKit::WebTouchEvent; |
+ |
+namespace content { |
+ |
+namespace { |
+ |
+// How many milliseconds apart synthetic scroll messages should be sent. |
+const int kSyntheticGestureMessageIntervalMs = 7; |
+ |
+} // namespace |
+ |
+SyntheticGestureTargetAura::SyntheticGestureTargetAura( |
+ RenderWidgetHostViewAura* render_view) |
+ : render_view_(render_view) { |
+} |
+ |
+void SyntheticGestureTargetAura::QueueInputEventToPlatform( |
+ const InputEvent& event) { |
+ aura::Window* window = render_view_->GetNativeView(); |
+ aura::RootWindow* root_window = window->GetRootWindow(); |
+ if (!root_window) |
+ return; |
+ |
+ aura::RootWindowHostDelegate* root_window_host_delegate = |
+ root_window->AsRootWindowHostDelegate(); |
+ |
+ const WebInputEvent* web_event = event.web_event.get(); |
+ if (WebInputEvent::isTouchEventType(web_event->type)) { |
+ ScopedVector<ui::TouchEvent> events; |
+ |
+ const WebTouchEvent* web_touch = |
+ static_cast<const WebTouchEvent*>(web_event); |
+ |
+ TouchEventWithLatencyInfo touch_with_latency( |
+ *web_touch, event.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; |
+ 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(); |
+ } |
+ |
+ if (!MakeUITouchEventsFromWebTouchEvents(touch_with_latency, &events, |
+ SCREEN_COORDINATES)) |
+ return; |
+ |
+ for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), |
+ end = events.end(); iter != end; ++iter) { |
+ root_window_host_delegate->OnHostTouchEvent(*iter); |
+ } |
+ } else |
+ NOTREACHED(); // FIXME: implement other types (MouseWheel?) |
+} |
+ |
+void SyntheticGestureTargetAura::OnSyntheticGestureCompleted( |
+ SyntheticGestureNew::Result result) { |
+} |
+ |
+base::TimeDelta |
+SyntheticGestureTargetAura::GetSyntheticGestureUpdateRate() const { |
+ return base::TimeDelta::FromMilliseconds(kSyntheticGestureMessageIntervalMs); |
+} |
+ |
+SyntheticGestureParams::GestureSourceType |
+SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { |
+ return SyntheticGestureParams::TOUCH_INPUT; |
+} |
+ |
+bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType( |
+ SyntheticGestureParams::GestureSourceType gesture_source_type) const { |
+ // FIXME: add support for mouse |
+ return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT; |
+} |
+ |
+} // namespace content |