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

Method getViewNodeForNodePath

valdi/src/valdi/runtime/Context/ViewNodeTree.cpp:100–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100Ref<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
127const Ref<ViewNode>& ViewNodeTree::getRootViewNode() const {
128 return _rootViewNode;

Callers 4

TEST_PFunction · 0.80
TEST_PFunction · 0.80
getViewNodeForIdFunction · 0.80

Calls 5

findAllNodesWithIdMethod · 0.80
clearMethod · 0.65
getEntriesMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 3

TEST_PFunction · 0.64
TEST_PFunction · 0.64
getViewNodeForIdFunction · 0.64