AX: [ATK] Explicitly-set aria-sort value of "none" should be exposed as an object...
authorjdiggs@igalia.com <jdiggs@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Oct 2017 17:12:34 +0000 (17:12 +0000)
committerjdiggs@igalia.com <jdiggs@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Oct 2017 17:12:34 +0000 (17:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177955

Reviewed by Chris Fleizach.

Source/WebCore:

Expose "none" as the value of aria-sort when the attribute is present and not
one of the other valid sort types. Also add a new AccessibilitySortDirection,
SortDirectionInvalid. This is currently only being used when the sort direction
is sought for a role which does not support this ARIA attribute, but might come
in handy if we want to add further sanity checks on the author-provided values.

Test: accessibility/gtk/aria-sort-values.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::sortDirection const):
* accessibility/AccessibilityObject.h:
* accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
(webkitAccessibleGetAttributes):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):

LayoutTests:

* accessibility/gtk/aria-sort-values-expected.txt: Added.
* accessibility/gtk/aria-sort-values.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/gtk/aria-sort-values-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/gtk/aria-sort-values.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

index 99e064db73a31e605356ed87c326f0926e0311ba..43598ff8c7c4f959fbe6a22c79b1c9cac8804072 100644 (file)
@@ -1,3 +1,13 @@
+2017-10-09  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: [ATK] Explicitly-set aria-sort value of "none" should be exposed as an object attribute
+        https://bugs.webkit.org/show_bug.cgi?id=177955
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/gtk/aria-sort-values-expected.txt: Added.
+        * accessibility/gtk/aria-sort-values.html: Added.
+
 2017-10-09  Ryan Haddad  <ryanhaddad@apple.com>
 
         Mark media/media-source/media-source-paint-to-canvas.html as failing.
diff --git a/LayoutTests/accessibility/gtk/aria-sort-values-expected.txt b/LayoutTests/accessibility/gtk/aria-sort-values-expected.txt
new file mode 100644 (file)
index 0000000..07eedde
--- /dev/null
@@ -0,0 +1,17 @@
+This verifies that explicitly-set values of aria-sort are exposed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+test1 AXRole: AXColumnHeader (sort attribute not exposed)
+test2 AXRole: AXColumnHeader sort:ascending
+test3 AXRole: AXColumnHeader sort:descending
+test4 AXRole: AXColumnHeader sort:other
+test5 AXRole: AXColumnHeader sort:none
+test6 AXRole: AXColumnHeader sort:none
+test7 AXRole: AXColumnHeader sort:none
+test8 AXRole: AXCell (sort attribute not exposed)
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/gtk/aria-sort-values.html b/LayoutTests/accessibility/gtk/aria-sort-values.html
new file mode 100644 (file)
index 0000000..22041d1
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+  <div id="content">
+    <div role="grid">
+      <div role="row">
+        <div role="columnheader" id="test1">content</div>
+        <div role="columnheader" id="test2" aria-sort="ascending">content</div>
+        <div role="columnheader" id="test3" aria-sort="descending">content</div>
+        <div role="columnheader" id="test4" aria-sort="other">content</div>
+        <div role="columnheader" id="test5" aria-sort="none">content</div>
+        <div role="columnheader" id="test6" aria-sort="foo">content</div>
+        <div role="columnheader" id="test7" aria-sort="">content</div>
+        <div role="gridcell" id="test8" aria-sort="other">content</div>
+      </div>
+    </div>
+  </div>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    function sortAttribute(axElement) {
+        var allAttributes = axElement.allAttributes();
+        var index = allAttributes.search("sort:");
+        if (index == -1)
+            return "(sort attribute not exposed)";
+        string = allAttributes.substring(index);
+        return string.substring(0, string.search(","));
+    }
+
+    description("This verifies that explicitly-set values of aria-sort are exposed.");
+    if (window.accessibilityController) {
+        for (var i = 1; i <= 8; i++) {
+            var axElement = accessibilityController.accessibleElementById("test" + i);
+            debug("test" + i + " " + axElement.role + " " + sortAttribute(axElement));
+        }
+
+        document.getElementById("content").style.visibility = "hidden";
+    }
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+
index 8fd842bb1483150bed5ec4932c5ea310cc769427..b88f6248c22bc26488e2032613c15d0801317f23 100644 (file)
@@ -1,3 +1,26 @@
+2017-10-09  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: [ATK] Explicitly-set aria-sort value of "none" should be exposed as an object attribute
+        https://bugs.webkit.org/show_bug.cgi?id=177955
+
+        Reviewed by Chris Fleizach.
+
+        Expose "none" as the value of aria-sort when the attribute is present and not
+        one of the other valid sort types. Also add a new AccessibilitySortDirection,
+        SortDirectionInvalid. This is currently only being used when the sort direction
+        is sought for a role which does not support this ARIA attribute, but might come
+        in handy if we want to add further sanity checks on the author-provided values.
+
+        Test: accessibility/gtk/aria-sort-values.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::sortDirection const):
+        * accessibility/AccessibilityObject.h:
+        * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
+        (webkitAccessibleGetAttributes):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
+
 2017-10-09  Robin Morisset  <rmorisset@apple.com>
 
         Make the names of the options consistent 
index 9983ec1f42a249cef4d9f2415bfcb87818c26f0f..c3edb8a5df1e3e2492054dcba3bb54b4cd27b609 100644 (file)
@@ -2588,6 +2588,10 @@ AccessibilityObject* AccessibilityObject::focusedUIElement() const
     
 AccessibilitySortDirection AccessibilityObject::sortDirection() const
 {
+    AccessibilityRole role = roleValue();
+    if (role != RowHeaderRole && role != ColumnHeaderRole)
+        return SortDirectionInvalid;
+
     const AtomicString& sortAttribute = getAttribute(aria_sortAttr);
     if (equalLettersIgnoringASCIICase(sortAttribute, "ascending"))
         return SortDirectionAscending;
index 371ba9209625466e2539f4988cf509729813ae58..d0d4063da663be7c47bdbdf3c6918547d1b5b244 100644 (file)
@@ -334,7 +334,8 @@ enum AccessibilitySortDirection {
     SortDirectionNone,
     SortDirectionAscending,
     SortDirectionDescending,
-    SortDirectionOther
+    SortDirectionOther,
+    SortDirectionInvalid
 };
 
 enum AccessibilitySearchDirection {
index 7b3bd0677fcf2dc31ff0f3cb45bd890d33f6d30d..c536db6911320f82c1f4f60ed8794aa5a7da175e 100644 (file)
@@ -508,11 +508,23 @@ static AtkAttributeSet* webkitAccessibleGetAttributes(AtkObject* object)
     if (coreObject->supportsARIACurrent())
         attributeSet = addToAtkAttributeSet(attributeSet, "current", coreObject->ariaCurrentValue().utf8().data());
 
-    AccessibilitySortDirection sortDirection = coreObject->sortDirection();
-    if (sortDirection != SortDirectionNone) {
-        // WAI-ARIA spec says to translate the value as is from the attribute.
-        const AtomicString& sortAttribute = coreObject->getAttribute(HTMLNames::aria_sortAttr);
-        attributeSet = addToAtkAttributeSet(attributeSet, "sort", sortAttribute.string().utf8().data());
+    // The Core AAM states that an explicitly-set value should be exposed, including "none".
+    if (coreObject->hasAttribute(HTMLNames::aria_sortAttr)) {
+        switch (coreObject->sortDirection()) {
+        case SortDirectionInvalid:
+            break;
+        case SortDirectionAscending:
+            attributeSet = addToAtkAttributeSet(attributeSet, "sort", "ascending");
+            break;
+        case SortDirectionDescending:
+            attributeSet = addToAtkAttributeSet(attributeSet, "sort", "descending");
+            break;
+        case SortDirectionOther:
+            attributeSet = addToAtkAttributeSet(attributeSet, "sort", "other");
+            break;
+        default:
+            attributeSet = addToAtkAttributeSet(attributeSet, "sort", "none");
+        }
     }
 
     if (coreObject->supportsARIAPosInSet())
index fe6314da219e8f74f6f2cb462be526244de1c68b..18d1a9b58e56d6fb7d857c07a16296fa3524df47 100644 (file)
@@ -1197,7 +1197,8 @@ static id textMarkerRangeFromVisiblePositions(AXObjectCache* cache, const Visibl
     if (m_object->supportsARIAPosInSet())
         [additional addObject:NSAccessibilityARIAPosInSetAttribute];
     
-    if (m_object->sortDirection() != SortDirectionNone)
+    AccessibilitySortDirection sortDirection = m_object->sortDirection();
+    if (sortDirection != SortDirectionNone && sortDirection != SortDirectionInvalid)
         [additional addObject:NSAccessibilitySortDirectionAttribute];
     
     // If an object is a child of a live region, then add these