Roll src/third_party/WebKit 06cb9e9:a978ee5 (svn 202558:202559)
[chromium-blink-merge.git] / ui / accessibility / ax_tree_source.h
blobfe6a8280f4d5eadf70b8553e5a07b35356f87940
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
3 // found in the LICENSE file.
5 #ifndef UI_ACCESSIBILITY_AX_TREE_SOURCE_H_
6 #define UI_ACCESSIBILITY_AX_TREE_SOURCE_H_
8 #include <vector>
10 namespace ui {
12 // An AXTreeSource is an abstract interface for a serializable
13 // accessibility tree. The tree may be in some other format or
14 // may be computed dynamically, but maintains the properties that
15 // it's a strict tree, it has a unique id for each node, and all
16 // of the accessibility information about a node can be serialized
17 // as an AXNodeData. This is the primary interface to use when
18 // an accessibility tree will be sent over an IPC before being
19 // consumed.
20 template<typename AXNodeSource, typename AXNodeData>
21 class AXTreeSource {
22 public:
23 virtual ~AXTreeSource() {}
25 // Get the root of the tree.
26 virtual AXNodeSource GetRoot() const = 0;
28 // Get a node by its id. If no node by that id exists in the tree, return a
29 // null node, i.e. one that will return false if you call IsValid on it.
30 virtual AXNodeSource GetFromId(int32 id) const = 0;
32 // Return the id of a node. All ids must be positive integers.
33 virtual int32 GetId(AXNodeSource node) const = 0;
35 // Append all children of |node| to |out_children|.
36 virtual void GetChildren(AXNodeSource node,
37 std::vector<AXNodeSource>* out_children) const = 0;
39 // Get the parent of |node|.
40 virtual AXNodeSource GetParent(AXNodeSource node) const = 0;
42 // Returns true if |node| is valid, and false if it's a null pointer or a
43 // node object representing the null pointer.
44 virtual bool IsValid(AXNodeSource node) const = 0;
46 // Returns true if two nodes are equal.
47 virtual bool IsEqual(AXNodeSource node1,
48 AXNodeSource node2) const = 0;
50 // Return a AXNodeSource representing null.
51 virtual AXNodeSource GetNull() const = 0;
53 // Serialize one node in the tree.
54 virtual void SerializeNode(AXNodeSource node, AXNodeData* out_data) const = 0;
56 protected:
57 AXTreeSource() {}
60 } // namespace ui
62 #endif // UI_ACCESSIBILITY_AX_TREE_SOURCE_H_