AccessibilityARIAGridRow.cpp [plain text]
#include "config.h"
#include "AccessibilityARIAGridRow.h"
#include "AccessibilityObject.h"
#include "AccessibilityTable.h"
#include "RenderObject.h"
namespace WebCore {
AccessibilityARIAGridRow::AccessibilityARIAGridRow(RenderObject* renderer)
: AccessibilityTableRow(renderer)
{
}
AccessibilityARIAGridRow::~AccessibilityARIAGridRow()
{
}
Ref<AccessibilityARIAGridRow> AccessibilityARIAGridRow::create(RenderObject* renderer)
{
return adoptRef(*new AccessibilityARIAGridRow(renderer));
}
bool AccessibilityARIAGridRow::isARIATreeGridRow() const
{
AccessibilityObject* parent = parentTable();
if (!parent)
return false;
return parent->ariaRoleAttribute() == TreeGridRole;
}
void AccessibilityARIAGridRow::disclosedRows(AccessibilityChildrenVector& disclosedRows)
{
AccessibilityObject* parent = parentObjectUnignored();
if (!is<AccessibilityTable>(*parent) || !downcast<AccessibilityTable>(*parent).isExposableThroughAccessibility())
return;
int index = rowIndex();
if (index < 0)
return;
unsigned level = hierarchicalLevel();
auto& allRows = downcast<AccessibilityTable>(*parent).rows();
int rowCount = allRows.size();
for (int k = index + 1; k < rowCount; ++k) {
AccessibilityObject* row = allRows[k].get();
if (row->hierarchicalLevel() != level + 1)
break;
disclosedRows.append(row);
}
}
AccessibilityObject* AccessibilityARIAGridRow::disclosedByRow() const
{
AccessibilityObject* parent = parentObjectUnignored();
if (!is<AccessibilityTable>(*parent) || !downcast<AccessibilityTable>(*parent).isExposableThroughAccessibility())
return nullptr;
unsigned level = hierarchicalLevel();
if (level <= 1)
return nullptr;
int index = rowIndex();
auto& allRows = downcast<AccessibilityTable>(parent)->rows();
int rowCount = allRows.size();
if (index >= rowCount)
return nullptr;
for (int k = index - 1; k >= 0; --k) {
AccessibilityObject* row = allRows[k].get();
if (row->hierarchicalLevel() == level - 1)
return row;
}
return nullptr;
}
AccessibilityObject* AccessibilityARIAGridRow::parentObjectUnignored() const
{
return parentTable();
}
AccessibilityTable* AccessibilityARIAGridRow::parentTable() const
{
for (AccessibilityObject* parent = parentObject(); parent; parent = parent->parentObject()) {
if (is<AccessibilityTable>(*parent)) {
AccessibilityTable& tableParent = downcast<AccessibilityTable>(*parent);
if (tableParent.isExposableThroughAccessibility() && tableParent.isAriaTable())
return &tableParent;
}
}
return nullptr;
}
AccessibilityObject* AccessibilityARIAGridRow::headerObject()
{
for (const auto& child : children()) {
if (child->ariaRoleAttribute() == RowHeaderRole)
return child.get();
}
return nullptr;
}
}