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

Side by Side Diff: content/browser/accessibility/accessibility_tree_formatter.cc

Issue 2891933004: Remove raw base::DictionaryValue::Set in //content (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/accessibility/accessibility_tree_formatter_auralinux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 void AccessibilityTreeFormatter::FormatAccessibilityTree( 51 void AccessibilityTreeFormatter::FormatAccessibilityTree(
52 BrowserAccessibility* root, base::string16* contents) { 52 BrowserAccessibility* root, base::string16* contents) {
53 std::unique_ptr<base::DictionaryValue> dict = BuildAccessibilityTree(root); 53 std::unique_ptr<base::DictionaryValue> dict = BuildAccessibilityTree(root);
54 RecursiveFormatAccessibilityTree(*(dict.get()), contents); 54 RecursiveFormatAccessibilityTree(*(dict.get()), contents);
55 } 55 }
56 56
57 void AccessibilityTreeFormatter::RecursiveBuildAccessibilityTree( 57 void AccessibilityTreeFormatter::RecursiveBuildAccessibilityTree(
58 const BrowserAccessibility& node, base::DictionaryValue* dict) { 58 const BrowserAccessibility& node, base::DictionaryValue* dict) {
59 AddProperties(node, dict); 59 AddProperties(node, dict);
60 60
61 base::ListValue* children = new base::ListValue; 61 auto children = base::MakeUnique<base::ListValue>();
62 dict->Set(kChildrenDictAttr, children);
63 62
64 for (size_t i = 0; i < ChildCount(node); ++i) { 63 for (size_t i = 0; i < ChildCount(node); ++i) {
65 BrowserAccessibility* child_node = GetChild(node, i); 64 BrowserAccessibility* child_node = GetChild(node, i);
66 std::unique_ptr<base::DictionaryValue> child_dict( 65 std::unique_ptr<base::DictionaryValue> child_dict(
67 new base::DictionaryValue); 66 new base::DictionaryValue);
68 RecursiveBuildAccessibilityTree(*child_node, child_dict.get()); 67 RecursiveBuildAccessibilityTree(*child_node, child_dict.get());
69 children->Append(std::move(child_dict)); 68 children->Append(std::move(child_dict));
70 } 69 }
70 dict->Set(kChildrenDictAttr, std::move(children));
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
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (attr.empty()) 159 if (attr.empty())
160 return; 160 return;
161 if (!MatchesFilters(attr, include_by_default)) 161 if (!MatchesFilters(attr, include_by_default))
162 return; 162 return;
163 if (!line->empty()) 163 if (!line->empty())
164 *line += base::ASCIIToUTF16(" "); 164 *line += base::ASCIIToUTF16(" ");
165 *line += attr; 165 *line += attr;
166 } 166 }
167 167
168 } // namespace content 168 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/accessibility/accessibility_tree_formatter_auralinux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698