Chromium Code Reviews| 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..0860fe07144363334cb5151a85cce4324a3ba452 100644 |
| --- a/ui/views/widget/root_view.cc |
| +++ b/ui/views/widget/root_view.cc |
| @@ -639,6 +639,24 @@ View::DragInfo* RootView::GetDragInfo() { |
| void RootView::DispatchGestureEvent(ui::GestureEvent* event) { |
| if (gesture_handler_) { |
| + // 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(); |
|
sadrul
2014/08/15 18:58:52
the indent here seems off
tdanderson
2014/08/15 20:21:50
Done.
|
| + |
| + if (event->type() == ui::ET_GESTURE_END) { |
| + DCHECK_EQ(1, event->details().touch_points()); |
| + // In case a drag was in progress, reset all the handlers. Otherwise, |
| + // just reset the gesture handler. |
| + if (gesture_handler_ == mouse_pressed_handler_) |
| + SetMouseHandler(NULL); |
| + else |
| + gesture_handler_ = NULL; |
| + } |
|
sadrul
2014/08/15 18:58:52
Can you combine this block with the code below in
tdanderson
2014/08/15 20:21:50
Done. (I didn't do this originally because the pla
|
| + |
| + return; |
| + } |
| + |
| // |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. |
| @@ -715,9 +733,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, |