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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
29 #include "ui/aura/client/aura_constants.h" 29 #include "ui/aura/client/aura_constants.h"
30 #include "ui/aura/client/cursor_client.h" 30 #include "ui/aura/client/cursor_client.h"
31 #include "ui/aura/client/screen_position_client.h" 31 #include "ui/aura/client/screen_position_client.h"
32 #include "ui/aura/client/tooltip_client.h" 32 #include "ui/aura/client/tooltip_client.h"
33 #include "ui/aura/client/window_types.h" 33 #include "ui/aura/client/window_types.h"
34 #include "ui/aura/env.h" 34 #include "ui/aura/env.h"
35 #include "ui/aura/event.h"
36 #include "ui/aura/root_window.h" 35 #include "ui/aura/root_window.h"
37 #include "ui/aura/window.h" 36 #include "ui/aura/window.h"
38 #include "ui/aura/window_observer.h" 37 #include "ui/aura/window_observer.h"
38 #include "ui/base/event.h"
39 #include "ui/base/gestures/gesture_recognizer.h" 39 #include "ui/base/gestures/gesture_recognizer.h"
40 #include "ui/base/hit_test.h" 40 #include "ui/base/hit_test.h"
41 #include "ui/base/ime/input_method.h" 41 #include "ui/base/ime/input_method.h"
42 #include "ui/base/ui_base_types.h" 42 #include "ui/base/ui_base_types.h"
43 #include "ui/compositor/compositor.h" 43 #include "ui/compositor/compositor.h"
44 #include "ui/compositor/layer.h" 44 #include "ui/compositor/layer.h"
45 #include "ui/gfx/canvas.h" 45 #include "ui/gfx/canvas.h"
46 #include "ui/gfx/display.h" 46 #include "ui/gfx/display.h"
47 #include "ui/gfx/screen.h" 47 #include "ui/gfx/screen.h"
48 #include "ui/gfx/skia_util.h" 48 #include "ui/gfx/skia_util.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 if (point->state != WebKit::WebTouchPoint::StateReleased) 82 if (point->state != WebKit::WebTouchPoint::StateReleased)
83 return; 83 return;
84 --event->touchesLength; 84 --event->touchesLength;
85 for (unsigned i = point - event->touches; 85 for (unsigned i = point - event->touches;
86 i < event->touchesLength; 86 i < event->touchesLength;
87 ++i) { 87 ++i) {
88 event->touches[i] = event->touches[i + 1]; 88 event->touches[i] = event->touches[i + 1];
89 } 89 }
90 } 90 }
91 91
92 bool CanRendererHandleEvent(const aura::MouseEvent* event) { 92 bool CanRendererHandleEvent(const ui::MouseEvent* event) {
93 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) 93 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED)
94 return false; 94 return false;
95 95
96 #if defined(OS_WIN) 96 #if defined(OS_WIN)
97 // Renderer cannot handle WM_XBUTTON events. 97 // Renderer cannot handle WM_XBUTTON events.
98 switch (event->native_event().message) { 98 switch (event->native_event().message) {
99 case WM_XBUTTONDOWN: 99 case WM_XBUTTONDOWN:
100 case WM_XBUTTONUP: 100 case WM_XBUTTONUP:
101 case WM_XBUTTONDBLCLK: 101 case WM_XBUTTONDBLCLK:
102 case WM_NCXBUTTONDOWN: 102 case WM_NCXBUTTONDOWN:
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 host_->SetInputMethodActive(false); 1142 host_->SetInputMethodActive(false);
1143 1143
1144 // If we lose the focus while fullscreen, close the window; Pepper Flash won't 1144 // If we lose the focus while fullscreen, close the window; Pepper Flash won't
1145 // do it for us (unlike NPAPI Flash). 1145 // do it for us (unlike NPAPI Flash).
1146 if (is_fullscreen_ && !in_shutdown_) { 1146 if (is_fullscreen_ && !in_shutdown_) {
1147 in_shutdown_ = true; 1147 in_shutdown_ = true;
1148 host_->Shutdown(); 1148 host_->Shutdown();
1149 } 1149 }
1150 } 1150 }
1151 1151
1152 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { 1152 bool RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
1153 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnKeyEvent"); 1153 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnKeyEvent");
1154 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab() && 1154 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab() &&
1155 popup_child_host_view_->OnKeyEvent(event)) 1155 popup_child_host_view_->OnKeyEvent(event))
1156 return true; 1156 return true;
1157 1157
1158 // We need to handle the Escape key for Pepper Flash. 1158 // We need to handle the Escape key for Pepper Flash.
1159 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { 1159 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) {
1160 if (!in_shutdown_) { 1160 if (!in_shutdown_) {
1161 in_shutdown_ = true; 1161 in_shutdown_ = true;
1162 host_->Shutdown(); 1162 host_->Shutdown();
(...skipping 26 matching lines...) Expand all
1189 const gfx::Point& point) const { 1189 const gfx::Point& point) const {
1190 return HTCLIENT; 1190 return HTCLIENT;
1191 } 1191 }
1192 1192
1193 bool RenderWidgetHostViewAura::ShouldDescendIntoChildForEventHandling( 1193 bool RenderWidgetHostViewAura::ShouldDescendIntoChildForEventHandling(
1194 aura::Window* child, 1194 aura::Window* child,
1195 const gfx::Point& location) { 1195 const gfx::Point& location) {
1196 return true; 1196 return true;
1197 } 1197 }
1198 1198
1199 bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { 1199 bool RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) {
1200 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); 1200 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent");
1201 if (mouse_locked_) { 1201 if (mouse_locked_) {
1202 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); 1202 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event);
1203 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); 1203 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint());
1204 1204
1205 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || 1205 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED ||
1206 event->type() == ui::ET_MOUSE_DRAGGED) && 1206 event->type() == ui::ET_MOUSE_DRAGGED) &&
1207 mouse_event.x == center.x() && mouse_event.y == center.y(); 1207 mouse_event.x == center.x() && mouse_event.y == center.y();
1208 1208
1209 ModifyEventMovementAndCoords(&mouse_event); 1209 ModifyEventMovementAndCoords(&mouse_event);
(...skipping 19 matching lines...) Expand all
1229 if (event->type() == ui::ET_MOUSEWHEEL) { 1229 if (event->type() == ui::ET_MOUSEWHEEL) {
1230 WebKit::WebMouseWheelEvent mouse_wheel_event = 1230 WebKit::WebMouseWheelEvent mouse_wheel_event =
1231 MakeWebMouseWheelEvent(event); 1231 MakeWebMouseWheelEvent(event);
1232 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) 1232 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0)
1233 host_->ForwardWheelEvent(mouse_wheel_event); 1233 host_->ForwardWheelEvent(mouse_wheel_event);
1234 } else if (event->type() == ui::ET_SCROLL) { 1234 } else if (event->type() == ui::ET_SCROLL) {
1235 WebKit::WebGestureEvent gesture_event = 1235 WebKit::WebGestureEvent gesture_event =
1236 MakeWebGestureEventFlingCancel(); 1236 MakeWebGestureEventFlingCancel();
1237 host_->ForwardGestureEvent(gesture_event); 1237 host_->ForwardGestureEvent(gesture_event);
1238 WebKit::WebMouseWheelEvent mouse_wheel_event = 1238 WebKit::WebMouseWheelEvent mouse_wheel_event =
1239 MakeWebMouseWheelEvent(static_cast<aura::ScrollEvent*>(event)); 1239 MakeWebMouseWheelEvent(static_cast<ui::ScrollEvent*>(event));
1240 host_->ForwardWheelEvent(mouse_wheel_event); 1240 host_->ForwardWheelEvent(mouse_wheel_event);
1241 RecordAction(UserMetricsAction("TrackpadScroll")); 1241 RecordAction(UserMetricsAction("TrackpadScroll"));
1242 } else if (event->type() == ui::ET_SCROLL_FLING_START || 1242 } else if (event->type() == ui::ET_SCROLL_FLING_START ||
1243 event->type() == ui::ET_SCROLL_FLING_CANCEL) { 1243 event->type() == ui::ET_SCROLL_FLING_CANCEL) {
1244 WebKit::WebGestureEvent gesture_event = 1244 WebKit::WebGestureEvent gesture_event =
1245 MakeWebGestureEvent(static_cast<aura::ScrollEvent*>(event)); 1245 MakeWebGestureEvent(static_cast<ui::ScrollEvent*>(event));
1246 host_->ForwardGestureEvent(gesture_event); 1246 host_->ForwardGestureEvent(gesture_event);
1247 if (event->type() == ui::ET_SCROLL_FLING_START) 1247 if (event->type() == ui::ET_SCROLL_FLING_START)
1248 RecordAction(UserMetricsAction("TrackpadScrollFling")); 1248 RecordAction(UserMetricsAction("TrackpadScrollFling"));
1249 } else if (CanRendererHandleEvent(event)) { 1249 } else if (CanRendererHandleEvent(event)) {
1250 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); 1250 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event);
1251 ModifyEventMovementAndCoords(&mouse_event); 1251 ModifyEventMovementAndCoords(&mouse_event);
1252 host_->ForwardMouseEvent(mouse_event); 1252 host_->ForwardMouseEvent(mouse_event);
1253 } 1253 }
1254 1254
1255 switch (event->type()) { 1255 switch (event->type()) {
(...skipping 13 matching lines...) Expand all
1269 // Needed to propagate mouse event to native_tab_contents_view_aura. 1269 // Needed to propagate mouse event to native_tab_contents_view_aura.
1270 // TODO(pkotwicz): Find a better way of doing this. 1270 // TODO(pkotwicz): Find a better way of doing this.
1271 if (window_->parent()->delegate()) 1271 if (window_->parent()->delegate())
1272 window_->parent()->delegate()->OnMouseEvent(event); 1272 window_->parent()->delegate()->OnMouseEvent(event);
1273 1273
1274 // Return true so that we receive released/drag events. 1274 // Return true so that we receive released/drag events.
1275 return true; 1275 return true;
1276 } 1276 }
1277 1277
1278 ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent( 1278 ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent(
1279 aura::TouchEvent* event) { 1279 ui::TouchEventImpl* event) {
1280 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnTouchEvent"); 1280 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnTouchEvent");
1281 // Update the touch event first. 1281 // Update the touch event first.
1282 WebKit::WebTouchPoint* point = UpdateWebTouchEvent(event, 1282 WebKit::WebTouchPoint* point = UpdateWebTouchEvent(event,
1283 &touch_event_); 1283 &touch_event_);
1284 1284
1285 // Forward the touch event only if a touch point was updated, and there's a 1285 // Forward the touch event only if a touch point was updated, and there's a
1286 // touch-event handler in the page. 1286 // touch-event handler in the page.
1287 if (point && host_->has_touch_handler()) { 1287 if (point && host_->has_touch_handler()) {
1288 host_->ForwardTouchEvent(touch_event_); 1288 host_->ForwardTouchEvent(touch_event_);
1289 UpdateWebTouchEventAfterDispatch(&touch_event_, point); 1289 UpdateWebTouchEventAfterDispatch(&touch_event_, point);
1290 return DecideTouchStatus(touch_event_, point); 1290 return DecideTouchStatus(touch_event_, point);
1291 } 1291 }
1292 1292
1293 return ui::TOUCH_STATUS_UNKNOWN; 1293 return ui::TOUCH_STATUS_UNKNOWN;
1294 } 1294 }
1295 1295
1296 ui::GestureStatus RenderWidgetHostViewAura::OnGestureEvent( 1296 ui::GestureStatus RenderWidgetHostViewAura::OnGestureEvent(
1297 aura::GestureEvent* event) { 1297 ui::GestureEventImpl* event) {
1298 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent"); 1298 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent");
1299 // Pinch gestures are currently disabled by default. See crbug.com/128477. 1299 // Pinch gestures are currently disabled by default. See crbug.com/128477.
1300 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 1300 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
1301 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 1301 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
1302 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { 1302 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) {
1303 return ui::GESTURE_STATUS_CONSUMED; 1303 return ui::GESTURE_STATUS_CONSUMED;
1304 } 1304 }
1305 1305
1306 RenderViewHostDelegate* delegate = NULL; 1306 RenderViewHostDelegate* delegate = NULL;
1307 if (popup_type_ == WebKit::WebPopupTypeNone && !is_fullscreen_) 1307 if (popup_type_ == WebKit::WebPopupTypeNone && !is_fullscreen_)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 bool RenderWidgetHostViewAura::HasHitTestMask() const { 1392 bool RenderWidgetHostViewAura::HasHitTestMask() const {
1393 return false; 1393 return false;
1394 } 1394 }
1395 1395
1396 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { 1396 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const {
1397 } 1397 }
1398 1398
1399 //////////////////////////////////////////////////////////////////////////////// 1399 ////////////////////////////////////////////////////////////////////////////////
1400 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: 1400 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation:
1401 1401
1402 bool RenderWidgetHostViewAura::ShouldActivate(const aura::Event* event) { 1402 bool RenderWidgetHostViewAura::ShouldActivate(const ui::Event* event) {
1403 bool activate = false; 1403 bool activate = false;
1404 if (event) { 1404 if (event) {
1405 if (event->type() == ui::ET_MOUSE_PRESSED) { 1405 if (event->type() == ui::ET_MOUSE_PRESSED) {
1406 activate = true; 1406 activate = true;
1407 } else if (event->type() == ui::ET_GESTURE_BEGIN) { 1407 } else if (event->type() == ui::ET_GESTURE_BEGIN) {
1408 activate = static_cast<const aura::GestureEvent*>(event)-> 1408 activate = static_cast<const ui::GestureEventImpl*>(event)->
1409 details().touch_points() == 1; 1409 details().touch_points() == 1;
1410 } 1410 }
1411 } 1411 }
1412 if (activate) 1412 if (activate)
1413 host_->OnPointerEventActivate(); 1413 host_->OnPointerEventActivate();
1414 return is_fullscreen_; 1414 return is_fullscreen_;
1415 } 1415 }
1416 1416
1417 void RenderWidgetHostViewAura::OnActivated() { 1417 void RenderWidgetHostViewAura::OnActivated() {
1418 } 1418 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 RenderWidgetHost* widget) { 1655 RenderWidgetHost* widget) {
1656 return new RenderWidgetHostViewAura(widget); 1656 return new RenderWidgetHostViewAura(widget);
1657 } 1657 }
1658 1658
1659 // static 1659 // static
1660 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 1660 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
1661 GetScreenInfoForWindow(results, NULL); 1661 GetScreenInfoForWindow(results, NULL);
1662 } 1662 }
1663 1663
1664 } // namespace content 1664 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | content/browser/renderer_host/web_input_event_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698