Bug 513848 - nsHTMLTableCellAccessible is used in dojo's crazy ARIA grid, r=marcoz, davidb

This commit is contained in:
Alexander Surkov 2009-09-15 11:55:26 +08:00
Родитель 62429fc2c2
Коммит a31625e7e3
6 изменённых файлов: 182 добавлений и 24 удалений

Просмотреть файл

@ -1494,7 +1494,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
frameType == nsAccessibilityAtoms::tableRowGroupFrame ||
frameType == nsAccessibilityAtoms::tableRowFrame;
if (!roleMapEntry && partOfHTMLTable) {
if (partOfHTMLTable) {
// Table-related frames don't get table-related roles
// unless they are inside a table, but they may still get generic
// accessibles
@ -1503,31 +1503,45 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
nsIFrame *tableFrame = aPresShell->GetPrimaryFrameFor(tableContent);
if (!tableFrame)
continue;
if (tableFrame->GetType() == nsAccessibilityAtoms::tableOuterFrame) {
nsCOMPtr<nsIDOMNode> tableNode(do_QueryInterface(tableContent));
nsCOMPtr<nsIAccessible> tableAccessible;
GetAccessibleInShell(tableNode, aPresShell, getter_AddRefs(tableAccessible));
if (!tableAccessible && !content->IsFocusable()) {
GetAccessibleInShell(tableNode, aPresShell,
getter_AddRefs(tableAccessible));
if (tableAccessible) {
if (!roleMapEntry &&
nsAccUtils::Role(tableAccessible) != nsIAccessibleRole::ROLE_TABLE) {
// No ARIA role and not in table: override role.
roleMapEntry = &nsARIAMap::gEmptyRoleMap;
}
break;
}
#ifdef DEBUG
nsRoleMapEntry *tableRoleMapEntry =
nsAccUtils::GetRoleMapEntry(tableNode);
NS_ASSERTION(tableRoleMapEntry &&
!nsCRT::strcmp(tableRoleMapEntry->roleString, "presentation"),
"No accessible for parent table and it didn't have role of presentation");
nsRoleMapEntry *tableRoleMapEntry =
nsAccUtils::GetRoleMapEntry(tableNode);
NS_ASSERTION(tableRoleMapEntry &&
!nsCRT::strcmp(tableRoleMapEntry->roleString, "presentation"),
"No accessible for parent table and it didn't have role of presentation");
#endif
// Table-related descendants of presentation table are also presentation
// Don't create accessibles for them unless they need to fire focus events
if (!roleMapEntry && !content->IsFocusable()) {
// Table-related descendants of presentation table are also
// presentation if they aren't focusable and have not explicit ARIA
// role (don't create accessibles for them unless they need to fire
// focus events).
return NS_OK;
}
if (tableAccessible &&
nsAccUtils::Role(tableAccessible) != nsIAccessibleRole::ROLE_TABLE) {
NS_ASSERTION(!roleMapEntry, "Should not be changing ARIA role, just overriding impl class role");
// Not in table: override role (roleMap entry was null).
roleMapEntry = &nsARIAMap::gEmptyRoleMap;
}
// otherwise create ARIA based accessible.
tryTagNameOrFrame = PR_FALSE;
break;
}
else if (tableContent->Tag() == nsAccessibilityAtoms::table) {
if (tableContent->Tag() == nsAccessibilityAtoms::table) {
// Stop before we are fooled by any additional table ancestors
// This table cell frameis part of a separate ancestor table.
tryTagNameOrFrame = PR_FALSE;

Просмотреть файл

@ -5,7 +5,7 @@ const nsIDOMKeyEvent = Components.interfaces.nsIDOMKeyEvent;
*/
function grid(aTableIdentifier)
{
this.getrowCount = function getrowCount()
this.getRowCount = function getRowCount()
{
return this.table.rows.length - (this.table.tHead ? 1 : 0);
}
@ -21,12 +21,12 @@ function grid(aTableIdentifier)
this.getMaxIndex = function getMaxIndex()
{
return this.getrowCount() * this.getColsCount() - 1;
return this.getRowCount() * this.getColsCount() - 1;
}
this.getCellAtIndex = function getCellAtIndex(aIndex)
{
var rowCount = this.getrowCount();
var rowCount = this.getRowCount();
var colsCount = this.getColsCount();
var rowIdx = Math.floor(aIndex / colsCount);

Просмотреть файл

@ -53,7 +53,28 @@
cell: "table_rh_2",
rowHeaderCells: [],
columnHeaderCells: [ "table_ch_1" ]
}
];
testHeaderCells(headerInfoMap);
//////////////////////////////////////////////////////////////////////////
// column and row headers from markup for crazy grid.
headerInfoMap = [
{
// not focusable cell (nsARIAGridCellAccessible is used)
cell: "table2_dc_1",
rowHeaderCells: [],
columnHeaderCells: [ "table2_ch_1" ]
},
{
// focusable cell (nsARIAGridCellAccessible is used)
cell: "table2_dc_2",
rowHeaderCells: [],
columnHeaderCells: [ "table2_ch_2" ]
}
];
testHeaderCells(headerInfoMap);
@ -70,13 +91,16 @@
<a target="_blank"
title="implement IAccessibleTable2"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=512424">Mozilla Bug 512424</a>
<a target="_blank"
title="nsHTMLTableCellAccessible is used in dojo's crazy ARIA grid"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=513848">Mozilla Bug 513848</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="table" role="grid">
<div role="grid">
<div role="row">
<span id="table_ch_1" role="columnheader">col_1</span>
<span id="table_ch_2" role="columnheader">col_2</span>
@ -94,5 +118,24 @@
</div>
</div>
<div role="grid">
<div role="row">
<table role="presentation">
<tr>
<td id="table2_ch_1" role="columnheader">header1</td>
<td id="table2_ch_2" role="columnheader">header2</td>
</tr>
</table>
</div>
<div role="row">
<table role="presentation">
<tr>
<td id="table2_dc_1" role="gridcell">cell1</td>
<td id="table2_dc_2" role="gridcell" tabindex="-1">cell2</td>
</tr>
</table>
</div>
</div>
</body>
</html>

Просмотреть файл

@ -30,6 +30,14 @@
];
testTableIndexes("grid", idxes);
//////////////////////////////////////////////////////////////////////////
// a bit crazy ARIA grid
idxes = [
[0, 1],
[2, 3]
];
testTableIndexes("grid2", idxes);
SimpleTest.finish();
}
@ -42,6 +50,10 @@
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=386813"
title="support nsIAccessibleTable on ARIA grid/treegrid">Mozilla Bug 386813</a>
<a target="_blank"
title="nsHTMLTableCellAccessible is used in dojo's crazy ARIA grid"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=513848">Mozilla Bug 513848</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -50,7 +62,7 @@
<div role="grid" id="grid">
<div role="row">
<span role="columnheader">column1</span>
<span id="a" role="columnheader">column2</span>
<span role="columnheader">column2</span>
<span role="columnheader">column3</span>
</div>
<div role="row">
@ -70,5 +82,24 @@
</div>
</div>
<div role="grid" id="grid2">
<div role="row">
<table role="presentation">
<tr>
<td role="columnheader">header1</td>
<td role="columnheader">header2</td>
</tr>
</table>
</div>
<div role="row">
<table role="presentation">
<tr>
<td role="gridcell">cell1</td>
<td role="gridcell" tabindex="-1">cell2</td>
</tr>
</table>
</div>
</div>
</body>
</html>

Просмотреть файл

@ -24,7 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052
function doTest()
{
//////////////////////////////////////////////////////////////////////////
// table
// ARIA grid
var cellsArray =
[
[ true, true, false, true],
@ -40,6 +40,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052
testSelectTableColumn("table", 0, cellsArray);
testSelectTableRow("table", 0, cellsArray);
//////////////////////////////////////////////////////////////////////////
// a bit crazy ARIA grid
cellsArray =
[
[ false, false],
[ false, false]
];
testTableSelection("grid2", cellsArray);
testSelectTableColumn("grid2", 0, cellsArray);
testSelectTableRow("grid2", 0, cellsArray);
testUnselectTableColumn("grid2", 0, cellsArray);
testUnselectTableRow("grid2", 0, cellsArray);
SimpleTest.finish();
}
@ -52,6 +66,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052
<a target="_blank"
title="implement nsIAccessibleTable selection methods for ARIA grids"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=410052">Mozilla Bug 410052</a>
<a target="_blank"
title="nsHTMLTableCellAccessible is used in dojo's crazy ARIA grid"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=513848">Mozilla Bug 513848</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -90,5 +108,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052
</div>
</div>
<div role="grid" id="grid2">
<div role="row">
<table role="presentation">
<tr>
<td role="columnheader">header1</td>
<td role="columnheader">header2</td>
</tr>
</table>
</div>
<div role="row">
<table role="presentation">
<tr>
<td role="gridcell">cell1</td>
<td role="gridcell" tabindex="-1">cell2</td>
</tr>
</table>
</div>
</div>
</body>
</html>

Просмотреть файл

@ -33,7 +33,7 @@
//////////////////////////////////////////////////////////////////////////
// HTML table based ARIA grid
var cellsArray = [
cellsArray = [
[kColHeaderCell, kColHeaderCell, kColHeaderCell],
[kDataCell, kDataCell, kDataCell],
[kDataCell, kDataCell, kDataCell]
@ -41,6 +41,15 @@
testTableStruct("grid", cellsArray);
//////////////////////////////////////////////////////////////////////////
// ARIA grid with HTML table elements
cellsArray = [
[kColHeaderCell, kColHeaderCell],
[kDataCell, kDataCell]
];
testTableStruct("grid2", cellsArray);
SimpleTest.finish();
}
@ -56,6 +65,9 @@
<a target="_blank"
title="implement IAccessibleTable2"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=512424">Mozilla Bug 512424</a>
<a target="_blank"
title="nsHTMLTableCellAccessible is used in dojo's crazy ARIA grid"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=513848">Mozilla Bug 513848</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -100,5 +112,26 @@
</tbody>
</table>
<!-- ARIA grid containing presentational HTML:table with HTML:td used as ARIA
grid cells (focusable and not focusable cells) -->
<div role="grid" id="grid2">
<div role="row">
<table role="presentation">
<tr>
<td role="columnheader">header1</td>
<td role="columnheader">header2</td>
</tr>
</table>
</div>
<div role="row">
<table role="presentation">
<tr>
<td role="gridcell">cell1</td>
<td role="gridcell" tabindex="-1">cell2</td>
</tr>
</table>
</div>
</div>
</body>
</html>