AccessibilityARIAGridRow.cpp [plain text]
#include "config.h"
#include "AccessibilityARIAGridRow.h"
#include "AccessibilityObject.h"
#include "AccessibilityTable.h"
#include "RenderObject.h"
using namespace std;
namespace WebCore {
AccessibilityARIAGridRow::AccessibilityARIAGridRow(RenderObject* renderer)
: AccessibilityTableRow(renderer)
{
}
AccessibilityARIAGridRow::~AccessibilityARIAGridRow()
{
}
PassRefPtr<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 (!parent || !parent->isAccessibilityTable())
return;
int index = rowIndex();
if (index < 0)
return;
unsigned level = hierarchicalLevel();
AccessibilityChildrenVector& allRows = static_cast<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 (!parent || !parent->isAccessibilityTable())
return 0;
unsigned level = hierarchicalLevel();
if (level <= 1)
return 0;
int index = rowIndex();
AccessibilityChildrenVector& allRows = static_cast<AccessibilityTable*>(parent)->rows();
int rowCount = allRows.size();
if (index >= rowCount)
return 0;
for (int k = index - 1; k >= 0; --k) {
AccessibilityObject* row = allRows[k].get();
if (row->hierarchicalLevel() == level - 1)
return row;
}
return 0;
}
AccessibilityObject* AccessibilityARIAGridRow::parentTable() const
{
AccessibilityObject* parent = parentObjectUnignored();
if (!parent->isAccessibilityTable())
return 0;
return parent;
}
AccessibilityObject* AccessibilityARIAGridRow::headerObject()
{
AccessibilityChildrenVector rowChildren = children();
unsigned childrenCount = rowChildren.size();
for (unsigned i = 0; i < childrenCount; ++i) {
AccessibilityObject* cell = rowChildren[i].get();
if (cell->ariaRoleAttribute() == RowHeaderRole)
return cell;
}
return 0;
}
}