diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 22:42:26 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 22:42:26 +0000 |
commit | 89c6202ef61755e8ec6e513096bc7ffb25818997 (patch) | |
tree | 547050d8ec838f0a216adbdaf7b501cb8a0ca720 /ui/views | |
parent | 5fef89241fe5e0ddaa7bf7b6a5f7e48727fde553 (diff) | |
download | chromium_src-89c6202ef61755e8ec6e513096bc7ffb25818997.zip chromium_src-89c6202ef61755e8ec6e513096bc7ffb25818997.tar.gz chromium_src-89c6202ef61755e8ec6e513096bc7ffb25818997.tar.bz2 |
Fix bug where layers weren't getting reordered correctly in a
NativeWidgetAura.
BUG=none
TEST=none
R=ben@chromium.org
Review URL: http://codereview.chromium.org/9214003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117715 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r-- | ui/views/view.cc | 4 | ||||
-rw-r--r-- | ui/views/view_unittest.cc | 28 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 4 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.h | 1 | ||||
-rw-r--r-- | ui/views/widget/native_widget_gtk.cc | 3 | ||||
-rw-r--r-- | ui/views/widget/native_widget_gtk.h | 1 | ||||
-rw-r--r-- | ui/views/widget/native_widget_private.h | 1 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 3 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.h | 1 | ||||
-rw-r--r-- | ui/views/widget/root_view.cc | 4 | ||||
-rw-r--r-- | ui/views/widget/root_view.h | 1 | ||||
-rw-r--r-- | ui/views/widget/widget.cc | 6 |
12 files changed, 40 insertions, 17 deletions
diff --git a/ui/views/view.cc b/ui/views/view.cc index d764d2f..5e371af 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -1199,7 +1199,7 @@ void View::ReorderLayers() { while (v && !v->layer()) v = v->parent(); - // Forward to widget in case we're in a NativeWidgetView. + // Forward to widget in case we're in a NativeWidgetAura. if (!v) { if (GetWidget()) GetWidget()->ReorderLayers(); diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc index 739d393..44d7456 100644 --- a/ui/views/view_unittest.cc +++ b/ui/views/view_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -3075,6 +3075,32 @@ TEST_F(ViewLayerTest, FLAKY_ViewLayerTreesInSync) { EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); } +#if defined(USE_AURA) +// Verifies when views are reordered the layer is also reordered. The widget is +// providing the parent layer. +TEST_F(ViewLayerTest, ReorderUnderWidget) { + View* content = new View; + widget()->SetContentsView(content); + View* c1 = new View; + c1->SetPaintToLayer(true); + content->AddChildView(c1); + View* c2 = new View; + c2->SetPaintToLayer(true); + content->AddChildView(c2); + + ui::Layer* parent_layer = c1->layer()->parent(); + ASSERT_TRUE(parent_layer); + ASSERT_EQ(2u, parent_layer->children().size()); + EXPECT_EQ(c1->layer(), parent_layer->children()[0]); + EXPECT_EQ(c2->layer(), parent_layer->children()[1]); + + // Move c1 to the front. The layers should have moved too. + content->ReorderChildView(c1, -1); + EXPECT_EQ(c1->layer(), parent_layer->children()[1]); + EXPECT_EQ(c2->layer(), parent_layer->children()[0]); +} +#endif + #endif // VIEWS_COMPOSITOR } // namespace views diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index b99aa40..16c1d7a 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -24,6 +24,7 @@ #include "ui/views/ime/input_method_bridge.h" #include "ui/views/widget/drop_helper.h" #include "ui/views/widget/native_widget_delegate.h" +#include "ui/views/widget/root_view.h" #include "ui/views/widget/tooltip_manager_aura.h" #include "ui/views/widget/widget_delegate.h" @@ -260,9 +261,6 @@ void NativeWidgetAura::CalculateOffsetToAncestorWithLayer( *layer_parent = window_->layer(); } -void NativeWidgetAura::ReorderLayers() { -} - void NativeWidgetAura::ViewRemoved(View* view) { DCHECK(drop_helper_.get() != NULL); drop_helper_->ResetTargetViewIfEquals(view); diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index af84d53..9f7ca18 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -55,7 +55,6 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, virtual void CalculateOffsetToAncestorWithLayer( gfx::Point* offset, ui::Layer** layer_parent) OVERRIDE; - virtual void ReorderLayers() OVERRIDE; virtual void ViewRemoved(View* view) OVERRIDE; virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; diff --git a/ui/views/widget/native_widget_gtk.cc b/ui/views/widget/native_widget_gtk.cc index c79e068..7aac5b4 100644 --- a/ui/views/widget/native_widget_gtk.cc +++ b/ui/views/widget/native_widget_gtk.cc @@ -829,9 +829,6 @@ void NativeWidgetGtk::CalculateOffsetToAncestorWithLayer( ui::Layer** layer_parent) { } -void NativeWidgetGtk::ReorderLayers() { -} - void NativeWidgetGtk::ViewRemoved(View* view) { if (drop_target_.get()) drop_target_->ResetTargetViewIfEquals(view); diff --git a/ui/views/widget/native_widget_gtk.h b/ui/views/widget/native_widget_gtk.h index dc9973f..79a9da7 100644 --- a/ui/views/widget/native_widget_gtk.h +++ b/ui/views/widget/native_widget_gtk.h @@ -159,7 +159,6 @@ class VIEWS_EXPORT NativeWidgetGtk : public internal::NativeWidgetPrivate, virtual void CalculateOffsetToAncestorWithLayer( gfx::Point* offset, ui::Layer** layer_parent) OVERRIDE; - virtual void ReorderLayers() OVERRIDE; virtual void ViewRemoved(View* view) OVERRIDE; virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; diff --git a/ui/views/widget/native_widget_private.h b/ui/views/widget/native_widget_private.h index ee94178..50a2785 100644 --- a/ui/views/widget/native_widget_private.h +++ b/ui/views/widget/native_widget_private.h @@ -98,7 +98,6 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget, // See description in View for details. virtual void CalculateOffsetToAncestorWithLayer(gfx::Point* offset, ui::Layer** layer_parent) = 0; - virtual void ReorderLayers() = 0; // Notifies the NativeWidget that a view was removed from the Widget's view // hierarchy. diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 841177a..43581ff 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -600,9 +600,6 @@ void NativeWidgetWin::CalculateOffsetToAncestorWithLayer( ui::Layer** layer_parent) { } -void NativeWidgetWin::ReorderLayers() { -} - void NativeWidgetWin::ViewRemoved(View* view) { if (drop_target_.get()) drop_target_->ResetTargetViewIfEquals(view); diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h index ab40897..3094cec 100644 --- a/ui/views/widget/native_widget_win.h +++ b/ui/views/widget/native_widget_win.h @@ -191,7 +191,6 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, virtual void CalculateOffsetToAncestorWithLayer( gfx::Point* offset, ui::Layer** layer_parent) OVERRIDE; - virtual void ReorderLayers() OVERRIDE; virtual void ViewRemoved(View* view) OVERRIDE; virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc index f1882bd1..c4978ca 100644 --- a/ui/views/widget/root_view.cc +++ b/ui/views/widget/root_view.cc @@ -401,6 +401,10 @@ void RootView::GetAccessibleState(ui::AccessibleViewState* state) { state->role = ui::AccessibilityTypes::ROLE_APPLICATION; } +void RootView::ReorderChildLayers(ui::Layer* parent_layer) { + View::ReorderChildLayers(parent_layer); +} + //////////////////////////////////////////////////////////////////////////////// // RootView, protected: diff --git a/ui/views/widget/root_view.h b/ui/views/widget/root_view.h index 36cd6aa..3f372e6 100644 --- a/ui/views/widget/root_view.h +++ b/ui/views/widget/root_view.h @@ -112,6 +112,7 @@ class VIEWS_EXPORT RootView : public View, public FocusTraversable { virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; virtual void SetMouseHandler(View* new_mouse_handler) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE; protected: // Overridden from View: diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index a69a1d2..73c2bd0 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -792,7 +792,11 @@ void Widget::CalculateOffsetToAncestorWithLayer(gfx::Point* offset, } void Widget::ReorderLayers() { - native_widget_->ReorderLayers(); + gfx::Point point; + ui::Layer* layer = NULL; + CalculateOffsetToAncestorWithLayer(&point, &layer); + if (layer) + root_view_->ReorderChildLayers(layer); } void Widget::NotifyAccessibilityEvent( |