OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/wm/core/transient_window_manager.h" | 5 #include "ui/wm/core/transient_window_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/aura/window_property.h" | 13 #include "ui/aura/window_property.h" |
14 #include "ui/aura/window_tracker.h" | |
14 #include "ui/wm/core/transient_window_observer.h" | 15 #include "ui/wm/core/transient_window_observer.h" |
15 #include "ui/wm/core/transient_window_stacking_client.h" | 16 #include "ui/wm/core/transient_window_stacking_client.h" |
16 #include "ui/wm/core/window_util.h" | 17 #include "ui/wm/core/window_util.h" |
17 | 18 |
18 using aura::Window; | 19 using aura::Window; |
19 | 20 |
20 DECLARE_WINDOW_PROPERTY_TYPE(wm::TransientWindowManager*); | 21 DECLARE_WINDOW_PROPERTY_TYPE(wm::TransientWindowManager*); |
21 | 22 |
22 namespace wm { | 23 namespace wm { |
23 namespace { | 24 namespace { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 } | 156 } |
156 } | 157 } |
157 | 158 |
158 void TransientWindowManager::OnWindowVisibilityChanged(Window* window, | 159 void TransientWindowManager::OnWindowVisibilityChanged(Window* window, |
159 bool visible) { | 160 bool visible) { |
160 if (window_ != window) | 161 if (window_ != window) |
161 return; | 162 return; |
162 | 163 |
163 // If the window has transient children, updates the transient children's | 164 // If the window has transient children, updates the transient children's |
164 // visiblity as well. | 165 // visiblity as well. |
166 aura::WindowTracker tracker; | |
sky
2015/11/22 15:24:16
Add a comment as to why you use WindowTracker.
| |
165 for (Window* child : transient_children_) | 167 for (Window* child : transient_children_) |
166 Get(child)->UpdateTransientChildVisibility(visible); | 168 tracker.Add(child); |
169 | |
170 while (!tracker.windows().empty()) { | |
171 Window* window = *(tracker.windows().begin()); | |
172 Get(window)->UpdateTransientChildVisibility(visible); | |
173 tracker.Remove(window); | |
174 } | |
167 | 175 |
168 // Remember the show request in |show_on_parent_visible_| and hide it again | 176 // Remember the show request in |show_on_parent_visible_| and hide it again |
169 // if the following conditions are met | 177 // if the following conditions are met |
170 // - |parent_controls_visibility| is set to true. | 178 // - |parent_controls_visibility| is set to true. |
171 // - the window is hidden while the transient parent is not visible. | 179 // - the window is hidden while the transient parent is not visible. |
172 // - Show/Hide was NOT called from TransientWindowManager. | 180 // - Show/Hide was NOT called from TransientWindowManager. |
173 if (ignore_visibility_changed_event_ || | 181 if (ignore_visibility_changed_event_ || |
174 !transient_parent_ || !parent_controls_visibility_) { | 182 !transient_parent_ || !parent_controls_visibility_) { |
175 return; | 183 return; |
176 } | 184 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 | 221 |
214 // Destroy transient children, only after we've removed ourselves from our | 222 // Destroy transient children, only after we've removed ourselves from our |
215 // parent, as destroying an active transient child may otherwise attempt to | 223 // parent, as destroying an active transient child may otherwise attempt to |
216 // refocus us. | 224 // refocus us. |
217 Windows transient_children(transient_children_); | 225 Windows transient_children(transient_children_); |
218 STLDeleteElements(&transient_children); | 226 STLDeleteElements(&transient_children); |
219 DCHECK(transient_children_.empty()); | 227 DCHECK(transient_children_.empty()); |
220 } | 228 } |
221 | 229 |
222 } // namespace wm | 230 } // namespace wm |
OLD | NEW |