Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1677)

Unified Diff: Source/modules/accessibility/AXTableCell.cpp

Issue 816423003: Assigned ax role for table headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/accessibility/AXTableCell.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « Source/modules/accessibility/AXTableCell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698