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

Unified Diff: ui/views/widget/root_view.cc

Issue 472303004: Do not dispatch gesture events to disabled views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/widget/root_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/root_view.cc
diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc
index 627b845b5364966d3649c5822823351cf3696f28..5bf3248067b951134b1c8977a659bdf29fec9214 100644
--- a/ui/views/widget/root_view.cc
+++ b/ui/views/widget/root_view.cc
@@ -639,16 +639,27 @@ View::DragInfo* RootView::GetDragInfo() {
void RootView::DispatchGestureEvent(ui::GestureEvent* event) {
if (gesture_handler_) {
- // |gesture_handler_| can be deleted during processing. In particular, it
- // will be set to NULL if the view is deleted or removed from the tree as
- // a result of an event dispatch.
- ui::GestureEvent handler_event(*event,
- static_cast<View*>(this),
- gesture_handler_);
- ui::EventDispatchDetails dispatch_details =
- DispatchEvent(gesture_handler_, &handler_event);
- if (dispatch_details.dispatcher_destroyed)
- return;
+ if (gesture_handler_->enabled()) {
+ // |gesture_handler_| can be deleted during processing. In particular, it
+ // will be set to NULL if the view is deleted or removed from the tree as
+ // a result of an event dispatch.
+ ui::GestureEvent handler_event(*event,
+ static_cast<View*>(this),
+ gesture_handler_);
+ ui::EventDispatchDetails dispatch_details =
+ DispatchEvent(gesture_handler_, &handler_event);
+ if (dispatch_details.dispatcher_destroyed)
+ return;
+
+ if (handler_event.stopped_propagation())
+ event->StopPropagation();
+ else if (handler_event.handled())
+ event->SetHandled();
+ } else {
+ // Disabled views are permitted to be targets of gesture events, but
+ // gesture events should never actually be dispatched to them.
+ event->SetHandled();
+ }
if (event->type() == ui::ET_GESTURE_END) {
DCHECK_EQ(1, event->details().touch_points());
@@ -660,13 +671,8 @@ void RootView::DispatchGestureEvent(ui::GestureEvent* event) {
gesture_handler_ = NULL;
}
- if (handler_event.stopped_propagation()) {
- event->StopPropagation();
- return;
- } else if (handler_event.handled()) {
- event->SetHandled();
+ if (event->handled())
return;
- }
if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN) {
// Some view started processing gesture events, however it does not
@@ -715,9 +721,19 @@ void RootView::DispatchGestureEvent(ui::GestureEvent* event) {
for (gesture_handler_ = gesture_handler;
gesture_handler_ && (gesture_handler_ != this);
gesture_handler_ = gesture_handler_->parent()) {
- // Disabled views eat events but are treated as not handled.
- if (!gesture_handler_->enabled())
+ // Disabled views are permitted to be targets of gesture events, but
+ // gesture events should never actually be dispatched to them.
+ if (!gesture_handler_->enabled()) {
+ event->SetHandled();
+
+ // Last ui::ET_GESTURE_END should not set the gesture_handler_.
+ if (event->type() == ui::ET_GESTURE_END) {
+ DCHECK_EQ(1, event->details().touch_points());
+ gesture_handler_ = NULL;
+ }
+
return;
+ }
// See if this view wants to handle the Gesture.
ui::GestureEvent gesture_event(*event,
« no previous file with comments | « no previous file | ui/views/widget/root_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698