Chromium Code Reviews| 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" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 if (modifiers & blink::WebInputEvent::LeftButtonDown) | 118 if (modifiers & blink::WebInputEvent::LeftButtonDown) |
| 119 flags |= ui::EF_LEFT_MOUSE_BUTTON; | 119 flags |= ui::EF_LEFT_MOUSE_BUTTON; |
| 120 if (modifiers & blink::WebInputEvent::MiddleButtonDown) | 120 if (modifiers & blink::WebInputEvent::MiddleButtonDown) |
| 121 flags |= ui::EF_MIDDLE_MOUSE_BUTTON; | 121 flags |= ui::EF_MIDDLE_MOUSE_BUTTON; |
| 122 if (modifiers & blink::WebInputEvent::RightButtonDown) | 122 if (modifiers & blink::WebInputEvent::RightButtonDown) |
| 123 flags |= ui::EF_RIGHT_MOUSE_BUTTON; | 123 flags |= ui::EF_RIGHT_MOUSE_BUTTON; |
| 124 | 124 |
| 125 return flags; | 125 return flags; |
| 126 } | 126 } |
| 127 | 127 |
| 128 ui::EventPointerType WebMousePointerTypeToEventPointerType( | |
| 129 blink::WebPointerProperties::PointerType type) { | |
| 130 if (type == blink::WebPointerProperties::PointerType::Mouse) | |
| 131 return ui::EventPointerType::POINTER_TYPE_MOUSE; | |
| 132 if (type == blink::WebPointerProperties::PointerType::Pen) | |
| 133 return ui::EventPointerType::POINTER_TYPE_PEN; | |
| 134 NOTREACHED() << "Unexpected mouse event pointer type"; | |
| 135 return ui::EventPointerType::POINTER_TYPE_UNKNOWN; | |
| 136 } | |
| 137 | |
| 128 } // namespace | 138 } // namespace |
| 129 | 139 |
| 130 void SyntheticGestureTargetAura::DispatchWebMouseEventToPlatform( | 140 void SyntheticGestureTargetAura::DispatchWebMouseEventToPlatform( |
| 131 const blink::WebMouseEvent& web_mouse, | 141 const blink::WebMouseEvent& web_mouse, |
|
tdresser
2017/01/25 15:22:46
While we're here, let's rename this to web_mouse_e
lanwei
2017/01/26 02:55:40
Done.
| |
| 132 const ui::LatencyInfo& latency_info) { | 142 const ui::LatencyInfo& latency_info) { |
| 133 ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type()); | 143 ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type()); |
| 134 int flags = WebEventModifiersToEventFlags(web_mouse.modifiers()); | 144 int flags = WebEventModifiersToEventFlags(web_mouse.modifiers()); |
| 135 ui::MouseEvent mouse_event(event_type, gfx::Point(), gfx::Point(), | 145 ui::MouseEvent mouse_event(event_type, gfx::Point(), gfx::Point(), |
| 136 ui::EventTimeForNow(), flags, flags); | 146 ui::EventTimeForNow(), flags, flags); |
| 137 gfx::PointF location(web_mouse.x * device_scale_factor_, | 147 gfx::PointF location(web_mouse.x * device_scale_factor_, |
| 138 web_mouse.y * device_scale_factor_); | 148 web_mouse.y * device_scale_factor_); |
| 139 mouse_event.set_location_f(location); | 149 mouse_event.set_location_f(location); |
| 140 mouse_event.set_root_location_f(location); | 150 mouse_event.set_root_location_f(location); |
| 151 ui::PointerDetails pointer_details = mouse_event.pointer_details(); | |
| 152 pointer_details.pointer_type = | |
| 153 WebMousePointerTypeToEventPointerType(web_mouse.pointerType); | |
| 154 mouse_event.set_pointer_details(pointer_details); | |
| 141 | 155 |
| 142 aura::Window* window = GetWindow(); | 156 aura::Window* window = GetWindow(); |
| 143 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow()); | 157 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow()); |
| 144 ui::EventDispatchDetails details = | 158 ui::EventDispatchDetails details = |
| 145 window->GetHost()->event_processor()->OnEventFromSource(&mouse_event); | 159 window->GetHost()->event_processor()->OnEventFromSource(&mouse_event); |
| 146 if (details.dispatcher_destroyed) | 160 if (details.dispatcher_destroyed) |
| 147 return; | 161 return; |
| 148 } | 162 } |
| 149 | 163 |
| 150 SyntheticGestureParams::GestureSourceType | 164 SyntheticGestureParams::GestureSourceType |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 165 ->min_distance_for_pinch_scroll_in_pixels(); | 179 ->min_distance_for_pinch_scroll_in_pixels(); |
| 166 } | 180 } |
| 167 | 181 |
| 168 aura::Window* SyntheticGestureTargetAura::GetWindow() const { | 182 aura::Window* SyntheticGestureTargetAura::GetWindow() const { |
| 169 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); | 183 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); |
| 170 DCHECK(window); | 184 DCHECK(window); |
| 171 return window; | 185 return window; |
| 172 } | 186 } |
| 173 | 187 |
| 174 } // namespace content | 188 } // namespace content |
| OLD | NEW |