void AccessibilityTableCell::rowIndexRange(pair<int, int>& rowRange) { if (!m_renderer) return; RenderTableCell* renderCell = static_cast<RenderTableCell*>(m_renderer); rowRange.first = renderCell->row(); 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* tableSection = table->header(); if (!tableSection) tableSection = table->firstBody(); unsigned rowOffset = 0; while (tableSection) { if (tableSection == section) break; rowOffset += tableSection->numRows(); tableSection = table->sectionBelow(tableSection, true); } rowRange.first += rowOffset; }
AccessibilityObject* AccessibilityTableCell::titleUIElement() const { // Try to find if the first cell in this row is a <th>. If it is, // then it can act as the title ui element. (This is only in the // case when the table is not appearing as an AXTable.) if (!m_renderer || isTableCell()) return 0; RenderTableCell* renderCell = static_cast<RenderTableCell*>(m_renderer); // If this cell is in the first column, there is no need to continue. int col = renderCell->col(); if (!col) return 0; int row = renderCell->row(); RenderTableSection* section = renderCell->section(); if (!section) return 0; RenderTableCell* headerCell = section->cellAt(row, 0).cell; if (!headerCell || headerCell == renderCell) return 0; Node* cellElement = headerCell->element(); if (!cellElement || !cellElement->hasTagName(thTag)) return 0; return axObjectCache()->get(headerCell); }
AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column, unsigned row) { if (!m_renderer) return 0; if (!hasChildren()) addChildren(); RenderTable* table = static_cast<RenderTable*>(m_renderer); RenderTableSection* tableSection = table->header(); if (!tableSection) tableSection = table->firstBody(); RenderTableCell* cell = 0; unsigned rowCount = 0; unsigned rowOffset = 0; while (tableSection) { rowCount += tableSection->numRows(); unsigned numCols = tableSection->numColumns(); if (row < rowCount && column < numCols) { int sectionSpecificRow = row - rowOffset; cell = tableSection->cellAt(sectionSpecificRow, column).cell; // we didn't find the cell, which means there's spanning happening // search backwards to find the spanning cell if (!cell) { // first try rows for (int testRow = sectionSpecificRow-1; testRow >= 0; --testRow) { cell = tableSection->cellAt(testRow, column).cell; // cell overlapped. use this one if (cell && ((cell->row() + (cell->rowSpan()-1)) >= (int)sectionSpecificRow)) break; cell = 0; } if (!cell) { // try cols for (int testCol = column-1; testCol >= 0; --testCol) { cell = tableSection->cellAt(sectionSpecificRow, testCol).cell; // cell overlapped. use this one if (cell && ((cell->col() + (cell->colSpan()-1)) >= (int)column)) break; cell = 0; } } } } if (cell) break; rowOffset += rowCount; // we didn't find anything between the rows we should have if (row < rowOffset) break; tableSection = table->sectionBelow(tableSection, true); } if (!cell) return 0; AccessibilityObject* cellObject = axObjectCache()->get(cell); ASSERT(cellObject->isTableCell()); return static_cast<AccessibilityTableCell*>(cellObject); }
AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column, unsigned row) { if (!m_renderer || !m_renderer->isTable()) return 0; updateChildrenIfNecessary(); RenderTable* table = toRenderTable(m_renderer); // FIXME: This will skip a table with just a tfoot. Should fix by using RenderTable::topSection. RenderTableSection* tableSection = table->header(); if (!tableSection) tableSection = table->firstBody(); RenderTableCell* cell = 0; unsigned rowCount = 0; unsigned rowOffset = 0; while (tableSection) { unsigned numRows = tableSection->numRows(); unsigned numCols = tableSection->numColumns(); rowCount += numRows; unsigned sectionSpecificRow = row - rowOffset; if (row < rowCount && column < numCols && sectionSpecificRow < numRows) { cell = tableSection->primaryCellAt(sectionSpecificRow, column); // we didn't find the cell, which means there's spanning happening // search backwards to find the spanning cell if (!cell) { // first try rows for (int testRow = sectionSpecificRow - 1; testRow >= 0; --testRow) { cell = tableSection->primaryCellAt(testRow, column); // cell overlapped. use this one ASSERT(cell->rowSpan() >= 1); if (cell && ((cell->row() + (cell->rowSpan() - 1)) >= sectionSpecificRow)) break; cell = 0; } if (!cell) { // try cols for (int testCol = column - 1; testCol >= 0; --testCol) { cell = tableSection->primaryCellAt(sectionSpecificRow, testCol); // cell overlapped. use this one ASSERT(cell->rowSpan() >= 1); if (cell && ((cell->col() + (cell->colSpan() - 1)) >= column)) break; cell = 0; } } } } if (cell) break; rowOffset += numRows; // we didn't find anything between the rows we should have if (row < rowCount) break; tableSection = table->sectionBelow(tableSection, SkipEmptySections); } if (!cell) return 0; AccessibilityObject* cellObject = axObjectCache()->getOrCreate(cell); ASSERT(cellObject->isTableCell()); return static_cast<AccessibilityTableCell*>(cellObject); }