Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Unified Diff: ui/accessibility/ax_tree.h

Issue 830943004: Improve the notifications sent from AXTree updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback, add missing call to parent class Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/accessibility/browser_accessibility_manager_win.cc ('k') | ui/accessibility/ax_tree.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/ax_tree.h
diff --git a/ui/accessibility/ax_tree.h b/ui/accessibility/ax_tree.h
index b4baac460ccff5dfa18ed890af5d90e0fc42a118..c8470c0a0b46915124d8fc1f66fca563ff8a9857 100644
--- a/ui/accessibility/ax_tree.h
+++ b/ui/accessibility/ax_tree.h
@@ -22,15 +22,15 @@ struct AXTreeUpdateState;
// Be careful, as the tree may be in an inconsistent state at this time;
// don't walk the parents and children at this time:
// OnNodeWillBeDeleted
+// OnSubtreeWillBeDeleted
// OnNodeCreated
// OnNodeChanged
//
-// Other notifications are called at the end of an atomic update operation.
-// From these, it's safe to walk the tree and do any initialization that
-// assumes the tree is in a consistent state.
-// OnNodeCreationFinished
-// OnNodeChangeFinished
-// OnRootChanged
+// In addition, one additional notification is fired at the end of an
+// atomic update, and it provides a vector of nodes that were added or
+// changed, for final postprocessing:
+// OnAtomicUpdateFinished
+//
class AX_EXPORT AXTreeDelegate {
public:
AXTreeDelegate();
@@ -41,6 +41,11 @@ class AX_EXPORT AXTreeDelegate {
// in the middle of an update, the tree may be in an invalid state!
virtual void OnNodeWillBeDeleted(AXNode* node) = 0;
+ // Same as OnNodeWillBeDeleted, but only called once for an entire subtree.
+ // This is called in the middle of an update, the tree may be in an
+ // invalid state!
+ virtual void OnSubtreeWillBeDeleted(AXNode* node) = 0;
+
// Called immediately after a new node is created. The tree may be in
// the middle of an update, don't walk the parents and children now.
virtual void OnNodeCreated(AXNode* node) = 0;
@@ -49,16 +54,28 @@ class AX_EXPORT AXTreeDelegate {
// the middle of an update, don't walk the parents and children now.
virtual void OnNodeChanged(AXNode* node) = 0;
- // Called for each new node at the end of an update operation,
- // when the tree is in a consistent state.
- virtual void OnNodeCreationFinished(AXNode* node) = 0;
-
- // Called for each existing node that changed at the end of an update
- // operation, when the tree is in a consistent state.
- virtual void OnNodeChangeFinished(AXNode* node) = 0;
-
- // Called at the end of an update operation when the root node changes.
- virtual void OnRootChanged(AXNode* new_root) = 0;
+ enum ChangeType {
+ NODE_CREATED,
+ SUBTREE_CREATED,
+ NODE_CHANGED
+ };
+
+ struct Change {
+ Change(AXNode* node, ChangeType type) {
+ this->node = node;
+ this->type = type;
+ }
+ AXNode *node;
+ ChangeType type;
+ };
+
+ // Called at the end of the update operation. Every node that was added
+ // or changed will be included in |changes|, along with an enum indicating
+ // the type of change - either (1) a node was created, (2) a node was created
+ // and it's the root of a new subtree, or (3) a node was changed. Finally,
+ // a bool indicates if the root of the tree was changed or not.
+ virtual void OnAtomicUpdateFinished(bool root_changed,
+ const std::vector<Change>& changes) = 0;
};
// AXTree is a live, managed tree of AXNode objects that can receive
@@ -97,6 +114,10 @@ class AX_EXPORT AXTree {
void OnRootChanged();
+ // Notify the delegate that the subtree rooted at |node| will be destroyed,
+ // then call DestroyNodeAndSubtree on it.
+ void DestroySubtree(AXNode* node);
+
// 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);
« no previous file with comments | « content/browser/accessibility/browser_accessibility_manager_win.cc ('k') | ui/accessibility/ax_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698