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

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

Issue 11568006: events: Update scroll and touch handlers to not return EventResult. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self-nit Created 8 years 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 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 1580
1581 // Needed to propagate mouse event to native_tab_contents_view_aura. 1581 // Needed to propagate mouse event to native_tab_contents_view_aura.
1582 // TODO(pkotwicz): Find a better way of doing this. 1582 // TODO(pkotwicz): Find a better way of doing this.
1583 if (window_->parent()->delegate()) 1583 if (window_->parent()->delegate())
1584 window_->parent()->delegate()->OnMouseEvent(event); 1584 window_->parent()->delegate()->OnMouseEvent(event);
1585 1585
1586 // Return true so that we receive released/drag events. 1586 // Return true so that we receive released/drag events.
1587 return ui::ER_HANDLED; 1587 return ui::ER_HANDLED;
1588 } 1588 }
1589 1589
1590 ui::EventResult RenderWidgetHostViewAura::OnScrollEvent( 1590 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
1591 ui::ScrollEvent* event) {
1592 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnScrollEvent"); 1591 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnScrollEvent");
1593 if (event->type() == ui::ET_SCROLL) { 1592 if (event->type() == ui::ET_SCROLL) {
1594 WebKit::WebGestureEvent gesture_event = 1593 WebKit::WebGestureEvent gesture_event =
1595 MakeWebGestureEventFlingCancel(); 1594 MakeWebGestureEventFlingCancel();
1596 host_->ForwardGestureEvent(gesture_event); 1595 host_->ForwardGestureEvent(gesture_event);
1597 WebKit::WebMouseWheelEvent mouse_wheel_event = 1596 WebKit::WebMouseWheelEvent mouse_wheel_event =
1598 MakeWebMouseWheelEvent(static_cast<ui::ScrollEvent*>(event)); 1597 MakeWebMouseWheelEvent(static_cast<ui::ScrollEvent*>(event));
1599 host_->ForwardWheelEvent(mouse_wheel_event); 1598 host_->ForwardWheelEvent(mouse_wheel_event);
1600 RecordAction(UserMetricsAction("TrackpadScroll")); 1599 RecordAction(UserMetricsAction("TrackpadScroll"));
1601 } else if (event->type() == ui::ET_SCROLL_FLING_START || 1600 } else if (event->type() == ui::ET_SCROLL_FLING_START ||
1602 event->type() == ui::ET_SCROLL_FLING_CANCEL) { 1601 event->type() == ui::ET_SCROLL_FLING_CANCEL) {
1603 WebKit::WebGestureEvent gesture_event = 1602 WebKit::WebGestureEvent gesture_event =
1604 MakeWebGestureEvent(static_cast<ui::ScrollEvent*>(event)); 1603 MakeWebGestureEvent(static_cast<ui::ScrollEvent*>(event));
1605 host_->ForwardGestureEvent(gesture_event); 1604 host_->ForwardGestureEvent(gesture_event);
1606 if (event->type() == ui::ET_SCROLL_FLING_START) 1605 if (event->type() == ui::ET_SCROLL_FLING_START)
1607 RecordAction(UserMetricsAction("TrackpadScrollFling")); 1606 RecordAction(UserMetricsAction("TrackpadScrollFling"));
1608 } 1607 }
1609 return ui::ER_HANDLED; 1608
1609 event->SetHandled();
1610 } 1610 }
1611 1611
1612 ui::EventResult RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { 1612 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
1613 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnTouchEvent"); 1613 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnTouchEvent");
1614 // Update the touch event first. 1614 // Update the touch event first.
1615 WebKit::WebTouchPoint* point = UpdateWebTouchEventFromUIEvent(*event, 1615 WebKit::WebTouchPoint* point = UpdateWebTouchEventFromUIEvent(*event,
1616 &touch_event_); 1616 &touch_event_);
1617 1617
1618 // Forward the touch event only if a touch point was updated, and there's a 1618 // Forward the touch event only if a touch point was updated, and there's a
1619 // touch-event handler in the page, and no other touch-event is in the queue. 1619 // touch-event handler in the page, and no other touch-event is in the queue.
1620 // It is important to always consume the event if there is a touch-event 1620 // It is important to always consume the event if there is a touch-event
1621 // handler in the page, or some touch-event is already in the queue, even if 1621 // handler in the page, or some touch-event is already in the queue, even if
1622 // no point has been updated, to make sure that this event does not get 1622 // no point has been updated, to make sure that this event does not get
1623 // processed by the gesture recognizer before the events in the queue. 1623 // processed by the gesture recognizer before the events in the queue.
1624 ui::EventResult result = host_->ShouldForwardTouchEvent() ? ui::ER_CONSUMED : 1624 if (host_->ShouldForwardTouchEvent())
1625 ui::ER_UNHANDLED; 1625 event->StopPropagation();
1626
1626 if (point) { 1627 if (point) {
1627 if (host_->ShouldForwardTouchEvent()) 1628 if (host_->ShouldForwardTouchEvent())
1628 host_->ForwardTouchEvent(touch_event_); 1629 host_->ForwardTouchEvent(touch_event_);
1629 UpdateWebTouchEventAfterDispatch(&touch_event_, point); 1630 UpdateWebTouchEventAfterDispatch(&touch_event_, point);
1630 } 1631 }
1631
1632 return result;
1633 } 1632 }
1634 1633
1635 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 1634 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
1636 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent"); 1635 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent");
1637 // Pinch gestures are currently disabled by default. See crbug.com/128477. 1636 // Pinch gestures are currently disabled by default. See crbug.com/128477.
1638 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 1637 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
1639 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 1638 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
1640 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { 1639 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) {
1641 event->SetHandled(); 1640 event->SetHandled();
1642 return; 1641 return;
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 RenderWidgetHost* widget) { 1994 RenderWidgetHost* widget) {
1996 return new RenderWidgetHostViewAura(widget); 1995 return new RenderWidgetHostViewAura(widget);
1997 } 1996 }
1998 1997
1999 // static 1998 // static
2000 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 1999 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
2001 GetScreenInfoForWindow(results, NULL); 2000 GetScreenInfoForWindow(results, NULL);
2002 } 2001 }
2003 2002
2004 } // namespace content 2003 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698