diff --git a/accessible/src/generic/TableCellAccessible.cpp b/accessible/src/generic/TableCellAccessible.cpp index 1491fad4b815..3c840127cb56 100644 --- a/accessible/src/generic/TableCellAccessible.cpp +++ b/accessible/src/generic/TableCellAccessible.cpp @@ -47,7 +47,7 @@ TableCellAccessible::ColHeaderCells(nsTArray* aCells) if (!table) return; - // Move to the left to find row header cells + // Move up to find column header cells for (uint32_t curRowIdx = rowIdx - 1; curRowIdx < rowIdx; curRowIdx--) { Accessible* cell = table->CellAt(curRowIdx, colIdx); if (!cell) diff --git a/accessible/src/html/HTMLTableAccessible.cpp b/accessible/src/html/HTMLTableAccessible.cpp index 1233f7fa911a..b8e6c8e1debb 100644 --- a/accessible/src/html/HTMLTableAccessible.cpp +++ b/accessible/src/html/HTMLTableAccessible.cpp @@ -213,9 +213,18 @@ void HTMLTableCellAccessible::ColHeaderCells(nsTArray* aCells) { IDRefsIterator itr(mDoc, mContent, nsGkAtoms::headers); - while (Accessible* cell = itr.Next()) - if (cell->Role() == roles::COLUMNHEADER) + while (Accessible* cell = itr.Next()) { + a11y::role cellRole = cell->Role(); + if (cellRole == roles::COLUMNHEADER) { aCells->AppendElement(cell); + } else if (cellRole != roles::ROWHEADER) { + // If referred table cell is at the same column then treat it as a column + // header. + TableCellAccessible* tableCell = cell->AsTableCell(); + if (tableCell && tableCell->ColIdx() == ColIdx()) + aCells->AppendElement(cell); + } + } if (aCells->IsEmpty()) TableCellAccessible::ColHeaderCells(aCells); @@ -225,9 +234,18 @@ void HTMLTableCellAccessible::RowHeaderCells(nsTArray* aCells) { IDRefsIterator itr(mDoc, mContent, nsGkAtoms::headers); - while (Accessible* cell = itr.Next()) - if (cell->Role() == roles::ROWHEADER) + while (Accessible* cell = itr.Next()) { + a11y::role cellRole = cell->Role(); + if (cellRole == roles::ROWHEADER) { aCells->AppendElement(cell); + } else if (cellRole != roles::COLUMNHEADER) { + // If referred table cell is at the same row then treat it as a column + // header. + TableCellAccessible* tableCell = cell->AsTableCell(); + if (tableCell && tableCell->RowIdx() == RowIdx()) + aCells->AppendElement(cell); + } + } if (aCells->IsEmpty()) TableCellAccessible::RowHeaderCells(aCells); @@ -294,7 +312,7 @@ HTMLTableHeaderCellAccessible::NativeRole() return roles::ROWHEADER; } - // Assume it's columnheader if there are headers in siblings, oterwise + // Assume it's columnheader if there are headers in siblings, otherwise // rowheader. nsIContent* parentContent = mContent->GetParent(); if (!parentContent) { @@ -306,7 +324,7 @@ HTMLTableHeaderCellAccessible::NativeRole() siblingContent = siblingContent->GetPreviousSibling()) { if (siblingContent->IsElement()) { return nsCoreUtils::IsHTMLTableHeader(siblingContent) ? - roles::COLUMNHEADER : roles::ROWHEADER; + roles::COLUMNHEADER : roles::ROWHEADER; } } @@ -314,7 +332,7 @@ HTMLTableHeaderCellAccessible::NativeRole() siblingContent = siblingContent->GetNextSibling()) { if (siblingContent->IsElement()) { return nsCoreUtils::IsHTMLTableHeader(siblingContent) ? - roles::COLUMNHEADER : roles::ROWHEADER; + roles::COLUMNHEADER : roles::ROWHEADER; } } diff --git a/accessible/tests/mochitest/table/test_headers_table.html b/accessible/tests/mochitest/table/test_headers_table.html index 4596ad4f387f..99c36f837be6 100644 --- a/accessible/tests/mochitest/table/test_headers_table.html +++ b/accessible/tests/mochitest/table/test_headers_table.html @@ -143,6 +143,19 @@ testHeaderCells(headerInfoMap); + ////////////////////////////////////////////////////////////////////////// + // @headers points to table cells + + headerInfoMap = [ + { + cell: "table6_cell", + rowHeaderCells: [ "table6_rh" ], + columnHeaderCells: [ "table6_ch" ] + } + ]; + + testHeaderCells(headerInfoMap); + SimpleTest.finish(); } @@ -154,7 +167,14 @@ Mozilla Bug 512424 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=512424"> + Bug 512424 + + + Bug 704465 +

@@ -244,5 +264,16 @@ cell + + + + + + + + +
empty cell + colheader
rowheader + cell