From cf3391de9afc147da1268cb85dfe5cb002c513fa Mon Sep 17 00:00:00 2001 From: James Teh Date: Tue, 9 Mar 2021 00:27:44 +0000 Subject: [PATCH] Bug 1686123: Fall back to ARIAGrid*Accessible for HTML table/tbody/thead/tr/td/th elements with no frame. r=morgan display: contents means there is no frame, which means we can't use HTMLTable*Accessible. However, we can (and should) use ARIAGrid*Accessible in this case. Differential Revision: https://phabricator.services.mozilla.com/D107407 --- accessible/base/MarkupMap.h | 19 ++++++----- .../mochitest/tree/test_display_contents.html | 32 +++++++++++++++++++ 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/accessible/base/MarkupMap.h b/accessible/base/MarkupMap.h index 3aea3361baaa..fddef535a593 100644 --- a/accessible/base/MarkupMap.h +++ b/accessible/base/MarkupMap.h @@ -450,7 +450,7 @@ MARKUPMAP( MARKUPMAP( table, [](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { - if (aElement->GetPrimaryFrame() && + if (!aElement->GetPrimaryFrame() || aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableType) { return new ARIAGridAccessibleWrap(aElement, aContext->Document()); } @@ -488,10 +488,9 @@ MARKUPMAP( // cell accessible, because there's no underlying table layout and // thus native HTML table cell class doesn't work. The same is // true if the cell itself has CSS display:block;. - if (!aContext->IsHTMLTableRow() || - (aElement->GetPrimaryFrame() && - aElement->GetPrimaryFrame()->AccessibleType() != - eHTMLTableCellType)) { + if (!aContext->IsHTMLTableRow() || !aElement->GetPrimaryFrame() || + aElement->GetPrimaryFrame()->AccessibleType() != + eHTMLTableCellType) { return new ARIAGridCellAccessibleWrap(aElement, aContext->Document()); } if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) { @@ -538,14 +537,14 @@ MARKUPMAP( if (table) { nsIContent* parentContent = aElement->GetParent(); nsIFrame* parentFrame = parentContent->GetPrimaryFrame(); - if (parentFrame && !parentFrame->IsTableWrapperFrame()) { + if (!parentFrame || !parentFrame->IsTableWrapperFrame()) { parentContent = parentContent->GetParent(); parentFrame = parentContent->GetPrimaryFrame(); if (table->GetContent() == parentContent && - ((parentFrame && !parentFrame->IsTableWrapperFrame()) || - (aElement->GetPrimaryFrame() && - aElement->GetPrimaryFrame()->AccessibleType() != - eHTMLTableRowType))) { + ((!parentFrame || !parentFrame->IsTableWrapperFrame()) || + !aElement->GetPrimaryFrame() || + aElement->GetPrimaryFrame()->AccessibleType() != + eHTMLTableRowType)) { return new ARIARowAccessible(aElement, aContext->Document()); } } diff --git a/accessible/tests/mochitest/tree/test_display_contents.html b/accessible/tests/mochitest/tree/test_display_contents.html index 371146e5ebc7..2cf60ce72aa0 100644 --- a/accessible/tests/mochitest/tree/test_display_contents.html +++ b/accessible/tests/mochitest/tree/test_display_contents.html @@ -28,6 +28,18 @@ function doTest() { ] }; testAccessibleTree("ul", tree); + tree = + { TABLE: [ + { ROW: [ + { CELL: [{ TEXT_LEAF: [] } ] }, + { CELL: [{ TEXT_LEAF: [] } ] }, + ]}, + ] }; + testAccessibleTree("tableTableContents", tree); + testAccessibleTree("tableTbodyContents", tree); + testAccessibleTree("tableTrContents", tree); + testAccessibleTree("tableTdContents", tree); + SimpleTest.finish(); } @@ -45,5 +57,25 @@ addA11yLoadEvent(doTest);
  • Supermarket 1
  • Supermarket 2
  • + + + + +
    ab
    + + + + +
    ab
    + + +
    ab
    + + + + + +
    ab