OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/accessibility/accessibility_tree_formatter.h" | 5 #include "content/browser/accessibility/accessibility_tree_formatter.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "content/browser/accessibility/browser_accessibility_manager.h" | 13 #include "content/browser/accessibility/browser_accessibility_manager.h" |
14 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 14 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
15 #include "content/browser/web_contents/web_contents_impl.h" | 15 #include "content/browser/web_contents/web_contents_impl.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 namespace { | 19 namespace { |
20 const char kIndentSymbol = '+'; | 20 const char kIndentSymbol = '+'; |
21 const int kIndentSymbolCount = 2; | 21 const int kIndentSymbolCount = 2; |
22 const char* kSkipString = "@NO_DUMP"; | 22 const char* kSkipString = "@NO_DUMP"; |
| 23 const char* kSkipChildren = "@NO_CHILDREN_DUMP"; |
23 const char* kChildrenDictAttr = "children"; | 24 const char* kChildrenDictAttr = "children"; |
24 } | 25 } |
25 | 26 |
26 AccessibilityTreeFormatter::AccessibilityTreeFormatter( | 27 AccessibilityTreeFormatter::AccessibilityTreeFormatter( |
27 BrowserAccessibility* root) | 28 BrowserAccessibility* root) |
28 : root_(root), | 29 : root_(root), |
29 show_ids_(false) { | 30 show_ids_(false) { |
30 Initialize(); | 31 Initialize(); |
31 } | 32 } |
32 | 33 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 78 |
78 void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree( | 79 void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree( |
79 const base::DictionaryValue& dict, base::string16* contents, int depth) { | 80 const base::DictionaryValue& dict, base::string16* contents, int depth) { |
80 base::string16 indent = base::string16(depth * kIndentSymbolCount, | 81 base::string16 indent = base::string16(depth * kIndentSymbolCount, |
81 kIndentSymbol); | 82 kIndentSymbol); |
82 base::string16 line = indent + ToString(dict); | 83 base::string16 line = indent + ToString(dict); |
83 if (line.find(base::ASCIIToUTF16(kSkipString)) != base::string16::npos) | 84 if (line.find(base::ASCIIToUTF16(kSkipString)) != base::string16::npos) |
84 return; | 85 return; |
85 | 86 |
86 *contents += line + base::ASCIIToUTF16("\n"); | 87 *contents += line + base::ASCIIToUTF16("\n"); |
| 88 if (line.find(base::ASCIIToUTF16(kSkipChildren)) != base::string16::npos) |
| 89 return; |
| 90 |
87 const base::ListValue* children; | 91 const base::ListValue* children; |
88 dict.GetList(kChildrenDictAttr, &children); | 92 dict.GetList(kChildrenDictAttr, &children); |
89 const base::DictionaryValue* child_dict; | 93 const base::DictionaryValue* child_dict; |
90 for (size_t i = 0; i < children->GetSize(); i++) { | 94 for (size_t i = 0; i < children->GetSize(); i++) { |
91 children->GetDictionary(i, &child_dict); | 95 children->GetDictionary(i, &child_dict); |
92 RecursiveFormatAccessibilityTree(*child_dict, contents, depth + 1); | 96 RecursiveFormatAccessibilityTree(*child_dict, contents, depth + 1); |
93 } | 97 } |
94 } | 98 } |
95 | 99 |
96 #if (!defined(OS_WIN) && !defined(OS_MACOSX) && !defined(OS_ANDROID)) | 100 #if (!defined(OS_WIN) && !defined(OS_MACOSX) && !defined(OS_ANDROID)) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 if (attr.empty()) | 191 if (attr.empty()) |
188 return; | 192 return; |
189 if (!MatchesFilters(attr, include_by_default)) | 193 if (!MatchesFilters(attr, include_by_default)) |
190 return; | 194 return; |
191 if (!line->empty()) | 195 if (!line->empty()) |
192 *line += base::ASCIIToUTF16(" "); | 196 *line += base::ASCIIToUTF16(" "); |
193 *line += attr; | 197 *line += attr; |
194 } | 198 } |
195 | 199 |
196 } // namespace content | 200 } // namespace content |
OLD | NEW |