summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 02:38:12 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 02:38:12 +0000
commit9c1a75a98415e74b4aa835786ae86825a11d2385 (patch)
tree612ccad3919bdf0458d7a616dec98f25d21a703b /ui
parent1738fde08f5ee274dac199c1a98da9b0be5230d0 (diff)
downloadchromium_src-9c1a75a98415e74b4aa835786ae86825a11d2385.zip
chromium_src-9c1a75a98415e74b4aa835786ae86825a11d2385.tar.gz
chromium_src-9c1a75a98415e74b4aa835786ae86825a11d2385.tar.bz2
Rename TreeNode::GetChildCount to TreeNode::child_count. Part 3.
This is part of a serie of patches to make the TreeNode API more closer to style used in the Views Tree API (see views/view.h for reference). BUG=None TEST=existing unit_tests. Review URL: http://codereview.chromium.org/6639015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77592 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/models/tree_node_iterator.h4
-rw-r--r--ui/base/models/tree_node_model.h19
2 files changed, 11 insertions, 12 deletions
diff --git a/ui/base/models/tree_node_iterator.h b/ui/base/models/tree_node_iterator.h
index 63074ea..1c40ddb 100644
--- a/ui/base/models/tree_node_iterator.h
+++ b/ui/base/models/tree_node_iterator.h
@@ -24,7 +24,7 @@ template <class NodeType>
class TreeNodeIterator {
public:
explicit TreeNodeIterator(NodeType* node) {
- if (node->GetChildCount() > 0)
+ if (node->child_count() > 0)
positions_.push(Position<NodeType>(node, 0));
}
@@ -48,7 +48,7 @@ class TreeNodeIterator {
// Advance to next position.
while (!positions_.empty() && positions_.top().index >=
- positions_.top().node->GetChildCount()) {
+ positions_.top().node->child_count()) {
positions_.pop();
}
diff --git a/ui/base/models/tree_node_model.h b/ui/base/models/tree_node_model.h
index 482221d..0064172 100644
--- a/ui/base/models/tree_node_model.h
+++ b/ui/base/models/tree_node_model.h
@@ -82,7 +82,7 @@ class TreeNode : public TreeModelNode {
virtual void Add(int index, NodeType* child) {
DCHECK(child);
DCHECK_LE(0, index);
- DCHECK_GE(GetChildCount(), index);
+ DCHECK_GE(child_count(), index);
// If the node has a parent, remove it from its parent.
NodeType* node_parent = child->parent();
if (node_parent)
@@ -94,7 +94,7 @@ class TreeNode : public TreeModelNode {
// Removes the node by index. This does NOT delete the specified node, it is
// up to the caller to delete it when done.
virtual NodeType* Remove(int index) {
- DCHECK(index >= 0 && index < GetChildCount());
+ DCHECK(index >= 0 && index < child_count());
NodeType* node = GetChild(index);
node->parent_ = NULL;
children_->erase(index + children_->begin());
@@ -109,9 +109,7 @@ class TreeNode : public TreeModelNode {
}
// Returns the number of children.
- int GetChildCount() const {
- return static_cast<int>(children_->size());
- }
+ int child_count() const { return static_cast<int>(children_->size()); }
// Returns the number of all nodes in teh subtree rooted at this node,
// including this node.
@@ -124,14 +122,14 @@ class TreeNode : public TreeModelNode {
return count;
}
- // Returns a child by index.
+ // Returns the node at |index|.
NodeType* GetChild(int index) {
- DCHECK(index >= 0 && index < GetChildCount());
+ DCHECK(index >= 0 && index < child_count());
return children_[index];
}
const NodeType* GetChild(int index) const {
DCHECK_LE(0, index);
- DCHECK_GT(GetChildCount(), index);
+ DCHECK_GT(child_count(), index);
return children_[index];
}
@@ -179,9 +177,10 @@ class TreeNode : public TreeModelNode {
// Title displayed in the tree.
string16 title_;
+ // This node's parent.
NodeType* parent_;
- // Children.
+ // This node's children.
ScopedVector<NodeType> children_;
DISALLOW_COPY_AND_ASSIGN(TreeNode);
@@ -237,7 +236,7 @@ class TreeNodeModel : public TreeModel {
virtual int GetChildCount(TreeModelNode* parent) {
DCHECK(parent);
- return AsNode(parent)->GetChildCount();
+ return AsNode(parent)->child_count();
}
virtual NodeType* GetChild(TreeModelNode* parent, int index) {