Title: [167934] trunk
Revision
167934
Author
cfleiz...@apple.com
Date
2014-04-29 09:15:14 -0700 (Tue, 29 Apr 2014)

Log Message

AX: Row span info is wrong for table cells when a footer section is placed above a body section
https://bugs.webkit.org/show_bug.cgi?id=131832

Reviewed by Mario Sanchez Prada.


Source/WebCore: 
If a <footer> section is placed before the body, it renders AX row information and order incorrectly.
This also affects ARIA tables because they add their children by looking at renderer children, instead
interrogating the RenderTable directly.

Test: accessibility/table-with-footer-section-above-body.html

* accessibility/AccessibilityARIAGrid.cpp:
(WebCore::AccessibilityARIAGrid::addTableCellChild):
(WebCore::AccessibilityARIAGrid::addChildren):
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::addChildren):
(WebCore::AccessibilityTable::addChildrenFromSection):
* accessibility/AccessibilityTable.h:
* accessibility/AccessibilityTableCell.cpp:
(WebCore::AccessibilityTableCell::rowIndexRange):
(WebCore::AccessibilityTableCell::columnIndexRange):

LayoutTests: 
* accessibility/table-with-footer-section-above-body-expected.txt: Added.
* accessibility/table-with-footer-section-above-body.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (167933 => 167934)


--- trunk/LayoutTests/ChangeLog	2014-04-29 16:04:57 UTC (rev 167933)
+++ trunk/LayoutTests/ChangeLog	2014-04-29 16:15:14 UTC (rev 167934)
@@ -1,5 +1,15 @@
 2014-04-29  Chris Fleizach  <cfleiz...@apple.com>
 
+        AX: Row span info is wrong for table cells when a footer section is placed above a body section
+        https://bugs.webkit.org/show_bug.cgi?id=131832
+
+        Reviewed by Mario Sanchez Prada.
+
+        * accessibility/table-with-footer-section-above-body-expected.txt: Added.
+        * accessibility/table-with-footer-section-above-body.html: Added.
+
+2014-04-29  Chris Fleizach  <cfleiz...@apple.com>
+
         AX: SpeechSynthesisUtterance cannot addEventListener
         https://bugs.webkit.org/show_bug.cgi?id=132321
 

Added: trunk/LayoutTests/accessibility/table-with-footer-section-above-body-expected.txt (0 => 167934)


--- trunk/LayoutTests/accessibility/table-with-footer-section-above-body-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/table-with-footer-section-above-body-expected.txt	2014-04-29 16:15:14 UTC (rev 167934)
@@ -0,0 +1,17 @@
+This tests that the row span information for the cells in the body is not offset by the footer section, even though the footer section is above the body in the DOM. This tests tables that have a role=grid and without.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Table1 cell content at {0, 1}: AXValue: a
+Table1 cell range at {0, 1}: {1, 1}
+Table1 cell content at {0, 2}: AXValue: Name
+Table1 cell range at {0, 2}: {2, 1}
+Table2 cell content at {0, 1}: AXValue: a
+Table2 cell range at {0, 1}: {1, 1}
+Table2 cell content at {0, 2}: AXValue: Name
+Table2 cell range at {0, 2}: {2, 1}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/table-with-footer-section-above-body.html (0 => 167934)


--- trunk/LayoutTests/accessibility/table-with-footer-section-above-body.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/table-with-footer-section-above-body.html	2014-04-29 16:15:14 UTC (rev 167934)
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div id="content">
+<table id="table1" cellspacing="0" role="grid">
+    <thead>
+        <tr role="row"><th>Name</th><th>Position</th><th>Office</th><th>Age</th><th>Start date</th><th>Salary</th></tr>
+    </thead>
+
+    <tfoot>
+        <tr role="row"><th>Name</th><th>Position</th><th>Office</th><th>Age</th><th>Start date</th><th>Salary</th></tr>
+    </tfoot>
+
+    <tbody>
+        <tr><td>a</td><td>b</td><td>c</td><td>d</td></tr>
+    </tbody>
+</table>
+
+<table id="table2" cellspacing="0">
+    <thead>
+        <tr><th>Name</th><th>Position</th><th>Office</th><th>Age</th><th>Start date</th><th>Salary</th></tr>
+    </thead>
+
+    <tfoot>
+        <tr><th>Name</th><th>Position</th><th>Office</th><th>Age</th><th>Start date</th><th>Salary</th></tr>
+    </tfoot>
+
+    <tbody>
+        <tr><td>a</td><td>b</td><td>c</td><td>d</td></tr>
+    </tbody>
+</table>
+
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that the row span information for the cells in the body is not offset by the footer section, even though the footer section is above the body in the DOM. This tests tables that have a role=grid and without.");
+
+    if (window.accessibilityController) {
+     
+        var table = accessibilityController.accessibleElementById("table1");
+        var testCell = table.cellForColumnAndRow(0, 1);
+        debug("Table1 cell content at {0, 1}: " + testCell.childAtIndex(0).stringValue);
+        debug("Table1 cell range at {0, 1}: " + testCell.rowIndexRange());
+
+        testCell = table.cellForColumnAndRow(0, 2);
+        debug("Table1 cell content at {0, 2}: " + testCell.childAtIndex(0).stringValue);
+        debug("Table1 cell range at {0, 2}: " + testCell.rowIndexRange());
+
+        table = accessibilityController.accessibleElementById("table2");
+        testCell = table.cellForColumnAndRow(0, 1);
+        debug("Table2 cell content at {0, 1}: " + testCell.childAtIndex(0).stringValue);
+        debug("Table2 cell range at {0, 1}: " + testCell.rowIndexRange());
+
+        testCell = table.cellForColumnAndRow(0, 2);
+        debug("Table2 cell content at {0, 2}: " + testCell.childAtIndex(0).stringValue);
+        debug("Table2 cell range at {0, 2}: " + testCell.rowIndexRange());
+
+        document.getElementById("content").style.visibility = "hidden";
+    }
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (167933 => 167934)


--- trunk/Source/WebCore/ChangeLog	2014-04-29 16:04:57 UTC (rev 167933)
+++ trunk/Source/WebCore/ChangeLog	2014-04-29 16:15:14 UTC (rev 167934)
@@ -1,5 +1,29 @@
 2014-04-29  Chris Fleizach  <cfleiz...@apple.com>
 
+        AX: Row span info is wrong for table cells when a footer section is placed above a body section
+        https://bugs.webkit.org/show_bug.cgi?id=131832
+
+        Reviewed by Mario Sanchez Prada.
+
+        If a <footer> section is placed before the body, it renders AX row information and order incorrectly.
+        This also affects ARIA tables because they add their children by looking at renderer children, instead
+        interrogating the RenderTable directly.
+
+        Test: accessibility/table-with-footer-section-above-body.html
+
+        * accessibility/AccessibilityARIAGrid.cpp:
+        (WebCore::AccessibilityARIAGrid::addTableCellChild):
+        (WebCore::AccessibilityARIAGrid::addChildren):
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::addChildren):
+        (WebCore::AccessibilityTable::addChildrenFromSection):
+        * accessibility/AccessibilityTable.h:
+        * accessibility/AccessibilityTableCell.cpp:
+        (WebCore::AccessibilityTableCell::rowIndexRange):
+        (WebCore::AccessibilityTableCell::columnIndexRange):
+
+2014-04-29  Chris Fleizach  <cfleiz...@apple.com>
+
         AX: SpeechSynthesisUtterance cannot addEventListener
         https://bugs.webkit.org/show_bug.cgi?id=132321
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityARIAGrid.cpp (167933 => 167934)


--- trunk/Source/WebCore/accessibility/AccessibilityARIAGrid.cpp	2014-04-29 16:04:57 UTC (rev 167933)
+++ trunk/Source/WebCore/accessibility/AccessibilityARIAGrid.cpp	2014-04-29 16:15:14 UTC (rev 167934)
@@ -35,6 +35,7 @@
 #include "AccessibilityTableHeaderContainer.h"
 #include "AccessibilityTableRow.h"
 #include "RenderObject.h"
+#include "RenderTableSection.h"
 
 namespace WebCore {
 
@@ -109,12 +110,29 @@
     
     AXObjectCache* axCache = m_renderer->document().axObjectCache();
     
-    // add only rows that are labeled as aria rows
+    // Add the children rows but be mindful in case there are footer sections in this table.
     HashSet<AccessibilityObject*> appendedRows;
     unsigned columnCount = 0;
-    for (RefPtr<AccessibilityObject> child = firstChild(); child; child = child->nextSibling())
-        addRowDescendant(child.get(), appendedRows, columnCount);
+    AccessibilityChildrenVector footerSections;
+    for (RefPtr<AccessibilityObject> child = firstChild(); child; child = child->nextSibling()) {
+        bool footerSection = false;
+        if (RenderObject* childRenderer = child->renderer()) {
+            if (childRenderer->isTableSection()) {
+                if (RenderTableSection* childSection = toRenderTableSection(childRenderer)) {
+                    if (childSection == childSection->table()->footer()) {
+                        footerSections.append(child);
+                        footerSection = true;
+                    }
+                }
+            }
+        }
+        if (!footerSection)
+            addRowDescendant(child.get(), appendedRows, columnCount);
+    }
     
+    for (const auto& footerSection : footerSections)
+        addRowDescendant(footerSection.get(), appendedRows, columnCount);
+    
     // make the columns based on the number of columns in the first body
     for (unsigned i = 0; i < columnCount; ++i) {
         AccessibilityTableColumn* column = toAccessibilityTableColumn(axCache->getOrCreate(ColumnRole));

Modified: trunk/Source/WebCore/accessibility/AccessibilityTable.cpp (167933 => 167934)


--- trunk/Source/WebCore/accessibility/AccessibilityTable.cpp	2014-04-29 16:04:57 UTC (rev 167933)
+++ trunk/Source/WebCore/accessibility/AccessibilityTable.cpp	2014-04-29 16:15:14 UTC (rev 167934)
@@ -360,50 +360,23 @@
         return;
     
     RenderTable* table = toRenderTable(m_renderer);
-    AXObjectCache* axCache = m_renderer->document().axObjectCache();
-
     // Go through all the available sections to pull out the rows and add them as children.
     table->recalcSectionsIfNeeded();
-    RenderTableSection* tableSection = table->topSection();
-    if (!tableSection)
-        return;
     
     unsigned maxColumnCount = 0;
-    while (tableSection) {
-        
-        HashSet<AccessibilityObject*> appendedRows;
-        unsigned numRows = tableSection->numRows();
-        for (unsigned rowIndex = 0; rowIndex < numRows; ++rowIndex) {
-            
-            RenderTableRow* renderRow = tableSection->rowRendererAt(rowIndex);
-            if (!renderRow)
-                continue;
-            
-            AccessibilityObject* rowObject = axCache->getOrCreate(renderRow);
-            if (!rowObject->isTableRow())
-                continue;
-            
-            AccessibilityTableRow* row = toAccessibilityTableRow(rowObject);
-            // We need to check every cell for a new row, because cell spans
-            // can cause us to miss rows if we just check the first column.
-            if (appendedRows.contains(row))
-                continue;
-            
-            row->setRowIndex(static_cast<int>(m_rows.size()));
-            m_rows.append(row);
-            if (!row->accessibilityIsIgnored())
-                m_children.append(row);
-#if PLATFORM(GTK) || PLATFORM(EFL)
-            else
-                m_children.appendVector(row->children());
-#endif
-            appendedRows.add(row);
-        }
+    RenderTableSection* footer = table->footer();
     
-        maxColumnCount = std::max(tableSection->numColumns(), maxColumnCount);
-        tableSection = table->sectionBelow(tableSection, SkipEmptySections);
+    for (RenderTableSection* tableSection = table->topSection(); tableSection; tableSection = table->sectionBelow(tableSection, SkipEmptySections)) {
+        if (tableSection == footer)
+            continue;
+        addChildrenFromSection(tableSection, maxColumnCount);
     }
     
+    // Process the footer last, in case it was ordered earlier in the DOM.
+    if (footer)
+        addChildrenFromSection(footer, maxColumnCount);
+    
+    AXObjectCache* axCache = m_renderer->document().axObjectCache();
     // make the columns based on the number of columns in the first body
     unsigned length = maxColumnCount;
     for (unsigned i = 0; i < length; ++i) {
@@ -419,7 +392,46 @@
     if (headerContainerObject && !headerContainerObject->accessibilityIsIgnored())
         m_children.append(headerContainerObject);
 }
+
+void AccessibilityTable::addChildrenFromSection(RenderTableSection* tableSection, unsigned& maxColumnCount)
+{
+    ASSERT(tableSection);
+    if (!tableSection)
+        return;
     
+    AXObjectCache* axCache = m_renderer->document().axObjectCache();
+    HashSet<AccessibilityObject*> appendedRows;
+    unsigned numRows = tableSection->numRows();
+    for (unsigned rowIndex = 0; rowIndex < numRows; ++rowIndex) {
+        
+        RenderTableRow* renderRow = tableSection->rowRendererAt(rowIndex);
+        if (!renderRow)
+            continue;
+        
+        AccessibilityObject* rowObject = axCache->getOrCreate(renderRow);
+        if (!rowObject->isTableRow())
+            continue;
+        
+        AccessibilityTableRow* row = toAccessibilityTableRow(rowObject);
+        // We need to check every cell for a new row, because cell spans
+        // can cause us to miss rows if we just check the first column.
+        if (appendedRows.contains(row))
+            continue;
+        
+        row->setRowIndex(static_cast<int>(m_rows.size()));
+        m_rows.append(row);
+        if (!row->accessibilityIsIgnored())
+            m_children.append(row);
+#if PLATFORM(GTK) || PLATFORM(EFL)
+        else
+            m_children.appendVector(row->children());
+#endif
+        appendedRows.add(row);
+    }
+    
+    maxColumnCount = std::max(tableSection->numColumns(), maxColumnCount);
+}
+    
 AccessibilityObject* AccessibilityTable::headerContainer()
 {
     if (m_headerContainer)

Modified: trunk/Source/WebCore/accessibility/AccessibilityTable.h (167933 => 167934)


--- trunk/Source/WebCore/accessibility/AccessibilityTable.h	2014-04-29 16:04:57 UTC (rev 167933)
+++ trunk/Source/WebCore/accessibility/AccessibilityTable.h	2014-04-29 16:15:14 UTC (rev 167934)
@@ -98,6 +98,7 @@
 private:
     virtual void titleElementText(Vector<AccessibilityText>&) const override;
     HTMLTableElement* tableElement() const;
+    void addChildrenFromSection(RenderTableSection*, unsigned& maxColumnCount);
 };
 
 ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityTable, isTable())

Modified: trunk/Source/WebCore/accessibility/AccessibilityTableCell.cpp (167933 => 167934)


--- trunk/Source/WebCore/accessibility/AccessibilityTableCell.cpp	2014-04-29 16:04:57 UTC (rev 167933)
+++ trunk/Source/WebCore/accessibility/AccessibilityTableCell.cpp	2014-04-29 16:15:14 UTC (rev 167934)
@@ -231,13 +231,15 @@
     if (!table || !section)
         return;
 
-    RenderTableSection* tableSection = table->topSection();    
+    RenderTableSection* footerSection = table->footer();
     unsigned rowOffset = 0;
-    while (tableSection) {
+    for (RenderTableSection* tableSection = table->topSection(); tableSection; tableSection = table->sectionBelow(tableSection, SkipEmptySections)) {
+        // Don't add row offsets for bottom sections that are placed in before the body section.
+        if (tableSection == footerSection)
+            continue;
         if (tableSection == section)
             break;
         rowOffset += tableSection->numRows();
-        tableSection = table->sectionBelow(tableSection, SkipEmptySections);
     }
 
     rowRange.first += rowOffset;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to