Chromium Code Reviews| Index: content/common/ax_node_impl.cc |
| diff --git a/content/common/ax_node_impl.cc b/content/common/ax_node_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1bbfcb4ff694454cdf525fc4138f1b03d4093954 |
| --- /dev/null |
| +++ b/content/common/ax_node_impl.cc |
| @@ -0,0 +1,79 @@ |
| +// 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. |
| + |
| +#include "content/common/ax_node_impl.h" |
| + |
| +#include "content/common/ax_tree_impl.h" |
| + |
| +namespace content { |
| + |
| +AXNodeImpl::AXNodeImpl() |
| + : index_in_parent_(0), |
| + parent_(NULL), |
| + tree_(NULL) { |
| +} |
| + |
| +AXNodeImpl::~AXNodeImpl() { |
| + fprintf(stderr, "Deleting node %p\n", this); fflush(stderr); |
|
aboxhall
2013/11/11 18:20:35
I assume this isn't meant to be checked in?
dmazzoni
2013/11/12 00:03:04
Done.
|
| +} |
| + |
| +int32 AXNodeImpl::GetId() const { |
| + return data_.id; |
| +} |
| + |
| +AXNode* AXNodeImpl::GetParent() const { |
| + return parent_; |
| +} |
| + |
| +int AXNodeImpl::GetChildCount() const { |
| + return static_cast<int>(children_.size()); |
| +} |
| + |
| +AXNode* AXNodeImpl::ChildAtIndex(int index) const { |
| + return children_[index]; |
| +} |
| + |
| +const AXNodeData& AXNodeImpl::data() const { |
| + return data_; |
| +} |
| + |
| +void AXNodeImpl::Init( |
| + AXTreeImpl* tree, AXNodeImpl* parent, int32 id, int32 index_in_parent) { |
| + tree_ = tree; |
| + parent_ = parent; |
| + data_.id = id; |
| + index_in_parent_ = index_in_parent; |
| +} |
| + |
| +void AXNodeImpl::SetData(const AXNodeData& src) { |
| + data_ = src; |
| +} |
| + |
| +void AXNodeImpl::UpdateIndexInParent(int index_in_parent) { |
| + index_in_parent_ = index_in_parent; |
| +} |
| + |
| +void AXNodeImpl::DetachTree(std::vector<AXNodeImpl*>* nodes) { |
| + nodes->push_back(this); |
| + for (size_t i = 0; i < children_.size(); ++i) |
| + children_[i]->DetachTree(nodes); |
| + children_.clear(); |
| + parent_ = NULL; |
| +} |
| + |
| +void AXNodeImpl::SwapChildren(std::vector<AXNodeImpl*>& children) { |
| + children.swap(children_); |
| +} |
| + |
| +void AXNodeImpl::Destroy() { |
| + for (std::vector<AXNodeImpl*>::iterator iter = children_.begin(); |
| + iter != children_.end(); |
| + ++iter) { |
| + (*iter)->Destroy(); |
| + } |
| + children_.clear(); |
| + tree_->NodeWasDestroyed(this); |
| +} |
| + |
| +} // namespace content |