| 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> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "content/browser/renderer_host/render_widget_host_impl.h" | 12 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 13 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 14 #include "content/browser/renderer_host/ui_events_helper.h" | 14 #include "content/browser/renderer_host/ui_events_helper.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_tree_host.h" | 16 #include "ui/aura/window_tree_host.h" |
| 17 #include "ui/events/event_processor.h" | 17 #include "ui/events/event_sink.h" |
| 18 #include "ui/events/event_utils.h" | 18 #include "ui/events/event_utils.h" |
| 19 #include "ui/events/gesture_detection/gesture_configuration.h" | 19 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 20 | 20 |
| 21 using blink::WebTouchEvent; | 21 using blink::WebTouchEvent; |
| 22 using blink::WebMouseWheelEvent; | 22 using blink::WebMouseWheelEvent; |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 SyntheticGestureTargetAura::SyntheticGestureTargetAura( | 26 SyntheticGestureTargetAura::SyntheticGestureTargetAura( |
| 27 RenderWidgetHostImpl* host) | 27 RenderWidgetHostImpl* host) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 51 | 51 |
| 52 // 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 |
| 53 // transformed to the target. | 53 // transformed to the target. |
| 54 gfx::PointF device_location = | 54 gfx::PointF device_location = |
| 55 gfx::ScalePoint(event->location_f(), device_scale_factor_); | 55 gfx::ScalePoint(event->location_f(), device_scale_factor_); |
| 56 gfx::PointF device_root_location = | 56 gfx::PointF device_root_location = |
| 57 gfx::ScalePoint(event->root_location_f(), device_scale_factor_); | 57 gfx::ScalePoint(event->root_location_f(), device_scale_factor_); |
| 58 event->set_location_f(device_location); | 58 event->set_location_f(device_location); |
| 59 event->set_root_location_f(device_root_location); | 59 event->set_root_location_f(device_root_location); |
| 60 ui::EventDispatchDetails details = | 60 ui::EventDispatchDetails details = |
| 61 host->event_processor()->OnEventFromSource(event.get()); | 61 host->event_sink()->OnEventFromSource(event.get()); |
| 62 if (details.dispatcher_destroyed) | 62 if (details.dispatcher_destroyed) |
| 63 break; | 63 break; |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( | 67 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( |
| 68 const blink::WebMouseWheelEvent& web_wheel, | 68 const blink::WebMouseWheelEvent& web_wheel, |
| 69 const ui::LatencyInfo&) { | 69 const ui::LatencyInfo&) { |
| 70 ui::MouseWheelEvent wheel_event( | 70 ui::MouseWheelEvent wheel_event( |
| 71 gfx::Vector2d(web_wheel.deltaX, web_wheel.deltaY), gfx::Point(), | 71 gfx::Vector2d(web_wheel.deltaX, web_wheel.deltaY), gfx::Point(), |
| 72 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 72 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 73 gfx::PointF location(web_wheel.x * device_scale_factor_, | 73 gfx::PointF location(web_wheel.x * device_scale_factor_, |
| 74 web_wheel.y * device_scale_factor_); | 74 web_wheel.y * device_scale_factor_); |
| 75 wheel_event.set_location_f(location); | 75 wheel_event.set_location_f(location); |
| 76 wheel_event.set_root_location_f(location); | 76 wheel_event.set_root_location_f(location); |
| 77 | 77 |
| 78 aura::Window* window = GetWindow(); | 78 aura::Window* window = GetWindow(); |
| 79 wheel_event.ConvertLocationToTarget(window, window->GetRootWindow()); | 79 wheel_event.ConvertLocationToTarget(window, window->GetRootWindow()); |
| 80 ui::EventDispatchDetails details = | 80 ui::EventDispatchDetails details = |
| 81 window->GetHost()->event_processor()->OnEventFromSource(&wheel_event); | 81 window->GetHost()->event_sink()->OnEventFromSource(&wheel_event); |
| 82 if (details.dispatcher_destroyed) | 82 if (details.dispatcher_destroyed) |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 | 85 |
| 86 namespace { | 86 namespace { |
| 87 | 87 |
| 88 ui::EventType | 88 ui::EventType |
| 89 WebMouseEventTypeToEventType(blink::WebInputEvent::Type web_type) { | 89 WebMouseEventTypeToEventType(blink::WebInputEvent::Type web_type) { |
| 90 switch (web_type) { | 90 switch (web_type) { |
| 91 case blink::WebInputEvent::MouseDown: | 91 case blink::WebInputEvent::MouseDown: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 mouse_event.set_location_f(location); | 152 mouse_event.set_location_f(location); |
| 153 mouse_event.set_root_location_f(location); | 153 mouse_event.set_root_location_f(location); |
| 154 ui::PointerDetails pointer_details = mouse_event.pointer_details(); | 154 ui::PointerDetails pointer_details = mouse_event.pointer_details(); |
| 155 pointer_details.pointer_type = | 155 pointer_details.pointer_type = |
| 156 WebMousePointerTypeToEventPointerType(web_mouse_event.pointerType); | 156 WebMousePointerTypeToEventPointerType(web_mouse_event.pointerType); |
| 157 mouse_event.set_pointer_details(pointer_details); | 157 mouse_event.set_pointer_details(pointer_details); |
| 158 | 158 |
| 159 aura::Window* window = GetWindow(); | 159 aura::Window* window = GetWindow(); |
| 160 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow()); | 160 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow()); |
| 161 ui::EventDispatchDetails details = | 161 ui::EventDispatchDetails details = |
| 162 window->GetHost()->event_processor()->OnEventFromSource(&mouse_event); | 162 window->GetHost()->event_sink()->OnEventFromSource(&mouse_event); |
| 163 if (details.dispatcher_destroyed) | 163 if (details.dispatcher_destroyed) |
| 164 return; | 164 return; |
| 165 } | 165 } |
| 166 | 166 |
| 167 SyntheticGestureParams::GestureSourceType | 167 SyntheticGestureParams::GestureSourceType |
| 168 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { | 168 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { |
| 169 return SyntheticGestureParams::TOUCH_INPUT; | 169 return SyntheticGestureParams::TOUCH_INPUT; |
| 170 } | 170 } |
| 171 | 171 |
| 172 float SyntheticGestureTargetAura::GetTouchSlopInDips() const { | 172 float SyntheticGestureTargetAura::GetTouchSlopInDips() const { |
| 173 // - 1 because Aura considers a pointer to be moving if it has moved at least | 173 // - 1 because Aura considers a pointer to be moving if it has moved at least |
| 174 // 'max_touch_move_in_pixels_for_click' pixels. | 174 // 'max_touch_move_in_pixels_for_click' pixels. |
| 175 return ui::GestureConfiguration::GetInstance() | 175 return ui::GestureConfiguration::GetInstance() |
| 176 ->max_touch_move_in_pixels_for_click() - | 176 ->max_touch_move_in_pixels_for_click() - |
| 177 1; | 177 1; |
| 178 } | 178 } |
| 179 | 179 |
| 180 float SyntheticGestureTargetAura::GetMinScalingSpanInDips() const { | 180 float SyntheticGestureTargetAura::GetMinScalingSpanInDips() const { |
| 181 return ui::GestureConfiguration::GetInstance() | 181 return ui::GestureConfiguration::GetInstance() |
| 182 ->min_distance_for_pinch_scroll_in_pixels(); | 182 ->min_distance_for_pinch_scroll_in_pixels(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 aura::Window* SyntheticGestureTargetAura::GetWindow() const { | 185 aura::Window* SyntheticGestureTargetAura::GetWindow() const { |
| 186 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); | 186 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); |
| 187 DCHECK(window); | 187 DCHECK(window); |
| 188 return window; | 188 return window; |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace content | 191 } // namespace content |
| OLD | NEW |