This source file includes following definitions.
- create
- computeAccessibilityIsIgnored
- parentTable
- isTableCell
- determineAccessibilityRole
- rowIndexRange
- columnIndexRange
- titleUIElement
#include "config.h"
#include "core/accessibility/AXTableCell.h"
#include "core/accessibility/AXObjectCache.h"
#include "core/rendering/RenderTableCell.h"
namespace WebCore {
using namespace HTMLNames;
AXTableCell::AXTableCell(RenderObject* renderer)
: AXRenderObject(renderer)
{
}
AXTableCell::~AXTableCell()
{
}
PassRefPtr<AXTableCell> AXTableCell::create(RenderObject* renderer)
{
return adoptRef(new AXTableCell(renderer));
}
bool AXTableCell::computeAccessibilityIsIgnored() const
{
AXObjectInclusion decision = defaultObjectInclusion();
if (decision == IncludeObject)
return false;
if (decision == IgnoreObject)
return true;
if (!isTableCell())
return AXRenderObject::computeAccessibilityIsIgnored();
return false;
}
AXObject* AXTableCell::parentTable() const
{
if (!m_renderer || !m_renderer->isTableCell())
return 0;
if (!axObjectCache())
return 0;
return axObjectCache()->get(toRenderTableCell(m_renderer)->table());
}
bool AXTableCell::isTableCell() const
{
AXObject* parent = parentObjectUnignored();
if (!parent || !parent->isTableRow())
return false;
return true;
}
AccessibilityRole AXTableCell::determineAccessibilityRole()
{
if (!isTableCell())
return AXRenderObject::determineAccessibilityRole();
return CellRole;
}
void AXTableCell::rowIndexRange(pair<unsigned, unsigned>& rowRange)
{
if (!m_renderer || !m_renderer->isTableCell())
return;
RenderTableCell* renderCell = toRenderTableCell(m_renderer);
rowRange.first = renderCell->rowIndex();
rowRange.second = renderCell->rowSpan();
RenderTableSection* section = renderCell->section();
RenderTable* table = renderCell->table();
if (!table || !section)
return;
RenderTableSection* tableSection = table->topSection();
unsigned rowOffset = 0;
while (tableSection) {
if (tableSection == section)
break;
rowOffset += tableSection->numRows();
tableSection = table->sectionBelow(tableSection, SkipEmptySections);
}
rowRange.first += rowOffset;
}
void AXTableCell::columnIndexRange(pair<unsigned, unsigned>& columnRange)
{
if (!m_renderer || !m_renderer->isTableCell())
return;
RenderTableCell* renderCell = toRenderTableCell(m_renderer);
columnRange.first = renderCell->col();
columnRange.second = renderCell->colSpan();
}
AXObject* AXTableCell::titleUIElement() const
{
if (isTableCell() || !m_renderer || !m_renderer->isTableCell())
return 0;
Node* node = m_renderer->node();
if (node && node->hasTagName(thTag))
return 0;
RenderTableCell* renderCell = toRenderTableCell(m_renderer);
int col = renderCell->col();
if (!col)
return 0;
int row = renderCell->rowIndex();
RenderTableSection* section = renderCell->section();
if (!section)
return 0;
RenderTableCell* headerCell = section->primaryCellAt(row, 0);
if (!headerCell || headerCell == renderCell)
return 0;
Node* cellElement = headerCell->node();
if (!cellElement || !cellElement->hasTagName(thTag))
return 0;
return axObjectCache()->getOrCreate(headerCell);
}
}