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

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

Issue 147203004: aura: Remove event-dispatch methods from WindowTreeHostDelegate interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win Created 6 years, 10 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/client/screen_position_client.h" 10 #include "ui/aura/client/screen_position_client.h"
(...skipping 29 matching lines...) Expand all
40 position_client->ConvertPointToScreen(window, &position); 40 position_client->ConvertPointToScreen(window, &position);
41 point->screenPosition.x = position.x(); 41 point->screenPosition.x = position.x();
42 point->screenPosition.y = position.y(); 42 point->screenPosition.y = position.y();
43 } 43 }
44 44
45 ScopedVector<ui::TouchEvent> events; 45 ScopedVector<ui::TouchEvent> events;
46 bool conversion_success = MakeUITouchEventsFromWebTouchEvents( 46 bool conversion_success = MakeUITouchEventsFromWebTouchEvents(
47 touch_with_latency, &events, SCREEN_COORDINATES); 47 touch_with_latency, &events, SCREEN_COORDINATES);
48 DCHECK(conversion_success); 48 DCHECK(conversion_success);
49 49
50 aura::WindowTreeHostDelegate* root_window_host_delegate = 50 aura::WindowEventDispatcher* dispatcher = GetWindowEventDispatcher();
51 GetWindowTreeHostDelegate();
52 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), 51 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
53 end = events.end(); iter != end; ++iter) { 52 end = events.end(); iter != end; ++iter) {
54 root_window_host_delegate->OnHostTouchEvent(*iter); 53 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(*iter);
54 if (details.dispatcher_destroyed)
55 break;
55 } 56 }
56 } 57 }
57 58
58 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( 59 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform(
59 const blink::WebMouseWheelEvent& web_wheel, 60 const blink::WebMouseWheelEvent& web_wheel,
60 const ui::LatencyInfo&) { 61 const ui::LatencyInfo&) {
61 aura::Window* window = GetWindow(); 62 aura::Window* window = GetWindow();
62 aura::client::ScreenPositionClient* position_client = 63 aura::client::ScreenPositionClient* position_client =
63 GetScreenPositionClient(); 64 GetScreenPositionClient();
64 gfx::Point location(web_wheel.x, web_wheel.y); 65 gfx::Point location(web_wheel.x, web_wheel.y);
65 position_client->ConvertPointToScreen(window, &location); 66 position_client->ConvertPointToScreen(window, &location);
66 67
67 ui::MouseEvent mouse_event( 68 ui::MouseEvent mouse_event(
68 ui::ET_MOUSEWHEEL, location, location, ui::EF_NONE, ui::EF_NONE); 69 ui::ET_MOUSEWHEEL, location, location, ui::EF_NONE, ui::EF_NONE);
69 ui::MouseWheelEvent wheel_event( 70 ui::MouseWheelEvent wheel_event(
70 mouse_event, web_wheel.deltaX, web_wheel.deltaY); 71 mouse_event, web_wheel.deltaX, web_wheel.deltaY);
71 72
72 GetWindowTreeHostDelegate()->OnHostMouseEvent(&wheel_event); 73 ui::EventDispatchDetails details =
74 GetWindowEventDispatcher()->OnEventFromSource(&wheel_event);
75 if (details.dispatcher_destroyed)
76 return;
73 } 77 }
74 78
75 namespace { 79 namespace {
76 80
77 ui::EventType 81 ui::EventType
78 WebMouseEventTypeToEventType(blink::WebInputEvent::Type web_type) { 82 WebMouseEventTypeToEventType(blink::WebInputEvent::Type web_type) {
79 switch (web_type) { 83 switch (web_type) {
80 case blink::WebInputEvent::MouseDown: 84 case blink::WebInputEvent::MouseDown:
81 return ui::ET_MOUSE_PRESSED; 85 return ui::ET_MOUSE_PRESSED;
82 86
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 aura::Window* window = GetWindow(); 133 aura::Window* window = GetWindow();
130 aura::client::ScreenPositionClient* position_client = 134 aura::client::ScreenPositionClient* position_client =
131 GetScreenPositionClient(); 135 GetScreenPositionClient();
132 gfx::Point location(web_mouse.x, web_mouse.y); 136 gfx::Point location(web_mouse.x, web_mouse.y);
133 position_client->ConvertPointToScreen(window, &location); 137 position_client->ConvertPointToScreen(window, &location);
134 138
135 ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type); 139 ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type);
136 int flags = WebMouseEventButtonToFlags(web_mouse.button); 140 int flags = WebMouseEventButtonToFlags(web_mouse.button);
137 ui::MouseEvent mouse_event(event_type, location, location, flags, flags); 141 ui::MouseEvent mouse_event(event_type, location, location, flags, flags);
138 142
139 GetWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_event); 143 ui::EventDispatchDetails details =
144 GetWindowEventDispatcher()->OnEventFromSource(&mouse_event);
145 if (details.dispatcher_destroyed)
146 return;
140 } 147 }
141 148
142 SyntheticGestureParams::GestureSourceType 149 SyntheticGestureParams::GestureSourceType
143 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { 150 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const {
144 return SyntheticGestureParams::MOUSE_INPUT; 151 return SyntheticGestureParams::MOUSE_INPUT;
145 } 152 }
146 153
147 bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType( 154 bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType(
148 SyntheticGestureParams::GestureSourceType gesture_source_type) const { 155 SyntheticGestureParams::GestureSourceType gesture_source_type) const {
149 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT || 156 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT ||
150 gesture_source_type == SyntheticGestureParams::MOUSE_INPUT; 157 gesture_source_type == SyntheticGestureParams::MOUSE_INPUT;
151 } 158 }
152 159
153 int SyntheticGestureTargetAura::GetTouchSlopInDips() const { 160 int SyntheticGestureTargetAura::GetTouchSlopInDips() const {
154 // - 1 because Aura considers a pointer to be moving if it has moved at least 161 // - 1 because Aura considers a pointer to be moving if it has moved at least
155 // 'max_touch_move_in_pixels_for_click' pixels. 162 // 'max_touch_move_in_pixels_for_click' pixels.
156 return ui::GestureConfiguration::max_touch_move_in_pixels_for_click() - 1; 163 return ui::GestureConfiguration::max_touch_move_in_pixels_for_click() - 1;
157 } 164 }
158 165
159 aura::Window* SyntheticGestureTargetAura::GetWindow() const { 166 aura::Window* SyntheticGestureTargetAura::GetWindow() const {
160 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); 167 aura::Window* window = render_widget_host()->GetView()->GetNativeView();
161 DCHECK(window); 168 DCHECK(window);
162 return window; 169 return window;
163 } 170 }
164 171
165 aura::WindowTreeHostDelegate* 172 aura::WindowEventDispatcher*
166 SyntheticGestureTargetAura::GetWindowTreeHostDelegate() const { 173 SyntheticGestureTargetAura::GetWindowEventDispatcher() const {
167 aura::Window* root_window = GetWindow()->GetRootWindow(); 174 aura::WindowEventDispatcher* dispatcher = GetWindow()->GetDispatcher();
168 aura::WindowTreeHostDelegate* root_window_host_delegate = 175 DCHECK(dispatcher);
169 root_window->GetDispatcher()->AsWindowTreeHostDelegate(); 176 return dispatcher;
170 DCHECK(root_window_host_delegate);
171 return root_window_host_delegate;
172 } 177 }
173 178
174 aura::client::ScreenPositionClient* 179 aura::client::ScreenPositionClient*
175 SyntheticGestureTargetAura::GetScreenPositionClient() const { 180 SyntheticGestureTargetAura::GetScreenPositionClient() const {
176 aura::Window* root_window = GetWindow()->GetRootWindow(); 181 aura::Window* root_window = GetWindow()->GetRootWindow();
177 aura::client::ScreenPositionClient* position_client = 182 aura::client::ScreenPositionClient* position_client =
178 aura::client::GetScreenPositionClient(root_window); 183 aura::client::GetScreenPositionClient(root_window);
179 DCHECK(position_client); 184 DCHECK(position_client);
180 return position_client; 185 return position_client;
181 } 186 }
182 187
183 } // namespace content 188 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698