void AXARIAGridCell::rowIndexRange(pair<unsigned, unsigned>& rowRange) { AXObject* parent = parentObjectUnignored(); if (!parent) return; if (parent->isTableRow()) { // We already got a table row, use its API. rowRange.first = toAXTableRow(parent)->rowIndex(); } else if (parent->isAXTable()) { // We reached the parent table, so we need to inspect its // children to determine the row index for the cell in it. unsigned columnCount = toAXTable(parent)->columnCount(); if (!columnCount) return; AccessibilityChildrenVector siblings = parent->children(); unsigned childrenSize = siblings.size(); for (unsigned k = 0; k < childrenSize; ++k) { if (siblings[k].get() == this) { rowRange.first = k / columnCount; break; } } } // as far as I can tell, grid cells cannot span rows rowRange.second = 1; }
bool AXARIAGrid::addTableCellChild(AXObject* child, HashSet<AXObject*>& appendedRows, unsigned& columnCount) { if (!child || !child->isTableRow() || child->ariaRoleAttribute() != RowRole) return false; AXTableRow* row = toAXTableRow(child); if (appendedRows.contains(row)) return false; // store the maximum number of columns unsigned rowCellCount = row->children().size(); if (rowCellCount > columnCount) columnCount = rowCellCount; row->setRowIndex((int)m_rows.size()); m_rows.append(row); // Try adding the row if it's not ignoring accessibility, // otherwise add its children (the cells) as the grid's children. if (!row->accessibilityIsIgnored()) m_children.append(row); else m_children.appendVector(row->children()); appendedRows.add(row); return true; }