| 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..78bba831ddbee5ad4777f7cda976770c974468c4 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,10 @@ 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;
|
|
|
| if (event->type() == ui::ET_GESTURE_END &&
|
| event->details().touch_points() <= 1) {
|
| @@ -312,7 +314,10 @@ 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
|
| @@ -447,12 +452,10 @@ bool RootView::OnMousePressed(const ui::MouseEvent& event) {
|
| mouse_pressed_event.set_flags(event.flags() & ~ui::EF_IS_DOUBLE_CLICK);
|
|
|
| drag_info_.Reset();
|
| - {
|
| - WidgetDeletionObserver widget_deletion_observer(widget_);
|
| - DispatchEventToTarget(mouse_pressed_handler_, &mouse_pressed_event);
|
| - if (!widget_deletion_observer.IsWidgetAlive())
|
| - return mouse_pressed_event.handled();
|
| - }
|
| + ui::EventDispatchDetails dispatch_details =
|
| + DispatchEventToTarget(mouse_pressed_handler_, &mouse_pressed_event);
|
| + if (dispatch_details.dispatcher_destroyed)
|
| + return mouse_pressed_event.handled();
|
|
|
| // The view could have removed itself from the tree when handling
|
| // OnMousePressed(). In this case, the removal notification will have
|
| @@ -702,12 +705,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,
|
|
|