| OLD | NEW |
| 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 "ui/views/widget/root_view.h" | 5 #include "ui/views/widget/root_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "ui/base/accessibility/accessible_view_state.h" | 11 #include "ui/base/accessibility/accessible_view_state.h" |
| 12 #include "ui/base/dragdrop/drag_drop_types.h" | 12 #include "ui/base/dragdrop/drag_drop_types.h" |
| 13 #include "ui/base/events/event.h" | 13 #include "ui/base/events/event.h" |
| 14 #include "ui/base/keycodes/keyboard_codes.h" | 14 #include "ui/base/keycodes/keyboard_codes.h" |
| 15 #include "ui/compositor/layer.h" | 15 #include "ui/compositor/layer.h" |
| 16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 17 #include "ui/views/focus/view_storage.h" | 17 #include "ui/views/focus/view_storage.h" |
| 18 #include "ui/views/layout/fill_layout.h" | 18 #include "ui/views/layout/fill_layout.h" |
| 19 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 20 #include "ui/views/widget/widget_delegate.h" | 20 #include "ui/views/widget/widget_delegate.h" |
| 21 #include "ui/views/widget/widget_deletion_observer.h" |
| 21 | 22 |
| 22 namespace views { | 23 namespace views { |
| 23 namespace internal { | 24 namespace internal { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 enum EventType { | 28 enum EventType { |
| 28 EVENT_ENTER, | 29 EVENT_ENTER, |
| 29 EVENT_EXIT | 30 EVENT_EXIT |
| 30 }; | 31 }; |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // See if this view wants to handle the mouse press. | 427 // See if this view wants to handle the mouse press. |
| 427 ui::MouseEvent mouse_pressed_event(event, static_cast<View*>(this), | 428 ui::MouseEvent mouse_pressed_event(event, static_cast<View*>(this), |
| 428 mouse_pressed_handler_); | 429 mouse_pressed_handler_); |
| 429 | 430 |
| 430 // Remove the double-click flag if the handler is different than the | 431 // Remove the double-click flag if the handler is different than the |
| 431 // one which got the first click part of the double-click. | 432 // one which got the first click part of the double-click. |
| 432 if (mouse_pressed_handler_ != last_click_handler_) | 433 if (mouse_pressed_handler_ != last_click_handler_) |
| 433 mouse_pressed_event.set_flags(event.flags() & ~ui::EF_IS_DOUBLE_CLICK); | 434 mouse_pressed_event.set_flags(event.flags() & ~ui::EF_IS_DOUBLE_CLICK); |
| 434 | 435 |
| 435 drag_info_.Reset(); | 436 drag_info_.Reset(); |
| 436 DispatchEventToTarget(mouse_pressed_handler_, &mouse_pressed_event); | 437 { |
| 438 WidgetDeletionObserver widget_deletion_observer(widget_); |
| 439 DispatchEventToTarget(mouse_pressed_handler_, &mouse_pressed_event); |
| 440 if (!widget_deletion_observer.IsWidgetAlive()) |
| 441 return mouse_pressed_event.handled(); |
| 442 } |
| 437 | 443 |
| 438 // The view could have removed itself from the tree when handling | 444 // The view could have removed itself from the tree when handling |
| 439 // OnMousePressed(). In this case, the removal notification will have | 445 // OnMousePressed(). In this case, the removal notification will have |
| 440 // reset mouse_pressed_handler_ to NULL out from under us. Detect this | 446 // reset mouse_pressed_handler_ to NULL out from under us. Detect this |
| 441 // case and stop. (See comments in view.h.) | 447 // case and stop. (See comments in view.h.) |
| 442 // | 448 // |
| 443 // NOTE: Don't return true here, because we don't want the frame to | 449 // NOTE: Don't return true here, because we don't want the frame to |
| 444 // forward future events to us when there's no handler. | 450 // forward future events to us when there's no handler. |
| 445 if (!mouse_pressed_handler_) | 451 if (!mouse_pressed_handler_) |
| 446 break; | 452 break; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 DispatchEventToTarget(p, ¬ify_event); | 698 DispatchEventToTarget(p, ¬ify_event); |
| 693 } | 699 } |
| 694 } | 700 } |
| 695 | 701 |
| 696 bool RootView::CanDispatchToTarget(ui::EventTarget* target) { | 702 bool RootView::CanDispatchToTarget(ui::EventTarget* target) { |
| 697 return event_dispatch_target_ == target; | 703 return event_dispatch_target_ == target; |
| 698 } | 704 } |
| 699 | 705 |
| 700 } // namespace internal | 706 } // namespace internal |
| 701 } // namespace views | 707 } // namespace views |
| OLD | NEW |