Title: [174860] trunk
Revision
174860
Author
[email protected]
Date
2014-10-18 08:20:38 -0700 (Sat, 18 Oct 2014)

Log Message

AX: Tables with <colgroups> are not reporting table column headers
https://bugs.webkit.org/show_bug.cgi?id=137846

Reviewed by Mario Sanchez Prada.

Source/WebCore:

The code to search for header objects was getting stuck on anonymous RenderTableSections.
We also need to check more rows for headers, in case the first row or more is not visible or is empty.

Test: accessibility/table-column-headers-with-captions.html

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

LayoutTests:

* accessibility/table-column-headers-with-captions-expected.txt: Added.
* accessibility/table-column-headers-with-captions.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (174859 => 174860)


--- trunk/LayoutTests/ChangeLog	2014-10-18 10:16:33 UTC (rev 174859)
+++ trunk/LayoutTests/ChangeLog	2014-10-18 15:20:38 UTC (rev 174860)
@@ -1,3 +1,13 @@
+2014-10-18  Chris Fleizach  <[email protected]>
+
+        AX: Tables with <colgroups> are not reporting table column headers
+        https://bugs.webkit.org/show_bug.cgi?id=137846
+
+        Reviewed by Mario Sanchez Prada.
+
+        * accessibility/table-column-headers-with-captions-expected.txt: Added.
+        * accessibility/table-column-headers-with-captions.html: Added.
+
 2014-10-17  Michael Saboff  <[email protected]>
 
         Don't create cached functions that access lexicalGlobalObject()

Added: trunk/LayoutTests/accessibility/table-column-headers-with-captions-expected.txt (0 => 174860)


--- trunk/LayoutTests/accessibility/table-column-headers-with-captions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/table-column-headers-with-captions-expected.txt	2014-10-18 15:20:38 UTC (rev 174860)
@@ -0,0 +1,14 @@
+caption
+header1	header2
+a	b
+This tests that a table with a caption and an empty colgroup will still correctly report its headers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS colHeaders[0].isEqual(table.rowAtIndex(0).childAtIndex(0)) is true
+PASS colHeaders[1].isEqual(table.rowAtIndex(0).childAtIndex(1)) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/table-column-headers-with-captions.html (0 => 174860)


--- trunk/LayoutTests/accessibility/table-column-headers-with-captions.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/table-column-headers-with-captions.html	2014-10-18 15:20:38 UTC (rev 174860)
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body id="body">
+
+<table id="table" width="100%" border="0" cellspacing="2" cellpadding="1">
+    <caption>caption</caption>
+    <colgroup width="100%" span="2"><col width="50%"><col width="50%"></colgroup>
+    <tbody>
+        <tr><th>header1</th><th>header2</th></tr>
+        <tr><td>a</td><td>b</td></tr>
+    </tbody>
+</table>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that a table with a caption and an empty colgroup will still correctly report its headers.");
+
+    if (window.accessibilityController) {
+
+        var table = accessibilityController.accessibleElementById("table");
+        var colHeaders = table.columnHeaders();
+
+        shouldBeTrue("colHeaders[0].isEqual(table.rowAtIndex(0).childAtIndex(0))");
+        shouldBeTrue("colHeaders[1].isEqual(table.rowAtIndex(0).childAtIndex(1))");
+    }
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (174859 => 174860)


--- trunk/Source/WebCore/ChangeLog	2014-10-18 10:16:33 UTC (rev 174859)
+++ trunk/Source/WebCore/ChangeLog	2014-10-18 15:20:38 UTC (rev 174860)
@@ -1,3 +1,19 @@
+2014-10-18  Chris Fleizach  <[email protected]>
+
+        AX: Tables with <colgroups> are not reporting table column headers
+        https://bugs.webkit.org/show_bug.cgi?id=137846
+
+        Reviewed by Mario Sanchez Prada.
+
+        The code to search for header objects was getting stuck on anonymous RenderTableSections.
+        We also need to check more rows for headers, in case the first row or more is not visible or is empty.
+
+        Test: accessibility/table-column-headers-with-captions.html
+
+        * accessibility/AccessibilityTableColumn.cpp:
+        (WebCore::AccessibilityTableColumn::headerObject):
+        (WebCore::AccessibilityTableColumn::headerObjectForSection):
+
 2014-10-18  KwangHyuk Kim  <[email protected]>
 
         [EFL] build break occurs on webkit efl build.

Modified: trunk/Source/WebCore/accessibility/AccessibilityTableColumn.cpp (174859 => 174860)


--- trunk/Source/WebCore/accessibility/AccessibilityTableColumn.cpp	2014-10-18 10:16:33 UTC (rev 174859)
+++ trunk/Source/WebCore/accessibility/AccessibilityTableColumn.cpp	2014-10-18 15:20:38 UTC (rev 174860)
@@ -98,8 +98,12 @@
     if (auto* headerObject = headerObjectForSection(table.header(), false))
         return headerObject;
     
-    // now try for <th> tags in the first body
-    return headerObjectForSection(table.firstBody(), true);
+    RenderTableSection* bodySection = table.firstBody();
+    while (bodySection && bodySection->isAnonymous())
+        bodySection = table.sectionBelow(bodySection, SkipEmptySections);
+    
+    // now try for <th> tags in the first body. If the first body is 
+    return headerObjectForSection(bodySection, true);
 }
 
 AccessibilityObject* AccessibilityTableColumn::headerObjectForSection(RenderTableSection* section, bool thTagRequired)
@@ -117,22 +121,30 @@
     RenderTableCell* cell = nullptr;
     // also account for cells that have a span
     for (int testCol = m_columnIndex; testCol >= 0; --testCol) {
-        RenderTableCell* testCell = section->primaryCellAt(0, testCol);
-        if (!testCell)
-            continue;
         
-        // we've reached a cell that doesn't even overlap our column 
-        // it can't be our header
-        if ((testCell->col() + (testCell->colSpan()-1)) < m_columnIndex)
+        // Run down the rows in case initial rows are invalid (like when a <caption> is used).
+        unsigned rowCount = section->numRows();
+        for (unsigned testRow = 0; testRow < rowCount; testRow++) {
+            RenderTableCell* testCell = section->primaryCellAt(testRow, testCol);
+            // No cell at this index, keep checking more rows and columns.
+            if (!testCell)
+                continue;
+            
+            // If we've reached a cell that doesn't even overlap our column it can't be the header.
+            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())
+                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))
+                break;
+            
+            cell = testCell;
             break;
-        
-        if (!testCell->element())
-            continue;
-        
-        if (thTagRequired && !testCell->element()->hasTagName(thTag))
-            continue;
-        
-        cell = testCell;
+        }
     }
     
     if (!cell)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to