Chromium Code Reviews| Index: ui/accessibility/ax_node.h |
| diff --git a/ui/accessibility/ax_node.h b/ui/accessibility/ax_node.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..49e2aa6ccde49148a27430710381ff9c499a5dfc |
| --- /dev/null |
| +++ b/ui/accessibility/ax_node.h |
| @@ -0,0 +1,61 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_ACCESSIBILITY_AX_NODE_H_ |
| +#define UI_ACCESSIBILITY_AX_NODE_H_ |
| + |
| +#include "ui/accessibility/ax_node_data.h" |
| + |
| +namespace ui { |
| + |
| +// One node in an AXTree. |
| +class UI_EXPORT AXNode { |
| + public: |
| + AXNode(); |
| + virtual ~AXNode(); |
| + |
| + // Accessors. |
| + int32 id() const { return data_.id; } |
| + AXNode* parent() const { return parent_; } |
| + int child_count() const { return static_cast<int>(children_.size()); } |
| + const AXNodeData& data() const { return data_; } |
| + const std::vector<AXNode*>& children() const { return children_; } |
| + |
| + // Get the child at the given index. |
| + AXNode* ChildAtIndex(int index) const { return children_[index]; } |
| + |
| + // Initialize the node. This sets up its place in the tree but does |
| + // not set its data yet. After initialization, only index_in_parent |
| + // is allowed to change, the others are guaranteed to never change. |
| + 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
|
| + |
| + // Set the node's accessibility data. This may be done during initial |
| + // initialization or later when the node data changes. |
| + virtual void SetData(const AXNodeData& src); |
| + |
| + // Update the index in parent if siblings were inserted or deleted. |
| + 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.
|
| + |
| + // Swap the internal children vector with |children|. This instance |
| + // now owns all of the passed children. |
| + virtual void SwapChildren(std::vector<AXNode*>& children); |
| + |
| + // This is called when the AXTree no longer includes this node in the |
| + // tree. Reference counting is used on some platforms because the |
| + // operating system may hold onto a reference to an AXNode |
| + // object even after we're through with it, so this may decrement the |
| + // reference count and clear out the object's data. |
| + virtual void Destroy(); |
| + |
| + private: |
| + int index_in_parent_; |
| + AXNode* parent_; |
| + std::vector<AXNode*> children_; |
| + AXNodeData data_; |
| +}; |
| + |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_ACCESSIBILITY_AX_NODE_H_ |