OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" | 5 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" |
6 | 6 |
7 #include "content/browser/renderer_host/render_widget_host_impl.h" | 7 #include "content/browser/renderer_host/render_widget_host_impl.h" |
8 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 8 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
9 #include "content/browser/renderer_host/ui_events_helper.h" | 9 #include "content/browser/renderer_host/ui_events_helper.h" |
10 #include "content/common/input/input_event.h" | 10 #include "content/common/input/input_event.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 position_client->ConvertPointToScreen(window, &position); | 41 position_client->ConvertPointToScreen(window, &position); |
42 point->screenPosition.x = position.x(); | 42 point->screenPosition.x = position.x(); |
43 point->screenPosition.y = position.y(); | 43 point->screenPosition.y = position.y(); |
44 } | 44 } |
45 | 45 |
46 ScopedVector<ui::TouchEvent> events; | 46 ScopedVector<ui::TouchEvent> events; |
47 bool conversion_success = MakeUITouchEventsFromWebTouchEvents( | 47 bool conversion_success = MakeUITouchEventsFromWebTouchEvents( |
48 touch_with_latency, &events, SCREEN_COORDINATES); | 48 touch_with_latency, &events, SCREEN_COORDINATES); |
49 DCHECK(conversion_success); | 49 DCHECK(conversion_success); |
50 | 50 |
51 aura::RootWindowHostDelegate* root_window_host_delegate = | 51 aura::WindowTreeHostDelegate* root_window_host_delegate = |
52 GetRootWindowHostDelegate(); | 52 GetWindowTreeHostDelegate(); |
53 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), | 53 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), |
54 end = events.end(); iter != end; ++iter) { | 54 end = events.end(); iter != end; ++iter) { |
55 root_window_host_delegate->OnHostTouchEvent(*iter); | 55 root_window_host_delegate->OnHostTouchEvent(*iter); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( | 59 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( |
60 const blink::WebMouseWheelEvent& web_wheel, | 60 const blink::WebMouseWheelEvent& web_wheel, |
61 const ui::LatencyInfo&) { | 61 const ui::LatencyInfo&) { |
62 aura::Window* window = GetWindow(); | 62 aura::Window* window = GetWindow(); |
63 aura::client::ScreenPositionClient* position_client = | 63 aura::client::ScreenPositionClient* position_client = |
64 GetScreenPositionClient(); | 64 GetScreenPositionClient(); |
65 gfx::Point location(web_wheel.x, web_wheel.y); | 65 gfx::Point location(web_wheel.x, web_wheel.y); |
66 position_client->ConvertPointToScreen(window, &location); | 66 position_client->ConvertPointToScreen(window, &location); |
67 | 67 |
68 ui::MouseEvent mouse_event( | 68 ui::MouseEvent mouse_event( |
69 ui::ET_MOUSEWHEEL, location, location, ui::EF_NONE, ui::EF_NONE); | 69 ui::ET_MOUSEWHEEL, location, location, ui::EF_NONE, ui::EF_NONE); |
70 ui::MouseWheelEvent wheel_event( | 70 ui::MouseWheelEvent wheel_event( |
71 mouse_event, web_wheel.deltaX, web_wheel.deltaY); | 71 mouse_event, web_wheel.deltaX, web_wheel.deltaY); |
72 | 72 |
73 GetRootWindowHostDelegate()->OnHostMouseEvent(&wheel_event); | 73 GetWindowTreeHostDelegate()->OnHostMouseEvent(&wheel_event); |
74 } | 74 } |
75 | 75 |
76 namespace { | 76 namespace { |
77 | 77 |
78 ui::EventType | 78 ui::EventType |
79 WebMouseEventTypeToEventType(blink::WebInputEvent::Type web_type) { | 79 WebMouseEventTypeToEventType(blink::WebInputEvent::Type web_type) { |
80 switch (web_type) { | 80 switch (web_type) { |
81 case blink::WebInputEvent::MouseDown: | 81 case blink::WebInputEvent::MouseDown: |
82 return ui::ET_MOUSE_PRESSED; | 82 return ui::ET_MOUSE_PRESSED; |
83 | 83 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 aura::Window* window = GetWindow(); | 130 aura::Window* window = GetWindow(); |
131 aura::client::ScreenPositionClient* position_client = | 131 aura::client::ScreenPositionClient* position_client = |
132 GetScreenPositionClient(); | 132 GetScreenPositionClient(); |
133 gfx::Point location(web_mouse.x, web_mouse.y); | 133 gfx::Point location(web_mouse.x, web_mouse.y); |
134 position_client->ConvertPointToScreen(window, &location); | 134 position_client->ConvertPointToScreen(window, &location); |
135 | 135 |
136 ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type); | 136 ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type); |
137 int flags = WebMouseEventButtonToFlags(web_mouse.button); | 137 int flags = WebMouseEventButtonToFlags(web_mouse.button); |
138 ui::MouseEvent mouse_event(event_type, location, location, flags, flags); | 138 ui::MouseEvent mouse_event(event_type, location, location, flags, flags); |
139 | 139 |
140 GetRootWindowHostDelegate()->OnHostMouseEvent(&mouse_event); | 140 GetWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_event); |
141 } | 141 } |
142 | 142 |
143 SyntheticGestureParams::GestureSourceType | 143 SyntheticGestureParams::GestureSourceType |
144 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { | 144 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { |
145 return SyntheticGestureParams::MOUSE_INPUT; | 145 return SyntheticGestureParams::MOUSE_INPUT; |
146 } | 146 } |
147 | 147 |
148 bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType( | 148 bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType( |
149 SyntheticGestureParams::GestureSourceType gesture_source_type) const { | 149 SyntheticGestureParams::GestureSourceType gesture_source_type) const { |
150 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT || | 150 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT || |
151 gesture_source_type == SyntheticGestureParams::MOUSE_INPUT; | 151 gesture_source_type == SyntheticGestureParams::MOUSE_INPUT; |
152 } | 152 } |
153 | 153 |
154 int SyntheticGestureTargetAura::GetTouchSlopInDips() const { | 154 int SyntheticGestureTargetAura::GetTouchSlopInDips() const { |
155 // - 1 because Aura considers a pointer to be moving if it has moved at least | 155 // - 1 because Aura considers a pointer to be moving if it has moved at least |
156 // 'max_touch_move_in_pixels_for_click' pixels. | 156 // 'max_touch_move_in_pixels_for_click' pixels. |
157 return ui::GestureConfiguration::max_touch_move_in_pixels_for_click() - 1; | 157 return ui::GestureConfiguration::max_touch_move_in_pixels_for_click() - 1; |
158 } | 158 } |
159 | 159 |
160 aura::Window* SyntheticGestureTargetAura::GetWindow() const { | 160 aura::Window* SyntheticGestureTargetAura::GetWindow() const { |
161 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); | 161 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); |
162 DCHECK(window); | 162 DCHECK(window); |
163 return window; | 163 return window; |
164 } | 164 } |
165 | 165 |
166 aura::RootWindowHostDelegate* | 166 aura::WindowTreeHostDelegate* |
167 SyntheticGestureTargetAura::GetRootWindowHostDelegate() const { | 167 SyntheticGestureTargetAura::GetWindowTreeHostDelegate() const { |
168 aura::Window* root_window = GetWindow()->GetRootWindow(); | 168 aura::Window* root_window = GetWindow()->GetRootWindow(); |
169 aura::RootWindowHostDelegate* root_window_host_delegate = | 169 aura::WindowTreeHostDelegate* root_window_host_delegate = |
170 root_window->GetDispatcher()->AsRootWindowHostDelegate(); | 170 root_window->GetDispatcher()->AsWindowTreeHostDelegate(); |
171 DCHECK(root_window_host_delegate); | 171 DCHECK(root_window_host_delegate); |
172 return root_window_host_delegate; | 172 return root_window_host_delegate; |
173 } | 173 } |
174 | 174 |
175 aura::client::ScreenPositionClient* | 175 aura::client::ScreenPositionClient* |
176 SyntheticGestureTargetAura::GetScreenPositionClient() const { | 176 SyntheticGestureTargetAura::GetScreenPositionClient() const { |
177 aura::Window* root_window = GetWindow()->GetRootWindow(); | 177 aura::Window* root_window = GetWindow()->GetRootWindow(); |
178 aura::client::ScreenPositionClient* position_client = | 178 aura::client::ScreenPositionClient* position_client = |
179 aura::client::GetScreenPositionClient(root_window); | 179 aura::client::GetScreenPositionClient(root_window); |
180 DCHECK(position_client); | 180 DCHECK(position_client); |
181 return position_client; | 181 return position_client; |
182 } | 182 } |
183 | 183 |
184 } // namespace content | 184 } // namespace content |
OLD | NEW |