mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 706849 - create accessible by tag name as fallback if table descendant style is used out of table context, r=tbsaunde
This commit is contained in:
parent
4fa9c4af7a
commit
e7ce500cf3
@ -1007,8 +1007,6 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
||||
}
|
||||
|
||||
if (weakFrame.IsAlive() && !newAcc && isHTML) { // HTML accessibles
|
||||
bool tryTagNameOrFrame = true;
|
||||
|
||||
nsIAtom *frameType = weakFrame.GetFrame()->GetType();
|
||||
|
||||
bool partOfHTMLTable =
|
||||
@ -1016,6 +1014,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
||||
frameType == nsGkAtoms::tableCellFrame ||
|
||||
frameType == nsGkAtoms::tableRowGroupFrame ||
|
||||
frameType == nsGkAtoms::tableRowFrame;
|
||||
bool legalPartOfHTMLTable = partOfHTMLTable;
|
||||
|
||||
if (partOfHTMLTable) {
|
||||
// Table-related frames don't get table-related roles
|
||||
@ -1057,26 +1056,26 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
||||
}
|
||||
|
||||
// otherwise create ARIA based accessible.
|
||||
tryTagNameOrFrame = false;
|
||||
legalPartOfHTMLTable = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (tableContent->Tag() == nsGkAtoms::table) {
|
||||
// Stop before we are fooled by any additional table ancestors
|
||||
// This table cell frameis part of a separate ancestor table.
|
||||
tryTagNameOrFrame = false;
|
||||
legalPartOfHTMLTable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tableContent)
|
||||
tryTagNameOrFrame = false;
|
||||
legalPartOfHTMLTable = false;
|
||||
}
|
||||
|
||||
if (roleMapEntry) {
|
||||
// Create ARIA grid/treegrid accessibles if node is not of a child or
|
||||
// valid child of HTML table and is not a HTML table.
|
||||
if ((!partOfHTMLTable || !tryTagNameOrFrame) &&
|
||||
// Create ARIA grid/treegrid accessibles if node is not a child or legal
|
||||
// child of HTML table and is not a HTML table.
|
||||
if ((!partOfHTMLTable || !legalPartOfHTMLTable) &&
|
||||
frameType != nsGkAtoms::tableOuterFrame) {
|
||||
|
||||
if (roleMapEntry->role == roles::TABLE ||
|
||||
@ -1091,16 +1090,16 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
||||
}
|
||||
}
|
||||
|
||||
if (!newAcc && tryTagNameOrFrame) {
|
||||
if (!newAcc) {
|
||||
// Prefer to use markup (mostly tag name, perhaps attributes) to
|
||||
// decide if and what kind of accessible to create.
|
||||
// The method creates accessibles for table related content too therefore
|
||||
// we do not call it if accessibles for table related content are
|
||||
// prevented above.
|
||||
newAcc = CreateHTMLAccessibleByMarkup(weakFrame.GetFrame(), content,
|
||||
docAcc);
|
||||
docAcc, legalPartOfHTMLTable);
|
||||
|
||||
if (!newAcc) {
|
||||
if (!newAcc && (!partOfHTMLTable || legalPartOfHTMLTable)) {
|
||||
// Do not create accessible object subtrees for non-rendered table
|
||||
// captions. This could not be done in
|
||||
// nsTableCaptionFrame::GetAccessible() because the descendants of
|
||||
@ -1553,8 +1552,20 @@ nsAccessibilityService::CreateAccessibleByType(nsIContent* aContent,
|
||||
already_AddRefed<Accessible>
|
||||
nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
|
||||
nsIContent* aContent,
|
||||
DocAccessible* aDoc)
|
||||
DocAccessible* aDoc,
|
||||
bool aIsLegalPartOfHTMLTable)
|
||||
{
|
||||
if (aIsLegalPartOfHTMLTable) {
|
||||
if (nsCoreUtils::IsHTMLTableHeader(aContent)) {
|
||||
Accessible* accessible =
|
||||
new HTMLTableHeaderCellAccessibleWrap(aContent, aDoc);
|
||||
NS_IF_ADDREF(accessible);
|
||||
return accessible;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// This method assumes we're in an HTML namespace.
|
||||
nsIAtom* tag = aContent->Tag();
|
||||
if (tag == nsGkAtoms::figcaption) {
|
||||
@ -1635,12 +1646,6 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
|
||||
return accessible;
|
||||
}
|
||||
|
||||
if (nsCoreUtils::IsHTMLTableHeader(aContent)) {
|
||||
Accessible* accessible = new HTMLTableHeaderCellAccessibleWrap(aContent, aDoc);
|
||||
NS_IF_ADDREF(accessible);
|
||||
return accessible;
|
||||
}
|
||||
|
||||
if (tag == nsGkAtoms::output) {
|
||||
Accessible* accessible = new HTMLOutputAccessible(aContent, aDoc);
|
||||
NS_IF_ADDREF(accessible);
|
||||
|
@ -229,7 +229,8 @@ private:
|
||||
*/
|
||||
already_AddRefed<Accessible>
|
||||
CreateHTMLAccessibleByMarkup(nsIFrame* aFrame, nsIContent* aContent,
|
||||
DocAccessible* aDoc);
|
||||
DocAccessible* aDoc,
|
||||
bool aIsLegalPartOfHTMLTable);
|
||||
|
||||
/**
|
||||
* Create accessible if parent is a deck frame.
|
||||
|
@ -17,6 +17,7 @@ MOCHITEST_A11Y_FILES =\
|
||||
test_aria_globals.html \
|
||||
test_aria_imgmap.html \
|
||||
test_aria_presentation.html \
|
||||
test_brokencontext.html \
|
||||
test_button.xul \
|
||||
test_canvas.html \
|
||||
test_combobox.xul \
|
||||
|
106
accessible/tests/mochitest/tree/test_brokencontext.html
Normal file
106
accessible/tests/mochitest/tree/test_brokencontext.html
Normal file
@ -0,0 +1,106 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Broken context hierarchy</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="../states.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// HTML table elements outside table context.
|
||||
|
||||
ok(!isAccessible("tr_in_presentation_table"), "tr shouldn't be accessible");
|
||||
ok(!isAccessible("th_in_presentation_table"), "th shouldn't be accessible");
|
||||
ok(!isAccessible("td_in_presentation_table"), "td shouldn't be accessible");
|
||||
|
||||
var tree =
|
||||
{ PUSHBUTTON: [ // table
|
||||
{ NOTHING: [ // tbody
|
||||
{ NOTHING: [ // tr
|
||||
{ NOTHING: [ // th
|
||||
{ TEXT_LEAF: [ ] }
|
||||
] },
|
||||
{ NOTHING: [ // td
|
||||
{ TEXT_LEAF: [ ] }
|
||||
] }
|
||||
] },
|
||||
] },
|
||||
] };
|
||||
testAccessibleTree("button_table", tree);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Styled as HTML table elements, accessible is created by tag name
|
||||
|
||||
tree =
|
||||
{ LINK: [ // a
|
||||
{ TEXT_LEAF: [ ] }
|
||||
] };
|
||||
testAccessibleTree("a_as_td", tree);
|
||||
|
||||
tree =
|
||||
{ HEADING: [
|
||||
{ TEXT_LEAF: [ ] }
|
||||
] };
|
||||
testAccessibleTree("h1_as_td", tree);
|
||||
testAccessibleTree("h2_as_td", tree);
|
||||
testAccessibleTree("h3_as_td", tree);
|
||||
testAccessibleTree("h4_as_td", tree);
|
||||
testAccessibleTree("h5_as_td", tree);
|
||||
testAccessibleTree("h6_as_td", tree);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=706849"
|
||||
title="Create accessible by tag name as fallback if table descendant style is used out of table context">
|
||||
Mozilla Bug 706849
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<!-- HTML table elements out of table -->
|
||||
<table role="presentation">
|
||||
<tr id="tr_in_presentation_table">
|
||||
<th id="th_in_presentation_table">not a header</th>
|
||||
<td id="td_in_presentation_table">not a cell</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table role="button" id="button_table">
|
||||
<tr id="tr_in_button_table">
|
||||
<th id="th_in_button_table">not a header</th>
|
||||
<td id="td_in_button_table">not a cell</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- styled as HTML table elements -->
|
||||
<a id="a_as_td" style="display:table-cell;" href="http://www.google.com">Google</a>
|
||||
<h1 id="h1_as_td" style="display: table-cell;">h1</h1>
|
||||
<h2 id="h2_as_td" style="display: table-cell;">h2</h2>
|
||||
<h3 id="h3_as_td" style="display: table-cell;">h3</h3>
|
||||
<h4 id="h4_as_td" style="display: table-cell;">h4</h4>
|
||||
<h5 id="h5_as_td" style="display: table-cell;">h5</h5>
|
||||
<h6 id="h6_as_td" style="display: table-cell;">h6</h6>
|
||||
</body>
|
||||
</html>
|
@ -139,6 +139,7 @@
|
||||
] } ]
|
||||
};
|
||||
testAccessibleTree("table4", accTree);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user