Chromium Code Reviews| 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 | 11 |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | |
| 12 #include "base/strings/pattern.h" | 14 #include "base/strings/pattern.h" |
| 13 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 17 #include "content/browser/accessibility/browser_accessibility_manager.h" | 19 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 18 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 20 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 19 #include "content/browser/web_contents/web_contents_impl.h" | 21 #include "content/browser/web_contents/web_contents_impl.h" |
| 20 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 21 | 23 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 | 56 |
| 55 void AccessibilityTreeFormatter::RecursiveBuildAccessibilityTree( | 57 void AccessibilityTreeFormatter::RecursiveBuildAccessibilityTree( |
| 56 const BrowserAccessibility& node, base::DictionaryValue* dict) { | 58 const BrowserAccessibility& node, base::DictionaryValue* dict) { |
| 57 AddProperties(node, dict); | 59 AddProperties(node, dict); |
| 58 | 60 |
| 59 base::ListValue* children = new base::ListValue; | 61 base::ListValue* children = new base::ListValue; |
| 60 dict->Set(kChildrenDictAttr, children); | 62 dict->Set(kChildrenDictAttr, children); |
| 61 | 63 |
| 62 for (size_t i = 0; i < ChildCount(node); ++i) { | 64 for (size_t i = 0; i < ChildCount(node); ++i) { |
| 63 BrowserAccessibility* child_node = GetChild(node, i); | 65 BrowserAccessibility* child_node = GetChild(node, i); |
| 64 base::DictionaryValue* child_dict = new base::DictionaryValue; | 66 std::unique_ptr<base::DictionaryValue> child_dict( |
| 65 children->Append(child_dict); | 67 new base::DictionaryValue); |
| 66 RecursiveBuildAccessibilityTree(*child_node, child_dict); | 68 RecursiveBuildAccessibilityTree(*child_node, child_dict.get()); |
|
danakj
2016/08/27 00:07:14
Wait.. doesn't this change the order. Now we recur
dcheng
2016/08/30 06:47:48
No, the recursive call builds the child node, whic
danakj
2016/09/06 21:55:39
Oh ya ok, you right. Children will not see themsel
| |
| 69 children->Append(std::move(child_dict)); | |
| 67 } | 70 } |
| 68 } | 71 } |
| 69 | 72 |
| 70 void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree( | 73 void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree( |
| 71 const base::DictionaryValue& dict, base::string16* contents, int depth) { | 74 const base::DictionaryValue& dict, base::string16* contents, int depth) { |
| 72 base::string16 indent = base::string16(depth * kIndentSymbolCount, | 75 base::string16 indent = base::string16(depth * kIndentSymbolCount, |
| 73 kIndentSymbol); | 76 kIndentSymbol); |
| 74 base::string16 line = indent + ToString(dict); | 77 base::string16 line = indent + ToString(dict); |
| 75 if (line.find(base::ASCIIToUTF16(kSkipString)) != base::string16::npos) | 78 if (line.find(base::ASCIIToUTF16(kSkipString)) != base::string16::npos) |
| 76 return; | 79 return; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 if (attr.empty()) | 153 if (attr.empty()) |
| 151 return; | 154 return; |
| 152 if (!MatchesFilters(attr, include_by_default)) | 155 if (!MatchesFilters(attr, include_by_default)) |
| 153 return; | 156 return; |
| 154 if (!line->empty()) | 157 if (!line->empty()) |
| 155 *line += base::ASCIIToUTF16(" "); | 158 *line += base::ASCIIToUTF16(" "); |
| 156 *line += attr; | 159 *line += attr; |
| 157 } | 160 } |
| 158 | 161 |
| 159 } // namespace content | 162 } // namespace content |
| OLD | NEW |