| 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 | |
| 176 void Window::SetType(client::WindowType type) { | 149 void Window::SetType(client::WindowType type) { |
| 177 // Cannot change type after the window is initialized. | 150 // Cannot change type after the window is initialized. |
| 178 DCHECK(!layer()); | 151 DCHECK(!layer()); |
| 179 type_ = type; | 152 type_ = type; |
| 180 } | 153 } |
| 181 | 154 |
| 182 void Window::SetName(const std::string& name) { | 155 void Window::SetName(const std::string& name) { |
| 183 name_ = name; | 156 name_ = name; |
| 184 | 157 |
| 185 if (layer()) | 158 if (layer()) |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 for (Windows::const_reverse_iterator it = children_.rbegin(), | 822 for (Windows::const_reverse_iterator it = children_.rbegin(), |
| 850 rend = children_.rend(); | 823 rend = children_.rend(); |
| 851 it != rend; ++it) { | 824 it != rend; ++it) { |
| 852 Window* child = *it; | 825 Window* child = *it; |
| 853 child->PrintWindowHierarchy(depth + 1); | 826 child->PrintWindowHierarchy(depth + 1); |
| 854 } | 827 } |
| 855 } | 828 } |
| 856 #endif | 829 #endif |
| 857 | 830 |
| 858 } // namespace aura | 831 } // namespace aura |
| OLD | NEW |