AX: Data table heuristics: assume data table if at least one row or column of TH...
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Jul 2010 22:36:34 +0000 (22:36 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Jul 2010 22:36:34 +0000 (22:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=41806

Reviewed by Beth Dakin.

WebCore:

Test: platform/mac/accessibility/table-with-row-col-of-headers.html

* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::isTableExposableThroughAccessibility):

LayoutTests:

* platform/mac-leopard/Skipped:
* platform/mac-tiger/Skipped:
* platform/mac/accessibility/table-with-row-col-of-headers-expected.txt: Added.
* platform/mac/accessibility/table-with-row-col-of-headers.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac-leopard/Skipped
LayoutTests/platform/mac-tiger/Skipped
LayoutTests/platform/mac/accessibility/table-with-row-col-of-headers-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/table-with-row-col-of-headers.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/accessibility/AccessibilityTable.cpp

index ccd8ca8..42a956b 100644 (file)
@@ -1,3 +1,15 @@
+2010-07-07  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        AX: Data table heuristics: assume data table if at least one row or column of TH cells exist
+        https://bugs.webkit.org/show_bug.cgi?id=41806
+
+        * platform/mac-leopard/Skipped:
+        * platform/mac-tiger/Skipped:
+        * platform/mac/accessibility/table-with-row-col-of-headers-expected.txt: Added.
+        * platform/mac/accessibility/table-with-row-col-of-headers.html: Added.
+
 2010-07-07  Peter Kasting  <pkasting@google.com>
 
         Not reviewed.  Chromium test expectation update.
index 9ab46e7..6002960 100644 (file)
@@ -35,6 +35,7 @@ platform/mac/accessibility/inherited-presentational-lists.html
 platform/mac/accessibility/stale-table-rows.html
 platform/mac/accessibility/parent-of-table-row-is-table.html
 platform/mac/accessibility/aria-expanded-notifications.html
+platform/mac/accessibility/table-with-first-row-of-headers.html
 
 # This test requires ogg codecs
 media/media-can-play-ogg.html
index 92ca5e8..801ec2a 100644 (file)
@@ -37,6 +37,7 @@ platform/mac/accessibility/aria-treegrid.html
 platform/mac/accessibility/stale-table-rows.html
 platform/mac/accessibility/parent-of-table-row-is-table.html
 platform/mac/accessibility/aria-expanded-notifications.html
+platform/mac/accessibility/table-with-first-row-of-headers.html
 # Lists are not supported on Leopard.
 platform/mac/accessibility/aria-directory.html
 platform/mac/accessibility/inherited-presentational-lists.html
diff --git a/LayoutTests/platform/mac/accessibility/table-with-row-col-of-headers-expected.txt b/LayoutTests/platform/mac/accessibility/table-with-row-col-of-headers-expected.txt
new file mode 100644 (file)
index 0000000..11029da
--- /dev/null
@@ -0,0 +1,21 @@
+header 1       header 2
+cell 1
+header 1       header 2
+cell 1 cell 1
+header 1       header 2
+cell 1
+header 1       header 2
+cell 1
+This tests that tables that have THs in the first row or first column will be exposed as AXTables.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS accessibilityController.focusedElement.role is 'AXRole: AXTable'
+PASS accessibilityController.focusedElement.role is 'AXRole: AXTable'
+PASS accessibilityController.focusedElement.role is 'AXRole: AXWebArea'
+PASS accessibilityController.focusedElement.role is 'AXRole: AXWebArea'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/table-with-row-col-of-headers.html b/LayoutTests/platform/mac/accessibility/table-with-row-col-of-headers.html
new file mode 100644 (file)
index 0000000..88040f3
--- /dev/null
@@ -0,0 +1,84 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script>
+var successfullyParsed = false;
+</script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<!-- This table should appear as an AXTable because it has all <th> in the first row -->
+<table tabindex=0 id="table1">
+  <tr>
+     <th>header 1</th>
+     <th>header 2</th>
+  </tr>
+  <tr> 
+     <td colspan=2>cell 1</td>
+  </tr>
+</table>
+
+<!-- This table should appear as an AXTable because it has all <th> in the first column -->
+<table tabindex=0 id="table2">
+  <tr>
+     <th>header 1</th>
+     <td>header 2</td>
+  </tr>
+  <tr> 
+     <th>cell 1</th>
+     <td>cell 1</td>
+  </tr>
+</table>
+
+<!-- This table should NOT appear as an AXTable because it does not have all <th> in the first row -->
+<table tabindex=0 id="table3">
+  <tr>
+     <th>header 1</th>
+     <td>header 2</td>
+  </tr>
+  <tr> 
+     <td colspan=2>cell 1</td>
+  </tr>
+</table>
+
+<!-- This table should appear as an AXTable because it has <th> in the second row -->
+<table tabindex=0 id="table4">
+  <tr>
+     <td>header 1</td>
+     <td>header 2</td>
+  </tr>
+  <tr> 
+     <th colspan=2>cell 1</th>
+  </tr>
+</table>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that tables that have THs in the first row or first column will be exposed as AXTables.");
+
+    if (window.accessibilityController) {
+
+          document.getElementById("table1").focus();
+          shouldBe("accessibilityController.focusedElement.role", "'AXRole: AXTable'");
+
+          document.getElementById("table2").focus();
+          shouldBe("accessibilityController.focusedElement.role", "'AXRole: AXTable'");
+
+          document.getElementById("table3").focus();
+          shouldBe("accessibilityController.focusedElement.role", "'AXRole: AXWebArea'");
+
+          document.getElementById("table4").focus();
+          shouldBe("accessibilityController.focusedElement.role", "'AXRole: AXWebArea'");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 345d287..911df3d 100644 (file)
@@ -1,3 +1,15 @@
+2010-07-07  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        AX: Data table heuristics: assume data table if at least one row or column of TH cells exist
+        https://bugs.webkit.org/show_bug.cgi?id=41806
+
+        Test: platform/mac/accessibility/table-with-row-col-of-headers.html
+
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::isTableExposableThroughAccessibility):
+
 2010-07-07  Mark Rowe  <mrowe@apple.com>
 
         Fix the build.
index 8e0562c..437ac38 100644 (file)
@@ -137,7 +137,10 @@ bool AccessibilityTable::isTableExposableThroughAccessibility()
     unsigned borderedCellCount = 0;
     unsigned backgroundDifferenceCellCount = 0;
     
+    int headersInFirstColumnCount = 0;
     for (int row = 0; row < numRows; ++row) {
+    
+        int headersInFirstRowCount = 0;
         for (int col = 0; col < numCols; ++col) {    
             RenderTableCell* cell = firstBody->cellAt(row, col).cell;
             if (!cell)
@@ -153,6 +156,15 @@ bool AccessibilityTable::isTableExposableThroughAccessibility()
             
             HTMLTableCellElement* cellElement = static_cast<HTMLTableCellElement*>(cellNode);
             
+            bool isTHCell = cellElement->hasTagName(thTag);
+            // If the first row is comprised of all <th> tags, assume it is a data table.
+            if (!row && isTHCell)
+                headersInFirstRowCount++;
+
+            // If the first column is comprised of all <tg> tags, assume it is a data table.
+            if (!col && isTHCell)
+                headersInFirstColumnCount++;
+            
             // in this case, the developer explicitly assigned a "data" table attribute
             if (!cellElement->headers().isEmpty() || !cellElement->abbr().isEmpty()
                 || !cellElement->axis().isEmpty() || !cellElement->scope().isEmpty())
@@ -178,8 +190,14 @@ bool AccessibilityTable::isTableExposableThroughAccessibility()
             if (borderedCellCount >= 10 || backgroundDifferenceCellCount >= 10)
                 return true;
         }
+        
+        if (!row && headersInFirstRowCount == numCols && numCols > 1)
+            return true;
     }
 
+    if (headersInFirstColumnCount == numRows && numRows > 1)
+        return true;
+    
     // if there is less than two valid cells, it's not a data table
     if (validCellCount <= 1)
         return false;