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

Unified Diff: content/renderer/accessibility/accessibility_node_serializer.cc

Issue 98183011: Expose semantics of landmark and related roles for assitive technologies (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 12 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/renderer/accessibility/accessibility_node_serializer.cc
===================================================================
--- content/renderer/accessibility/accessibility_node_serializer.cc (revision 242763)
+++ content/renderer/accessibility/accessibility_node_serializer.cc (working copy)
@@ -124,6 +124,30 @@
return state;
}
+std::string ConvertRole(const blink::WebAXRole role) {
dmazzoni 2014/01/05 05:27:38 Let's call this GetEquivalentAriaRoleString.
+ switch (role) {
+ case blink::WebAXRoleArticle:
+ return "article";
+ case blink::WebAXRoleComplementary:
+ return "complementary";
+ case blink::WebAXRoleContentInfo:
+ case blink::WebAXRoleFooter:
+ return "contentinfo";
+ case blink::WebAXRoleBanner:
+ return "banner";
+ case blink::WebAXRoleMain:
+ return "main";
+ case blink::WebAXRoleNavigation:
+ return "navigation";
+ case blink::WebAXRoleRegion:
+ return "region";
+ default:
+ break;
+ }
+
+ return std::string();
+}
+
} // Anonymous namespace
void SerializeAccessibilityNode(
@@ -278,6 +302,11 @@
if (element.hasAttribute("role")) {
dst->AddStringAttribute(dst->ATTR_ROLE,
base::UTF16ToUTF8(element.getAttribute("role")));
+ } else {
+ std::string role = ConvertRole(src.role());
+ if (!role.empty()) {
dmazzoni 2014/01/05 05:27:38 Nit: the Chromium style is to not use { } braces w
+ dst->AddStringAttribute(dst->ATTR_ROLE, role);
+ }
}
// Live region attributes

Powered by Google App Engine
This is Rietveld 408576698