summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-27 19:00:31 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-27 19:00:31 +0000
commit654bd970faf35df7605600f40b9312e015cf36c1 (patch)
treecd3a4773669ae95e80404cb065bca3b849a4185d /ui
parent692a0c216902d5096cc857f35d695c377158dd9e (diff)
downloadchromium_src-654bd970faf35df7605600f40b9312e015cf36c1.zip
chromium_src-654bd970faf35df7605600f40b9312e015cf36c1.tar.gz
chromium_src-654bd970faf35df7605600f40b9312e015cf36c1.tar.bz2
Make RecreateLayer() order the old layer above the new layer.
This is required to stack layers with LayerOwners below layers without LayerOwners as per sky@'s suggestion in https://codereview.chromium.org/15114002/ Review URL: https://chromiumcodereview.appspot.com/15932003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202457 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/window.cc4
-rw-r--r--ui/aura/window_unittest.cc15
-rw-r--r--ui/views/view.cc6
3 files changed, 23 insertions, 2 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index 90a8fed..c1f7487 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -163,10 +163,10 @@ ui::Layer* Window::RecreateLayer() {
UpdateLayerName(name_);
layer_->SetFillsBoundsOpaquely(!transparent_);
- // Install new layer as a sibling of the old layer, stacked on top of it.
+ // 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()->StackAbove(layer_, old_layer);
+ old_layer->parent()->StackBelow(layer_, old_layer);
}
// Migrate all the child layers over to the new layer. Copy the list because
// the items are removed during iteration.
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index a38ab01..0991080 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -2057,6 +2057,21 @@ TEST_F(WindowTest, RecreateLayer) {
EXPECT_TRUE(layer->GetMasksToBounds());
}
+// Verify that RecreateLayer() stacks the old layer above the newly creatd
+// layer.
+TEST_F(WindowTest, RecreateLayerZOrder) {
+ scoped_ptr<Window> w(
+ CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(0, 0, 100, 100),
+ root_window()));
+ scoped_ptr<ui::Layer> old_layer(w->RecreateLayer());
+
+ const std::vector<ui::Layer*>& child_layers =
+ root_window()->layer()->children();
+ ASSERT_EQ(2u, child_layers.size());
+ EXPECT_EQ(w->layer(), child_layers[0]);
+ EXPECT_EQ(old_layer.get(), child_layers[1]);
+}
+
// Ensure that acquiring a layer then recreating a layer does not crash
// and that RecreateLayer returns null.
TEST_F(WindowTest, AcquireThenRecreateLayer) {
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 2b965e7..43719f3 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -535,6 +535,12 @@ ui::Layer* View::RecreateLayer() {
return NULL;
CreateLayer();
+
+ // TODO(pkotwicz): Remove this once ReorderLayers() stacks layers not attached
+ // to a view above layers attached to a view.
+ if (layer->parent())
+ layer->parent()->StackAtTop(layer);
+
layer_->set_scale_content(layer->scale_content());
return layer;
}