MCPcopy Create free account
hub / github.com/Snapchat/Valdi / insertChild

Method insertChild

snap_drawing/src/snap_drawing/cpp/Layers/Layer.cpp:218–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void Layer::insertChild(const Valdi::Ref<Layer>& childLayer, size_t index) {
219 SC_ASSERT(this != childLayer.get());
220
221 if (childLayer->_hasParent) {
222 bool shouldNotify = childLayer->getParent().get() != this;
223 childLayer->removeFromParent(shouldNotify);
224 }
225
226 {
227 auto children = _children.writeAccess();
228 SC_ASSERT(index <= children->size());
229 if (index == children->size()) {
230 children->emplace_back(childLayer);
231 } else {
232 children->emplace(children->begin() + index, childLayer);
233 }
234 }
235
236 childLayer->onParentChanged(Valdi::strongSmallRef(this));
237
238 setChildNeedsDisplay();
239
240 onChildInserted(childLayer.get(), index);
241
242 if (childLayer->_needsLayout) {
243 setNeedsLayout();
244 }
245 childLayer->setNeedsDisplay();
246}
247
248void Layer::onChildInserted(Layer* /*childLayer*/, size_t /*index*/) {}
249

Callers

nothing calls this directly

Calls 10

strongSmallRefFunction · 0.85
onParentChangedMethod · 0.80
setNeedsDisplayMethod · 0.80
getMethod · 0.65
getParentMethod · 0.65
removeFromParentMethod · 0.45
writeAccessMethod · 0.45
sizeMethod · 0.45
emplaceMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected