An accessibility tree update with two roots should be rejected.
If an AXTreeUpdate had two root nodes, the second one would cause the
first one to be deleted, but that could leave dangling pointers in
|pending_nodes|. Fix this by first ensuring that |pending_nodes| is
always cleaned up when nodse are deleted, but also by specifically
returning an error if we encounter two root nodes since that should
never happen.
BUG=479743
Review URL: https://codereview.chromium.org/1151393006
Cr-Commit-Position: refs/heads/master@{#332212}
diff --git a/ui/accessibility/ax_tree.h b/ui/accessibility/ax_tree.h
index 5f723079..d496e59 100644
--- a/ui/accessibility/ax_tree.h
+++ b/ui/accessibility/ax_tree.h
@@ -120,17 +120,18 @@
// Notify the delegate that the subtree rooted at |node| will be destroyed,
// then call DestroyNodeAndSubtree on it.
- void DestroySubtree(AXNode* node);
+ void DestroySubtree(AXNode* node, AXTreeUpdateState* update_state);
// Call Destroy() on |node|, and delete it from the id map, and then
// call recursively on all nodes in its subtree.
- void DestroyNodeAndSubtree(AXNode* node);
+ void DestroyNodeAndSubtree(AXNode* node, AXTreeUpdateState* update_state);
// Iterate over the children of |node| and for each child, destroy the
// child and its subtree if its id is not in |new_child_ids|. Returns
// true on success, false on fatal error.
bool DeleteOldChildren(AXNode* node,
- const std::vector<int32>& new_child_ids);
+ const std::vector<int32>& new_child_ids,
+ AXTreeUpdateState* update_state);
// Iterate over |new_child_ids| and populate |new_children| with
// pointers to child nodes, reusing existing nodes already in the tree