| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 layer_ = new ui::Layer(layer_type); | 139 layer_ = new ui::Layer(layer_type); |
| 140 layer_owner_.reset(layer_); | 140 layer_owner_.reset(layer_); |
| 141 layer_->SetVisible(false); | 141 layer_->SetVisible(false); |
| 142 layer_->set_delegate(this); | 142 layer_->set_delegate(this); |
| 143 UpdateLayerName(name_); | 143 UpdateLayerName(name_); |
| 144 layer_->SetFillsBoundsOpaquely(!transparent_); | 144 layer_->SetFillsBoundsOpaquely(!transparent_); |
| 145 | 145 |
| 146 Env::GetInstance()->NotifyWindowInitialized(this); | 146 Env::GetInstance()->NotifyWindowInitialized(this); |
| 147 } | 147 } |
| 148 | 148 |
| 149 ui::Layer* Window::RecreateLayer() { |
| 150 // Disconnect the old layer, but don't delete it. |
| 151 ui::Layer* old_layer = AcquireLayer(); |
| 152 old_layer->set_delegate(NULL); |
| 153 layer_ = new ui::Layer(old_layer->type()); |
| 154 layer_owner_.reset(layer_); |
| 155 layer_->SetVisible(old_layer->visible()); |
| 156 layer_->set_delegate(this); |
| 157 UpdateLayerName(name_); |
| 158 layer_->SetFillsBoundsOpaquely(!transparent_); |
| 159 // Install new layer as a sibling of the old layer, stacked on top of it. |
| 160 if (old_layer->parent()) { |
| 161 old_layer->parent()->Add(layer_); |
| 162 old_layer->parent()->StackAbove(layer_, old_layer); |
| 163 } |
| 164 // Migrate all the child layers over to the new layer. Copy the list because |
| 165 // the items are removed during iteration. |
| 166 std::vector<ui::Layer*> children_copy = old_layer->children(); |
| 167 for (std::vector<ui::Layer*>::const_iterator it = children_copy.begin(); |
| 168 it != children_copy.end(); |
| 169 ++it) { |
| 170 ui::Layer* child = *it; |
| 171 layer_->Add(child); |
| 172 } |
| 173 return old_layer; |
| 174 } |
| 175 |
| 149 void Window::SetType(client::WindowType type) { | 176 void Window::SetType(client::WindowType type) { |
| 150 // Cannot change type after the window is initialized. | 177 // Cannot change type after the window is initialized. |
| 151 DCHECK(!layer()); | 178 DCHECK(!layer()); |
| 152 type_ = type; | 179 type_ = type; |
| 153 } | 180 } |
| 154 | 181 |
| 155 void Window::SetName(const std::string& name) { | 182 void Window::SetName(const std::string& name) { |
| 156 name_ = name; | 183 name_ = name; |
| 157 | 184 |
| 158 if (layer()) | 185 if (layer()) |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 for (Windows::const_reverse_iterator it = children_.rbegin(), | 849 for (Windows::const_reverse_iterator it = children_.rbegin(), |
| 823 rend = children_.rend(); | 850 rend = children_.rend(); |
| 824 it != rend; ++it) { | 851 it != rend; ++it) { |
| 825 Window* child = *it; | 852 Window* child = *it; |
| 826 child->PrintWindowHierarchy(depth + 1); | 853 child->PrintWindowHierarchy(depth + 1); |
| 827 } | 854 } |
| 828 } | 855 } |
| 829 #endif | 856 #endif |
| 830 | 857 |
| 831 } // namespace aura | 858 } // namespace aura |
| OLD | NEW |