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_
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
20 template<typename AXNodeSource
, typename AXNodeData
>
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;
62 #endif // UI_ACCESSIBILITY_AX_TREE_SOURCE_H_