Chromium Code Reviews| 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 #include "content/common/ax_node_impl.h" | |
| 6 | |
| 7 #include "content/common/ax_tree_impl.h" | |
| 8 | |
| 9 namespace content { | |
| 10 | |
| 11 AXNodeImpl::AXNodeImpl() | |
| 12 : index_in_parent_(0), | |
| 13 parent_(NULL), | |
| 14 tree_(NULL) { | |
| 15 } | |
| 16 | |
| 17 AXNodeImpl::~AXNodeImpl() { | |
| 18 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.
| |
| 19 } | |
| 20 | |
| 21 int32 AXNodeImpl::GetId() const { | |
| 22 return data_.id; | |
| 23 } | |
| 24 | |
| 25 AXNode* AXNodeImpl::GetParent() const { | |
| 26 return parent_; | |
| 27 } | |
| 28 | |
| 29 int AXNodeImpl::GetChildCount() const { | |
| 30 return static_cast<int>(children_.size()); | |
| 31 } | |
| 32 | |
| 33 AXNode* AXNodeImpl::ChildAtIndex(int index) const { | |
| 34 return children_[index]; | |
| 35 } | |
| 36 | |
| 37 const AXNodeData& AXNodeImpl::data() const { | |
| 38 return data_; | |
| 39 } | |
| 40 | |
| 41 void AXNodeImpl::Init( | |
| 42 AXTreeImpl* tree, AXNodeImpl* parent, int32 id, int32 index_in_parent) { | |
| 43 tree_ = tree; | |
| 44 parent_ = parent; | |
| 45 data_.id = id; | |
| 46 index_in_parent_ = index_in_parent; | |
| 47 } | |
| 48 | |
| 49 void AXNodeImpl::SetData(const AXNodeData& src) { | |
| 50 data_ = src; | |
| 51 } | |
| 52 | |
| 53 void AXNodeImpl::UpdateIndexInParent(int index_in_parent) { | |
| 54 index_in_parent_ = index_in_parent; | |
| 55 } | |
| 56 | |
| 57 void AXNodeImpl::DetachTree(std::vector<AXNodeImpl*>* nodes) { | |
| 58 nodes->push_back(this); | |
| 59 for (size_t i = 0; i < children_.size(); ++i) | |
| 60 children_[i]->DetachTree(nodes); | |
| 61 children_.clear(); | |
| 62 parent_ = NULL; | |
| 63 } | |
| 64 | |
| 65 void AXNodeImpl::SwapChildren(std::vector<AXNodeImpl*>& children) { | |
| 66 children.swap(children_); | |
| 67 } | |
| 68 | |
| 69 void AXNodeImpl::Destroy() { | |
| 70 for (std::vector<AXNodeImpl*>::iterator iter = children_.begin(); | |
| 71 iter != children_.end(); | |
| 72 ++iter) { | |
| 73 (*iter)->Destroy(); | |
| 74 } | |
| 75 children_.clear(); | |
| 76 tree_->NodeWasDestroyed(this); | |
| 77 } | |
| 78 | |
| 79 } // namespace content | |
| OLD | NEW |