Chromium Code Reviews| Index: content/browser/accessibility/dump_accessibility_tree_helper.cc |
| diff --git a/content/browser/accessibility/dump_accessibility_tree_helper.cc b/content/browser/accessibility/dump_accessibility_tree_helper.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..28804d2a268acc6530d772860d4c31e509e59e8c |
| --- /dev/null |
| +++ b/content/browser/accessibility/dump_accessibility_tree_helper.cc |
| @@ -0,0 +1,26 @@ |
| +// Copyright (c) 2012 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/browser/accessibility/dump_accessibility_tree_helper.h" |
| + |
| +#include "base/memory/scoped_ptr.h" |
| + |
| +void DumpAccessibilityTreeHelper::DumpAccessibilityTree( |
| + BrowserAccessibility* node, string16* contents) { |
| + RecursiveDumpAccessibilityTree(node, contents, 0); |
| +} |
| + |
|
David Tseng
2012/03/06 23:49:05
nit: extra line.
dmazzoni
2012/03/08 07:10:37
Done.
|
| + |
| +void DumpAccessibilityTreeHelper::RecursiveDumpAccessibilityTree( |
| + BrowserAccessibility* node, string16* contents, int indent) { |
| + scoped_array<char> prefix(new char(indent + 1)); |
| + for (int i = 0; i < indent; i++) |
|
David Tseng
2012/03/06 23:49:05
nit: ++i
dmazzoni
2012/03/08 07:10:37
Done.
|
| + prefix[i] = ' '; |
| + prefix[indent] = 0; |
|
David Tseng
2012/03/06 23:49:05
nit: 0 -> NULL for clearity?
dmazzoni
2012/03/08 07:10:37
I think NULL is only supposed to be for pointers.
|
| + |
| + *contents += ToString(node, prefix.get()); |
| + for (size_t i = 0; i < node->children().size(); ++i) { |
| + RecursiveDumpAccessibilityTree(node->children()[i], contents, indent + 4); |
|
David Tseng
2012/03/06 23:49:05
nit: define the indent step as a constant somewher
dmazzoni
2012/03/08 07:10:37
Done.
|
| + } |
| +} |