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/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "ui/aura/client/capture_client.h" | 16 #include "ui/aura/client/capture_client.h" |
17 #include "ui/aura/client/event_client.h" | 17 #include "ui/aura/client/event_client.h" |
18 #include "ui/aura/client/screen_position_client.h" | 18 #include "ui/aura/client/screen_position_client.h" |
19 #include "ui/aura/client/stacking_client.h" | 19 #include "ui/aura/client/stacking_client.h" |
20 #include "ui/aura/client/visibility_client.h" | 20 #include "ui/aura/client/visibility_client.h" |
21 #include "ui/aura/env.h" | 21 #include "ui/aura/env.h" |
22 #include "ui/aura/focus_manager.h" | 22 #include "ui/aura/focus_manager.h" |
23 #include "ui/aura/layout_manager.h" | 23 #include "ui/aura/layout_manager.h" |
24 #include "ui/aura/root_window.h" | 24 #include "ui/aura/root_window.h" |
25 #include "ui/aura/window_delegate.h" | 25 #include "ui/aura/window_delegate.h" |
26 #include "ui/aura/window_destruction_observer.h" | |
27 #include "ui/aura/window_observer.h" | 26 #include "ui/aura/window_observer.h" |
| 27 #include "ui/aura/window_tracker.h" |
28 #include "ui/base/animation/multi_animation.h" | 28 #include "ui/base/animation/multi_animation.h" |
29 #include "ui/compositor/compositor.h" | 29 #include "ui/compositor/compositor.h" |
30 #include "ui/compositor/layer.h" | 30 #include "ui/compositor/layer.h" |
31 #include "ui/gfx/canvas.h" | 31 #include "ui/gfx/canvas.h" |
32 #include "ui/gfx/path.h" | 32 #include "ui/gfx/path.h" |
33 #include "ui/gfx/screen.h" | 33 #include "ui/gfx/screen.h" |
34 | 34 |
35 namespace aura { | 35 namespace aura { |
36 | 36 |
37 namespace { | 37 namespace { |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 void Window::NotifyWindowVisibilityChanged(aura::Window* target, | 1020 void Window::NotifyWindowVisibilityChanged(aura::Window* target, |
1021 bool visible) { | 1021 bool visible) { |
1022 if (!NotifyWindowVisibilityChangedDown(target, visible)) { | 1022 if (!NotifyWindowVisibilityChangedDown(target, visible)) { |
1023 return; // |this| has been deleted. | 1023 return; // |this| has been deleted. |
1024 } | 1024 } |
1025 NotifyWindowVisibilityChangedUp(target, visible); | 1025 NotifyWindowVisibilityChangedUp(target, visible); |
1026 } | 1026 } |
1027 | 1027 |
1028 bool Window::NotifyWindowVisibilityChangedAtReceiver(aura::Window* target, | 1028 bool Window::NotifyWindowVisibilityChangedAtReceiver(aura::Window* target, |
1029 bool visible) { | 1029 bool visible) { |
1030 // |this| may be deleted during a call to OnWindowVisibilityChanged | 1030 // |this| may be deleted during a call to OnWindowVisibilityChanged() on one |
1031 // on one of the observers. We create an local observer for that. In | 1031 // of the observers. We create an local observer for that. In that case we |
1032 // that case we exit without further access to any members. | 1032 // exit without further access to any members. |
1033 WindowDestructionObserver destruction_observer(this); | 1033 WindowTracker tracker; |
| 1034 tracker.Add(this); |
1034 FOR_EACH_OBSERVER(WindowObserver, observers_, | 1035 FOR_EACH_OBSERVER(WindowObserver, observers_, |
1035 OnWindowVisibilityChanged(target, visible)); | 1036 OnWindowVisibilityChanged(target, visible)); |
1036 return !destruction_observer.destroyed(); | 1037 return tracker.Contains(this); |
1037 } | 1038 } |
1038 | 1039 |
1039 bool Window::NotifyWindowVisibilityChangedDown(aura::Window* target, | 1040 bool Window::NotifyWindowVisibilityChangedDown(aura::Window* target, |
1040 bool visible) { | 1041 bool visible) { |
1041 if (!NotifyWindowVisibilityChangedAtReceiver(target, visible)) | 1042 if (!NotifyWindowVisibilityChangedAtReceiver(target, visible)) |
1042 return false; // |this| was deleted. | 1043 return false; // |this| was deleted. |
1043 std::set<const Window*> child_already_processed; | 1044 std::set<const Window*> child_already_processed; |
1044 bool child_destroyed = false; | 1045 bool child_destroyed = false; |
1045 do { | 1046 do { |
1046 child_destroyed = false; | 1047 child_destroyed = false; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 bool contains_mouse = false; | 1128 bool contains_mouse = false; |
1128 if (IsVisible()) { | 1129 if (IsVisible()) { |
1129 RootWindow* root_window = GetRootWindow(); | 1130 RootWindow* root_window = GetRootWindow(); |
1130 contains_mouse = root_window && | 1131 contains_mouse = root_window && |
1131 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); | 1132 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); |
1132 } | 1133 } |
1133 return contains_mouse; | 1134 return contains_mouse; |
1134 } | 1135 } |
1135 | 1136 |
1136 } // namespace aura | 1137 } // namespace aura |
OLD | NEW |