Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
AX: Table with CSS that makes a row anonymous can return NULL from ce…
…llForColumnAndRow

https://bugs.webkit.org/show_bug.cgi?id=148293

Patch by Doug Russell <d_russell@apple.com> on 2015-08-21
Reviewed by Chris Fleizach.

When RenderTableRows are anonymous, they may not be added to the accessible data
table's internal row list. However, when calculating the row range for a cell,
we were still accounting for those anonymous sections.
Change how the row range is calculated to directly ask the accessible parent row
for its index. This will ensure it’s more inline with what’s being represented to
the accessibility API.

Source/WebCore:

Test: accessibility/aria-table-content.html

* accessibility/AccessibilityTableCell.cpp:
(WebCore::AccessibilityTableCell::parentRow):
(WebCore::AccessibilityTableCell::rowIndexRange):
* accessibility/AccessibilityTableCell.h:

LayoutTests:

* accessibility/aria-table-content-expected.txt: Added.
* accessibility/aria-table-content.html: Added.

Canonical link: https://commits.webkit.org/166419@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188769 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Doug Russell authored and webkit-commit-queue committed Aug 21, 2015
1 parent 2b0b7ca commit 5be31db
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 28 deletions.
17 changes: 17 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
2015-08-21 Doug Russell <d_russell@apple.com>

AX: Table with CSS that makes a row anonymous can return NULL from cellForColumnAndRow
https://bugs.webkit.org/show_bug.cgi?id=148293

Reviewed by Chris Fleizach.

When RenderTableRows are anonymous, they may not be added to the accessible data
table's internal row list. However, when calculating the row range for a cell,
we were still accounting for those anonymous sections.
Change how the row range is calculated to directly ask the accessible parent row
for its index. This will ensure it’s more inline with what’s being represented to
the accessibility API.

* accessibility/aria-table-content-expected.txt: Added.
* accessibility/aria-table-content.html: Added.

2015-08-21 Joseph Pecoraro <pecoraro@apple.com>

Web Inspector: REGRESSION(173684): Edit as HTML not working
Expand Down
16 changes: 16 additions & 0 deletions LayoutTests/accessibility/aria-table-content-expected.txt
@@ -0,0 +1,16 @@
Header
Item 1

This tests that in an aria table with CSS that makes a row anonymous, the cells can be accessed.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS cell00.role is 'AXRole: AXCell'
PASS cell01.role is 'AXRole: AXCell'
PASS cell00.isEqual(table.rowAtIndex(0).childAtIndex(0)) is true
PASS cell01.isEqual(table.rowAtIndex(1).childAtIndex(0)) is true
PASS successfullyParsed is true

TEST COMPLETE

38 changes: 38 additions & 0 deletions LayoutTests/accessibility/aria-table-content.html
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<style type="text/css">
div.foo table:not(.no-header):before{content:'';}
</style>
<title>Table Anonymous Row</title>
</head>
<body>
<div class="foo" role="grid" id="table">
<table>
<thead> <tr> <th>Header</th> </tr> </thead>
<tbody> <tr> <td> <p>Item 1</p> </td> </tr> </tbody>
</table>
</div>

<p id="description"></p>
<div id="console"></div>

<script>
description("This tests that in an aria table with CSS that makes a row anonymous, the cells can be accessed.");

if (window.accessibilityController) {
var table = accessibilityController.accessibleElementById("table");
var cell00 = table.cellForColumnAndRow(0,0);
shouldBe("cell00.role", "'AXRole: AXCell'");
var cell01 = table.cellForColumnAndRow(0,1);
shouldBe("cell01.role", "'AXRole: AXCell'");
shouldBeTrue("cell00.isEqual(table.rowAtIndex(0).childAtIndex(0))");
shouldBeTrue("cell01.isEqual(table.rowAtIndex(1).childAtIndex(0))");
}

</script>

<script src="../resources/js-test-post.js"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,24 @@
2015-08-21 Doug Russell <d_russell@apple.com>

AX: Table with CSS that makes a row anonymous can return NULL from cellForColumnAndRow
https://bugs.webkit.org/show_bug.cgi?id=148293

Reviewed by Chris Fleizach.

When RenderTableRows are anonymous, they may not be added to the accessible data
table's internal row list. However, when calculating the row range for a cell,
we were still accounting for those anonymous sections.
Change how the row range is calculated to directly ask the accessible parent row
for its index. This will ensure it’s more inline with what’s being represented to
the accessibility API.

Test: accessibility/aria-table-content.html

* accessibility/AccessibilityTableCell.cpp:
(WebCore::AccessibilityTableCell::parentRow):
(WebCore::AccessibilityTableCell::rowIndexRange):
* accessibility/AccessibilityTableCell.h:

2015-08-21 Joseph Pecoraro <pecoraro@apple.com>

Web Inspector: REGRESSION(173684): Edit as HTML not working
Expand Down
38 changes: 11 additions & 27 deletions Source/WebCore/accessibility/AccessibilityTableCell.cpp
Expand Up @@ -302,41 +302,25 @@ void AccessibilityTableCell::rowHeaders(AccessibilityChildrenVector& headers)
headers.append(tableCell);
}
}


AccessibilityTableRow* AccessibilityTableCell::parentRow() const
{
AccessibilityObject* parent = parentObjectUnignored();
if (!is<AccessibilityTableRow>(*parent))
return nullptr;
return downcast<AccessibilityTableRow>(parent);
}

void AccessibilityTableCell::rowIndexRange(std::pair<unsigned, unsigned>& rowRange) const
{
if (!is<RenderTableCell>(m_renderer))
return;

RenderTableCell& renderCell = downcast<RenderTableCell>(*m_renderer);
rowRange.first = renderCell.rowIndex();
rowRange.second = renderCell.rowSpan();

// since our table might have multiple sections, we have to offset our row appropriately
RenderTableSection* section = renderCell.section();
RenderTable* table = renderCell.table();
if (!table || !section)
return;

RenderTableSection* footerSection = table->footer();
unsigned rowOffset = 0;
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) {
// If the table section is anonymous, we should to use the parent row's API to get the rowIndex
if (tableSection->isAnonymous()) {
AccessibilityObject* parent = parentObjectUnignored();
if (is<AccessibilityTableRow>(*parent))
rowOffset = downcast<AccessibilityTableRow>(*parent).rowIndex();
}
break;
}
rowOffset += tableSection->numRows();
}

rowRange.first += rowOffset;
if (AccessibilityTableRow* parentRow = this->parentRow())
rowRange.first = parentRow->rowIndex();
}

void AccessibilityTableCell::columnIndexRange(std::pair<unsigned, unsigned>& columnRange) const
Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/accessibility/AccessibilityTableCell.h
Expand Up @@ -34,7 +34,8 @@
namespace WebCore {

class AccessibilityTable;

class AccessibilityTableRow;

class AccessibilityTableCell : public AccessibilityRenderObject {
public:
static Ref<AccessibilityTableCell> create(RenderObject*);
Expand All @@ -56,6 +57,7 @@ class AccessibilityTableCell : public AccessibilityRenderObject {
protected:
explicit AccessibilityTableCell(RenderObject*);

AccessibilityTableRow* parentRow() const;
virtual AccessibilityTable* parentTable() const;
virtual AccessibilityRole determineAccessibilityRole() override final;

Expand Down

0 comments on commit 5be31db

Please sign in to comment.