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

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

Issue 10964051: events: Clean up dispatching code for touch-events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 reinterpret_cast<RenderWidgetHostViewAura*>(param); 104 reinterpret_cast<RenderWidgetHostViewAura*>(param);
105 105
106 HWND parent = 106 HWND parent =
107 widget->GetNativeView()->GetRootWindow()->GetAcceleratedWidget(); 107 widget->GetNativeView()->GetRootWindow()->GetAcceleratedWidget();
108 if (GetProp(window, kWidgetOwnerProperty) == widget) 108 if (GetProp(window, kWidgetOwnerProperty) == widget)
109 SetParent(window, parent); 109 SetParent(window, parent);
110 return TRUE; 110 return TRUE;
111 } 111 }
112 #endif 112 #endif
113 113
114 ui::TouchStatus DecideTouchStatus(const WebKit::WebTouchEvent& event,
115 WebKit::WebTouchPoint* point) {
116 if (event.type == WebKit::WebInputEvent::TouchEnd &&
117 event.touchesLength == 0)
118 return ui::TOUCH_STATUS_QUEUED_END;
119
120 return ui::TOUCH_STATUS_QUEUED;
121 }
122
123 void UpdateWebTouchEventAfterDispatch(WebKit::WebTouchEvent* event, 114 void UpdateWebTouchEventAfterDispatch(WebKit::WebTouchEvent* event,
124 WebKit::WebTouchPoint* point) { 115 WebKit::WebTouchPoint* point) {
125 if (point->state != WebKit::WebTouchPoint::StateReleased) 116 if (point->state != WebKit::WebTouchPoint::StateReleased)
126 return; 117 return;
127 --event->touchesLength; 118 --event->touchesLength;
128 for (unsigned i = point - event->touches; 119 for (unsigned i = point - event->touches;
129 i < event->touchesLength; 120 i < event->touchesLength;
130 ++i) { 121 ++i) {
131 event->touches[i] = event->touches[i + 1]; 122 event->touches[i] = event->touches[i + 1];
132 } 123 }
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 1530
1540 // Needed to propagate mouse event to native_tab_contents_view_aura. 1531 // Needed to propagate mouse event to native_tab_contents_view_aura.
1541 // TODO(pkotwicz): Find a better way of doing this. 1532 // TODO(pkotwicz): Find a better way of doing this.
1542 if (window_->parent()->delegate()) 1533 if (window_->parent()->delegate())
1543 window_->parent()->delegate()->OnMouseEvent(event); 1534 window_->parent()->delegate()->OnMouseEvent(event);
1544 1535
1545 // Return true so that we receive released/drag events. 1536 // Return true so that we receive released/drag events.
1546 return ui::ER_HANDLED; 1537 return ui::ER_HANDLED;
1547 } 1538 }
1548 1539
1549 ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent( 1540 ui::EventResult RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
1550 ui::TouchEvent* event) {
1551 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnTouchEvent"); 1541 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnTouchEvent");
1552 // Update the touch event first. 1542 // Update the touch event first.
1553 WebKit::WebTouchPoint* point = UpdateWebTouchEvent(event, 1543 WebKit::WebTouchPoint* point = UpdateWebTouchEvent(event,
1554 &touch_event_); 1544 &touch_event_);
1555 1545
1556 // Forward the touch event only if a touch point was updated, and there's a 1546 // Forward the touch event only if a touch point was updated, and there's a
1557 // touch-event handler in the page. 1547 // touch-event handler in the page.
1558 if (point && host_->has_touch_handler()) { 1548 if (point && host_->has_touch_handler()) {
1559 host_->ForwardTouchEvent(touch_event_); 1549 host_->ForwardTouchEvent(touch_event_);
1560 UpdateWebTouchEventAfterDispatch(&touch_event_, point); 1550 UpdateWebTouchEventAfterDispatch(&touch_event_, point);
1561 return DecideTouchStatus(touch_event_, point); 1551 return ui::ER_ASYNC;
1562 } 1552 }
1563 1553
1564 return ui::TOUCH_STATUS_UNKNOWN; 1554 return ui::ER_UNHANDLED;
1565 } 1555 }
1566 1556
1567 ui::EventResult RenderWidgetHostViewAura::OnGestureEvent( 1557 ui::EventResult RenderWidgetHostViewAura::OnGestureEvent(
1568 ui::GestureEvent* event) { 1558 ui::GestureEvent* event) {
1569 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent"); 1559 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent");
1570 // Pinch gestures are currently disabled by default. See crbug.com/128477. 1560 // Pinch gestures are currently disabled by default. See crbug.com/128477.
1571 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 1561 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
1572 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 1562 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
1573 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { 1563 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) {
1574 return ui::ER_CONSUMED; 1564 return ui::ER_CONSUMED;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 RenderWidgetHost* widget) { 1871 RenderWidgetHost* widget) {
1882 return new RenderWidgetHostViewAura(widget); 1872 return new RenderWidgetHostViewAura(widget);
1883 } 1873 }
1884 1874
1885 // static 1875 // static
1886 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 1876 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
1887 GetScreenInfoForWindow(results, NULL); 1877 GetScreenInfoForWindow(results, NULL);
1888 } 1878 }
1889 1879
1890 } // namespace content 1880 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698