| 98 | } |
| 99 | |
| 100 | Ref<ViewNode> ViewNodeTree::getViewNodeForNodePath(const ViewNodePath& nodePath) const { |
| 101 | auto current = getRootViewNode(); |
| 102 | if (current == nullptr) { |
| 103 | return nullptr; |
| 104 | } |
| 105 | |
| 106 | std::vector<SharedViewNode> nodes; |
| 107 | |
| 108 | for (const auto& entry : nodePath.getEntries()) { |
| 109 | current->findAllNodesWithId(entry.nodeId, nodes); |
| 110 | |
| 111 | if (nodes.empty()) { |
| 112 | return nullptr; |
| 113 | } |
| 114 | |
| 115 | auto itemIndex = static_cast<size_t>(entry.itemIndex); |
| 116 | if (itemIndex >= nodes.size()) { |
| 117 | return nullptr; |
| 118 | } |
| 119 | |
| 120 | current = nodes[itemIndex]; |
| 121 | nodes.clear(); |
| 122 | } |
| 123 | |
| 124 | return current; |
| 125 | } |
| 126 | |
| 127 | const Ref<ViewNode>& ViewNodeTree::getRootViewNode() const { |
| 128 | return _rootViewNode; |