diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/view.cc | 38 | ||||
-rw-r--r-- | views/view.h | 9 |
2 files changed, 47 insertions, 0 deletions
diff --git a/views/view.cc b/views/view.cc index ffca496..ce96853 100644 --- a/views/view.cc +++ b/views/view.cc @@ -181,6 +181,9 @@ void View::AddChildViewAt(View* view, int index) { if (layout_manager_.get()) layout_manager_->ViewAdded(this, view); + + if (use_acceleration_when_possible) + ReorderLayers(); } void View::ReorderChildView(View* view, int index) { @@ -207,6 +210,9 @@ void View::ReorderChildView(View* view, int index) { // Add it in the specified index now. InitFocusSiblings(view, index); children_.insert(children_.begin() + index, view); + + if (use_acceleration_when_possible) + ReorderLayers(); } void View::RemoveChildView(View* view) { @@ -1717,6 +1723,12 @@ void View::CreateLayer() { layer_->SetVisible(IsVisible()); UpdateParentLayers(); + + // The new layer needs to be ordered in the layer tree according + // to the view tree. Children of this layer were added in order + // in UpdateParentLayers(). + if (parent()) + parent()->ReorderLayers(); } void View::UpdateParentLayers() { @@ -1783,6 +1795,9 @@ void View::DestroyLayer() { layer_.reset(); + if (new_parent) + ReorderLayers(); + gfx::Point offset; CalculateOffsetToAncestorWithLayer(&offset, NULL); UpdateChildLayerBounds(offset); @@ -1790,6 +1805,29 @@ 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 bdd2ab0..8bc1b95 100644 --- a/views/view.h +++ b/views/view.h @@ -1246,6 +1246,15 @@ 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 |