Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: ui/views/view.cc

Issue 15114002: Reorder the NativeViews attached to a view via kViewHostKey according to the position of the view (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 4bd82c84994af9c27ef343a7fadd29d3a4bef176..6ffde85a978df982752892df305267888696f89b 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -1452,8 +1452,8 @@ void View::ReorderLayers() {
while (v && !v->layer())
v = v->parent();
+ Widget* widget = GetWidget();
if (!v) {
- Widget* widget = GetWidget();
if (widget) {
ui::Layer* layer = widget->GetLayer();
if (layer)
@@ -1462,15 +1462,29 @@ void View::ReorderLayers() {
} else {
v->ReorderChildLayers(v->layer());
}
+
+ if (widget) {
+ // Reorder the widget's child NativeViews in case a child NativeView is
+ // associated with a view (eg via a NativeViewHost). Always do the
+ // reordering because the associated NativeView's layer (if it has one)
+ // is parented to the widget's layer regardless of whether the host view has
+ // an ancestor with a layer.
+ widget->ReorderNativeViews();
+ }
}
void View::ReorderChildLayers(ui::Layer* parent_layer) {
if (layer() && layer() != parent_layer) {
DCHECK_EQ(parent_layer, layer()->parent());
- parent_layer->StackAtTop(layer());
+ parent_layer->StackAtBottom(layer());
} else {
- for (Views::const_iterator i(children_.begin()); i != children_.end(); ++i)
- (*i)->ReorderChildLayers(parent_layer);
+ // Iterate backwards through the children so that a child with a layer
+ // which is further to the back is stacked above one which is further to
+ // the front.
+ for (Views::const_reverse_iterator it(children_.rbegin());
+ it != children_.rend(); ++it) {
+ (*it)->ReorderChildLayers(parent_layer);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698