AX: kAXCellForColumnAndRowParameterizedAttribute doesn't work ARIA grids with colspans
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Mar 2011 17:20:03 +0000 (17:20 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Mar 2011 17:20:03 +0000 (17:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=55735

Reviewed by Beth Dakin.

Source/WebCore:

The ARIA grid implementation needed to verify the row/column range of a cell instead of
assuming a 1-1 mapping between children and row/column.

Test: platform/mac/accessibility/aria-table-with-colspan-cells.html

* accessibility/AccessibilityARIAGrid.cpp:
(WebCore::AccessibilityARIAGrid::cellForColumnAndRow):

LayoutTests:

* platform/mac/accessibility/aria-table-with-colspan-cells-expected.txt: Added.
* platform/mac/accessibility/aria-table-with-colspan-cells.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/aria-table-with-colspan-cells-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/aria-table-with-colspan-cells.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityARIAGrid.cpp

index b928e05..a5f5c5a 100644 (file)
@@ -1,3 +1,13 @@
+2011-03-07  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        AX: kAXCellForColumnAndRowParameterizedAttribute doesn't work ARIA grids with colspans
+        https://bugs.webkit.org/show_bug.cgi?id=55735
+
+        * platform/mac/accessibility/aria-table-with-colspan-cells-expected.txt: Added.
+        * platform/mac/accessibility/aria-table-with-colspan-cells.html: Added.
+
 2011-03-07  Andrei Popescu  <andreip@google.com>
 
         Reviewed by Steve Block.
diff --git a/LayoutTests/platform/mac/accessibility/aria-table-with-colspan-cells-expected.txt b/LayoutTests/platform/mac/accessibility/aria-table-with-colspan-cells-expected.txt
new file mode 100644 (file)
index 0000000..faa2bcf
--- /dev/null
@@ -0,0 +1,18 @@
+Fremont
+Leaves Arrives Route
+7:00 AM        8:00 AM FB1
+7:00 AM        8:00 AM
+7:00 AM        8:00 AM
+This tests if an ARIA grid has a table cell with colspans, then cellForRowAndColumn still returns the correct cell.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS grid.cellForColumnAndRow(2, 0).role is 'AXRole: AXCell'
+PASS grid.cellForColumnAndRow(2, 0).description is 'AXDescription: ColspanCell'
+PASS grid.cellForColumnAndRow(2, 4).role is 'AXRole: AXCell'
+PASS grid.cellForColumnAndRow(2, 4).description is 'AXDescription: RowspanCell'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/aria-table-with-colspan-cells.html b/LayoutTests/platform/mac/accessibility/aria-table-with-colspan-cells.html
new file mode 100644 (file)
index 0000000..8639007
--- /dev/null
@@ -0,0 +1,51 @@
+<!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">
+
+<table tabindex="0" id="grid" role="grid" class="am" aria-label="Morning schedule">
+<tr role="row"><th colspan="3" aria-label="ColspanCell">Fremont</th></tr>
+<tr role="row"><td role="columnheader">Leaves</td><td role="columnheader">Arrives</td><td role="columnheader">Route</td></tr>
+<tr role="row"><td aria-label="BART at">7:00 AM</td><td>8:00 AM</td><td aria-label="RowspanCell" rowspan="3">FB1</td></tr>
+<tr role="row"><td aria-label="BART at">7:00 AM</td><td>8:00 AM</td></tr>
+<tr role="row"><td aria-label="BART at">7:00 AM</td><td>8:00 AM</td></tr>
+</table>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests if an ARIA grid has a table cell with colspans, then cellForRowAndColumn still returns the correct cell.");
+
+    if (window.accessibilityController) {
+
+        document.getElementById("grid").focus();
+        var grid = accessibilityController.focusedElement;
+
+        shouldBe("grid.cellForColumnAndRow(2, 0).role", "'AXRole: AXCell'");
+        shouldBe("grid.cellForColumnAndRow(2, 0).description", "'AXDescription: ColspanCell'");
+
+        shouldBe("grid.cellForColumnAndRow(2, 4).role", "'AXRole: AXCell'");
+        shouldBe("grid.cellForColumnAndRow(2, 4).description", "'AXDescription: RowspanCell'");
+
+        // Verify nothing funny happens when we ask for strange values. We'll crash if something went awry.
+        for (var k = -1; k < 10; k++) {
+            for (var j = -1; j < 10; j++) {
+                var test = grid.cellForColumnAndRow(k, j);
+            }
+        }
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 270fe99..3b59125 100644 (file)
@@ -1,3 +1,18 @@
+2011-03-07  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        AX: kAXCellForColumnAndRowParameterizedAttribute doesn't work ARIA grids with colspans
+        https://bugs.webkit.org/show_bug.cgi?id=55735
+
+        The ARIA grid implementation needed to verify the row/column range of a cell instead of 
+        assuming a 1-1 mapping between children and row/column.
+
+        Test: platform/mac/accessibility/aria-table-with-colspan-cells.html
+
+        * accessibility/AccessibilityARIAGrid.cpp:
+        (WebCore::AccessibilityARIAGrid::cellForColumnAndRow):
+
 2011-03-07  Andrei Popescu  <andreip@google.com>
 
         Reviewed by Steve Block.
index 8651a80..d51750a 100644 (file)
@@ -137,18 +137,40 @@ AccessibilityTableCell* AccessibilityARIAGrid::cellForColumnAndRow(unsigned colu
     if (column >= columnCount() || row >= rowCount())
         return 0;
     
-    AccessibilityObject* tableRow = m_rows[row].get();
-    if (!tableRow)
-        return 0;
+    int intRow = (int)row;
+    int intColumn = (int)column;
+
+    pair<int, int> columnRange;
+    pair<int, int> rowRange;
     
-    AccessibilityChildrenVector children = tableRow->children();
-    // in case this row had fewer columns than other rows
-    AccessibilityObject* tableCell = 0;
-    if (column >= children.size())
-        return 0;
+    // Iterate backwards through the rows in case the desired cell has a rowspan and exists
+    // in a previous row.
+    for (; intRow >= 0; --intRow) {
+        AccessibilityObject* tableRow = m_rows[intRow].get();
+        if (!tableRow)
+            continue;
+        
+        AccessibilityChildrenVector children = tableRow->children();
+        unsigned childrenLength = children.size();
+        
+        // Since some cells may have colspans, we have to check the actual range of each
+        // cell to determine which is the right one.
+        for (unsigned k = 0; k < childrenLength; ++k) {
+            AccessibilityObject* child = children[k].get();
+            if (!child->isTableCell()) 
+                continue;
+            
+            AccessibilityTableCell* tableCellChild = static_cast<AccessibilityTableCell*>(child);
+            tableCellChild->columnIndexRange(columnRange);
+            tableCellChild->rowIndexRange(rowRange);
+            
+            if ((intColumn >= columnRange.first && intColumn < (columnRange.first + columnRange.second))
+                && (intRow >= rowRange.first && intRow < (rowRange.first + rowRange.second)))
+                return tableCellChild;
+        }
+    }
 
-    tableCell = children[column].get();
-    return static_cast<AccessibilityTableCell*>(tableCell);
+    return 0;
 }
     
 } // namespace WebCore