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

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: Fix Linux build error, tolerate different line endings 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..1d667c952676206fb0d73cbc0d62f8d131a3520a
--- /dev/null
+++ b/content/browser/accessibility/dump_accessibility_tree_helper.cc
@@ -0,0 +1,30 @@
+// 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"
+
+namespace {
+const int kIndentSpaces = 4;
+}
+
+void DumpAccessibilityTreeHelper::DumpAccessibilityTree(
+ BrowserAccessibility* node, string16* contents) {
+ RecursiveDumpAccessibilityTree(node, contents, 0);
+}
+
+void DumpAccessibilityTreeHelper::RecursiveDumpAccessibilityTree(
+ BrowserAccessibility* node, string16* contents, int indent) {
+ scoped_array<char> prefix(new char[indent + 1]);
+ for (int i = 0; i < indent; ++i)
+ prefix[i] = ' ';
+ prefix[indent] = '\0';
+
+ *contents += ToString(node, prefix.get());
+ for (size_t i = 0; i < node->children().size(); ++i) {
+ RecursiveDumpAccessibilityTree(node->children()[i], contents,
+ indent + kIndentSpaces);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698