On Thu Nov 10 17:22:53 2022 +0000, Connor McAdams wrote:
The only part of `get_sibling_node_for_tree` that is logically coupled to `traverse_uia_node_tree` is the `at_root_level` argument. The operation that `get_sibling_node_for_tree` implements also gets used by `UiaNavigate` when navigating with `NavigateDirection_{Previous/Next}Sibling`. An example:
+------------------------------------+-----------------------------------+ | 'Raw' (ConditionType_True) | UIA_IsControlElementPropertyId | | tree view | equals TRUE tree view | +------------------------------------+-----------------------------------+ | | | | +---+---+ | +---+---+ | | | | | | | | | | 1 + | | 1 + | | | | | | | | | +---+---+ | +---+---+ | | | | | | | +-----------+-----------+ | +-----------+-----------+ | | | | | | | | | | +---+---+ +---+---+ +---+---+ | +---+---+ +---+---+ | | | | | | | | | | | | | | | | 2 +---| 3 +---| 4 + | | 6 +---------------| 4 + | | | | | | | | | | | | | | | +---+---+ +---+---+ +---+---+ | +---+---+ +---+---+ | | | | | | +---+---+ | | | | | | | | | 5 | | | | | | | | | +---+---+ | | | | | | | +---+---+ | | | | | | | | | 6 | | | | | | | | | +-------+ | | | | | +------------------------------------+-----------------------------------+
If our view condition here is `UIA_IsControlElementPropertyId` being set to TRUE, and only nodes 6 and 4 return TRUE for that property, how do we navigate from node 6 to its sibling node 4 in the treeview? First, we need to do what `get_sibling_node_for_tree` does:
- Check if node 6 has a sibling. It doesn't.
- Navigate to node 5 from node 6.
- Check if node 5 matches our view condition, and is therefore a parent
of 6 in this treeview. It doesn't.
- Check if node 5 has any siblings. It doesn't.
- Navigate to node 2 from node 5.
- Check if node 2 matches our view condition, and is therefore a parent
of 6 in this treeview. It doesn't.
- Check if node 2 has any siblings. It does. Return its sibling, node 3
from `get_sibling_node_for_tree`. Now, we're back to whatever function called `get_sibling_node_for_tree` (either `UiaNavigate` or `traverse_uia_node_tree`) and can continue doing whatever we need to do to get from node 3 to node 4. In the case of `UiaNavigate`:
- Check if node 3 matches our view condition. It doesn't.
- Get node 3's sibling, node 4.
- Check if node 4 matches our view condition. It does. Return node 4.
In the case of `traverse_uia_node`, we just pass the node we received into another call to `traverse_uia_node`, like any other sibling.
What is the relationship between node 6 and node 3 in this example? It's easy for me to understand the relationship between node 6 and node 4, but I'm confused about this one.