void AXTableCell::columnIndexRange(std::pair<unsigned, unsigned>& columnRange) { if (!m_layoutObject || !m_layoutObject->isTableCell()) return; LayoutTableCell* cell = toLayoutTableCell(m_layoutObject); columnRange.first = cell->table()->colToEffCol(cell->col()); columnRange.second = cell->table()->colToEffCol(cell->col() + cell->colSpan()) - columnRange.first; }
void AXTableCell::rowIndexRange(std::pair<unsigned, unsigned>& rowRange) { if (!m_layoutObject || !m_layoutObject->isTableCell()) return; LayoutTableCell* layoutCell = toLayoutTableCell(m_layoutObject); rowRange.first = layoutCell->rowIndex(); rowRange.second = layoutCell->rowSpan(); // since our table might have multiple sections, we have to offset our row appropriately LayoutTableSection* section = layoutCell->section(); LayoutTable* table = layoutCell->table(); if (!table || !section) return; LayoutTableSection* tableSection = table->topSection(); unsigned rowOffset = 0; while (tableSection) { if (tableSection == section) break; rowOffset += tableSection->numRows(); tableSection = table->sectionBelow(tableSection, SkipEmptySections); } rowRange.first += rowOffset; }
HTMLTableCellElement* HTMLTableCellElement::cellAbove() const { LayoutObject* cellLayoutObject = layoutObject(); if (!cellLayoutObject) return nullptr; if (!cellLayoutObject->isTableCell()) return nullptr; LayoutTableCell* tableCellLayoutObject = toLayoutTableCell(cellLayoutObject); LayoutTableCell* cellAboveLayoutObject = tableCellLayoutObject->table()->cellAbove(tableCellLayoutObject); if (!cellAboveLayoutObject) return nullptr; return toHTMLTableCellElement(cellAboveLayoutObject->node()); }