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

Side by Side Diff: ui/accessibility/ax_tree.h

Issue 2737043003: Add support for attribute change callbacks in AXNodeData. (Closed)
Patch Set: Address feedback, lambda in local var Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/accessibility/ax_tree.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_ACCESSIBILITY_AX_TREE_H_ 5 #ifndef UI_ACCESSIBILITY_AX_TREE_H_
6 #define UI_ACCESSIBILITY_AX_TREE_H_ 6 #define UI_ACCESSIBILITY_AX_TREE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 class AX_EXPORT AXTreeDelegate { 42 class AX_EXPORT AXTreeDelegate {
43 public: 43 public:
44 AXTreeDelegate(); 44 AXTreeDelegate();
45 virtual ~AXTreeDelegate(); 45 virtual ~AXTreeDelegate();
46 46
47 // Called before a node's data gets updated. 47 // Called before a node's data gets updated.
48 virtual void OnNodeDataWillChange(AXTree* tree, 48 virtual void OnNodeDataWillChange(AXTree* tree,
49 const AXNodeData& old_node_data, 49 const AXNodeData& old_node_data,
50 const AXNodeData& new_node_data) = 0; 50 const AXNodeData& new_node_data) = 0;
51 51
52 // Individual callbacks for every attribute of AXNodeData that can change.
53 virtual void OnRoleChanged(AXTree* tree,
54 AXNode* node,
55 AXRole old_role,
56 AXRole new_role) {}
57 virtual void OnStateChanged(AXTree* tree,
58 AXNode* node,
59 AXState state,
60 bool new_value) {}
61 virtual void OnStringAttributeChanged(AXTree* tree,
62 AXNode* node,
63 AXStringAttribute attr,
64 const std::string& old_value,
65 const std::string& new_value) {}
66 virtual void OnIntAttributeChanged(AXTree* tree,
67 AXNode* node,
68 AXIntAttribute attr,
69 int32_t old_value,
70 int32_t new_value) {}
71 virtual void OnFloatAttributeChanged(AXTree* tree,
72 AXNode* node,
73 AXFloatAttribute attr,
74 float old_value,
75 float new_value) {}
76 virtual void OnBoolAttributeChanged(AXTree* tree,
77 AXNode* node,
78 AXBoolAttribute attr,
79 bool new_value) {}
80 virtual void OnIntListAttributeChanged(
81 AXTree* tree,
82 AXNode* node,
83 AXIntListAttribute attr,
84 const std::vector<int32_t>& old_value,
85 const std::vector<int32_t>& new_value) {}
86
52 // Called when tree data changes. 87 // Called when tree data changes.
53 virtual void OnTreeDataChanged(AXTree* tree) = 0; 88 virtual void OnTreeDataChanged(AXTree* tree) = 0;
54 89
55 // Called just before a node is deleted. Its id and data will be valid, 90 // Called just before a node is deleted. Its id and data will be valid,
56 // but its links to parents and children are invalid. This is called 91 // but its links to parents and children are invalid. This is called
57 // in the middle of an update, the tree may be in an invalid state! 92 // in the middle of an update, the tree may be in an invalid state!
58 virtual void OnNodeWillBeDeleted(AXTree* tree, AXNode* node) = 0; 93 virtual void OnNodeWillBeDeleted(AXTree* tree, AXNode* node) = 0;
59 94
60 // Same as OnNodeWillBeDeleted, but only called once for an entire subtree. 95 // Same as OnNodeWillBeDeleted, but only called once for an entire subtree.
61 // This is called in the middle of an update, the tree may be in an 96 // This is called in the middle of an update, the tree may be in an
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 AXNode* CreateNode(AXNode* parent, 184 AXNode* CreateNode(AXNode* parent,
150 int32_t id, 185 int32_t id,
151 int32_t index_in_parent, 186 int32_t index_in_parent,
152 AXTreeUpdateState* update_state); 187 AXTreeUpdateState* update_state);
153 188
154 // This is called from within Unserialize(), it returns true on success. 189 // This is called from within Unserialize(), it returns true on success.
155 bool UpdateNode(const AXNodeData& src, 190 bool UpdateNode(const AXNodeData& src,
156 bool is_new_root, 191 bool is_new_root,
157 AXTreeUpdateState* update_state); 192 AXTreeUpdateState* update_state);
158 193
194 void CallNodeChangeCallbacks(AXNode* node, const AXNodeData& new_data);
195
159 void OnRootChanged(); 196 void OnRootChanged();
160 197
161 // Notify the delegate that the subtree rooted at |node| will be destroyed, 198 // Notify the delegate that the subtree rooted at |node| will be destroyed,
162 // then call DestroyNodeAndSubtree on it. 199 // then call DestroyNodeAndSubtree on it.
163 void DestroySubtree(AXNode* node, AXTreeUpdateState* update_state); 200 void DestroySubtree(AXNode* node, AXTreeUpdateState* update_state);
164 201
165 // Call Destroy() on |node|, and delete it from the id map, and then 202 // Call Destroy() on |node|, and delete it from the id map, and then
166 // call recursively on all nodes in its subtree. 203 // call recursively on all nodes in its subtree.
167 void DestroyNodeAndSubtree(AXNode* node, AXTreeUpdateState* update_state); 204 void DestroyNodeAndSubtree(AXNode* node, AXTreeUpdateState* update_state);
168 205
(...skipping 17 matching lines...) Expand all
186 AXTreeDelegate* delegate_; 223 AXTreeDelegate* delegate_;
187 AXNode* root_; 224 AXNode* root_;
188 base::hash_map<int32_t, AXNode*> id_map_; 225 base::hash_map<int32_t, AXNode*> id_map_;
189 std::string error_; 226 std::string error_;
190 AXTreeData data_; 227 AXTreeData data_;
191 }; 228 };
192 229
193 } // namespace ui 230 } // namespace ui
194 231
195 #endif // UI_ACCESSIBILITY_AX_TREE_H_ 232 #endif // UI_ACCESSIBILITY_AX_TREE_H_
OLDNEW
« no previous file with comments | « no previous file | ui/accessibility/ax_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698