Bug 1676344 - Treat TEXT_CONTAINER accessibles between tables and table rows, as well as table rows and cells, as presentational, r=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D96532
This commit is contained in:
Marco Zehe 2020-11-10 22:52:34 +00:00
Родитель ccd859ffae
Коммит 1c9ba3438f
3 изменённых файлов: 89 добавлений и 2 удалений

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

@ -1467,14 +1467,20 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
case eHTMLTextFieldType: case eHTMLTextFieldType:
newAcc = new HTMLTextFieldAccessible(aContent, document); newAcc = new HTMLTextFieldAccessible(aContent, document);
break; break;
case eHyperTextType: case eHyperTextType: {
if (aContext->IsTable() || aContext->IsTableRow()) {
// This is some generic hyperText, for example a block frame element
// inserted between a table and table row. Treat it as presentational.
return nullptr;
}
if (!aContent->IsAnyOfHTMLElements(nsGkAtoms::dt, nsGkAtoms::dd, if (!aContent->IsAnyOfHTMLElements(nsGkAtoms::dt, nsGkAtoms::dd,
nsGkAtoms::div, nsGkAtoms::thead, nsGkAtoms::div, nsGkAtoms::thead,
nsGkAtoms::tfoot, nsGkAtoms::tbody)) { nsGkAtoms::tfoot, nsGkAtoms::tbody)) {
newAcc = new HyperTextAccessibleWrap(aContent, document); newAcc = new HyperTextAccessibleWrap(aContent, document);
} }
break; break;
}
case eImageType: case eImageType:
newAcc = new ImageAccessibleWrap(aContent, document); newAcc = new ImageAccessibleWrap(aContent, document);
break; break;

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

@ -189,6 +189,30 @@
testAccessibleTree("whitespaces-grid", accTree); testAccessibleTree("whitespaces-grid", accTree);
// grids that could contain text container accessibles but shouldn't.
accTree =
{ TABLE: [
{ ROW: [
{ GRID_CELL: [
{ TEXT_LEAF: [ ] },
] },
{ GRID_CELL: [
{ TEXT_LEAF: [ ] },
] },
] },
{ ROW: [
{ GRID_CELL: [
{ TEXT_LEAF: [ ] },
] },
{ GRID_CELL: [
{ TEXT_LEAF: [ ] },
] },
] },
] };
testAccessibleTree("gridWithPresentationalBlockElement", accTree);
SimpleTest.finish(); SimpleTest.finish();
} }
@ -273,5 +297,22 @@
<span role="gridcell">a user1</span> <span role="gridcell">a user1</span>
</div> </div>
</div> </div>
<div id="gridWithPresentationalBlockElement" role="grid">
<span style="display: block;">
<div role="row">
<div role="gridcell">Cell 1</div>
<div role="gridcell">Cell 2</div>
</div>
</span>
<span style="display: block;">
<div role="row">
<span style="display: block;">
<div role="gridcell">Cell 3</div>
<div role="gridcell">Cell 4</div>
</span>
</div>
</span>
</div>
</body> </body>
</html> </html>

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

@ -30,6 +30,30 @@
testAccessibleTree("table", accTree); testAccessibleTree("table", accTree);
// tables that could contain text container accessibles but shouldn't.
accTree =
{ TABLE: [
{ ROW: [
{ CELL: [
{ TEXT_LEAF: [ ] },
] },
{ CELL: [
{ TEXT_LEAF: [ ] },
] },
] },
{ ROW: [
{ CELL: [
{ TEXT_LEAF: [ ] },
] },
{ CELL: [
{ TEXT_LEAF: [ ] },
] },
] },
] };
testAccessibleTree("tableWithPresentationalBlockElement", accTree);
SimpleTest.finish(); SimpleTest.finish();
} }
@ -57,5 +81,21 @@
</div> </div>
</div> </div>
<div id="tableWithPresentationalBlockElement" role="table">
<span style="display: block;">
<div role="row">
<div role="cell">Cell 1</div>
<div role="cell">Cell 2</div>
</div>
</span>
<span style="display: block;">
<div role="row">
<span style="display: block;">
<div role="cell">Cell 3</div>
<div role="cell">Cell 4</div>
</span>
</div>
</span>
</div>
</body> </body>
</html> </html>