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

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

Issue 2799413002: Views a11y: Add AXNodeData.actions bitfield to indicate supported actions by UI. (Closed)
Patch Set: Fix tests broken from rebase. 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_util.h"
8 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
9 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h" 10 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h"
10 #include "content/browser/accessibility/browser_accessibility_manager.h" 11 #include "content/browser/accessibility/browser_accessibility_manager.h"
11 #include "ui/gfx/geometry/rect_conversions.h" 12 #include "ui/gfx/geometry/rect_conversions.h"
12 #include "ui/gfx/transform.h" 13 #include "ui/gfx/transform.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 AccessibilityTreeFormatterBlink::AccessibilityTreeFormatterBlink() 17 AccessibilityTreeFormatterBlink::AccessibilityTreeFormatterBlink()
17 : AccessibilityTreeFormatter() { 18 : AccessibilityTreeFormatter() {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 value_list->AppendString(ui::ToString(target->GetData().role)); 128 value_list->AppendString(ui::ToString(target->GetData().role));
128 else 129 else
129 value_list->AppendString("null"); 130 value_list->AppendString("null");
130 } else { 131 } else {
131 value_list->AppendInteger(values[i]); 132 value_list->AppendInteger(values[i]);
132 } 133 }
133 } 134 }
134 dict->Set(ui::ToString(attr), value_list); 135 dict->Set(ui::ToString(attr), value_list);
135 } 136 }
136 } 137 }
138
139 std::vector<std::string> actions_strings;
140 for (int action_index = ui::AX_ACTION_NONE + 1;
141 action_index <= ui::AX_ACTION_LAST; ++action_index) {
142 auto action = static_cast<ui::AXAction>(action_index);
143 if (node.HasAction(action))
144 actions_strings.push_back(ui::ToString(action));
145 }
146 if (!actions_strings.empty())
147 dict->SetString("actions", base::JoinString(actions_strings, ","));
137 } 148 }
138 149
139 base::string16 AccessibilityTreeFormatterBlink::ToString( 150 base::string16 AccessibilityTreeFormatterBlink::ToString(
140 const base::DictionaryValue& dict) { 151 const base::DictionaryValue& dict) {
141 base::string16 line; 152 base::string16 line;
142 153
143 if (show_ids()) { 154 if (show_ids()) {
144 int id_value; 155 int id_value;
145 dict.GetInteger("id", &id_value); 156 dict.GetInteger("id", &id_value);
146 WriteAttribute(true, base::IntToString16(id_value), &line); 157 WriteAttribute(true, base::IntToString16(id_value), &line);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 attr_string += string_value; 266 attr_string += string_value;
256 } else { 267 } else {
257 int int_value; 268 int int_value;
258 value->GetInteger(i, &int_value); 269 value->GetInteger(i, &int_value);
259 attr_string += base::IntToString(int_value); 270 attr_string += base::IntToString(int_value);
260 } 271 }
261 } 272 }
262 WriteAttribute(false, attr_string, &line); 273 WriteAttribute(false, attr_string, &line);
263 } 274 }
264 275
276 std::string string_value;
277 if (dict.GetString("actions", &string_value)) {
278 WriteAttribute(false,
279 base::StringPrintf("%s=%s", "actions", string_value.c_str()),
280 &line);
281 }
282
265 return line; 283 return line;
266 } 284 }
267 285
268 const base::FilePath::StringType 286 const base::FilePath::StringType
269 AccessibilityTreeFormatterBlink::GetExpectedFileSuffix() { 287 AccessibilityTreeFormatterBlink::GetExpectedFileSuffix() {
270 return FILE_PATH_LITERAL("-expected-blink.txt"); 288 return FILE_PATH_LITERAL("-expected-blink.txt");
271 } 289 }
272 290
273 const std::string AccessibilityTreeFormatterBlink::GetAllowEmptyString() { 291 const std::string AccessibilityTreeFormatterBlink::GetAllowEmptyString() {
274 return "@BLINK-ALLOW-EMPTY:"; 292 return "@BLINK-ALLOW-EMPTY:";
275 } 293 }
276 294
277 const std::string AccessibilityTreeFormatterBlink::GetAllowString() { 295 const std::string AccessibilityTreeFormatterBlink::GetAllowString() {
278 return "@BLINK-ALLOW:"; 296 return "@BLINK-ALLOW:";
279 } 297 }
280 298
281 const std::string AccessibilityTreeFormatterBlink::GetDenyString() { 299 const std::string AccessibilityTreeFormatterBlink::GetDenyString() {
282 return "@BLINK-DENY:"; 300 return "@BLINK-DENY:";
283 } 301 }
284 302
285 } // namespace content 303 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698