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/wm/core/window_util.h" | 5 #include "ui/wm/core/window_util.h" |
6 | 6 |
7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
8 #include "ui/compositor/layer.h" | 8 #include "ui/compositor/layer.h" |
9 #include "ui/compositor/layer_tree_owner.h" | 9 #include "ui/compositor/layer_tree_owner.h" |
10 #include "ui/wm/core/transient_window_manager.h" | 10 #include "ui/wm/core/transient_window_manager.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 wm::LayerDelegateFactory* factory) { | 21 wm::LayerDelegateFactory* factory) { |
22 typedef std::vector<ui::Layer*> Layers; | 22 typedef std::vector<ui::Layer*> Layers; |
23 // Make a copy of the children since RecreateLayer() mutates it. | 23 // Make a copy of the children since RecreateLayer() mutates it. |
24 Layers children(to_clone->children()); | 24 Layers children(to_clone->children()); |
25 for (Layers::const_iterator i = children.begin(); i != children.end(); ++i) { | 25 for (Layers::const_iterator i = children.begin(); i != children.end(); ++i) { |
26 ui::LayerOwner* owner = (*i)->owner(); | 26 ui::LayerOwner* owner = (*i)->owner(); |
27 ui::Layer* old_layer = owner ? owner->RecreateLayer().release() : NULL; | 27 ui::Layer* old_layer = owner ? owner->RecreateLayer().release() : NULL; |
28 if (old_layer) { | 28 if (old_layer) { |
29 if (factory && owner->layer()->delegate()) | 29 if (factory && owner->layer()->delegate()) |
30 old_layer->set_delegate( | 30 old_layer->set_delegate( |
31 factory->CreateDelegate(owner->layer()->delegate())); | 31 factory->CreateDelegate(old_layer, owner->layer())); |
32 parent->Add(old_layer); | 32 parent->Add(old_layer); |
33 // RecreateLayer() moves the existing children to the new layer. Create a | 33 // RecreateLayer() moves the existing children to the new layer. Create a |
34 // copy of those. | 34 // copy of those. |
35 CloneChildren(owner->layer(), old_layer, factory); | 35 CloneChildren(owner->layer(), old_layer, factory); |
36 } | 36 } |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 86 } |
87 | 87 |
88 std::unique_ptr<ui::LayerTreeOwner> RecreateLayers( | 88 std::unique_ptr<ui::LayerTreeOwner> RecreateLayers( |
89 ui::LayerOwner* root, | 89 ui::LayerOwner* root, |
90 LayerDelegateFactory* factory) { | 90 LayerDelegateFactory* factory) { |
91 std::unique_ptr<ui::LayerTreeOwner> old_layer( | 91 std::unique_ptr<ui::LayerTreeOwner> old_layer( |
92 new ui::LayerTreeOwner(root->RecreateLayer().release())); | 92 new ui::LayerTreeOwner(root->RecreateLayer().release())); |
93 if (old_layer->root()) { | 93 if (old_layer->root()) { |
94 if (factory) { | 94 if (factory) { |
95 old_layer->root()->set_delegate( | 95 old_layer->root()->set_delegate( |
96 factory->CreateDelegate(root->layer()->delegate())); | 96 factory->CreateDelegate(old_layer->root(), root->layer())); |
97 } | 97 } |
98 CloneChildren(root->layer(), old_layer->root(), factory); | 98 CloneChildren(root->layer(), old_layer->root(), factory); |
99 } | 99 } |
100 return old_layer; | 100 return old_layer; |
101 } | 101 } |
102 | 102 |
103 aura::Window* GetTransientParent(aura::Window* window) { | 103 aura::Window* GetTransientParent(aura::Window* window) { |
104 return const_cast<aura::Window*>(GetTransientParent( | 104 return const_cast<aura::Window*>(GetTransientParent( |
105 const_cast<const aura::Window*>(window))); | 105 const_cast<const aura::Window*>(window))); |
106 } | 106 } |
(...skipping 24 matching lines...) Expand all Loading... |
131 bool HasTransientAncestor(const aura::Window* window, | 131 bool HasTransientAncestor(const aura::Window* window, |
132 const aura::Window* ancestor) { | 132 const aura::Window* ancestor) { |
133 const aura::Window* transient_parent = GetTransientParent(window); | 133 const aura::Window* transient_parent = GetTransientParent(window); |
134 if (transient_parent == ancestor) | 134 if (transient_parent == ancestor) |
135 return true; | 135 return true; |
136 return transient_parent ? | 136 return transient_parent ? |
137 HasTransientAncestor(transient_parent, ancestor) : false; | 137 HasTransientAncestor(transient_parent, ancestor) : false; |
138 } | 138 } |
139 | 139 |
140 } // namespace wm | 140 } // namespace wm |
OLD | NEW |