Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_target_aura.cc

Issue 196383014: Remove window/host accessors from WED; IWYU for WTH (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/aura/window_event_dispatcher.h" 11 #include "ui/aura/window_tree_host.h"
12 #include "ui/events/event_processor.h"
12 #include "ui/events/gestures/gesture_configuration.h" 13 #include "ui/events/gestures/gesture_configuration.h"
13 14
14 using blink::WebTouchEvent; 15 using blink::WebTouchEvent;
15 using blink::WebMouseWheelEvent; 16 using blink::WebMouseWheelEvent;
16 17
17 namespace content { 18 namespace content {
18 19
19 SyntheticGestureTargetAura::SyntheticGestureTargetAura( 20 SyntheticGestureTargetAura::SyntheticGestureTargetAura(
20 RenderWidgetHostImpl* host) 21 RenderWidgetHostImpl* host)
21 : SyntheticGestureTargetBase(host) { 22 : SyntheticGestureTargetBase(host) {
22 } 23 }
23 24
24 void SyntheticGestureTargetAura::DispatchWebTouchEventToPlatform( 25 void SyntheticGestureTargetAura::DispatchWebTouchEventToPlatform(
25 const WebTouchEvent& web_touch, 26 const WebTouchEvent& web_touch,
26 const ui::LatencyInfo& latency_info) { 27 const ui::LatencyInfo& latency_info) {
27 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info); 28 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info);
28 ScopedVector<ui::TouchEvent> events; 29 ScopedVector<ui::TouchEvent> events;
29 bool conversion_success = MakeUITouchEventsFromWebTouchEvents( 30 bool conversion_success = MakeUITouchEventsFromWebTouchEvents(
30 touch_with_latency, &events, LOCAL_COORDINATES); 31 touch_with_latency, &events, LOCAL_COORDINATES);
31 DCHECK(conversion_success); 32 DCHECK(conversion_success);
32 33
33 aura::Window* window = GetWindow(); 34 aura::Window* window = GetWindow();
34 aura::WindowTreeHost* host = window->GetHost(); 35 aura::WindowTreeHost* host = window->GetHost();
35 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), 36 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
36 end = events.end(); iter != end; ++iter) { 37 end = events.end(); iter != end; ++iter) {
37 (*iter)->ConvertLocationToTarget(window, host->window()); 38 (*iter)->ConvertLocationToTarget(window, host->window());
38 ui::EventDispatchDetails details = 39 ui::EventDispatchDetails details =
39 host->dispatcher()->OnEventFromSource(*iter); 40 host->event_processor()->OnEventFromSource(*iter);
40 if (details.dispatcher_destroyed) 41 if (details.dispatcher_destroyed)
41 break; 42 break;
42 } 43 }
43 } 44 }
44 45
45 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( 46 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform(
46 const blink::WebMouseWheelEvent& web_wheel, 47 const blink::WebMouseWheelEvent& web_wheel,
47 const ui::LatencyInfo&) { 48 const ui::LatencyInfo&) {
48 gfx::Point location(web_wheel.x, web_wheel.y); 49 gfx::Point location(web_wheel.x, web_wheel.y);
49 ui::MouseEvent mouse_event( 50 ui::MouseEvent mouse_event(
50 ui::ET_MOUSEWHEEL, location, location, ui::EF_NONE, ui::EF_NONE); 51 ui::ET_MOUSEWHEEL, location, location, ui::EF_NONE, ui::EF_NONE);
51 ui::MouseWheelEvent wheel_event( 52 ui::MouseWheelEvent wheel_event(
52 mouse_event, web_wheel.deltaX, web_wheel.deltaY); 53 mouse_event, web_wheel.deltaX, web_wheel.deltaY);
53 54
54 aura::Window* window = GetWindow(); 55 aura::Window* window = GetWindow();
55 wheel_event.ConvertLocationToTarget(window, window->GetRootWindow()); 56 wheel_event.ConvertLocationToTarget(window, window->GetRootWindow());
56 ui::EventDispatchDetails details = 57 ui::EventDispatchDetails details =
57 window->GetHost()->dispatcher()->OnEventFromSource(&wheel_event); 58 window->GetHost()->event_processor()->OnEventFromSource(&wheel_event);
58 if (details.dispatcher_destroyed) 59 if (details.dispatcher_destroyed)
59 return; 60 return;
60 } 61 }
61 62
62 namespace { 63 namespace {
63 64
64 ui::EventType 65 ui::EventType
65 WebMouseEventTypeToEventType(blink::WebInputEvent::Type web_type) { 66 WebMouseEventTypeToEventType(blink::WebInputEvent::Type web_type) {
66 switch (web_type) { 67 switch (web_type) {
67 case blink::WebInputEvent::MouseDown: 68 case blink::WebInputEvent::MouseDown:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 const blink::WebMouseEvent& web_mouse, 115 const blink::WebMouseEvent& web_mouse,
115 const ui::LatencyInfo& latency_info) { 116 const ui::LatencyInfo& latency_info) {
116 gfx::Point location(web_mouse.x, web_mouse.y); 117 gfx::Point location(web_mouse.x, web_mouse.y);
117 ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type); 118 ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type);
118 int flags = WebMouseEventButtonToFlags(web_mouse.button); 119 int flags = WebMouseEventButtonToFlags(web_mouse.button);
119 ui::MouseEvent mouse_event(event_type, location, location, flags, flags); 120 ui::MouseEvent mouse_event(event_type, location, location, flags, flags);
120 121
121 aura::Window* window = GetWindow(); 122 aura::Window* window = GetWindow();
122 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow()); 123 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow());
123 ui::EventDispatchDetails details = 124 ui::EventDispatchDetails details =
124 window->GetHost()->dispatcher()->OnEventFromSource(&mouse_event); 125 window->GetHost()->event_processor()->OnEventFromSource(&mouse_event);
125 if (details.dispatcher_destroyed) 126 if (details.dispatcher_destroyed)
126 return; 127 return;
127 } 128 }
128 129
129 SyntheticGestureParams::GestureSourceType 130 SyntheticGestureParams::GestureSourceType
130 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { 131 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const {
131 return SyntheticGestureParams::TOUCH_INPUT; 132 return SyntheticGestureParams::TOUCH_INPUT;
132 } 133 }
133 134
134 bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType( 135 bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType(
135 SyntheticGestureParams::GestureSourceType gesture_source_type) const { 136 SyntheticGestureParams::GestureSourceType gesture_source_type) const {
136 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT || 137 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT ||
137 gesture_source_type == SyntheticGestureParams::MOUSE_INPUT; 138 gesture_source_type == SyntheticGestureParams::MOUSE_INPUT;
138 } 139 }
139 140
140 int SyntheticGestureTargetAura::GetTouchSlopInDips() const { 141 int SyntheticGestureTargetAura::GetTouchSlopInDips() const {
141 // - 1 because Aura considers a pointer to be moving if it has moved at least 142 // - 1 because Aura considers a pointer to be moving if it has moved at least
142 // 'max_touch_move_in_pixels_for_click' pixels. 143 // 'max_touch_move_in_pixels_for_click' pixels.
143 return ui::GestureConfiguration::max_touch_move_in_pixels_for_click() - 1; 144 return ui::GestureConfiguration::max_touch_move_in_pixels_for_click() - 1;
144 } 145 }
145 146
146 aura::Window* SyntheticGestureTargetAura::GetWindow() const { 147 aura::Window* SyntheticGestureTargetAura::GetWindow() const {
147 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); 148 aura::Window* window = render_widget_host()->GetView()->GetNativeView();
148 DCHECK(window); 149 DCHECK(window);
149 return window; 150 return window;
150 } 151 }
151 152
152 } // namespace content 153 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698