AX: [GTK] Implement computedRoleString in AccessibilityUIElement
https://bugs.webkit.org/show_bug.cgi?id=128420
Reviewed by Chris Fleizach.
Source/WebCore:
Expose all ARIA roles (not just landmark-related roles) via an "xml-roles" AtkObject
attribute as per http://www.w3.org/TR/core-aam-1.1/#roleMappingGeneralRules
Expose non-empty computed role strings via AtkObject attribute named "computed-role".
Currently the computed role and the ARIA role value happen to be the same string, but
that might not always be the case. And AtkObject attributes are cheap.
Test: platform/gtk/accessibility/xml-roles-exposed.html.
* accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
(webkitAccessibleGetAttributes):
Tools:
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::computedRoleString): Implemented.
LayoutTests:
* platform/gtk/TestExpectations: Removed roles-computedRoleString from the failing test.
* platform/gtk/accessibility/image-link-expected.txt: Updated to reflect the new object attribute.
* platform/gtk/accessibility/image-map2-expected.txt: Updated to reflect the new object attribute.
* platform/gtk/accessibility/lists-expected.txt: Updated to reflect the new object attribute.
* platform/gtk/accessibility/roles-computedRoleString-expected.txt: Added.
* platform/gtk/accessibility/table-attributes-expected.txt: Updated to reflect the new object attribute.
* platform/gtk/accessibility/table-cell-spans-expected.txt: Updated to reflect the new object attribute.
* platform/gtk/accessibility/table-cells-expected.txt: Updated to reflect the new object attribute.
* platform/gtk/accessibility/table-detection-expected.txt: Updated to reflect the new object attribute.
* platform/gtk/accessibility/table-sections-expected.txt: Updated to reflect the new object attribute.
* platform/gtk/accessibility/table-with-rules-expected.txt: Updated to reflect the new object attribute.
* platform/gtk/accessibility/xml-roles-exposed-expected.txt: Added.
* platform/gtk/accessibility/xml-roles-exposed.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@184754 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp b/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
index a9c2ba4..b472935 100644
--- a/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
+++ b/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
@@ -451,30 +451,18 @@
if (coreObject->supportsARIASetSize())
attributeSet = addToAtkAttributeSet(attributeSet, "setsize", String::number(coreObject->ariaSetSize()).utf8().data());
- // Landmarks will be exposed with xml-roles object attributes, with the exception
- // of LandmarkApplicationRole, which will be exposed with ATK_ROLE_EMBEDDED.
- AccessibilityRole role = coreObject->roleValue();
- switch (role) {
- case LandmarkBannerRole:
- attributeSet = addToAtkAttributeSet(attributeSet, "xml-roles", "banner");
- break;
- case LandmarkComplementaryRole:
- attributeSet = addToAtkAttributeSet(attributeSet, "xml-roles", "complementary");
- break;
- case LandmarkContentInfoRole:
- attributeSet = addToAtkAttributeSet(attributeSet, "xml-roles", "contentinfo");
- break;
- case LandmarkMainRole:
- attributeSet = addToAtkAttributeSet(attributeSet, "xml-roles", "main");
- break;
- case LandmarkNavigationRole:
- attributeSet = addToAtkAttributeSet(attributeSet, "xml-roles", "navigation");
- break;
- case LandmarkSearchRole:
- attributeSet = addToAtkAttributeSet(attributeSet, "xml-roles", "search");
- break;
- default:
- break;
+ // According to the W3C Core Accessibility API Mappings 1.1, section 5.4.1 General Rules:
+ // "User agents must expose the WAI-ARIA role string if the API supports a mechanism to do so."
+ // In the case of ATK, the mechanism to do so is an object attribute pair (xml-roles:"string").
+ // The computedRoleString is primarily for testing, and not limited to elements with ARIA roles.
+ // Because the computedRoleString currently contains the ARIA role string, we'll use it for
+ // both purposes, as the "computed-role" object attribute for all elements which have a value
+ // and also via the "xml-roles" attribute for elements with ARIA, as well as for landmarks.
+ String roleString = coreObject->computedRoleString();
+ if (!roleString.isEmpty()) {
+ if (coreObject->ariaRoleAttribute() != UnknownRole || coreObject->isLandmark())
+ attributeSet = addToAtkAttributeSet(attributeSet, "xml-roles", roleString.utf8().data());
+ attributeSet = addToAtkAttributeSet(attributeSet, "computed-role", roleString.utf8().data());
}
return attributeSet;