OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |