mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1001637 - Make math tables implement the nsIAccessibleTable interface. r=surkov
This commit is contained in:
parent
308ff4d0ec
commit
41894967bf
@ -205,22 +205,22 @@ MARKUPMAP(mmultiscripts_,
|
||||
roles::MATHML_MULTISCRIPTS)
|
||||
|
||||
MARKUPMAP(mtable_,
|
||||
New_HyperText,
|
||||
New_HTMLTableAccessible,
|
||||
roles::MATHML_TABLE,
|
||||
AttrFromDOM(align, align),
|
||||
AttrFromDOM(columnlines_, columnlines_),
|
||||
AttrFromDOM(rowlines_, rowlines_))
|
||||
|
||||
MARKUPMAP(mlabeledtr_,
|
||||
New_HyperText,
|
||||
New_HTMLTableRowAccessible,
|
||||
roles::MATHML_LABELED_ROW)
|
||||
|
||||
MARKUPMAP(mtr_,
|
||||
New_HyperText,
|
||||
New_HTMLTableRowAccessible,
|
||||
roles::MATHML_TABLE_ROW)
|
||||
|
||||
MARKUPMAP(mtd_,
|
||||
New_HyperText,
|
||||
New_HTMLTableCellAccessible,
|
||||
roles::MATHML_CELL)
|
||||
|
||||
MARKUPMAP(maction_,
|
||||
|
@ -200,6 +200,18 @@ static Accessible* New_HTMLOutput(nsIContent* aContent, Accessible* aContext)
|
||||
static Accessible* New_HTMLProgress(nsIContent* aContent, Accessible* aContext)
|
||||
{ return new HTMLProgressMeterAccessible(aContent, aContext->Document()); }
|
||||
|
||||
static Accessible*
|
||||
New_HTMLTableAccessible(nsIContent* aContent, Accessible* aContext)
|
||||
{ return new HTMLTableAccessible(aContent, aContext->Document()); }
|
||||
|
||||
static Accessible*
|
||||
New_HTMLTableRowAccessible(nsIContent* aContent, Accessible* aContext)
|
||||
{ return new HTMLTableRowAccessible(aContent, aContext->Document()); }
|
||||
|
||||
static Accessible*
|
||||
New_HTMLTableCellAccessible(nsIContent* aContent, Accessible* aContext)
|
||||
{ return new HTMLTableCellAccessible(aContent, aContext->Document()); }
|
||||
|
||||
static Accessible*
|
||||
New_HTMLTableHeaderCell(nsIContent* aContent, Accessible* aContext)
|
||||
{
|
||||
|
@ -60,6 +60,9 @@ NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableCellAccessible, HyperTextAccessible)
|
||||
role
|
||||
HTMLTableCellAccessible::NativeRole()
|
||||
{
|
||||
if (mContent->IsMathMLElement(nsGkAtoms::mtd_)) {
|
||||
return roles::MATHML_CELL;
|
||||
}
|
||||
return roles::CELL;
|
||||
}
|
||||
|
||||
@ -148,8 +151,7 @@ HTMLTableCellAccessible::Table() const
|
||||
{
|
||||
Accessible* parent = const_cast<HTMLTableCellAccessible*>(this);
|
||||
while ((parent = parent->Parent())) {
|
||||
roles::Role role = parent->Role();
|
||||
if (role == roles::TABLE || role == roles::TREE_TABLE)
|
||||
if (parent->IsTable())
|
||||
return parent->AsTable();
|
||||
}
|
||||
|
||||
@ -349,6 +351,11 @@ NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableRowAccessible, Accessible)
|
||||
role
|
||||
HTMLTableRowAccessible::NativeRole()
|
||||
{
|
||||
if (mContent->IsMathMLElement(nsGkAtoms::mtr_)) {
|
||||
return roles::MATHML_TABLE_ROW;
|
||||
} else if (mContent->IsMathMLElement(nsGkAtoms::mlabeledtr_)) {
|
||||
return roles::MATHML_LABELED_ROW;
|
||||
}
|
||||
return roles::ROW;
|
||||
}
|
||||
|
||||
@ -384,6 +391,9 @@ HTMLTableAccessible::CacheChildren()
|
||||
role
|
||||
HTMLTableAccessible::NativeRole()
|
||||
{
|
||||
if (mContent->IsMathMLElement(nsGkAtoms::mtable_)) {
|
||||
return roles::MATHML_TABLE;
|
||||
}
|
||||
return roles::TABLE;
|
||||
}
|
||||
|
||||
@ -421,6 +431,11 @@ HTMLTableAccessible::NativeAttributes()
|
||||
{
|
||||
nsCOMPtr<nsIPersistentProperties> attributes =
|
||||
AccessibleWrap::NativeAttributes();
|
||||
|
||||
if (mContent->IsMathMLElement(nsGkAtoms::mtable_)) {
|
||||
GetAccService()->MarkupAttributes(mContent, attributes);
|
||||
}
|
||||
|
||||
if (IsProbablyLayoutTable()) {
|
||||
nsAutoString unused;
|
||||
attributes->SetStringProperty(NS_LITERAL_CSTRING("layout-guess"),
|
||||
|
@ -27,6 +27,13 @@ const kNoColumnHeader = 0;
|
||||
const kListboxColumnHeader = 1;
|
||||
const kTreeColumnHeader = 2;
|
||||
|
||||
/**
|
||||
* Constants to define table type.
|
||||
*/
|
||||
const kTable = 0;
|
||||
const kTreeTable = 1;
|
||||
const kMathTable = 2;
|
||||
|
||||
/**
|
||||
* Test table structure and related methods.
|
||||
*
|
||||
@ -37,10 +44,11 @@ const kTreeColumnHeader = 2;
|
||||
* arranged into the list.
|
||||
* @param aCaption [in] caption text if any
|
||||
* @param aSummary [in] summary text if any
|
||||
* @param aIsTreeTable [in] specifies whether given table is tree table
|
||||
* @param aTableType [in] specifies the table type.
|
||||
* @param aRowRoles [in] array of row roles.
|
||||
*/
|
||||
function testTableStruct(aIdentifier, aCellsArray, aColHeaderType,
|
||||
aCaption, aSummary, aIsTreeTable)
|
||||
aCaption, aSummary, aTableType, aRowRoles)
|
||||
{
|
||||
var tableNode = getNode(aIdentifier);
|
||||
var isGrid = tableNode.getAttribute("role") == "grid" ||
|
||||
@ -52,9 +60,19 @@ function testTableStruct(aIdentifier, aCellsArray, aColHeaderType,
|
||||
|
||||
// Test table accessible tree.
|
||||
var tableObj = {
|
||||
role: aIsTreeTable ? ROLE_TREE_TABLE : ROLE_TABLE,
|
||||
children: []
|
||||
};
|
||||
switch (aTableType) {
|
||||
case kTable:
|
||||
tableObj.role = ROLE_TABLE;
|
||||
break;
|
||||
case kTreeTable:
|
||||
tableObj.role = ROLE_TREE_TABLE;
|
||||
break;
|
||||
case kMathTable:
|
||||
tableObj.role = ROLE_MATHML_TABLE;
|
||||
break;
|
||||
}
|
||||
|
||||
// caption accessible handling
|
||||
if (aCaption) {
|
||||
@ -99,7 +117,7 @@ function testTableStruct(aIdentifier, aCellsArray, aColHeaderType,
|
||||
// rows and cells accessibles
|
||||
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
|
||||
var rowObj = {
|
||||
role: ROLE_ROW,
|
||||
role: aRowRoles ? aRowRoles[rowIdx] : ROLE_ROW,
|
||||
children: []
|
||||
};
|
||||
|
||||
@ -109,7 +127,8 @@ function testTableStruct(aIdentifier, aCellsArray, aColHeaderType,
|
||||
var role = ROLE_NOTHING;
|
||||
switch (celltype) {
|
||||
case kDataCell:
|
||||
role = (isGrid ? ROLE_GRID_CELL : ROLE_CELL);
|
||||
role = (aTableType == kMathTable ? ROLE_MATHML_CELL :
|
||||
(isGrid ? ROLE_GRID_CELL : ROLE_CELL));
|
||||
break;
|
||||
case kRowHeaderCell:
|
||||
role = ROLE_ROWHEADER;
|
||||
|
@ -9,6 +9,7 @@
|
||||
[test_indexes_table.html]
|
||||
[test_indexes_tree.xul]
|
||||
[test_layoutguess.html]
|
||||
[test_mtable.html]
|
||||
[test_sels_ariagrid.html]
|
||||
[test_sels_listbox.xul]
|
||||
[test_sels_table.html]
|
||||
|
128
accessible/tests/mochitest/table/test_mtable.html
Normal file
128
accessible/tests/mochitest/table/test_mtable.html
Normal file
@ -0,0 +1,128 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>MathML table tests</title>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../role.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../table.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
// 'Simple' table
|
||||
var idxes = [
|
||||
[0, 1],
|
||||
[2, 3]
|
||||
];
|
||||
testTableIndexes("simple", idxes);
|
||||
var cellsArray = [
|
||||
[kDataCell, kDataCell],
|
||||
[kDataCell, kDataCell]
|
||||
];
|
||||
var rowsArray = [ROLE_MATHML_TABLE_ROW, ROLE_MATHML_TABLE_ROW];
|
||||
testTableStruct("simple", cellsArray, kNoColumnHeader,
|
||||
"", "", kMathTable, rowsArray);
|
||||
|
||||
// 'Complex' table
|
||||
idxes = [
|
||||
[0, 0, 0],
|
||||
[1, 1, 2],
|
||||
[1, 1, 3]
|
||||
];
|
||||
testTableIndexes("complex", idxes);
|
||||
cellsArray = [
|
||||
[kDataCell, kColSpanned, kColSpanned],
|
||||
[kDataCell, kColSpanned, kDataCell],
|
||||
[kRowSpanned, kSpanned, kDataCell],
|
||||
];
|
||||
rowsArray = [
|
||||
ROLE_MATHML_TABLE_ROW,
|
||||
ROLE_MATHML_TABLE_ROW,
|
||||
ROLE_MATHML_TABLE_ROW
|
||||
];
|
||||
testTableStruct("complex", cellsArray, kNoColumnHeader,
|
||||
"", "", kMathTable, rowsArray);
|
||||
|
||||
// 'Simple' table with mlabeledtr
|
||||
// At the moment we do not implement mlabeledtr but just hide the label
|
||||
// with display: none. Thus we just test the role for now. See bug 689641.
|
||||
var idxes = [[0]];
|
||||
testTableIndexes("simple_label", idxes);
|
||||
var cellsArray = [[kDataCell]];
|
||||
rowsArray = [ROLE_MATHML_LABELED_ROW];
|
||||
testTableStruct("simple_label", cellsArray, kNoColumnHeader,
|
||||
"", "", kMathTable, rowsArray);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<math>
|
||||
<mtable id="simple">
|
||||
<mtr>
|
||||
<mtd>
|
||||
<mn>1</mn>
|
||||
</mtd>
|
||||
<mtd>
|
||||
<mn>0</mn>
|
||||
</mtd>
|
||||
</mtr>
|
||||
<mtr>
|
||||
<mtd>
|
||||
<mn>0</mn>
|
||||
</mtd>
|
||||
<mtd>
|
||||
<mn>1</mn>
|
||||
</mtd>
|
||||
</mtr>
|
||||
</mtable>
|
||||
|
||||
<mtable id="complex">
|
||||
<mtr>
|
||||
<mtd columnspan="3">
|
||||
<mtext>1 x 3</mtext>
|
||||
</mtd>
|
||||
</mtr>
|
||||
<mtr>
|
||||
<mtd rowspan="2" columnspan="2">
|
||||
<mtext>2 x 2</mtext>
|
||||
</mtd>
|
||||
<mtd>
|
||||
<mtext>1 x 1</mtext>
|
||||
</mtd>
|
||||
</mtr>
|
||||
<mtr>
|
||||
<mtd>
|
||||
<mtext>1 x 1</mtext>
|
||||
</mtd>
|
||||
</mtr>
|
||||
</mtable>
|
||||
|
||||
<mtable id="simple_label">
|
||||
<mlabeledtr>
|
||||
<mtd><mtext>1</mtext></mtd>
|
||||
<mtd><mtext>label</mtext></mtd>
|
||||
</mlabeledtr>
|
||||
</mtable>
|
||||
</math>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -28,7 +28,8 @@
|
||||
[kDataCell, kDataCell, kDataCell]
|
||||
];
|
||||
|
||||
testTableStruct("treegrid", cellsArray, kNoColumnHeader, "", "", true);
|
||||
testTableStruct("treegrid", cellsArray, kNoColumnHeader, "", "",
|
||||
kTreeTable);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user