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

Unified Diff: cc/layer_impl.cc

Issue 11491007: cc: Remove dangerous LayerImpl::removeFromParent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « cc/layer_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_impl.cc
diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc
index 48cdec0d6d5b0346cf14f6657f3a9ccc811ce084..268f0b4bb221cdd39d93c76117930ba148e5fce0 100644
--- a/cc/layer_impl.cc
+++ b/cc/layer_impl.cc
@@ -72,28 +72,23 @@ void LayerImpl::addChild(scoped_ptr<LayerImpl> child)
m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
}
-void LayerImpl::removeFromParent()
+scoped_ptr<LayerImpl> LayerImpl::removeChild(LayerImpl* child)
{
- if (!m_parent)
- return;
-
- LayerImpl* parent = m_parent;
- m_parent = 0;
-
- for (size_t i = 0; i < parent->m_children.size(); ++i) {
- if (parent->m_children[i] == this) {
+ for (size_t i = 0; i < m_children.size(); ++i) {
+ if (m_children[i] == child) {
+ scoped_ptr<LayerImpl> ret = m_children.take(i);
+ m_children.remove(i);
m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
- // This remove call deletes |this|, so don't touch it anymore.
- parent->m_children.remove(i);
- return;
+ return ret.Pass();
danakj 2012/12/09 23:35:51 nom nom, yay.
}
}
+ return scoped_ptr<LayerImpl>();
}
void LayerImpl::removeAllChildren()
{
- while (m_children.size())
- m_children[0]->removeFromParent();
+ m_children.clear();
+ m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
}
void LayerImpl::clearChildList()
« no previous file with comments | « cc/layer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698