Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / accessibility / ax_tree_source.h
blob1f13d8f59f5f664e7cc965c60721286c974d1e12
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 #include "ui/accessibility/ax_node_data.h"
12 namespace ui {
14 // An AXTreeSource is an abstract interface for a serializable
15 // accessibility tree. The tree may be in some other format or
16 // may be computed dynamically, but maintains the properties that
17 // it's a strict tree, it has a unique id for each node, and all
18 // of the accessibility information about a node can be serialized
19 // as an AXNodeData. This is the primary interface to use when
20 // an accessibility tree will be sent over an IPC before being
21 // consumed.
22 template<typename AXNodeSource>
23 class AXTreeSource {
24 public:
25 virtual ~AXTreeSource() {}
27 // Get the root of the tree.
28 virtual AXNodeSource GetRoot() const = 0;
30 // Get a node by its id. If no node by that id exists in the tree, return a
31 // null node, i.e. one that will return false if you call IsValid on it.
32 virtual AXNodeSource GetFromId(int32 id) const = 0;
34 // Return the id of a node. All ids must be positive integers.
35 virtual int32 GetId(AXNodeSource node) const = 0;
37 // Append all children of |node| to |out_children|.
38 virtual void GetChildren(AXNodeSource node,
39 std::vector<AXNodeSource>* out_children) const = 0;
41 // Get the parent of |node|.
42 virtual AXNodeSource GetParent(AXNodeSource node) const = 0;
44 // Returns true if |node| is valid, and false if it's a null pointer or a
45 // node object representing the null pointer.
46 virtual bool IsValid(AXNodeSource node) const = 0;
48 // Returns true if two nodes are equal.
49 virtual bool IsEqual(AXNodeSource node1,
50 AXNodeSource node2) const = 0;
52 // Return a AXNodeSource representing null.
53 virtual AXNodeSource GetNull() const = 0;
55 // Serialize one node in the tree.
56 virtual void SerializeNode(AXNodeSource node, AXNodeData* out_data) const = 0;
58 protected:
59 AXTreeSource() {}
62 } // namespace ui
64 #endif // UI_ACCESSIBILITY_AX_TREE_SOURCE_H_