| 224 | } |
| 225 | |
| 226 | void 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 | |
| 267 | YGNodeRef YGNodeGetChild(const YGNodeRef nodeRef, const size_t index) { |
| 268 | const auto node = resolveRef(nodeRef); |
nothing calls this directly
no test coverage detected