This source file includes following definitions.
- create
- addTableCellChild
- addChildren
#include "config.h"
#include "core/accessibility/AXARIAGrid.h"
#include "core/accessibility/AXObjectCache.h"
#include "core/accessibility/AXTableColumn.h"
#include "core/accessibility/AXTableRow.h"
#include "core/rendering/RenderObject.h"
namespace WebCore {
AXARIAGrid::AXARIAGrid(RenderObject* renderer)
: AXTable(renderer)
{
}
AXARIAGrid::~AXARIAGrid()
{
}
PassRefPtr<AXARIAGrid> AXARIAGrid::create(RenderObject* renderer)
{
return adoptRef(new AXARIAGrid(renderer));
}
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;
unsigned rowCellCount = row->children().size();
if (rowCellCount > columnCount)
columnCount = rowCellCount;
row->setRowIndex((int)m_rows.size());
m_rows.append(row);
if (!row->accessibilityIsIgnored())
m_children.append(row);
else
m_children.appendVector(row->children());
appendedRows.add(row);
return true;
}
void AXARIAGrid::addChildren()
{
ASSERT(!m_haveChildren);
if (!isAXTable()) {
AXRenderObject::addChildren();
return;
}
m_haveChildren = true;
if (!m_renderer)
return;
AXObjectCache* axCache = m_renderer->document().axObjectCache();
HashSet<AXObject*> appendedRows;
unsigned columnCount = 0;
for (RefPtr<AXObject> child = firstChild(); child; child = child->nextSibling()) {
if (!addTableCellChild(child.get(), appendedRows, columnCount)) {
if (!child->hasChildren())
child->addChildren();
AccessibilityChildrenVector children = child->children();
size_t length = children.size();
for (size_t i = 0; i < length; ++i)
addTableCellChild(children[i].get(), appendedRows, columnCount);
}
}
for (unsigned i = 0; i < columnCount; ++i) {
AXTableColumn* column = toAXTableColumn(axCache->getOrCreate(ColumnRole));
column->setColumnIndex((int)i);
column->setParent(this);
m_columns.append(column);
if (!column->accessibilityIsIgnored())
m_children.append(column);
}
AXObject* headerContainerObject = headerContainer();
if (headerContainerObject && !headerContainerObject->accessibilityIsIgnored())
m_children.append(headerContainerObject);
}
}