Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1862)

Unified Diff: content/browser/accessibility/dump_accessibility_tree_helper.cc

Issue 9617019: Improve formatting of accessibility tests that dump the tree. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing files Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698