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

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

Issue 67283004: First step to move common accessibility code out of content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Git rid of AX_EXPORT from templatized function Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ui/accessibility/ax_serializable_tree.cc ('k') | 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_ACCESSIBILITY_AX_TREE_H_
6 #define UI_ACCESSIBILITY_AX_TREE_H_
7
8 #include "base/containers/hash_tables.h"
9
10 #include "ui/accessibility/ax_export.h"
11 #include "ui/accessibility/ax_tree.h"
12 #include "ui/accessibility/ax_tree_update.h"
13
14 namespace ui {
15
16 class AXNode;
17
18 // AXTree is a live, managed tree of AXNode objects that can receive
19 // updates from another AXTreeSource via AXTreeUpdates, and it can be
20 // used as a source for sending updates to another client tree.
21 // It's designed to be subclassed to implement support for native
22 // accessibility APIs on a specific platform.
23 class AX_EXPORT AXTree {
24 public:
25 AXTree();
26 explicit AXTree(const AXTreeUpdate& initial_state);
27 virtual ~AXTree();
28
29 virtual AXNode* GetRoot() const;
30 virtual AXNode* GetFromId(int32 id) const;
31
32 virtual bool Unserialize(const AXTreeUpdate& update);
33
34 protected:
35 // Subclasses can override this to use a subclass of AXNode.
36 virtual AXNode* CreateNode(AXNode* parent, int32 id, int32 index_in_parent);
37
38 // This is called from within Unserialize(), it returns true on success.
39 // Subclasses can override this to do additional processing.
40 virtual bool UpdateNode(const AXNodeData& src);
41
42 // Subclasses can override this to do special behavior when the root changes.
43 virtual void OnRootChanged();
44
45 private:
46 // Convenience function to create a node and call Initialize on it.
47 AXNode* CreateAndInitializeNode(
48 AXNode* parent, int32 id, int32 index_in_parent);
49
50 // Call Destroy() on |node|, and delete it from the id map, and then
51 // call recursively on all nodes in its subtree.
52 void DestroyNodeAndSubtree(AXNode* node);
53
54 // Iterate over the children of |node| and for each child, destroy the
55 // child and its subtree if its id is not in |new_child_ids|. Returns
56 // true on success, false on fatal error.
57 bool DeleteOldChildren(AXNode* node,
58 const std::vector<int32> new_child_ids);
59
60 // Iterate over |new_child_ids| and populate |new_children| with
61 // pointers to child nodes, reusing existing nodes already in the tree
62 // if they exist, and creating otherwise. Reparenting is disallowed, so
63 // if the id already exists as the child of another node, that's an
64 // error. Returns true on success, false on fatal error.
65 bool CreateNewChildVector(AXNode* node,
66 const std::vector<int32> new_child_ids,
67 std::vector<AXNode*>* new_children);
68
69 AXNode* root_;
70 base::hash_map<int32, AXNode*> id_map_;
71 };
72
73 } // namespace ui
74
75 #endif // UI_ACCESSIBILITY_AX_TREE_H_
OLDNEW
« no previous file with comments | « ui/accessibility/ax_serializable_tree.cc ('k') | ui/accessibility/ax_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698