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

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

Issue 1128183010: ATK accessibility support for web content on Aura Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing nits Created 5 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/accessibility/accessibility_tree_formatter.h"
6
7 #include <atk/atk.h>
8
9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "content/browser/accessibility/browser_accessibility_auralinux.h"
15
16 namespace content {
17
18 void AccessibilityTreeFormatter::AddProperties(const BrowserAccessibility& node,
19 base::DictionaryValue* dict) {
20 dict->SetInteger("id", node.GetId());
21 BrowserAccessibilityAuraLinux* acc_obj =
22 const_cast<BrowserAccessibility*>(&node)
23 ->ToBrowserAccessibilityAuraLinux();
24
25 AtkObject* atk_object = acc_obj->GetAtkObject();
26 AtkRole role = acc_obj->atk_role();
27 if (role != ATK_ROLE_UNKNOWN)
28 dict->SetString("role", atk_role_get_name(role));
29 dict->SetString("name", atk_object_get_name(atk_object));
30 dict->SetString("description", atk_object_get_description(atk_object));
31 AtkStateSet* state_set = atk_object_ref_state_set(atk_object);
32 base::ListValue* states = new base::ListValue;
33 for (int i = ATK_STATE_INVALID; i < ATK_STATE_LAST_DEFINED; i++) {
34 AtkStateType state_type = static_cast<AtkStateType>(i);
35 if (atk_state_set_contains_state(state_set, state_type))
36 states->AppendString(atk_state_type_get_name(state_type));
37 }
38 dict->Set("states", states);
39 }
40
41 base::string16 AccessibilityTreeFormatter::ToString(
42 const base::DictionaryValue& node) {
43 base::string16 line;
44 std::string role_value;
45 node.GetString("role", &role_value);
46 if (!role_value.empty()) {
47 WriteAttribute(true, base::StringPrintf("[%s]", role_value.c_str()), &line);
48 }
49
50 std::string name_value;
51 node.GetString("name", &name_value);
52 WriteAttribute(true, base::StringPrintf("name='%s'", name_value.c_str()),
53 &line);
54
55 std::string description_value;
56 node.GetString("description", &description_value);
57 WriteAttribute(
58 false, base::StringPrintf("description='%s'", description_value.c_str()),
59 &line);
60
61 const base::ListValue* states_value;
62 node.GetList("states", &states_value);
63 for (base::ListValue::const_iterator it = states_value->begin();
64 it != states_value->end(); ++it) {
65 std::string state_value;
66 if ((*it)->GetAsString(&state_value))
67 WriteAttribute(true, state_value, &line);
68 }
69
70 int id_value;
71 node.GetInteger("id", &id_value);
72 WriteAttribute(false, base::StringPrintf("id=%d", id_value), &line);
73
74 return line + base::ASCIIToUTF16("\n");
75 }
76
77 void AccessibilityTreeFormatter::Initialize() {
78 }
79
80 // static
81 const base::FilePath::StringType
82 AccessibilityTreeFormatter::GetActualFileSuffix() {
83 return FILE_PATH_LITERAL("-actual-auralinux.txt");
84 }
85
86 // static
87 const base::FilePath::StringType
88 AccessibilityTreeFormatter::GetExpectedFileSuffix() {
89 return FILE_PATH_LITERAL("-expected-auralinux.txt");
90 }
91
92 // static
93 const std::string AccessibilityTreeFormatter::GetAllowEmptyString() {
94 return "@AURALINUX-ALLOW-EMPTY:";
95 }
96
97 // static
98 const std::string AccessibilityTreeFormatter::GetAllowString() {
99 return "@AURALINUX-ALLOW:";
100 }
101
102 // static
103 const std::string AccessibilityTreeFormatter::GetDenyString() {
104 return "@AURALINUX-DENY:";
105 }
106 }
OLDNEW
« no previous file with comments | « content/browser/accessibility/accessibility_tree_formatter.cc ('k') | content/browser/accessibility/browser_accessibility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698