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 f3ad2a08d6849b779e7bf5634218b57b6144176f..59c7c91a0c802e13b46dc99b9a4f62c3f3f19fcb 100644 |
| --- a/ui/views/widget/root_view.cc |
| +++ b/ui/views/widget/root_view.cc |
| @@ -19,7 +19,6 @@ |
| #include "ui/views/views_switches.h" |
| #include "ui/views/widget/widget.h" |
| #include "ui/views/widget/widget_delegate.h" |
| -#include "ui/views/widget/widget_deletion_observer.h" |
| #if defined(USE_AURA) |
| #include "ui/base/cursor/cursor.h" |
| @@ -224,7 +223,13 @@ void RootView::DispatchGestureEvent(ui::GestureEvent* event) { |
| (event->IsScrollGestureEvent() || event->IsFlingScrollEvent()) ? |
| scroll_gesture_handler_ : gesture_handler_; |
| ui::GestureEvent handler_event(*event, static_cast<View*>(this), handler); |
| - DispatchEventToTarget(handler, &handler_event); |
| + |
| + { |
| + ui::EventDispatchDetails dispatch_details = |
| + DispatchEventToTarget(handler, &handler_event); |
| + if (dispatch_details.dispatcher_destroyed) |
| + return; |
| + } |
|
sadrul
2014/02/19 18:32:34
The nested scope isn't necessary, is it?
pkotwicz
2014/02/19 20:14:11
Removed!
|
| if (event->type() == ui::ET_GESTURE_END && |
| event->details().touch_points() <= 1) { |
| @@ -312,7 +317,13 @@ void RootView::DispatchGestureEvent(ui::GestureEvent* event) { |
| // See if this view wants to handle the Gesture. |
| ui::GestureEvent gesture_event(*event, static_cast<View*>(this), |
| gesture_handler_); |
| - DispatchEventToTarget(gesture_handler_, &gesture_event); |
| + |
| + { |
| + ui::EventDispatchDetails dispatch_details = |
| + DispatchEventToTarget(gesture_handler_, &gesture_event); |
| + if (dispatch_details.dispatcher_destroyed) |
| + return; |
| + } |
| // The view could have removed itself from the tree when handling |
| // OnGestureEvent(). So handle as per OnMousePressed. NB: we |
| @@ -448,9 +459,9 @@ bool RootView::OnMousePressed(const ui::MouseEvent& event) { |
| drag_info_.Reset(); |
| { |
| - WidgetDeletionObserver widget_deletion_observer(widget_); |
| - DispatchEventToTarget(mouse_pressed_handler_, &mouse_pressed_event); |
| - if (!widget_deletion_observer.IsWidgetAlive()) |
| + ui::EventDispatchDetails dispatch_details = |
| + DispatchEventToTarget(mouse_pressed_handler_, &mouse_pressed_event); |
| + if (dispatch_details.dispatcher_destroyed) |
| return mouse_pressed_event.handled(); |
| } |
| @@ -702,12 +713,14 @@ void RootView::SetMouseLocationAndFlags(const ui::MouseEvent& event) { |
| last_mouse_event_y_ = event.y(); |
| } |
| -void RootView::DispatchEventToTarget(View* target, ui::Event* event) { |
| +ui::EventDispatchDetails RootView::DispatchEventToTarget(View* target, |
| + ui::Event* event) { |
| View* old_target = event_dispatch_target_; |
| event_dispatch_target_ = target; |
| ui::EventDispatchDetails details = DispatchEvent(target, event); |
| if (!details.dispatcher_destroyed) |
| event_dispatch_target_ = old_target; |
| + return details; |
| } |
| void RootView::NotifyEnterExitOfDescendant(const ui::MouseEvent& event, |