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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree( | 73 void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree( |
74 const base::DictionaryValue& dict, base::string16* contents, int depth) { | 74 const base::DictionaryValue& dict, base::string16* contents, int depth) { |
75 base::string16 indent = base::string16(depth * kIndentSymbolCount, | 75 base::string16 indent = base::string16(depth * kIndentSymbolCount, |
76 kIndentSymbol); | 76 kIndentSymbol); |
77 base::string16 line = indent + ToString(dict); | 77 base::string16 line = indent + ToString(dict); |
78 if (line.find(base::ASCIIToUTF16(kSkipString)) != base::string16::npos) | 78 if (line.find(base::ASCIIToUTF16(kSkipString)) != base::string16::npos) |
79 return; | 79 return; |
80 | 80 |
81 // Replace literal newlines with "<newline>" | |
82 base::ReplaceChars(line, | |
83 base::ASCIIToUTF16("\n"), | |
84 base::ASCIIToUTF16("<newline>"), | |
85 &line); | |
86 | |
87 *contents += line + base::ASCIIToUTF16("\n"); | 81 *contents += line + base::ASCIIToUTF16("\n"); |
88 if (line.find(base::ASCIIToUTF16(kSkipChildren)) != base::string16::npos) | 82 if (line.find(base::ASCIIToUTF16(kSkipChildren)) != base::string16::npos) |
89 return; | 83 return; |
90 | 84 |
91 const base::ListValue* children; | 85 const base::ListValue* children; |
92 dict.GetList(kChildrenDictAttr, &children); | 86 dict.GetList(kChildrenDictAttr, &children); |
93 const base::DictionaryValue* child_dict; | 87 const base::DictionaryValue* child_dict; |
94 for (size_t i = 0; i < children->GetSize(); i++) { | 88 for (size_t i = 0; i < children->GetSize(); i++) { |
95 children->GetDictionary(i, &child_dict); | 89 children->GetDictionary(i, &child_dict); |
96 RecursiveFormatAccessibilityTree(*child_dict, contents, depth + 1); | 90 RecursiveFormatAccessibilityTree(*child_dict, contents, depth + 1); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (attr.empty()) | 153 if (attr.empty()) |
160 return; | 154 return; |
161 if (!MatchesFilters(attr, include_by_default)) | 155 if (!MatchesFilters(attr, include_by_default)) |
162 return; | 156 return; |
163 if (!line->empty()) | 157 if (!line->empty()) |
164 *line += base::ASCIIToUTF16(" "); | 158 *line += base::ASCIIToUTF16(" "); |
165 *line += attr; | 159 *line += attr; |
166 } | 160 } |
167 | 161 |
168 } // namespace content | 162 } // namespace content |
OLD | NEW |