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

Function YGNodeSetChildren

third-party/yoga/src/yoga/YGNode.cpp:226–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void YGNodeSetChildren(
227 const YGNodeRef ownerRef,
228 const YGNodeRef* childrenRefs,
229 const size_t count) {
230 auto owner = resolveRef(ownerRef);
231 auto children = reinterpret_cast<yoga::Node* const*>(childrenRefs);
232
233 if (owner == nullptr) {
234 return;
235 }
236
237 const std::vector<yoga::Node*> childrenVector = {children, children + count};
238 if (childrenVector.empty()) {
239 if (owner->getChildCount() > 0) {
240 for (auto* child : owner->getChildren()) {
241 child->setLayout({});
242 child->setOwner(nullptr);
243 }
244 owner->setChildren({});
245 owner->markDirtyAndPropagate();
246 }
247 } else {
248 if (owner->getChildCount() > 0) {
249 for (auto* oldChild : owner->getChildren()) {
250 // Our new children may have nodes in common with the old children. We
251 // don't reset these common nodes.
252 if (std::find(childrenVector.begin(), childrenVector.end(), oldChild) ==
253 childrenVector.end()) {
254 oldChild->setLayout({});
255 oldChild->setOwner(nullptr);
256 }
257 }
258 }
259 owner->setChildren(childrenVector);
260 for (yoga::Node* child : childrenVector) {
261 child->setOwner(owner);
262 }
263 owner->markDirtyAndPropagate();
264 }
265}
266
267YGNodeRef YGNodeGetChild(const YGNodeRef nodeRef, const size_t index) {
268 const auto node = resolveRef(nodeRef);

Callers

nothing calls this directly

Calls 10

setOwnerMethod · 0.80
setChildrenMethod · 0.80
markDirtyAndPropagateMethod · 0.80
getChildrenMethod · 0.65
endMethod · 0.65
resolveRefFunction · 0.50
findFunction · 0.50
emptyMethod · 0.45
getChildCountMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected