AX: VoiceOver is not detecting ARIA treeview if it contains role="presentation"
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Oct 2016 01:15:21 +0000 (01:15 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Oct 2016 01:15:21 +0000 (01:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163763

Reviewed by Chris Fleizach.

Source/WebCore:

Test: accessibility/mac/aria-tree-with-presentation-role.html

Web authors sometimes use presentation role in the aria tree to hide elements. We should
consider this a valid case if they specify tree items and groups correctly.

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::hierarchicalLevel):
* accessibility/AccessibilityTree.cpp:
(WebCore::AccessibilityTree::nodeHasTreeItemChild):
(WebCore::AccessibilityTree::isTreeValid):
* accessibility/AccessibilityTree.h:

LayoutTests:

* accessibility/mac/aria-tree-with-presentation-role-expected.txt: Added.
* accessibility/mac/aria-tree-with-presentation-role.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/mac/aria-tree-with-presentation-role-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/aria-tree-with-presentation-role.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityTree.cpp
Source/WebCore/accessibility/AccessibilityTree.h

index eff2c13..0783a84 100644 (file)
@@ -1,3 +1,13 @@
+2016-10-20  Nan Wang  <n_wang@apple.com>
+
+        AX: VoiceOver is not detecting ARIA treeview if it contains role="presentation"
+        https://bugs.webkit.org/show_bug.cgi?id=163763
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/aria-tree-with-presentation-role-expected.txt: Added.
+        * accessibility/mac/aria-tree-with-presentation-role.html: Added.
+
 2016-10-19  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [macOS] [iOS] Disable variation fonts on macOS El Capitan and iOS 9
diff --git a/LayoutTests/accessibility/mac/aria-tree-with-presentation-role-expected.txt b/LayoutTests/accessibility/mac/aria-tree-with-presentation-role-expected.txt
new file mode 100644 (file)
index 0000000..04afdd5
--- /dev/null
@@ -0,0 +1,22 @@
+Release Notes
+Using Search
+Power Search
+Common Info Area
+This tests that aria trees are correctly exposed when there is role='presentation' presented.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+AXRole: AXOutline AXValue: 
+  AXRole: AXRow level: 0
+    AXRole: AXStaticText AXValue: Release Notes
+  AXRole: AXRow level: 0
+    AXRole: AXStaticText AXValue: Using Search
+  AXRole: AXRow level: 1
+    AXRole: AXStaticText AXValue: Power Search
+  AXRole: AXRow level: 0
+    AXRole: AXStaticText AXValue: Common Info Area
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/mac/aria-tree-with-presentation-role.html b/LayoutTests/accessibility/mac/aria-tree-with-presentation-role.html
new file mode 100644 (file)
index 0000000..cc37610
--- /dev/null
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<ul id="tree" role="tree" aria-label="Help Topics">
+<li role="treeitem">Release Notes</li>
+<li role="presentation">  
+<span role="treeitem" aria-expanded="true">Using Search</span>
+<ul role="group" aria-label="Using Search" aria-expanded="true">
+<li role="treeitem">Power Search</li>
+</ul>
+</li>
+<li role="presentation">
+<span role="treeitem" aria-expanded="false">Common Info Area</span>
+</li>
+</ul>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that aria trees are correctly exposed when there is role='presentation' presented.");
+
+    if (window.accessibilityController) {
+    
+          // Test tree attributes.
+          var tree = accessibilityController.accessibleElementById("tree");
+          dumpAccessibilityChildren(tree, 0);
+    }
+    
+    function dumpAccessibilityChildren(element, level) {
+        if (element.stringValue.indexOf('End of test') >= 0)
+            return false;
+
+        var indent = "";
+        for (var k = 0; k < level; k++) { indent += "  "; }
+        if (element.role == "AXRole: AXRow")
+            debug(indent + element.role + " " + "level: " + element.hierarchicalLevel);
+        else
+            debug(indent + element.role + " " + element.stringValue);
+        var childrenCount = element.childrenCount;
+        for (var k = 0; k < childrenCount; k++) {
+            if (!dumpAccessibilityChildren(element.childAtIndex(k), level+1))
+                return false;
+        }
+        return true;
+    }
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index a8320f2..f73a5af 100644 (file)
@@ -1,3 +1,22 @@
+2016-10-20  Nan Wang  <n_wang@apple.com>
+
+        AX: VoiceOver is not detecting ARIA treeview if it contains role="presentation"
+        https://bugs.webkit.org/show_bug.cgi?id=163763
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/mac/aria-tree-with-presentation-role.html
+
+        Web authors sometimes use presentation role in the aria tree to hide elements. We should
+        consider this a valid case if they specify tree items and groups correctly.
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::hierarchicalLevel):
+        * accessibility/AccessibilityTree.cpp:
+        (WebCore::AccessibilityTree::nodeHasTreeItemChild):
+        (WebCore::AccessibilityTree::isTreeValid):
+        * accessibility/AccessibilityTree.h:
+
 2016-10-20  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Many WebGL functions which don't throw are marked as possibly throwing
index 3c88853..1bc9a5e 100644 (file)
@@ -1615,7 +1615,7 @@ unsigned AccessibilityNodeObject::hierarchicalLevel() const
     // We measure tree hierarchy by the number of groups that the item is within.
     unsigned level = 1;
     for (AccessibilityObject* parent = parentObject(); parent; parent = parent->parentObject()) {
-        AccessibilityRole parentRole = parent->roleValue();
+        AccessibilityRole parentRole = parent->ariaRoleAttribute();
         if (parentRole == GroupRole)
             level++;
         else if (parentRole == TreeRole)
index f4613cd..07f3136 100644 (file)
@@ -67,6 +67,15 @@ AccessibilityRole AccessibilityTree::determineAccessibilityRole()
     return isTreeValid() ? TreeRole : GroupRole;
 }
 
+bool AccessibilityTree::nodeHasTreeItemChild(Node& node) const
+{
+    for (auto* child = node.firstChild(); child; child = child->nextSibling()) {
+        if (nodeHasRole(child, "treeitem"))
+            return true;
+    }
+    return false;
+}
+
 bool AccessibilityTree::isTreeValid() const
 {
     // A valid tree can only have treeitem or group of treeitems as a child
@@ -87,6 +96,11 @@ bool AccessibilityTree::isTreeValid() const
             continue;
         if (nodeHasRole(child, "treeitem"))
             continue;
+        if (nodeHasRole(child, "presentation")) {
+            if (!nodeHasTreeItemChild(*child))
+                return false;
+            continue;
+        }
         if (!nodeHasRole(child, "group"))
             return false;
 
index 8769ab1..ddc1a56 100644 (file)
@@ -44,6 +44,7 @@ private:
     bool computeAccessibilityIsIgnored() const override;
     AccessibilityRole determineAccessibilityRole() override;
     bool isTreeValid() const;
+    bool nodeHasTreeItemChild(Node&) const;
 };
     
 } // namespace WebCore