OLD | NEW |
---|---|
(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_NODE_H_ | |
6 #define UI_ACCESSIBILITY_AX_NODE_H_ | |
7 | |
8 #include "ui/accessibility/ax_node_data.h" | |
9 | |
10 namespace ui { | |
11 | |
12 // One node in an AXTree. | |
13 class UI_EXPORT AXNode { | |
14 public: | |
15 AXNode(); | |
16 virtual ~AXNode(); | |
17 | |
18 // Accessors. | |
19 int32 id() const { return data_.id; } | |
20 AXNode* parent() const { return parent_; } | |
21 int child_count() const { return static_cast<int>(children_.size()); } | |
22 const AXNodeData& data() const { return data_; } | |
23 const std::vector<AXNode*>& children() const { return children_; } | |
24 | |
25 // Get the child at the given index. | |
26 AXNode* ChildAtIndex(int index) const { return children_[index]; } | |
27 | |
28 // Initialize the node. This sets up its place in the tree but does | |
29 // not set its data yet. After initialization, only index_in_parent | |
30 // is allowed to change, the others are guaranteed to never change. | |
31 virtual void Init(AXNode* parent, int32 id, int32 index_in_parent); | |
David Tseng
2013/11/15 18:05:31
Where does this id come from? Id is part of the AX
dmazzoni
2013/11/18 08:09:25
The node isn't valid without a parent, id, and ind
| |
32 | |
33 // Set the node's accessibility data. This may be done during initial | |
34 // initialization or later when the node data changes. | |
35 virtual void SetData(const AXNodeData& src); | |
36 | |
37 // Update the index in parent if siblings were inserted or deleted. | |
38 void UpdateIndexInParent(int index_in_parent); | |
David Tseng
2013/11/15 18:05:31
Just a setter; call it SetIndexInParent.
dmazzoni
2013/11/18 08:09:25
Done.
| |
39 | |
40 // Swap the internal children vector with |children|. This instance | |
41 // now owns all of the passed children. | |
42 virtual void SwapChildren(std::vector<AXNode*>& children); | |
43 | |
44 // This is called when the AXTree no longer includes this node in the | |
45 // tree. Reference counting is used on some platforms because the | |
46 // operating system may hold onto a reference to an AXNode | |
47 // object even after we're through with it, so this may decrement the | |
48 // reference count and clear out the object's data. | |
49 virtual void Destroy(); | |
50 | |
51 private: | |
52 int index_in_parent_; | |
53 AXNode* parent_; | |
54 std::vector<AXNode*> children_; | |
55 AXNodeData data_; | |
56 }; | |
57 | |
58 | |
59 } // namespace ui | |
60 | |
61 #endif // UI_ACCESSIBILITY_AX_NODE_H_ | |
OLD | NEW |