AX: Headers of table not read by VoiceOver
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Dec 2016 07:47:56 +0000 (07:47 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Dec 2016 07:47:56 +0000 (07:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158693
<rdar://problem/26771065>

Reviewed by Darin Adler.

Source/WebCore:

If a table cell header is hidden, by pushing off screen then the content won't be accessible.
It seems that unless specifically requested (such as using aria-hidden), we should try to return
that table cell header.

Test: accessibility/hidden-th-still-column-header.html

* accessibility/AccessibilityTableColumn.cpp:
(WebCore::AccessibilityTableColumn::headerObjectForSection):

LayoutTests:

* accessibility/hidden-th-still-column-header-expected.txt: Added.
* accessibility/hidden-th-still-column-header.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/hidden-th-still-column-header-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/hidden-th-still-column-header.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityTableColumn.cpp

index 789635b..4121a35 100644 (file)
@@ -1,3 +1,14 @@
+2016-12-25  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Headers of table not read by VoiceOver
+        https://bugs.webkit.org/show_bug.cgi?id=158693
+        <rdar://problem/26771065>
+
+        Reviewed by Darin Adler.
+
+        * accessibility/hidden-th-still-column-header-expected.txt: Added.
+        * accessibility/hidden-th-still-column-header.html: Added.
+
 2016-12-25  Sam Weinig  <sam@webkit.org>
 
         [WebIDL] Remove (most) custom bindings for the IndexedDB code
 2016-12-25  Sam Weinig  <sam@webkit.org>
 
         [WebIDL] Remove (most) custom bindings for the IndexedDB code
diff --git a/LayoutTests/accessibility/hidden-th-still-column-header-expected.txt b/LayoutTests/accessibility/hidden-th-still-column-header-expected.txt
new file mode 100644 (file)
index 0000000..1ec676d
--- /dev/null
@@ -0,0 +1,14 @@
+header 1header2        header 3
+cell1  cell2   cell3
+This tests confirms even when a th tag is hidden, it will still be returned as a column header (unless it is hidden).
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS colHeaders.length is 2
+PASS colHeaders[0].childAtIndex(0).childAtIndex(0).stringValue is 'AXValue: header 1'
+PASS colHeaders[1].childAtIndex(0).stringValue is 'AXValue: header 3'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/hidden-th-still-column-header.html b/LayoutTests/accessibility/hidden-th-still-column-header.html
new file mode 100644 (file)
index 0000000..73fef09
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+<script src="../resources/accessibility-helper.js"></script>
+</head>
+<body>
+
+<table border="1" id="table">
+<tr><th style="position: absolute; left: -99999px;">header 1</th>
+<th style="position: absolute; left: -99999px;" aria-hidden="true">header2</th>
+<th>header 3</th>
+</tr>
+<tr><td>cell1</td><td>cell2</td><td>cell3</td></tr>
+</table>
+
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests confirms even when a th tag is hidden, it will still be returned as a column header (unless it is hidden).");
+    if (window.accessibilityController) {
+        var table = accessibilityController.accessibleElementById("table");
+        var colHeaders = table.columnHeaders();
+        shouldBe("colHeaders.length", "2");
+        shouldBe("colHeaders[0].childAtIndex(0).childAtIndex(0).stringValue", "'AXValue: header 1'");
+        shouldBe("colHeaders[1].childAtIndex(0).stringValue", "'AXValue: header 3'");
+    }
+</script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
index 3218bc1..458d3f3 100644 (file)
@@ -1,3 +1,20 @@
+2016-12-25  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Headers of table not read by VoiceOver
+        https://bugs.webkit.org/show_bug.cgi?id=158693
+        <rdar://problem/26771065>
+
+        Reviewed by Darin Adler.
+
+        If a table cell header is hidden, by pushing off screen then the content won't be accessible.
+        It seems that unless specifically requested (such as using aria-hidden), we should try to return
+        that table cell header.
+
+        Test: accessibility/hidden-th-still-column-header.html
+
+        * accessibility/AccessibilityTableColumn.cpp:
+        (WebCore::AccessibilityTableColumn::headerObjectForSection):
+
 2016-12-25  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Propagate the source origin as much as possible
 2016-12-25  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Propagate the source origin as much as possible
index 3fa78b5..ec7b2e4 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "AXObjectCache.h"
 #include "AccessibilityTableCell.h"
 
 #include "AXObjectCache.h"
 #include "AccessibilityTableCell.h"
+#include "HTMLCollection.h"
 #include "HTMLElement.h"
 #include "HTMLNames.h"
 #include "RenderTable.h"
 #include "HTMLElement.h"
 #include "HTMLNames.h"
 #include "RenderTable.h"
@@ -142,12 +143,21 @@ AccessibilityObject* AccessibilityTableColumn::headerObjectForSection(RenderTabl
             if ((testCell->col() + (testCell->colSpan()-1)) < m_columnIndex)
                 break;
             
             if ((testCell->col() + (testCell->colSpan()-1)) < m_columnIndex)
                 break;
             
-            // If this does not have an element (like a <caption>) then check the next row
-            if (!testCell->element())
+            Node* testCellNode = testCell->element();
+            // If the RenderTableCell doesn't have an element because its anonymous,
+            // try to see if we can find the original cell element to check if it has a <th> tag.
+            if (!testCellNode && testCell->isAnonymous()) {
+                if (Element* parentElement = testCell->parent() ? testCell->parent()->element() : nullptr) {
+                    if (parentElement->hasTagName(trTag) && testCol < static_cast<int>(parentElement->countChildNodes()))
+                        testCellNode = parentElement->traverseToChildAt(testCol);
+                }
+            }
+
+            if (!testCellNode)
                 continue;
             
             // If th is required, but we found an element that doesn't have a th tag, we can stop looking.
                 continue;
             
             // If th is required, but we found an element that doesn't have a th tag, we can stop looking.
-            if (thTagRequired && !testCell->element()->hasTagName(thTag))
+            if (thTagRequired && !testCellNode->hasTagName(thTag))
                 break;
             
             cell = testCell;
                 break;
             
             cell = testCell;
@@ -158,7 +168,11 @@ AccessibilityObject* AccessibilityTableColumn::headerObjectForSection(RenderTabl
     if (!cell)
         return nullptr;
 
     if (!cell)
         return nullptr;
 
-    return axObjectCache()->getOrCreate(cell);
+    auto* cellObject = axObjectCache()->getOrCreate(cell);
+    if (!cellObject || cellObject->accessibilityIsIgnored())
+        return nullptr;
+        
+    return cellObject;
 }
     
 bool AccessibilityTableColumn::computeAccessibilityIsIgnored() const
 }
     
 bool AccessibilityTableColumn::computeAccessibilityIsIgnored() const