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_view_aura.h" | |
8 #include "content/browser/renderer_host/ui_events_helper.h" | |
9 #include "content/common/input/input_event.h" | |
10 #include "ui/aura/root_window.h" | |
11 #include "ui/aura/window.h" | |
12 | |
13 using WebKit::WebTouchEvent; | |
14 using WebKit::WebMouseWheelEvent; | |
15 | |
16 namespace content { | |
17 | |
18 SyntheticGestureTargetAura::SyntheticGestureTargetAura( | |
19 RenderWidgetHostViewAura* render_view) | |
20 : SyntheticGestureTargetBase(render_view) { | |
21 } | |
22 | |
23 void SyntheticGestureTargetAura::QueueWebTouchEventToPlatform( | |
24 const WebTouchEvent& web_touch, | |
25 const ui::LatencyInfo& latency_info) { | |
26 aura::Window* window = render_view_aura()->GetNativeView(); | |
27 aura::RootWindow* root_window = | |
28 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.
| |
29 if (!root_window) | |
30 return; | |
31 | |
32 aura::RootWindowHostDelegate* root_window_host_delegate = | |
33 root_window->AsRootWindowHostDelegate(); | |
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 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.
| |
40 for (unsigned 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 aura::Window::ConvertPointToTarget(window, root_window, &position); | |
44 root_window->ConvertPointToHost(&position); | |
45 point->screenPosition.x = position.x(); | |
46 point->screenPosition.y = position.y(); | |
47 } | |
48 | |
49 ScopedVector<ui::TouchEvent> events; | |
50 if (!MakeUITouchEventsFromWebTouchEvents(touch_with_latency, &events, | |
51 SCREEN_COORDINATES)) | |
52 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.
| |
53 | |
54 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), | |
55 end = events.end(); iter != end; ++iter) { | |
56 root_window_host_delegate->OnHostTouchEvent(*iter); | |
57 } | |
58 } | |
59 | |
60 SyntheticGestureParams::GestureSourceType | |
61 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { | |
62 return SyntheticGestureParams::TOUCH_INPUT; | |
63 } | |
64 | |
65 bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType( | |
66 SyntheticGestureParams::GestureSourceType gesture_source_type) const { | |
67 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT | |
68 || gesture_source_type == SyntheticGestureParams::MOUSE_INPUT; | |
69 } | |
70 | |
71 } // namespace content | |
OLD | NEW |