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 |
81 *contents += line + base::ASCIIToUTF16("\n"); | 87 *contents += line + base::ASCIIToUTF16("\n"); |
82 if (line.find(base::ASCIIToUTF16(kSkipChildren)) != base::string16::npos) | 88 if (line.find(base::ASCIIToUTF16(kSkipChildren)) != base::string16::npos) |
83 return; | 89 return; |
84 | 90 |
85 const base::ListValue* children; | 91 const base::ListValue* children; |
86 dict.GetList(kChildrenDictAttr, &children); | 92 dict.GetList(kChildrenDictAttr, &children); |
87 const base::DictionaryValue* child_dict; | 93 const base::DictionaryValue* child_dict; |
88 for (size_t i = 0; i < children->GetSize(); i++) { | 94 for (size_t i = 0; i < children->GetSize(); i++) { |
89 children->GetDictionary(i, &child_dict); | 95 children->GetDictionary(i, &child_dict); |
90 RecursiveFormatAccessibilityTree(*child_dict, contents, depth + 1); | 96 RecursiveFormatAccessibilityTree(*child_dict, contents, depth + 1); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 if (attr.empty()) | 159 if (attr.empty()) |
154 return; | 160 return; |
155 if (!MatchesFilters(attr, include_by_default)) | 161 if (!MatchesFilters(attr, include_by_default)) |
156 return; | 162 return; |
157 if (!line->empty()) | 163 if (!line->empty()) |
158 *line += base::ASCIIToUTF16(" "); | 164 *line += base::ASCIIToUTF16(" "); |
159 *line += attr; | 165 *line += attr; |
160 } | 166 } |
161 | 167 |
162 } // namespace content | 168 } // namespace content |
OLD | NEW |