HTMLTableElement* AccessibilityTable::tableElement() const { if (!is<RenderTable>(*m_renderer)) return nullptr; RenderTable& table = downcast<RenderTable>(*m_renderer); if (is<HTMLTableElement>(table.element())) return downcast<HTMLTableElement>(table.element()); // If the table has a display:table-row-group, then the RenderTable does not have a pointer to it's HTMLTableElement. // We can instead find it by asking the firstSection for its parent. RenderTableSection* firstBody = table.firstBody(); if (!firstBody || !firstBody->element()) return nullptr; Element* actualTable = firstBody->element()->parentElement(); if (!is<HTMLTableElement>(actualTable)) return nullptr; return downcast<HTMLTableElement>(actualTable); }
HTMLTableElement* AccessibilityTable::tableElement() const { if (!m_renderer->isTable()) return nullptr; RenderTable* table = toRenderTable(m_renderer); if (table->element() && isHTMLTableElement(table->element())) return toHTMLTableElement(table->element()); // If the table has a display:table-row-group, then the RenderTable does not have a pointer to it's HTMLTableElement. // We can instead find it by asking the firstSection for its parent. RenderTableSection* firstBody = table->firstBody(); if (!firstBody || !firstBody->element()) return nullptr; Element* actualTable = firstBody->element()->parentElement(); if (!actualTable || !isHTMLTableElement(actualTable)) return nullptr; return toHTMLTableElement(actualTable); }