| Index: Source/modules/accessibility/AXTableCell.cpp
|
| diff --git a/Source/modules/accessibility/AXTableCell.cpp b/Source/modules/accessibility/AXTableCell.cpp
|
| index 748860a07530988c01748b241bec97091480302b..3d669dfda73050cb93ec4a65eb0a6ebde28c6648 100644
|
| --- a/Source/modules/accessibility/AXTableCell.cpp
|
| +++ b/Source/modules/accessibility/AXTableCell.cpp
|
| @@ -91,12 +91,57 @@ bool AXTableCell::isTableCell() const
|
| return true;
|
| }
|
|
|
| +static AccessibilityRole decideRoleFromSibling(Node* siblingNode)
|
| +{
|
| + if (!siblingNode)
|
| + return CellRole;
|
| + if (siblingNode->hasTagName(thTag))
|
| + return ColumnHeaderRole;
|
| + if (siblingNode->hasTagName(tdTag))
|
| + return RowHeaderRole;
|
| + return CellRole;
|
| +}
|
| +
|
| +AccessibilityRole AXTableCell::scanToDecideHeaderRole()
|
| +{
|
| + Node* node = m_renderer ? m_renderer->node() : 0;
|
| + if (!node || !node->hasTagName(thTag))
|
| + return CellRole;
|
| +
|
| + // Check scope attribute first.
|
| + const AtomicString& scope = getAttribute(scopeAttr);
|
| + if (equalIgnoringCase(scope, "row"))
|
| + return RowHeaderRole;
|
| + if (equalIgnoringCase(scope, "col"))
|
| + return ColumnHeaderRole;
|
| +
|
| + // Check the previous cell and the next cell
|
| + RenderTableCell* renderCell = toRenderTableCell(m_renderer);
|
| + AccessibilityRole headerRole = CellRole;
|
| +
|
| + // if header is preceded by header cells then it's a column header,
|
| + // if it is preceded by cells then it's a row header.
|
| + if (RenderTableCell* cell = renderCell->previousCell()) {
|
| + Node* siblingNode = cell->node();
|
| + headerRole = decideRoleFromSibling(siblingNode);
|
| + if (headerRole != CellRole)
|
| + return headerRole;
|
| + }
|
| + // if header is followed by header cells then it's a column header,
|
| + // if it is followed by cells then it's a row header.
|
| + if (RenderTableCell* cell = renderCell->nextCell()) {
|
| + Node* siblingNode = cell->node();
|
| + headerRole = decideRoleFromSibling(siblingNode);
|
| + }
|
| + return headerRole;
|
| +}
|
| +
|
| AccessibilityRole AXTableCell::determineAccessibilityRole()
|
| {
|
| if (!isTableCell())
|
| return AXRenderObject::determineAccessibilityRole();
|
|
|
| - return CellRole;
|
| + return scanToDecideHeaderRole();
|
| }
|
|
|
| void AXTableCell::rowIndexRange(pair<unsigned, unsigned>& rowRange)
|
|
|