| 492 | // Raw APIs |
| 493 | |
| 494 | Ref<ViewNode> ViewNodeTree::removeViewNode(RawViewNodeId id) { |
| 495 | const auto& iterator = _rawViewNodes.find(id); |
| 496 | if (iterator == _rawViewNodes.end()) { |
| 497 | return nullptr; |
| 498 | } |
| 499 | |
| 500 | auto viewNode = iterator->second; |
| 501 | _rawViewNodes.erase(iterator); |
| 502 | |
| 503 | auto& viewTransactionScope = getCurrentViewTransactionScope(); |
| 504 | |
| 505 | while (viewNode->getChildCount() > 0) { |
| 506 | auto* child = viewNode->getChildAt(viewNode->getChildCount() - 1); |
| 507 | if (removeViewNode(child->getRawId()) == nullptr) { |
| 508 | child->removeFromParent(viewTransactionScope); |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | viewNode->clear(viewTransactionScope); |
| 513 | |
| 514 | if (viewNode == _rootViewNode) { |
| 515 | setRootViewNode(nullptr, false); |
| 516 | } |
| 517 | |
| 518 | return viewNode; |
| 519 | } |
| 520 | |
| 521 | Ref<ViewNode> ViewNodeTree::getViewNode(RawViewNodeId id) { |
| 522 | const auto& iterator = _rawViewNodes.find(id); |