Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Unified Diff: ui/aura/window.cc

Issue 204793004: Makes View::RecreateLayer() and Window::RecreateLayer() the same (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/compositor/clone_layer.h » ('j') | ui/compositor/clone_layer.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window.cc
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index c55651b95c0f71642ecd8166c1e7b2fa39e5b3eb..40275c34d0e301e8198c5860009bf9fd31e6984d 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -27,6 +27,7 @@
#include "ui/aura/window_observer.h"
#include "ui/aura/window_tracker.h"
#include "ui/aura/window_tree_host.h"
+#include "ui/compositor/clone_layer.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#include "ui/events/event_target_iterator.h"
@@ -277,45 +278,6 @@ void Window::Init(WindowLayerType window_layer_type) {
Env::GetInstance()->NotifyWindowInitialized(this);
}
-// TODO(sky): move to match new position.
-scoped_ptr<ui::Layer> Window::RecreateLayer() {
- // Disconnect the old layer, but don't delete it.
- scoped_ptr<ui::Layer> old_layer(AcquireLayer());
- if (!old_layer)
- return old_layer.Pass();
-
- old_layer->set_delegate(NULL);
-
- const gfx::Rect layer_bounds(old_layer->bounds());
- SetLayer(new ui::Layer(old_layer->type()));
- layer()->SetVisible(old_layer->visible());
- layer()->set_scale_content(old_layer->scale_content());
- layer()->SetBounds(layer_bounds);
- layer()->set_delegate(this);
- layer()->SetMasksToBounds(old_layer->GetMasksToBounds());
-
- if (delegate_)
- delegate_->DidRecreateLayer(old_layer.get(), layer());
-
- UpdateLayerName(name_);
- layer()->SetFillsBoundsOpaquely(!transparent_);
- // Install new layer as a sibling of the old layer, stacked below it.
- if (old_layer->parent()) {
- old_layer->parent()->Add(layer());
- old_layer->parent()->StackBelow(layer(), old_layer.get());
- }
- // Migrate all the child layers over to the new layer. Copy the list because
- // the items are removed during iteration.
- std::vector<ui::Layer*> children_copy = old_layer->children();
- for (std::vector<ui::Layer*>::const_iterator it = children_copy.begin();
- it != children_copy.end();
- ++it) {
- ui::Layer* child = *it;
- layer()->Add(child);
- }
- return old_layer.Pass();
-}
-
void Window::SetType(ui::wm::WindowType type) {
// Cannot change type after the window is initialized.
DCHECK(!layer());
@@ -791,6 +753,17 @@ void Window::OnDeviceScaleFactorChanged(float device_scale_factor) {
delegate_->OnDeviceScaleFactorChanged(device_scale_factor);
}
+scoped_ptr<ui::Layer> Window::RecreateLayer() {
+ scoped_ptr<ui::Layer> old_layer(ui::CloneLayer(this));
+ if (!old_layer)
+ return old_layer.Pass();
+
+ if (delegate_)
+ delegate_->DidRecreateLayer(old_layer.get(), layer());
+
+ return old_layer.Pass();
+}
+
#if !defined(NDEBUG)
std::string Window::GetDebugInfo() const {
return base::StringPrintf(
« no previous file with comments | « no previous file | ui/compositor/clone_layer.h » ('j') | ui/compositor/clone_layer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698