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

Side by Side Diff: cc/layer.cc

Issue 11377108: [cc] Fix crash when adding a child layer to its own parent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments Created 8 years, 1 month 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 | « no previous file | cc/layer_unittest.cc » ('j') | cc/layer_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer.h" 7 #include "cc/layer.h"
8 8
9 #include "cc/active_animation.h" 9 #include "cc/active_animation.h"
10 #include "cc/animation_events.h" 10 #include "cc/animation_events.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return false; 148 return false;
149 } 149 }
150 150
151 void Layer::addChild(scoped_refptr<Layer> child) 151 void Layer::addChild(scoped_refptr<Layer> child)
152 { 152 {
153 insertChild(child, numChildren()); 153 insertChild(child, numChildren());
154 } 154 }
155 155
156 void Layer::insertChild(scoped_refptr<Layer> child, size_t index) 156 void Layer::insertChild(scoped_refptr<Layer> child, size_t index)
157 { 157 {
158 index = min(index, m_children.size());
159 child->removeFromParent(); 158 child->removeFromParent();
160 child->setParent(this); 159 child->setParent(this);
161 child->m_stackingOrderChanged = true; 160 child->m_stackingOrderChanged = true;
162 161
162 index = min(index, m_children.size());
163 LayerList::iterator iter = m_children.begin(); 163 LayerList::iterator iter = m_children.begin();
164 m_children.insert(iter + index, child); 164 m_children.insert(iter + index, child);
165 setNeedsCommit(); 165 setNeedsCommit();
166 } 166 }
167 167
168 void Layer::removeFromParent() 168 void Layer::removeFromParent()
169 { 169 {
170 if (m_parent) 170 if (m_parent)
171 m_parent->removeChild(this); 171 m_parent->removeChild(this);
172 } 172 }
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 { 851 {
852 return 0; 852 return 0;
853 } 853 }
854 854
855 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*) 855 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*)
856 { 856 {
857 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers. 857 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers.
858 } 858 }
859 859
860 } // namespace cc 860 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layer_unittest.cc » ('j') | cc/layer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698