summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-08 11:53:35 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-08 11:53:35 +0000
commit9ef00a5b0b51f5a60d925ed27979745d8240d700 (patch)
tree38864a823f25f8209430a0af55ca9c0fc0d1c65e /views
parent9af487d4c521414c9f006ae342d3b9974f5a6bed (diff)
downloadchromium_src-9ef00a5b0b51f5a60d925ed27979745d8240d700.zip
chromium_src-9ef00a5b0b51f5a60d925ed27979745d8240d700.tar.gz
chromium_src-9ef00a5b0b51f5a60d925ed27979745d8240d700.tar.bz2
Reorder Layers with NativeWidgetViews.
The presence of NativeWidgetViews complicates the process of keeping the Layer tree in sync with the View tree. Specifically, when walking up the View tree to find a View with a Layer, we may have to walk up through a NativeWidgetViews to a NativeWidgetView in a different View tree. Similarly, when walking down the tree to find Views with Layers, we may have to walk down through a NativeWidgetView to a NativeWidgetViews. BUG=none TEST=none Review URL: http://codereview.chromium.org/8201008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/view.cc50
-rw-r--r--views/view.h18
-rw-r--r--views/widget/native_widget_aura.cc3
-rw-r--r--views/widget/native_widget_aura.h1
-rw-r--r--views/widget/native_widget_gtk.cc3
-rw-r--r--views/widget/native_widget_gtk.h1
-rw-r--r--views/widget/native_widget_private.h1
-rw-r--r--views/widget/native_widget_view.cc12
-rw-r--r--views/widget/native_widget_view.h2
-rw-r--r--views/widget/native_widget_views.cc4
-rw-r--r--views/widget/native_widget_views.h1
-rw-r--r--views/widget/native_widget_wayland.cc3
-rw-r--r--views/widget/native_widget_wayland.h1
-rw-r--r--views/widget/native_widget_win.cc3
-rw-r--r--views/widget/widget.cc4
-rw-r--r--views/widget/widget.h3
16 files changed, 78 insertions, 32 deletions
diff --git a/views/view.cc b/views/view.cc
index ce96853..b49fab6 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -1147,6 +1147,33 @@ void View::OnPaintLayer(gfx::Canvas* canvas) {
PaintCommon(canvas);
}
+void View::ReorderLayers() {
+ View* v = this;
+ while (v && !v->layer())
+ v = v->parent();
+
+ // Forward to widget in case we're in a NativeWidgetView.
+ if (!v) {
+ if (GetWidget())
+ GetWidget()->ReorderLayers();
+ } else {
+ for (Views::const_iterator i(v->children_.begin());
+ i != v->children_.end();
+ ++i)
+ (*i)->ReorderChildLayers(v->layer());
+ }
+}
+
+void View::ReorderChildLayers(ui::Layer* parent_layer) {
+ if (layer()) {
+ DCHECK_EQ(parent_layer, layer()->parent());
+ parent_layer->MoveToFront(layer());
+ } else {
+ for (Views::const_iterator i(children_.begin()); i != children_.end(); ++i)
+ (*i)->ReorderChildLayers(parent_layer);
+ }
+}
+
// Input -----------------------------------------------------------------------
bool View::HasHitTestMask() const {
@@ -1805,29 +1832,6 @@ void View::DestroyLayer() {
SchedulePaint();
}
-void View::ReorderLayers() {
- View* v = this;
- while (v && !v->layer())
- v = v->parent();
-
- if (v) {
- for (Views::const_iterator i(v->children_.begin());
- i != v->children_.end();
- ++i)
- (*i)->ReorderChildLayers(v->layer());
- }
-}
-
-void View::ReorderChildLayers(ui::Layer* parent_layer) {
- if (layer()) {
- DCHECK_EQ(parent_layer, layer()->parent());
- parent_layer->MoveToFront(layer());
- } else {
- for (Views::const_iterator i(children_.begin()); i != children_.end(); ++i)
- (*i)->ReorderChildLayers(parent_layer);
- }
-}
-
// Input -----------------------------------------------------------------------
bool View::ProcessMousePressed(const MouseEvent& event, DragInfo* drag_info) {
diff --git a/views/view.h b/views/view.h
index 8bc1b95..5875cfb0 100644
--- a/views/view.h
+++ b/views/view.h
@@ -990,6 +990,15 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Overridden from ui::LayerDelegate:
virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
+ // Finds the layer that this view paints to (it may belong to an ancestor
+ // view), then reorders the immediate children of that layer to match the
+ // order of the view tree.
+ virtual void ReorderLayers();
+
+ // This reorders the immediate children of |*parent_layer| to match the
+ // order of the view tree.
+ virtual void ReorderChildLayers(ui::Layer* parent_layer);
+
// Input ---------------------------------------------------------------------
// Called by HitTest to see if this View has a custom hit test mask. If the
@@ -1246,15 +1255,6 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// to the destroyed layer's parent.
void DestroyLayer();
- // Finds the layer that this view paints to (it may belong to an ancestor
- // view), then reorders the immediate children of that layer to match the
- // order of the view tree.
- void ReorderLayers();
-
- // This reorders the immediate children of |*parent_layer| to match the
- // order of the view tree.
- void ReorderChildLayers(ui::Layer* parent_layer);
-
// Input ---------------------------------------------------------------------
// RootView invokes these. These in turn invoke the appropriate OnMouseXXX
diff --git a/views/widget/native_widget_aura.cc b/views/widget/native_widget_aura.cc
index c9d88e1..1060f40 100644
--- a/views/widget/native_widget_aura.cc
+++ b/views/widget/native_widget_aura.cc
@@ -163,6 +163,9 @@ void NativeWidgetAura::CalculateOffsetToAncestorWithLayer(
*layer_parent = window_->layer();
}
+void NativeWidgetAura::ReorderLayers() {
+}
+
void NativeWidgetAura::ViewRemoved(View* view) {
NOTIMPLEMENTED();
}
diff --git a/views/widget/native_widget_aura.h b/views/widget/native_widget_aura.h
index 0e437c9..70cd7ae 100644
--- a/views/widget/native_widget_aura.h
+++ b/views/widget/native_widget_aura.h
@@ -48,6 +48,7 @@ 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/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index d9af97a..a160342 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -885,6 +885,9 @@ 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/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h
index 6c841708..7538930 100644
--- a/views/widget/native_widget_gtk.h
+++ b/views/widget/native_widget_gtk.h
@@ -157,6 +157,7 @@ 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/views/widget/native_widget_private.h b/views/widget/native_widget_private.h
index e615470..3613ee2 100644
--- a/views/widget/native_widget_private.h
+++ b/views/widget/native_widget_private.h
@@ -97,6 +97,7 @@ 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/views/widget/native_widget_view.cc b/views/widget/native_widget_view.cc
index 26f5faa..d9d6289 100644
--- a/views/widget/native_widget_view.cc
+++ b/views/widget/native_widget_view.cc
@@ -47,6 +47,10 @@ void NativeWidgetView::CalculateOffsetToAncestorWithLayer(
View::CalculateOffsetToAncestorWithLayer(offset, layer_parent);
}
+void NativeWidgetView::ReorderLayers() {
+ View::ReorderLayers();
+}
+
#if !defined(NDEBUG)
std::string NativeWidgetView::PrintViewGraph(bool first) {
return DoPrintViewGraph(first, GetAssociatedWidget()->GetRootView());
@@ -161,5 +165,13 @@ void NativeWidgetView::UpdateChildLayerBounds(const gfx::Point& offset) {
}
}
+void NativeWidgetView::ReorderChildLayers(ui::Layer* parent_layer) {
+ if (layer()) {
+ View::ReorderChildLayers(parent_layer);
+ } else {
+ GetAssociatedWidget()->GetRootView()->ReorderChildLayers(parent_layer);
+ }
+}
+
} // namespace internal
} // namespace views
diff --git a/views/widget/native_widget_view.h b/views/widget/native_widget_view.h
index 813a16b..a64cbf7 100644
--- a/views/widget/native_widget_view.h
+++ b/views/widget/native_widget_view.h
@@ -44,6 +44,7 @@ class VIEWS_EXPORT NativeWidgetView : public View {
virtual void CalculateOffsetToAncestorWithLayer(
gfx::Point* offset,
ui::Layer** layer_parent) OVERRIDE;
+ virtual void ReorderLayers() OVERRIDE;
#if !defined(NDEBUG)
virtual std::string PrintViewGraph(bool first) OVERRIDE;
@@ -75,6 +76,7 @@ class VIEWS_EXPORT NativeWidgetView : public View {
virtual void MoveLayerToParent(ui::Layer* parent_layer,
const gfx::Point& point) OVERRIDE;
virtual void UpdateChildLayerBounds(const gfx::Point& offset) OVERRIDE;
+ virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE;
internal::NativeWidgetDelegate* delegate() {
return native_widget_->delegate();
diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc
index ed61424..906e020 100644
--- a/views/widget/native_widget_views.cc
+++ b/views/widget/native_widget_views.cc
@@ -214,6 +214,10 @@ void NativeWidgetViews::CalculateOffsetToAncestorWithLayer(
view_->CalculateOffsetToAncestorWithLayer(offset, layer_parent);
}
+void NativeWidgetViews::ReorderLayers() {
+ view_->ReorderLayers();
+}
+
void NativeWidgetViews::ViewRemoved(View* view) {
internal::NativeWidgetPrivate* parent = GetParentNativeWidget();
if (parent)
diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h
index 7a992ae..cc853c3 100644
--- a/views/widget/native_widget_views.h
+++ b/views/widget/native_widget_views.h
@@ -72,6 +72,7 @@ class VIEWS_EXPORT NativeWidgetViews : 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/views/widget/native_widget_wayland.cc b/views/widget/native_widget_wayland.cc
index d58c4f8..ebb61b5 100644
--- a/views/widget/native_widget_wayland.cc
+++ b/views/widget/native_widget_wayland.cc
@@ -187,6 +187,9 @@ void NativeWidgetWayland::CalculateOffsetToAncestorWithLayer(
ui::Layer** layer_parent) {
}
+void NativeWidgetWayland::ReorderLayers() {
+}
+
void NativeWidgetWayland::ViewRemoved(View* view) {
NOTIMPLEMENTED();
}
diff --git a/views/widget/native_widget_wayland.h b/views/widget/native_widget_wayland.h
index b59e4b2..ee2f003 100644
--- a/views/widget/native_widget_wayland.h
+++ b/views/widget/native_widget_wayland.h
@@ -62,6 +62,7 @@ class NativeWidgetWayland : 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/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc
index 90d8eb4..02ee2e5 100644
--- a/views/widget/native_widget_win.cc
+++ b/views/widget/native_widget_win.cc
@@ -585,6 +585,9 @@ 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/views/widget/widget.cc b/views/widget/widget.cc
index 64b6670..9ce902a 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -764,6 +764,10 @@ void Widget::CalculateOffsetToAncestorWithLayer(gfx::Point* offset,
native_widget_->CalculateOffsetToAncestorWithLayer(offset, layer_parent);
}
+void Widget::ReorderLayers() {
+ native_widget_->ReorderLayers();
+}
+
void Widget::NotifyAccessibilityEvent(
View* view,
ui::AccessibilityTypes::Event event_type,
diff --git a/views/widget/widget.h b/views/widget/widget.h
index acece5d..17413c3 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -510,6 +510,9 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
void CalculateOffsetToAncestorWithLayer(gfx::Point* offset,
ui::Layer** layer_parent);
+ // Invokes method of same name on the NativeWidget.
+ void ReorderLayers();
+
// Notifies assistive technology that an accessibility event has
// occurred on |view|, such as when the view is focused or when its
// value changes. Pass true for |send_native_event| except for rare