Skip to content

Commit

Permalink
Bug 1130793 - wrong class is used for ARIA grid cell contained by HTM…
Browse files Browse the repository at this point in the history
…L tr@role='row', r=yzen
  • Loading branch information
asurkov committed Feb 14, 2015
1 parent 1e543eb commit e0e4459
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 37 deletions.
69 changes: 34 additions & 35 deletions accessible/base/nsAccessibilityService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,51 +970,50 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
}

if (!newAcc && isHTML) { // HTML accessibles
if (roleMapEntry) {
// Create pure ARIA grid/treegrid related accessibles if they weren't used
// on accessible HTML table elements.
bool isARIATableOrCell = roleMapEntry &&
(roleMapEntry->accTypes & (eTableCell | eTable));

if (!isARIATableOrCell ||
frame->AccessibleType() == eHTMLTableCellType ||
frame->AccessibleType() == eHTMLTableType) {
// Prefer to use markup (mostly tag name, perhaps attributes) to decide if
// and what kind of accessible to create,
newAcc = CreateHTMLAccessibleByMarkup(frame, content, aContext);
if (!newAcc) // try by frame accessible type.
newAcc = CreateAccessibleByFrameType(frame, content, aContext);
}

// In case of ARIA grids use grid-specific classes if it's not native table
// based.
if (isARIATableOrCell && (!newAcc || newAcc->IsGenericHyperText())) {
if ((roleMapEntry->accTypes & eTableCell)) {
if (aContext->IsTableRow() &&
(frame->AccessibleType() != eHTMLTableCellType ||
aContext->GetContent() != content->GetParent())) {
if (aContext->IsTableRow())
newAcc = new ARIAGridCellAccessibleWrap(content, document);
}

} else if ((roleMapEntry->IsOfType(eTable)) &&
frame->AccessibleType() != eHTMLTableType) {
} else if (roleMapEntry->IsOfType(eTable)) {
newAcc = new ARIAGridAccessibleWrap(content, document);
}
}

if (!newAcc) {
// Prefer to use markup (mostly tag name, perhaps attributes) to decide if
// and what kind of accessible to create.
newAcc = CreateHTMLAccessibleByMarkup(frame, content, aContext);

// Try using frame to do it.
if (!newAcc)
newAcc = CreateAccessibleByFrameType(frame, content, aContext);
// If table has strong ARIA role then all table descendants shouldn't
// expose their native roles.
if (!roleMapEntry && newAcc && aContext->HasStrongARIARole()) {
if (frame->AccessibleType() == eHTMLTableRowType) {
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
if (!contextRoleMap->IsOfType(eTable))
roleMapEntry = &aria::gEmptyRoleMap;

// If table has strong ARIA role then all table descendants shouldn't
// expose their native roles.
if (!roleMapEntry && newAcc && aContext->HasStrongARIARole()) {
if (frame->AccessibleType() == eHTMLTableRowType) {
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
if (!contextRoleMap->IsOfType(eTable))
roleMapEntry = &aria::gEmptyRoleMap;
} else if (frame->AccessibleType() == eHTMLTableCellType &&
aContext->ARIARoleMap() == &aria::gEmptyRoleMap) {
roleMapEntry = &aria::gEmptyRoleMap;

} else if (frame->AccessibleType() == eHTMLTableCellType &&
aContext->ARIARoleMap() == &aria::gEmptyRoleMap) {
} else if (content->Tag() == nsGkAtoms::dt ||
content->Tag() == nsGkAtoms::li ||
content->Tag() == nsGkAtoms::dd ||
frame->AccessibleType() == eHTMLLiType) {
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
if (!contextRoleMap->IsOfType(eList))
roleMapEntry = &aria::gEmptyRoleMap;

} else if (content->Tag() == nsGkAtoms::dt ||
content->Tag() == nsGkAtoms::li ||
content->Tag() == nsGkAtoms::dd ||
frame->AccessibleType() == eHTMLLiType) {
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
if (!contextRoleMap->IsOfType(eList))
roleMapEntry = &aria::gEmptyRoleMap;
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions accessible/generic/ARIAGridAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,5 +604,12 @@ ARIAGridCellAccessible::NativeAttributes()
stringIdx.AppendInt(rowIdx * colCount + colIdx);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);

#ifdef DEBUG
nsAutoString unused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("cppclass"),
NS_LITERAL_STRING("ARIAGridCellAccessible"),
unused);
#endif

return attributes.forget();
}
1 change: 1 addition & 0 deletions accessible/generic/Accessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ class Accessible : public nsISupports
bool IsDoc() const { return HasGenericType(eDocument); }
DocAccessible* AsDoc();

bool IsGenericHyperText() const { return mType == eHyperTextType; }
bool IsHyperText() const { return HasGenericType(eHyperText); }
HyperTextAccessible* AsHyperText();

Expand Down
1 change: 1 addition & 0 deletions accessible/generic/HyperTextAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ HyperTextAccessible::
HyperTextAccessible(nsIContent* aNode, DocAccessible* aDoc) :
AccessibleWrap(aNode, aDoc)
{
mType = eHyperTextType;
mGenericTypes |= eHyperText;
}

Expand Down
8 changes: 8 additions & 0 deletions accessible/html/HTMLTableAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ HTMLTableCellAccessible::
HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc)
{
mType = eHTMLTableCellType;
mGenericTypes |= eTableCell;
}

Expand Down Expand Up @@ -129,6 +130,13 @@ HTMLTableCellAccessible::NativeAttributes()
if (!axisText.IsEmpty())
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::axis, axisText);

#ifdef DEBUG
nsAutoString unused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("cppclass"),
NS_LITERAL_STRING("HTMLTableCellAccessible"),
unused);
#endif

return attributes.forget();
}

Expand Down
50 changes: 48 additions & 2 deletions accessible/tests/mochitest/table/test_headers_ariagrid.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@

headerInfoMap = [
{
// not focusable cell (nsARIAGridCellAccessible is used)
// not focusable cell (ARIAGridCellAccessible is used)
cell: "table2_dc_1",
rowHeaderCells: [],
columnHeaderCells: [ "table2_ch_1" ]
},
{
// focusable cell (nsARIAGridCellAccessible is used)
// focusable cell (ARIAGridCellAccessible is used)
cell: "table2_dc_2",
rowHeaderCells: [],
columnHeaderCells: [ "table2_ch_2" ]
Expand All @@ -77,6 +77,27 @@

testHeaderCells(headerInfoMap);


//////////////////////////////////////////////////////////////////////////
// column and row headers from markup for one more crazy grid.

headerInfoMap = [
{
// ARIAGridCellAccessible is used
cell: "t3_dc_1",
rowHeaderCells: [ "t3_rh_1" ],
columnHeaderCells: [ ]
},
{
// ARIAGridCellAccessible is used (inside rowgroup)
cell: "t3_dc_2",
rowHeaderCells: [ "t3_rh_2" ],
columnHeaderCells: [ ]
}
];

testHeaderCells(headerInfoMap);

SimpleTest.finish();
}

Expand Down Expand Up @@ -135,5 +156,30 @@
</div>
</div>

<div role="grid">
<table role="presentation">
<tbody role="presentation">
<tr role="row">
<th id="t3_rh_1" role="rowheader">Row 1</th>
<td id="t3_dc_1" role="gridcell" tabindex="-1">
Apple Inc.
</td>
</tr>
</tbody>
</table>
<div role="rowgroup" tabindex="0">
<table role="presentation">
<tbody role="presentation">
<tr role="row">
<th id="t3_rh_2" role="rowheader">Row 2</th>
<td id="t3_dc_2" role="gridcell" tabindex="-1">
Apple-Shmapple Inc.
</td>
</tr>
</tbody>
</table>
</div>
</div>

</body>
</html>

0 comments on commit e0e4459

Please sign in to comment.