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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/accessibility/accessibility_tree_formatter_auralinux.cc
diff --git a/content/browser/accessibility/accessibility_tree_formatter_auralinux.cc b/content/browser/accessibility/accessibility_tree_formatter_auralinux.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8ceefe8699378940d4947e0f96ddc0c28b926a73
--- /dev/null
+++ b/content/browser/accessibility/accessibility_tree_formatter_auralinux.cc
@@ -0,0 +1,106 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/accessibility/accessibility_tree_formatter.h"
+
+#include <atk/atk.h>
+
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/browser/accessibility/browser_accessibility_auralinux.h"
+
+namespace content {
+
+void AccessibilityTreeFormatter::AddProperties(const BrowserAccessibility& node,
+ base::DictionaryValue* dict) {
+ dict->SetInteger("id", node.GetId());
+ BrowserAccessibilityAuraLinux* acc_obj =
+ const_cast<BrowserAccessibility*>(&node)
+ ->ToBrowserAccessibilityAuraLinux();
+
+ AtkObject* atk_object = acc_obj->GetAtkObject();
+ AtkRole role = acc_obj->atk_role();
+ if (role != ATK_ROLE_UNKNOWN)
+ dict->SetString("role", atk_role_get_name(role));
+ dict->SetString("name", atk_object_get_name(atk_object));
+ dict->SetString("description", atk_object_get_description(atk_object));
+ AtkStateSet* state_set = atk_object_ref_state_set(atk_object);
+ base::ListValue* states = new base::ListValue;
+ for (int i = ATK_STATE_INVALID; i < ATK_STATE_LAST_DEFINED; i++) {
+ AtkStateType state_type = static_cast<AtkStateType>(i);
+ if (atk_state_set_contains_state(state_set, state_type))
+ states->AppendString(atk_state_type_get_name(state_type));
+ }
+ dict->Set("states", states);
+}
+
+base::string16 AccessibilityTreeFormatter::ToString(
+ const base::DictionaryValue& node) {
+ base::string16 line;
+ std::string role_value;
+ node.GetString("role", &role_value);
+ if (!role_value.empty()) {
+ WriteAttribute(true, base::StringPrintf("[%s]", role_value.c_str()), &line);
+ }
+
+ std::string name_value;
+ node.GetString("name", &name_value);
+ WriteAttribute(true, base::StringPrintf("name='%s'", name_value.c_str()),
+ &line);
+
+ std::string description_value;
+ node.GetString("description", &description_value);
+ WriteAttribute(
+ false, base::StringPrintf("description='%s'", description_value.c_str()),
+ &line);
+
+ const base::ListValue* states_value;
+ node.GetList("states", &states_value);
+ for (base::ListValue::const_iterator it = states_value->begin();
+ it != states_value->end(); ++it) {
+ std::string state_value;
+ if ((*it)->GetAsString(&state_value))
+ WriteAttribute(true, state_value, &line);
+ }
+
+ int id_value;
+ node.GetInteger("id", &id_value);
+ WriteAttribute(false, base::StringPrintf("id=%d", id_value), &line);
+
+ return line + base::ASCIIToUTF16("\n");
+}
+
+void AccessibilityTreeFormatter::Initialize() {
+}
+
+// static
+const base::FilePath::StringType
+AccessibilityTreeFormatter::GetActualFileSuffix() {
+ return FILE_PATH_LITERAL("-actual-auralinux.txt");
+}
+
+// static
+const base::FilePath::StringType
+AccessibilityTreeFormatter::GetExpectedFileSuffix() {
+ return FILE_PATH_LITERAL("-expected-auralinux.txt");
+}
+
+// static
+const std::string AccessibilityTreeFormatter::GetAllowEmptyString() {
+ return "@AURALINUX-ALLOW-EMPTY:";
+}
+
+// static
+const std::string AccessibilityTreeFormatter::GetAllowString() {
+ return "@AURALINUX-ALLOW:";
+}
+
+// static
+const std::string AccessibilityTreeFormatter::GetDenyString() {
+ return "@AURALINUX-DENY:";
+}
+}
« 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