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 <memory> |
| 10 #include <vector> |
| 11 |
9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 12 #include "content/browser/renderer_host/render_widget_host_impl.h" |
10 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 13 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
11 #include "content/browser/renderer_host/ui_events_helper.h" | 14 #include "content/browser/renderer_host/ui_events_helper.h" |
12 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
13 #include "ui/aura/window_tree_host.h" | 16 #include "ui/aura/window_tree_host.h" |
14 #include "ui/events/event_processor.h" | 17 #include "ui/events/event_processor.h" |
15 #include "ui/events/event_utils.h" | 18 #include "ui/events/event_utils.h" |
16 #include "ui/events/gesture_detection/gesture_configuration.h" | 19 #include "ui/events/gesture_detection/gesture_configuration.h" |
17 | 20 |
18 using blink::WebTouchEvent; | 21 using blink::WebTouchEvent; |
(...skipping 10 matching lines...) Expand all Loading... |
29 } | 32 } |
30 | 33 |
31 void SyntheticGestureTargetAura::DispatchWebTouchEventToPlatform( | 34 void SyntheticGestureTargetAura::DispatchWebTouchEventToPlatform( |
32 const WebTouchEvent& web_touch, | 35 const WebTouchEvent& web_touch, |
33 const ui::LatencyInfo& latency_info) { | 36 const ui::LatencyInfo& latency_info) { |
34 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info); | 37 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info); |
35 for (size_t i = 0; i < touch_with_latency.event.touchesLength; i++) { | 38 for (size_t i = 0; i < touch_with_latency.event.touchesLength; i++) { |
36 touch_with_latency.event.touches[i].radiusX *= device_scale_factor_; | 39 touch_with_latency.event.touches[i].radiusX *= device_scale_factor_; |
37 touch_with_latency.event.touches[i].radiusY *= device_scale_factor_; | 40 touch_with_latency.event.touches[i].radiusY *= device_scale_factor_; |
38 } | 41 } |
39 ScopedVector<ui::TouchEvent> events; | 42 std::vector<std::unique_ptr<ui::TouchEvent>> events; |
40 bool conversion_success = MakeUITouchEventsFromWebTouchEvents( | 43 bool conversion_success = MakeUITouchEventsFromWebTouchEvents( |
41 touch_with_latency, &events, LOCAL_COORDINATES); | 44 touch_with_latency, &events, LOCAL_COORDINATES); |
42 DCHECK(conversion_success); | 45 DCHECK(conversion_success); |
43 | 46 |
44 aura::Window* window = GetWindow(); | 47 aura::Window* window = GetWindow(); |
45 aura::WindowTreeHost* host = window->GetHost(); | 48 aura::WindowTreeHost* host = window->GetHost(); |
46 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), | 49 for (const auto& event : events) { |
47 end = events.end(); iter != end; ++iter) { | 50 event->ConvertLocationToTarget(window, host->window()); |
48 (*iter)->ConvertLocationToTarget(window, host->window()); | |
49 | 51 |
50 // Apply the screen scale factor to the event location after it has been | 52 // Apply the screen scale factor to the event location after it has been |
51 // transformed to the target. | 53 // transformed to the target. |
52 gfx::PointF device_location = | 54 gfx::PointF device_location = |
53 gfx::ScalePoint((*iter)->location_f(), device_scale_factor_); | 55 gfx::ScalePoint(event->location_f(), device_scale_factor_); |
54 gfx::PointF device_root_location = | 56 gfx::PointF device_root_location = |
55 gfx::ScalePoint((*iter)->root_location_f(), device_scale_factor_); | 57 gfx::ScalePoint(event->root_location_f(), device_scale_factor_); |
56 (*iter)->set_location_f(device_location); | 58 event->set_location_f(device_location); |
57 (*iter)->set_root_location_f(device_root_location); | 59 event->set_root_location_f(device_root_location); |
58 ui::EventDispatchDetails details = | 60 ui::EventDispatchDetails details = |
59 host->event_processor()->OnEventFromSource(*iter); | 61 host->event_processor()->OnEventFromSource(event.get()); |
60 if (details.dispatcher_destroyed) | 62 if (details.dispatcher_destroyed) |
61 break; | 63 break; |
62 } | 64 } |
63 } | 65 } |
64 | 66 |
65 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( | 67 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( |
66 const blink::WebMouseWheelEvent& web_wheel, | 68 const blink::WebMouseWheelEvent& web_wheel, |
67 const ui::LatencyInfo&) { | 69 const ui::LatencyInfo&) { |
68 ui::MouseWheelEvent wheel_event( | 70 ui::MouseWheelEvent wheel_event( |
69 gfx::Vector2d(web_wheel.deltaX, web_wheel.deltaY), gfx::Point(), | 71 gfx::Vector2d(web_wheel.deltaX, web_wheel.deltaY), gfx::Point(), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 ->min_distance_for_pinch_scroll_in_pixels(); | 182 ->min_distance_for_pinch_scroll_in_pixels(); |
181 } | 183 } |
182 | 184 |
183 aura::Window* SyntheticGestureTargetAura::GetWindow() const { | 185 aura::Window* SyntheticGestureTargetAura::GetWindow() const { |
184 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); | 186 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); |
185 DCHECK(window); | 187 DCHECK(window); |
186 return window; | 188 return window; |
187 } | 189 } |
188 | 190 |
189 } // namespace content | 191 } // namespace content |
OLD | NEW |