AX: implement @aria-roledescription
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Jun 2015 23:02:03 +0000 (23:02 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Jun 2015 23:02:03 +0000 (23:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146274

Reviewed by Darin Adler.

Source/WebCore:

Add support for aria-roledescription.

Test: accessibility/aria-roledescription.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::hasHighlighting):
(WebCore::AccessibilityObject::roleDescription):
(WebCore::nodeHasPresentationRole):
* accessibility/AccessibilityObject.h:
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper _accessibilityMaxValue]):
(-[WebAccessibilityObjectWrapper accessibilityRoleDescription]):
(-[WebAccessibilityObjectWrapper accessibilityLabel]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper roleDescription]):

LayoutTests:

* accessibility/aria-roledescription-expected.txt: Added.
* accessibility/aria-roledescription.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186038 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/accessibility/aria-roledescription-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/aria-roledescription.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/html/HTMLAttributeNames.in

index 69575a3..b284793 100644 (file)
@@ -1,3 +1,13 @@
+2015-06-27  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: implement @aria-roledescription
+        https://bugs.webkit.org/show_bug.cgi?id=146274
+
+        Reviewed by Darin Adler.
+
+        * accessibility/aria-roledescription-expected.txt: Added.
+        * accessibility/aria-roledescription.html: Added.
+
 2015-06-27  Myles C. Maxfield  <mmaxfield@apple.com>
 
         REGRESSION (r186001): fast/text/han-generic-font-families.html always fails on Yosemite
diff --git a/LayoutTests/accessibility/aria-roledescription-expected.txt b/LayoutTests/accessibility/aria-roledescription-expected.txt
new file mode 100644 (file)
index 0000000..1cc8484
--- /dev/null
@@ -0,0 +1,13 @@
+text
+This tests that aria-roledescription works.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Role description: AXRoleDescription: Super Button
+Role description: AXRoleDescription: 
+Role description: AXRoleDescription: button
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/aria-roledescription.html b/LayoutTests/accessibility/aria-roledescription.html
new file mode 100644 (file)
index 0000000..d7ee2fe
--- /dev/null
@@ -0,0 +1,37 @@
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+
+<div id="btn" role="button" aria-roledescription="Super Button">text</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+function runTest() {
+    description("This tests that aria-roledescription works.");
+
+    if (window.accessibilityController) {
+
+        // Confirm we can override our role description.
+        debug("Role description: " + accessibilityController.accessibleElementById("btn").roleDescription);
+
+        // Confirm our role description is empty when set to zero length.
+        document.getElementById("btn").setAttribute("aria-roledescription", "");
+        debug("Role description: " + accessibilityController.accessibleElementById("btn").roleDescription);
+
+        // Confirm our role description returns to default when removed.
+        document.getElementById("btn").removeAttribute("aria-roledescription");
+        debug("Role description: " + accessibilityController.accessibleElementById("btn").roleDescription);
+    }
+}
+
+runTest();
+</script>
+
+</body>
+<script src="../resources/js-test-post.js"></script>
+</html>
index 2b69eb7..058d983 100644 (file)
@@ -1,3 +1,26 @@
+2015-06-27  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: implement @aria-roledescription
+        https://bugs.webkit.org/show_bug.cgi?id=146274
+
+        Reviewed by Darin Adler.
+
+        Add support for aria-roledescription.
+
+        Test: accessibility/aria-roledescription.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::hasHighlighting):
+        (WebCore::AccessibilityObject::roleDescription):
+        (WebCore::nodeHasPresentationRole):
+        * accessibility/AccessibilityObject.h:
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper _accessibilityMaxValue]):
+        (-[WebAccessibilityObjectWrapper accessibilityRoleDescription]):
+        (-[WebAccessibilityObjectWrapper accessibilityLabel]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper roleDescription]):
+
 2015-06-27  Darin Adler  <darin@apple.com>
 
         Fix the build.
index f74b755..e7c6fcb 100644 (file)
@@ -2027,6 +2027,11 @@ bool AccessibilityObject::hasHighlighting() const
     return false;
 }
 
+const AtomicString& AccessibilityObject::roleDescription() const
+{
+    return getAttribute(aria_roledescriptionAttr);
+}
+    
 static bool nodeHasPresentationRole(Node* node)
 {
     return nodeHasRole(node, "presentation") || nodeHasRole(node, "none");
index 102db9a..9f292a6 100644 (file)
@@ -621,6 +621,7 @@ public:
     bool supportsRangeValue() const;
     String identifierAttribute() const;
     void classList(Vector<String>&) const;
+    const AtomicString& roleDescription() const;
     
     bool supportsARIASetSize() const;
     bool supportsARIAPosInSet() const;
index 9f674fd..97059f9 100644 (file)
@@ -853,6 +853,11 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
     return m_object->maxValueForRange();
 }
 
+- (NSString *)accessibilityRoleDescription
+{
+    return m_object->roleDescription();
+}
+
 - (NSString *)accessibilityLabel
 {
     if (![self _prepareAccessibilityCall])
index 00b259b..8ae0036 100644 (file)
@@ -2206,6 +2206,10 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         return [[self attachmentView] accessibilityAttributeValue:NSAccessibilityRoleDescriptionAttribute];
 #pragma clang diagnostic pop
 
+    const AtomicString& overrideRoleDescription = m_object->roleDescription();
+    if (!overrideRoleDescription.isNull())
+        return overrideRoleDescription;
+    
     NSString* axRole = [self role];
     
     if ([axRole isEqualToString:NSAccessibilityGroupRole]) {
index 174bc66..9ed84f0 100644 (file)
@@ -42,6 +42,7 @@ aria-pressed
 aria-readonly
 aria-relevant
 aria-required
+aria-roledescription
 aria-selected
 aria-setsize
 aria-sort