Bug 1688532: Don't use the cached column header on a previous table cell if that cell starts in a different column. r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D103146
This commit is contained in:
James Teh 2021-01-28 17:21:47 +00:00
parent 5d24a92232
commit 42351bc1af
2 changed files with 59 additions and 1 deletions

View File

@ -67,7 +67,20 @@ Accessible* TableCellAccessible::PrevColHeader() {
// Check whether the previous table cell has a cached value.
cachedHeader = cache.GetWeak(tableCell, &inCache);
if (inCache && cell->Role() != roles::COLUMNHEADER) {
if (
// We check the cache first because even though we might not use it,
// it's faster than the other conditions.
inCache &&
// Only use the cached value if:
// 1. cell is a table cell which is not a column header. In that case,
// cell is the previous header and cachedHeader is the one before that.
// We will return cell later.
cell->Role() != roles::COLUMNHEADER &&
// 2. cell starts in this column. If it starts in a previous column and
// extends into this one, its header will be for the starting column,
// which is wrong for this cell.
// ColExtent is faster than ColIdx, so check that first.
(tableCell->ColExtent() == 1 || tableCell->ColIdx() == colIdx)) {
if (!cachedHeader || !cachedHeader->IsDefunct()) {
// Cache it for this cell.
cache.Put(this, RefPtr<Accessible>(cachedHeader));

View File

@ -426,6 +426,37 @@
testHeaderCells(headerInfoMap);
// ////////////////////////////////////////////////////////////////////////
// Ensure correct column headers after colspan in a previous row.
headerInfoMap = [
{
cell: "t11r1c1",
columnHeaderCells: [],
rowHeaderCells: [],
},
{
cell: "t11r1c2",
columnHeaderCells: [],
rowHeaderCells: [],
},
{
cell: "t11r2c1_2",
columnHeaderCells: ["t11r1c1"],
rowHeaderCells: [],
},
{
cell: "t11r3c1",
columnHeaderCells: ["t11r1c1"],
rowHeaderCells: [],
},
{
cell: "t11r3c2",
columnHeaderCells: ["t11r1c2"],
rowHeaderCells: [],
},
];
testHeaderCells(headerInfoMap);
SimpleTest.finish();
}
@ -707,5 +738,19 @@
<td headers="t10_males t10_todd t10_10km" id="t10_r3c4">50:35</td>
</tr>
</table>
<table id="table11">
<tr>
<th id="t11r1c1">a</th>
<th id="t11r1c2">b</th>
</tr>
<tr>
<td id="t11r2c1_2" colspan="2"></td>
</tr>
<tr>
<td id="t11r3c1">e</td>
<td id="t11r3c2">f</td>
</tr>
</table>
</body>
</html>