OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" |
| 6 |
| 7 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 9 #include "content/browser/renderer_host/ui_events_helper.h" |
| 10 #include "content/common/input/input_event.h" |
| 11 #include "ui/aura/client/screen_position_client.h" |
| 12 #include "ui/aura/root_window.h" |
| 13 #include "ui/aura/window.h" |
| 14 |
| 15 using WebKit::WebTouchEvent; |
| 16 using WebKit::WebMouseWheelEvent; |
| 17 |
| 18 namespace content { |
| 19 |
| 20 SyntheticGestureTargetAura::SyntheticGestureTargetAura( |
| 21 RenderWidgetHostImpl* host) |
| 22 : SyntheticGestureTargetBase(host) { |
| 23 } |
| 24 |
| 25 void SyntheticGestureTargetAura::QueueWebTouchEventToPlatform( |
| 26 const WebTouchEvent& web_touch, |
| 27 const ui::LatencyInfo& latency_info) { |
| 28 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); |
| 29 aura::RootWindow* root_window = |
| 30 static_cast<aura::RootWindow*>(window->GetRootWindow()); |
| 31 aura::client::ScreenPositionClient* position_client = |
| 32 aura::client::GetScreenPositionClient(root_window); |
| 33 DCHECK(position_client); |
| 34 |
| 35 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info); |
| 36 |
| 37 // SyntheticGesture may skip calculating screenPosition, so we will fill it |
| 38 // in here. "screenPosition" is converted from "position". |
| 39 const size_t num_touches = touch_with_latency.event.touchesLength; |
| 40 for (size_t i = 0; i < num_touches; ++ i) { |
| 41 WebKit::WebTouchPoint* point = &touch_with_latency.event.touches[i]; |
| 42 gfx::Point position(point->position.x, point->position.y); |
| 43 position_client->ConvertPointToScreen(window, &position); |
| 44 point->screenPosition.x = position.x(); |
| 45 point->screenPosition.y = position.y(); |
| 46 } |
| 47 |
| 48 ScopedVector<ui::TouchEvent> events; |
| 49 bool conversion_success = MakeUITouchEventsFromWebTouchEvents( |
| 50 touch_with_latency, &events, SCREEN_COORDINATES); |
| 51 DCHECK(conversion_success); |
| 52 |
| 53 aura::RootWindowHostDelegate* root_window_host_delegate = |
| 54 root_window->AsRootWindowHostDelegate(); |
| 55 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), |
| 56 end = events.end(); iter != end; ++iter) { |
| 57 root_window_host_delegate->OnHostTouchEvent(*iter); |
| 58 } |
| 59 } |
| 60 |
| 61 SyntheticGestureParams::GestureSourceType |
| 62 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { |
| 63 return SyntheticGestureParams::TOUCH_INPUT; |
| 64 } |
| 65 |
| 66 bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType( |
| 67 SyntheticGestureParams::GestureSourceType gesture_source_type) const { |
| 68 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT || |
| 69 gesture_source_type == SyntheticGestureParams::MOUSE_INPUT; |
| 70 } |
| 71 |
| 72 } // namespace content |
OLD | NEW |