From 1c9ba3438f2777336b8347699bfcdff8feb254e1 Mon Sep 17 00:00:00 2001 From: Marco Zehe Date: Tue, 10 Nov 2020 22:52:34 +0000 Subject: [PATCH] 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 --- accessible/base/nsAccessibilityService.cpp | 10 ++++- .../tests/mochitest/tree/test_aria_grid.html | 41 +++++++++++++++++++ .../tests/mochitest/tree/test_aria_table.html | 40 ++++++++++++++++++ 3 files changed, 89 insertions(+), 2 deletions(-) diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index ed904e81999e..1f9048f63263 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -1467,14 +1467,20 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame, case eHTMLTextFieldType: newAcc = new HTMLTextFieldAccessible(aContent, document); 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, nsGkAtoms::div, nsGkAtoms::thead, nsGkAtoms::tfoot, nsGkAtoms::tbody)) { newAcc = new HyperTextAccessibleWrap(aContent, document); } break; - + } case eImageType: newAcc = new ImageAccessibleWrap(aContent, document); break; diff --git a/accessible/tests/mochitest/tree/test_aria_grid.html b/accessible/tests/mochitest/tree/test_aria_grid.html index 63b0e89c76d1..80ff97095b8b 100644 --- a/accessible/tests/mochitest/tree/test_aria_grid.html +++ b/accessible/tests/mochitest/tree/test_aria_grid.html @@ -189,6 +189,30 @@ 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(); } @@ -273,5 +297,22 @@ a user1 + +
+ +
+
Cell 1
+
Cell 2
+
+
+ +
+ +
Cell 3
+
Cell 4
+
+
+
+
diff --git a/accessible/tests/mochitest/tree/test_aria_table.html b/accessible/tests/mochitest/tree/test_aria_table.html index e3b47468663f..22375faf5917 100644 --- a/accessible/tests/mochitest/tree/test_aria_table.html +++ b/accessible/tests/mochitest/tree/test_aria_table.html @@ -30,6 +30,30 @@ 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(); } @@ -57,5 +81,21 @@ +
+ +
+
Cell 1
+
Cell 2
+
+
+ +
+ +
Cell 3
+
Cell 4
+
+
+
+