Bug 1779162: Don't walk ancestors unnecessarily in CachedTableCellAccessible::RowHeaderCells. r=morgan

Previously, we used CellAt, but this returns the Accessible, discarding the CachedTableCellAccessible.
RowHeaderCells needs both, so it then called AsTableCellBase, which must walk ancestors to get the table.
We already have the table and access to its private data, so use it directly.
This is probably an insignificant performance improvement, but the unnecessary indirection was bothering me.

Differential Revision: https://phabricator.services.mozilla.com/D151571
This commit is contained in:
James Teh 2022-07-14 00:44:56 +00:00
Родитель 758dbfe527
Коммит cd91557c45
1 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -456,20 +456,22 @@ void CachedTableCellAccessible::RowHeaderCells(nsTArray<Accessible*>* aCells) {
return;
}
}
Accessible* doc = nsAccUtils::DocumentFor(table->AsAccessible());
// We don't cache implicit row headers because there are usually not that many
// cells per row. Get all the row headers on the row before this cell.
uint32_t row = RowIdx();
uint32_t thisCol = ColIdx();
for (uint32_t col = thisCol - 1; col < thisCol; --col) {
Accessible* cellAcc = table->CellAt(row, col);
if (!cellAcc) {
int32_t cellIdx = table->CellIndexAt(row, col);
if (cellIdx == -1) {
continue;
}
TableCellAccessibleBase* cell = cellAcc->AsTableCellBase();
MOZ_ASSERT(cell);
CachedTableCellAccessible& cell = table->mCells[cellIdx];
Accessible* cellAcc = nsAccUtils::GetAccessibleByID(doc, cell.mAccID);
MOZ_ASSERT(cellAcc);
// cell might span multiple columns. We don't want to visit it multiple
// times, so ensure col is set to cell's starting column.
col = cell->ColIdx();
col = cell.ColIdx();
if (cellAcc->Role() != roles::ROWHEADER) {
continue;
}