| 1057 | break; |
| 1058 | // Track the deepest node that has a trackable (non-zero) rawId. If the deepest node is |
| 1059 | // id-less we fall back to this ancestor rather than returning an unanchorable node, which |
| 1060 | // would clear the anchor and let the next reflow jump. |
| 1061 | if (next->getRawId() != 0) { |
| 1062 | anchor = next; |
| 1063 | } |
| 1064 | node = next; |
| 1065 | nodeTop = nextTop; |
| 1066 | } |
| 1067 | return anchor; |
| 1068 | } |
| 1069 | |
| 1070 | ViewNode* preserveFindDescendantById(ViewNode* node, RawViewNodeId id, int depth) { |
| 1071 | // id 0 is the unset/default rawId (e.g. synthetic placeholder nodes); never "match" it, or |
| 1072 | // we would anchor to the first id-less node (content top) and jump the viewport. |
| 1073 | if (depth <= 0 || id == 0) |
| 1074 | return nullptr; |
| 1075 | for (auto* child : *node) { |
| 1076 | if (child->getRawId() == id) |
| 1077 | return child; |
| 1078 | auto* found = preserveFindDescendantById(child, id, depth - 1); |
| 1079 | if (found) |
| 1080 | return found; |
| 1081 | } |
no test coverage detected