summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-26 02:25:53 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-26 02:25:53 +0000
commit313aa5d635ee33b659948ffa95a3e4914e165db6 (patch)
treef98bf7cd6e7b26fdc7f4fd03e4ce79492c642dac
parentf3ca90933fa31ae47572933743391a41bedc9d88 (diff)
downloadchromium_src-313aa5d635ee33b659948ffa95a3e4914e165db6.zip
chromium_src-313aa5d635ee33b659948ffa95a3e4914e165db6.tar.gz
chromium_src-313aa5d635ee33b659948ffa95a3e4914e165db6.tar.bz2
Renames Rename CalculateOffsetToAncestorWithLayer() to GetLayer().
Refactors View::ReorderLayers() so that it does not call into the widget anymore. Bug=237650 Test=None Review URL: https://chromiumcodereview.appspot.com/15922004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202333 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/views/view.cc47
-rw-r--r--ui/views/view.h10
-rw-r--r--ui/views/view_unittest.cc7
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.cc7
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.h3
-rw-r--r--ui/views/widget/native_widget_aura.cc7
-rw-r--r--ui/views/widget/native_widget_aura.h3
-rw-r--r--ui/views/widget/native_widget_private.h5
-rw-r--r--ui/views/widget/native_widget_win.cc5
-rw-r--r--ui/views/widget/native_widget_win.h3
-rw-r--r--ui/views/widget/root_view.cc9
-rw-r--r--ui/views/widget/root_view.h2
-rw-r--r--ui/views/widget/widget.cc12
-rw-r--r--ui/views/widget/widget.h8
14 files changed, 49 insertions, 79 deletions
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 0e12e14..4bd82c8 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -1374,6 +1374,19 @@ gfx::Vector2d View::CalculateOffsetToAncestorWithLayer(
parent_->CalculateOffsetToAncestorWithLayer(layer_parent);
}
+void View::UpdateParentLayer() {
+ if (!layer())
+ return;
+
+ ui::Layer* parent_layer = NULL;
+ gfx::Vector2d offset(GetMirroredX(), y());
+
+ if (parent_)
+ offset += parent_->CalculateOffsetToAncestorWithLayer(&parent_layer);
+
+ ReparentLayer(offset, parent_layer);
+}
+
void View::MoveLayerToParent(ui::Layer* parent_layer,
const gfx::Point& point) {
gfx::Point local_point(point);
@@ -1439,20 +1452,20 @@ void View::ReorderLayers() {
while (v && !v->layer())
v = v->parent();
- // Forward to widget in case we're in a NativeWidgetAura.
if (!v) {
- if (GetWidget())
- GetWidget()->ReorderLayers();
+ Widget* widget = GetWidget();
+ if (widget) {
+ ui::Layer* layer = widget->GetLayer();
+ if (layer)
+ widget->GetRootView()->ReorderChildLayers(layer);
+ }
} else {
- for (Views::const_iterator i(v->children_.begin());
- i != v->children_.end();
- ++i)
- (*i)->ReorderChildLayers(v->layer());
+ v->ReorderChildLayers(v->layer());
}
}
void View::ReorderChildLayers(ui::Layer* parent_layer) {
- if (layer()) {
+ if (layer() && layer() != parent_layer) {
DCHECK_EQ(parent_layer, layer()->parent());
parent_layer->StackAtTop(layer());
} else {
@@ -2020,24 +2033,6 @@ void View::UpdateParentLayers() {
}
}
-void View::UpdateParentLayer() {
- if (!layer())
- return;
-
- ui::Layer* parent_layer = NULL;
- gfx::Vector2d offset(GetMirroredX(), y());
-
- // TODO(sad): The NULL check here for parent_ essentially is to check if this
- // is the RootView. Instead of doing this, this function should be made
- // virtual and overridden from the RootView.
- if (parent_)
- offset += parent_->CalculateOffsetToAncestorWithLayer(&parent_layer);
- else if (!parent_ && GetWidget())
- offset += GetWidget()->CalculateOffsetToAncestorWithLayer(&parent_layer);
-
- ReparentLayer(offset, parent_layer);
-}
-
void View::OrphanLayers() {
if (layer()) {
if (layer()->parent())
diff --git a/ui/views/view.h b/ui/views/view.h
index 9447364..db2452b 100644
--- a/ui/views/view.h
+++ b/ui/views/view.h
@@ -1076,6 +1076,11 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
virtual gfx::Vector2d CalculateOffsetToAncestorWithLayer(
ui::Layer** layer_parent);
+ // Updates the view's layer's parent. Called when a view is added to a view
+ // hierarchy, responsible for parenting the view's layer to the enclosing
+ // layer in the hierarchy.
+ virtual void UpdateParentLayer();
+
// If this view has a layer, the layer is reparented to |parent_layer| and its
// bounds is set based on |point|. If this view does not have a layer, then
// recurses through all children. This is used when adding a layer to an
@@ -1317,11 +1322,6 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// layer.
void UpdateParentLayers();
- // Updates the view's layer's parent. Called when a view is added to a view
- // hierarchy, responsible for parenting the view's layer to the enclosing
- // layer in the hierarchy.
- void UpdateParentLayer();
-
// Parents this view's layer to |parent_layer|, and sets its bounds and other
// properties in accordance to |offset|, the view's offset from the
// |parent_layer|.
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index 1707f74..a5ccc2e 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -2894,9 +2894,7 @@ class ViewLayerTest : public ViewsTestBase {
// Returns the Layer used by the RootView.
ui::Layer* GetRootLayer() {
- ui::Layer* root_layer = NULL;
- widget()->CalculateOffsetToAncestorWithLayer(&root_layer);
- return root_layer;
+ return widget()->GetLayer();
}
virtual void SetUp() OVERRIDE {
@@ -2929,8 +2927,7 @@ class ViewLayerTest : public ViewsTestBase {
TEST_F(ViewLayerTest, LayerToggling) {
// Because we lazily create textures the calls to DrawTree are necessary to
// ensure we trigger creation of textures.
- ui::Layer* root_layer = NULL;
- widget()->CalculateOffsetToAncestorWithLayer(&root_layer);
+ ui::Layer* root_layer = widget()->GetLayer();
View* content_view = new View;
widget()->SetContentsView(content_view);
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index 9eb0e5c..4e6c1c4 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -312,11 +312,8 @@ ui::Compositor* DesktopNativeWidgetAura::GetCompositor() {
return window_->layer()->GetCompositor();
}
-gfx::Vector2d DesktopNativeWidgetAura::CalculateOffsetToAncestorWithLayer(
- ui::Layer** layer_parent) {
- if (layer_parent)
- *layer_parent = window_->layer();
- return gfx::Vector2d();
+ui::Layer* DesktopNativeWidgetAura::GetLayer() {
+ return window_->layer();
}
void DesktopNativeWidgetAura::ViewRemoved(View* view) {
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
index 5450bae..7a79db8 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
@@ -79,8 +79,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
virtual Widget* GetTopLevelWidget() OVERRIDE;
virtual const ui::Compositor* GetCompositor() const OVERRIDE;
virtual ui::Compositor* GetCompositor() OVERRIDE;
- virtual gfx::Vector2d CalculateOffsetToAncestorWithLayer(
- ui::Layer** layer_parent) OVERRIDE;
+ virtual ui::Layer* GetLayer() 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_aura.cc b/ui/views/widget/native_widget_aura.cc
index 754b258..37a6e41 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -219,11 +219,8 @@ ui::Compositor* NativeWidgetAura::GetCompositor() {
return window_->layer()->GetCompositor();
}
-gfx::Vector2d NativeWidgetAura::CalculateOffsetToAncestorWithLayer(
- ui::Layer** layer_parent) {
- if (layer_parent)
- *layer_parent = window_->layer();
- return gfx::Vector2d();
+ui::Layer* NativeWidgetAura::GetLayer() {
+ return window_->layer();
}
void NativeWidgetAura::ViewRemoved(View* view) {
diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h
index c799111..3dc64d6 100644
--- a/ui/views/widget/native_widget_aura.h
+++ b/ui/views/widget/native_widget_aura.h
@@ -57,8 +57,7 @@ class VIEWS_EXPORT NativeWidgetAura
virtual Widget* GetTopLevelWidget() OVERRIDE;
virtual const ui::Compositor* GetCompositor() const OVERRIDE;
virtual ui::Compositor* GetCompositor() OVERRIDE;
- virtual gfx::Vector2d CalculateOffsetToAncestorWithLayer(
- ui::Layer** layer_parent) OVERRIDE;
+ virtual ui::Layer* GetLayer() 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 9d43c78..2bb61c0 100644
--- a/ui/views/widget/native_widget_private.h
+++ b/ui/views/widget/native_widget_private.h
@@ -97,9 +97,8 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
virtual const ui::Compositor* GetCompositor() const = 0;
virtual ui::Compositor* GetCompositor() = 0;
- // See description in View for details.
- virtual gfx::Vector2d CalculateOffsetToAncestorWithLayer(
- ui::Layer** layer_parent) = 0;
+ // Returns the NativeWidget's layer, if any.
+ virtual ui::Layer* GetLayer() = 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 53cc385..59abe0b 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -157,9 +157,8 @@ ui::Compositor* NativeWidgetWin::GetCompositor() {
return NULL;
}
-gfx::Vector2d NativeWidgetWin::CalculateOffsetToAncestorWithLayer(
- ui::Layer** layer_parent) {
- return gfx::Vector2d();
+ui::Layer* NativeWidgetWin::GetLayer() {
+ return NULL;
}
void NativeWidgetWin::ViewRemoved(View* view) {
diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h
index ff018fc..85f1e84 100644
--- a/ui/views/widget/native_widget_win.h
+++ b/ui/views/widget/native_widget_win.h
@@ -79,8 +79,7 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate,
virtual Widget* GetTopLevelWidget() OVERRIDE;
virtual const ui::Compositor* GetCompositor() const OVERRIDE;
virtual ui::Compositor* GetCompositor() OVERRIDE;
- virtual gfx::Vector2d CalculateOffsetToAncestorWithLayer(
- ui::Layer** layer_parent) OVERRIDE;
+ virtual ui::Layer* GetLayer() 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 bbe11b8..5393a2f 100644
--- a/ui/views/widget/root_view.cc
+++ b/ui/views/widget/root_view.cc
@@ -590,8 +590,9 @@ void RootView::GetAccessibleState(ui::AccessibleViewState* state) {
state->role = widget_->widget_delegate()->GetAccessibleWindowRole();
}
-void RootView::ReorderChildLayers(ui::Layer* parent_layer) {
- View::ReorderChildLayers(parent_layer);
+void RootView::UpdateParentLayer() {
+ if (layer())
+ ReparentLayer(gfx::Vector2d(GetMirroredX(), y()), widget_->GetLayer());
}
////////////////////////////////////////////////////////////////////////////////
@@ -631,8 +632,8 @@ void RootView::OnPaint(gfx::Canvas* canvas) {
gfx::Vector2d RootView::CalculateOffsetToAncestorWithLayer(
ui::Layer** layer_parent) {
gfx::Vector2d offset(View::CalculateOffsetToAncestorWithLayer(layer_parent));
- if (!layer())
- offset += widget_->CalculateOffsetToAncestorWithLayer(layer_parent);
+ if (!layer() && layer_parent)
+ *layer_parent = widget_->GetLayer();
return offset;
}
diff --git a/ui/views/widget/root_view.h b/ui/views/widget/root_view.h
index 46f8bef..d8a95da 100644
--- a/ui/views/widget/root_view.h
+++ b/ui/views/widget/root_view.h
@@ -108,7 +108,7 @@ class VIEWS_EXPORT RootView : public View,
virtual bool OnMouseWheel(const ui::MouseWheelEvent& 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;
+ virtual void UpdateParentLayer() OVERRIDE;
protected:
// Overridden from View:
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index cf9e3b3..c78d90c 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -880,16 +880,8 @@ ui::Compositor* Widget::GetCompositor() {
return native_widget_->GetCompositor();
}
-gfx::Vector2d Widget::CalculateOffsetToAncestorWithLayer(
- ui::Layer** layer_parent) {
- return native_widget_->CalculateOffsetToAncestorWithLayer(layer_parent);
-}
-
-void Widget::ReorderLayers() {
- ui::Layer* layer = NULL;
- CalculateOffsetToAncestorWithLayer(&layer);
- if (layer)
- root_view_->ReorderChildLayers(layer);
+ui::Layer* Widget::GetLayer() {
+ return native_widget_->GetLayer();
}
void Widget::UpdateRootLayers() {
diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h
index 9190769..6246faa 100644
--- a/ui/views/widget/widget.h
+++ b/ui/views/widget/widget.h
@@ -570,12 +570,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
const ui::Compositor* GetCompositor() const;
ui::Compositor* GetCompositor();
- // Invokes method of same name on the NativeWidget.
- gfx::Vector2d CalculateOffsetToAncestorWithLayer(
- ui::Layer** layer_parent);
-
- // Invokes method of same name on the NativeWidget.
- void ReorderLayers();
+ // Returns the widget's layer, if any.
+ ui::Layer* GetLayer();
// Schedules an update to the root layers. The actual processing occurs when
// GetRootLayers() is invoked.