AccessibilityARIAGridCell.cpp [plain text]
#include "config.h"
#include "AccessibilityARIAGridCell.h"
#include "AccessibilityObject.h"
#include "AccessibilityTable.h"
#include "AccessibilityTableRow.h"
namespace WebCore {
AccessibilityARIAGridCell::AccessibilityARIAGridCell(RenderObject* renderer)
: AccessibilityTableCell(renderer)
{
}
AccessibilityARIAGridCell::~AccessibilityARIAGridCell()
{
}
Ref<AccessibilityARIAGridCell> AccessibilityARIAGridCell::create(RenderObject* renderer)
{
return adoptRef(*new AccessibilityARIAGridCell(renderer));
}
AccessibilityTable* AccessibilityARIAGridCell::parentTable() const
{
for (AccessibilityObject* parent = parentObjectUnignored(); parent; parent = parent->parentObjectUnignored()) {
if (is<AccessibilityTable>(*parent) && downcast<AccessibilityTable>(*parent).isExposableThroughAccessibility())
return downcast<AccessibilityTable>(parent);
}
return nullptr;
}
void AccessibilityARIAGridCell::rowIndexRange(std::pair<unsigned, unsigned>& rowRange) const
{
AccessibilityObject* parent = parentObjectUnignored();
if (!parent)
return;
if (is<AccessibilityTableRow>(*parent)) {
rowRange.first = downcast<AccessibilityTableRow>(*parent).rowIndex();
} else if (is<AccessibilityTable>(*parent) && downcast<AccessibilityTable>(*parent).isExposableThroughAccessibility()) {
unsigned columnCount = downcast<AccessibilityTable>(*parent).columnCount();
if (!columnCount)
return;
const auto& siblings = parent->children();
unsigned childrenSize = siblings.size();
for (unsigned k = 0; k < childrenSize; ++k) {
if (siblings[k].get() == this) {
rowRange.first = k / columnCount;
break;
}
}
}
rowRange.second = 1;
}
void AccessibilityARIAGridCell::columnIndexRange(std::pair<unsigned, unsigned>& columnRange) const
{
AccessibilityObject* parent = parentObjectUnignored();
if (!parent)
return;
if (!is<AccessibilityTableRow>(*parent)
&& !(is<AccessibilityTable>(*parent) && downcast<AccessibilityTable>(*parent).isExposableThroughAccessibility()))
return;
const AccessibilityChildrenVector& siblings = parent->children();
unsigned childrenSize = siblings.size();
for (unsigned k = 0; k < childrenSize; ++k) {
if (siblings[k].get() == this) {
columnRange.first = k;
break;
}
}
columnRange.second = 1;
}
}