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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
10 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 10 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
11 #include "content/browser/renderer_host/ui_events_helper.h" | 11 #include "content/browser/renderer_host/ui_events_helper.h" |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/aura/window_tree_host.h" | 13 #include "ui/aura/window_tree_host.h" |
14 #include "ui/events/event_processor.h" | 14 #include "ui/events/event_processor.h" |
15 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
16 #include "ui/events/gesture_detection/gesture_configuration.h" | 16 #include "ui/events/gesture_detection/gesture_configuration.h" |
17 | 17 |
18 using blink::WebTouchEvent; | 18 using blink::WebTouchEvent; |
19 using blink::WebMouseWheelEvent; | 19 using blink::WebMouseWheelEvent; |
20 using blink::WebGestureEvent; | |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 SyntheticGestureTargetAura::SyntheticGestureTargetAura( | 24 SyntheticGestureTargetAura::SyntheticGestureTargetAura( |
24 RenderWidgetHostImpl* host) | 25 RenderWidgetHostImpl* host) |
25 : SyntheticGestureTargetBase(host) { | 26 : SyntheticGestureTargetBase(host) { |
26 ScreenInfo screen_info; | 27 ScreenInfo screen_info; |
27 host->GetScreenInfo(&screen_info); | 28 host->GetScreenInfo(&screen_info); |
28 device_scale_factor_ = screen_info.device_scale_factor; | 29 device_scale_factor_ = screen_info.device_scale_factor; |
29 } | 30 } |
(...skipping 28 matching lines...) Expand all Loading... | |
58 ui::EventDispatchDetails details = | 59 ui::EventDispatchDetails details = |
59 host->event_processor()->OnEventFromSource(*iter); | 60 host->event_processor()->OnEventFromSource(*iter); |
60 if (details.dispatcher_destroyed) | 61 if (details.dispatcher_destroyed) |
61 break; | 62 break; |
62 } | 63 } |
63 } | 64 } |
64 | 65 |
65 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( | 66 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( |
66 const blink::WebMouseWheelEvent& web_wheel, | 67 const blink::WebMouseWheelEvent& web_wheel, |
67 const ui::LatencyInfo&) { | 68 const ui::LatencyInfo&) { |
69 base::TimeTicks timestamp = | |
70 ui::EventTimeStampFromSeconds(web_wheel.timeStampSeconds()); | |
68 ui::MouseWheelEvent wheel_event( | 71 ui::MouseWheelEvent wheel_event( |
69 gfx::Vector2d(web_wheel.deltaX, web_wheel.deltaY), gfx::Point(), | 72 gfx::Vector2d(web_wheel.deltaX, web_wheel.deltaY), gfx::Point(), |
70 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 73 gfx::Point(), timestamp, ui::EF_NONE, ui::EF_NONE); |
bokan
2017/03/10 14:41:57
Is this change related?
sahel
2017/03/10 21:51:41
Yes, it is. It used to use eventTimeForNow instead
bokan
2017/03/13 13:43:13
Acknowledged.
| |
71 gfx::PointF location(web_wheel.x * device_scale_factor_, | 74 gfx::PointF location(web_wheel.x * device_scale_factor_, |
72 web_wheel.y * device_scale_factor_); | 75 web_wheel.y * device_scale_factor_); |
73 wheel_event.set_location_f(location); | 76 wheel_event.set_location_f(location); |
74 wheel_event.set_root_location_f(location); | 77 wheel_event.set_root_location_f(location); |
75 | 78 |
76 aura::Window* window = GetWindow(); | 79 aura::Window* window = GetWindow(); |
77 wheel_event.ConvertLocationToTarget(window, window->GetRootWindow()); | 80 wheel_event.ConvertLocationToTarget(window, window->GetRootWindow()); |
78 ui::EventDispatchDetails details = | 81 ui::EventDispatchDetails details = |
79 window->GetHost()->event_processor()->OnEventFromSource(&wheel_event); | 82 window->GetHost()->event_processor()->OnEventFromSource(&wheel_event); |
80 if (details.dispatcher_destroyed) | 83 if (details.dispatcher_destroyed) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 mouse_event.set_pointer_details(pointer_details); | 158 mouse_event.set_pointer_details(pointer_details); |
156 | 159 |
157 aura::Window* window = GetWindow(); | 160 aura::Window* window = GetWindow(); |
158 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow()); | 161 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow()); |
159 ui::EventDispatchDetails details = | 162 ui::EventDispatchDetails details = |
160 window->GetHost()->event_processor()->OnEventFromSource(&mouse_event); | 163 window->GetHost()->event_processor()->OnEventFromSource(&mouse_event); |
161 if (details.dispatcher_destroyed) | 164 if (details.dispatcher_destroyed) |
162 return; | 165 return; |
163 } | 166 } |
164 | 167 |
168 void SyntheticGestureTargetAura::DispatchTouchpadGestureFlingStartToPlatform( | |
169 const blink::WebGestureEvent& web_gesture, | |
170 const ui::LatencyInfo& latency_info) { | |
171 DCHECK_EQ(web_gesture.type(), blink::WebInputEvent::GestureFlingStart); | |
172 | |
173 if (web_gesture.type() != blink::WebInputEvent::GestureFlingStart) | |
bokan
2017/03/10 14:41:57
The style guide prohibits handing a failed DCHECK:
sahel
2017/03/10 21:51:41
Done.
| |
174 return; | |
175 | |
176 float velocity_x = web_gesture.data.flingStart.velocityX; | |
177 float velocity_y = web_gesture.data.flingStart.velocityY; | |
178 DCHECK(velocity_x || velocity_y); | |
179 | |
180 if (!velocity_x && !velocity_y) | |
181 return; | |
182 | |
183 base::TimeTicks timestamp = | |
184 ui::EventTimeStampFromSeconds(web_gesture.timeStampSeconds()); | |
185 ui::ScrollEvent fling_event(ui::ET_SCROLL_FLING_START, gfx::Point(), | |
186 timestamp, ui::EF_NONE, velocity_x, velocity_y, | |
187 velocity_x, velocity_y, | |
188 2); // finger_count | |
189 gfx::PointF location(web_gesture.x * device_scale_factor_, | |
190 web_gesture.y * device_scale_factor_); | |
191 fling_event.set_location_f(location); | |
192 fling_event.set_root_location_f(location); | |
193 | |
194 aura::Window* window = GetWindow(); | |
195 fling_event.ConvertLocationToTarget(window, window->GetRootWindow()); | |
196 ui::EventDispatchDetails details = | |
197 window->GetHost()->event_processor()->OnEventFromSource(&fling_event); | |
198 if (details.dispatcher_destroyed) | |
199 return; | |
200 } | |
201 | |
165 SyntheticGestureParams::GestureSourceType | 202 SyntheticGestureParams::GestureSourceType |
166 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { | 203 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { |
167 return SyntheticGestureParams::TOUCH_INPUT; | 204 return SyntheticGestureParams::TOUCH_INPUT; |
168 } | 205 } |
169 | 206 |
170 float SyntheticGestureTargetAura::GetTouchSlopInDips() const { | 207 float SyntheticGestureTargetAura::GetTouchSlopInDips() const { |
171 // - 1 because Aura considers a pointer to be moving if it has moved at least | 208 // - 1 because Aura considers a pointer to be moving if it has moved at least |
172 // 'max_touch_move_in_pixels_for_click' pixels. | 209 // 'max_touch_move_in_pixels_for_click' pixels. |
173 return ui::GestureConfiguration::GetInstance() | 210 return ui::GestureConfiguration::GetInstance() |
174 ->max_touch_move_in_pixels_for_click() - | 211 ->max_touch_move_in_pixels_for_click() - |
175 1; | 212 1; |
176 } | 213 } |
177 | 214 |
178 float SyntheticGestureTargetAura::GetMinScalingSpanInDips() const { | 215 float SyntheticGestureTargetAura::GetMinScalingSpanInDips() const { |
179 return ui::GestureConfiguration::GetInstance() | 216 return ui::GestureConfiguration::GetInstance() |
180 ->min_distance_for_pinch_scroll_in_pixels(); | 217 ->min_distance_for_pinch_scroll_in_pixels(); |
181 } | 218 } |
182 | 219 |
183 aura::Window* SyntheticGestureTargetAura::GetWindow() const { | 220 aura::Window* SyntheticGestureTargetAura::GetWindow() const { |
184 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); | 221 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); |
185 DCHECK(window); | 222 DCHECK(window); |
186 return window; | 223 return window; |
187 } | 224 } |
188 | 225 |
189 } // namespace content | 226 } // namespace content |
OLD | NEW |