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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer_impl.h" 5 #include "cc/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "cc/debug_border_draw_quad.h" 10 #include "cc/debug_border_draw_quad.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) 67 void LayerImpl::addChild(scoped_ptr<LayerImpl> child)
68 { 68 {
69 child->setParent(this); 69 child->setParent(this);
70 DCHECK_EQ(layerTreeHostImpl(), child->layerTreeHostImpl()); 70 DCHECK_EQ(layerTreeHostImpl(), child->layerTreeHostImpl());
71 m_children.append(child.Pass()); 71 m_children.append(child.Pass());
72 m_layerTreeHostImpl->setNeedsUpdateDrawProperties(); 72 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
73 } 73 }
74 74
75 void LayerImpl::removeFromParent() 75 scoped_ptr<LayerImpl> LayerImpl::removeChild(LayerImpl* child)
76 { 76 {
77 if (!m_parent) 77 for (size_t i = 0; i < m_children.size(); ++i) {
78 return; 78 if (m_children[i] == child) {
79 79 scoped_ptr<LayerImpl> ret = m_children.take(i);
80 LayerImpl* parent = m_parent; 80 m_children.remove(i);
81 m_parent = 0;
82
83 for (size_t i = 0; i < parent->m_children.size(); ++i) {
84 if (parent->m_children[i] == this) {
85 m_layerTreeHostImpl->setNeedsUpdateDrawProperties(); 81 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
86 // This remove call deletes |this|, so don't touch it anymore. 82 return ret.Pass();
danakj 2012/12/09 23:35:51 nom nom, yay.
87 parent->m_children.remove(i);
88 return;
89 } 83 }
90 } 84 }
85 return scoped_ptr<LayerImpl>();
91 } 86 }
92 87
93 void LayerImpl::removeAllChildren() 88 void LayerImpl::removeAllChildren()
94 { 89 {
95 while (m_children.size()) 90 m_children.clear();
96 m_children[0]->removeFromParent(); 91 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
97 } 92 }
98 93
99 void LayerImpl::clearChildList() 94 void LayerImpl::clearChildList()
100 { 95 {
101 if (m_children.isEmpty()) 96 if (m_children.isEmpty())
102 return; 97 return;
103 98
104 m_children.clear(); 99 m_children.clear();
105 m_layerTreeHostImpl->setNeedsUpdateDrawProperties(); 100 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
106 } 101 }
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 775
781 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 776 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
782 { 777 {
783 if (!m_scrollbarAnimationController) 778 if (!m_scrollbarAnimationController)
784 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 779 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
785 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 780 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
786 m_scrollbarAnimationController->updateScrollOffset(this); 781 m_scrollbarAnimationController->updateScrollOffset(this);
787 } 782 }
788 783
789 } // namespace cc 784 } // namespace cc
OLDNEW
« 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