Chromium Code Reviews| 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 |