| OLD | NEW |
| 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_SOURCE_H_ | 5 #ifndef UI_ACCESSIBILITY_AX_TREE_SOURCE_H_ |
| 6 #define UI_ACCESSIBILITY_AX_TREE_SOURCE_H_ | 6 #define UI_ACCESSIBILITY_AX_TREE_SOURCE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <vector> | 10 #include <vector> |
| 9 | 11 |
| 10 namespace ui { | 12 namespace ui { |
| 11 | 13 |
| 12 // An AXTreeSource is an abstract interface for a serializable | 14 // An AXTreeSource is an abstract interface for a serializable |
| 13 // accessibility tree. The tree may be in some other format or | 15 // accessibility tree. The tree may be in some other format or |
| 14 // may be computed dynamically, but maintains the properties that | 16 // 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 | 17 // 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 | 18 // of the accessibility information about a node can be serialized |
| 17 // as an AXNodeData. This is the primary interface to use when | 19 // as an AXNodeData. This is the primary interface to use when |
| 18 // an accessibility tree will be sent over an IPC before being | 20 // an accessibility tree will be sent over an IPC before being |
| 19 // consumed. | 21 // consumed. |
| 20 template<typename AXNodeSource, typename AXNodeData, typename AXTreeData> | 22 template<typename AXNodeSource, typename AXNodeData, typename AXTreeData> |
| 21 class AXTreeSource { | 23 class AXTreeSource { |
| 22 public: | 24 public: |
| 23 virtual ~AXTreeSource() {} | 25 virtual ~AXTreeSource() {} |
| 24 | 26 |
| 25 // Get the tree data. | 27 // Get the tree data. |
| 26 virtual AXTreeData GetTreeData() const = 0; | 28 virtual AXTreeData GetTreeData() const = 0; |
| 27 | 29 |
| 28 // Get the root of the tree. | 30 // Get the root of the tree. |
| 29 virtual AXNodeSource GetRoot() const = 0; | 31 virtual AXNodeSource GetRoot() const = 0; |
| 30 | 32 |
| 31 // Get a node by its id. If no node by that id exists in the tree, return a | 33 // Get a node by its id. If no node by that id exists in the tree, return a |
| 32 // null node, i.e. one that will return false if you call IsValid on it. | 34 // null node, i.e. one that will return false if you call IsValid on it. |
| 33 virtual AXNodeSource GetFromId(int32 id) const = 0; | 35 virtual AXNodeSource GetFromId(int32_t id) const = 0; |
| 34 | 36 |
| 35 // Return the id of a node. All ids must be positive integers. | 37 // Return the id of a node. All ids must be positive integers. |
| 36 virtual int32 GetId(AXNodeSource node) const = 0; | 38 virtual int32_t GetId(AXNodeSource node) const = 0; |
| 37 | 39 |
| 38 // Append all children of |node| to |out_children|. | 40 // Append all children of |node| to |out_children|. |
| 39 virtual void GetChildren(AXNodeSource node, | 41 virtual void GetChildren(AXNodeSource node, |
| 40 std::vector<AXNodeSource>* out_children) const = 0; | 42 std::vector<AXNodeSource>* out_children) const = 0; |
| 41 | 43 |
| 42 // Get the parent of |node|. | 44 // Get the parent of |node|. |
| 43 virtual AXNodeSource GetParent(AXNodeSource node) const = 0; | 45 virtual AXNodeSource GetParent(AXNodeSource node) const = 0; |
| 44 | 46 |
| 45 // Returns true if |node| is valid, and false if it's a null pointer or a | 47 // Returns true if |node| is valid, and false if it's a null pointer or a |
| 46 // node object representing the null pointer. | 48 // node object representing the null pointer. |
| 47 virtual bool IsValid(AXNodeSource node) const = 0; | 49 virtual bool IsValid(AXNodeSource node) const = 0; |
| 48 | 50 |
| 49 // Returns true if two nodes are equal. | 51 // Returns true if two nodes are equal. |
| 50 virtual bool IsEqual(AXNodeSource node1, | 52 virtual bool IsEqual(AXNodeSource node1, |
| 51 AXNodeSource node2) const = 0; | 53 AXNodeSource node2) const = 0; |
| 52 | 54 |
| 53 // Return a AXNodeSource representing null. | 55 // Return a AXNodeSource representing null. |
| 54 virtual AXNodeSource GetNull() const = 0; | 56 virtual AXNodeSource GetNull() const = 0; |
| 55 | 57 |
| 56 // Serialize one node in the tree. | 58 // Serialize one node in the tree. |
| 57 virtual void SerializeNode(AXNodeSource node, AXNodeData* out_data) const = 0; | 59 virtual void SerializeNode(AXNodeSource node, AXNodeData* out_data) const = 0; |
| 58 | 60 |
| 59 protected: | 61 protected: |
| 60 AXTreeSource() {} | 62 AXTreeSource() {} |
| 61 }; | 63 }; |
| 62 | 64 |
| 63 } // namespace ui | 65 } // namespace ui |
| 64 | 66 |
| 65 #endif // UI_ACCESSIBILITY_AX_TREE_SOURCE_H_ | 67 #endif // UI_ACCESSIBILITY_AX_TREE_SOURCE_H_ |
| OLD | NEW |