| 216 | } |
| 217 | |
| 218 | void 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 | |
| 248 | void Layer::onChildInserted(Layer* /*childLayer*/, size_t /*index*/) {} |
| 249 |
nothing calls this directly
no test coverage detected