diff options
-rw-r--r-- | ash/system/tray/system_tray_bubble.cc | 8 | ||||
-rw-r--r-- | ui/aura/window.cc | 4 | ||||
-rw-r--r-- | ui/aura/window_unittest.cc | 15 | ||||
-rw-r--r-- | ui/views/view.cc | 6 |
4 files changed, 28 insertions, 5 deletions
diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc index a88a40b..d44dc94 100644 --- a/ash/system/tray/system_tray_bubble.cc +++ b/ash/system/tray/system_tray_bubble.cc @@ -167,9 +167,6 @@ void SystemTrayBubble::UpdateView( // When transitioning from detailed view to default view, animate the // existing view (slide out towards the right). if (bubble_type == BUBBLE_TYPE_DEFAULT) { - // Make sure the old view is visibile over the new view during the - // animation. - layer->parent()->StackAbove(layer, bubble_view_->layer()); ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); settings.AddObserver( new AnimationObserverDeleteLayer(scoped_layer.release())); @@ -230,6 +227,11 @@ void SystemTrayBubble::UpdateView( // view (slide in from the right). if (bubble_type == BUBBLE_TYPE_DETAILED) { ui::Layer* new_layer = bubble_view_->layer(); + + // Make sure the new layer is stacked above the old layer during the + // animation. + new_layer->parent()->StackAbove(new_layer, scoped_layer.get()); + gfx::Rect bounds = new_layer->bounds(); gfx::Transform transform; transform.Translate(bounds.width(), 0.0); 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; } |