Bug 1545190 - Allow table in host and row in shadow. r=Jamie a=pascalc
Differential Revision:
https://phabricator.services.mozilla.com/D27993
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -1388,24 +1388,29 @@ nsAccessibilityService::CreateAccessible
case eHTMLTableRowType: {
// Accessible HTML table row may be a child of tbody/tfoot/thead of
// accessible HTML table or a direct child of accessible of HTML table.
Accessible* table = aContext->IsTable() ? aContext : nullptr;
if (!table && aContext->Parent() && aContext->Parent()->IsTable())
table = aContext->Parent();
if (table) {
- nsIContent* parentContent = aContent->GetParent();
- nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
- if (!parentFrame->IsTableWrapperFrame()) {
- parentContent = parentContent->GetParent();
+ nsIContent* parentContent = aContent->GetParentOrHostNode()->AsContent();
+ nsIFrame* parentFrame = nullptr;
+ if (parentContent) {
parentFrame = parentContent->GetPrimaryFrame();
+ if (!parentFrame || !parentFrame->IsTableWrapperFrame()) {
+ parentContent = parentContent->GetParentOrHostNode()->AsContent();
+ if (parentContent) {
+ parentFrame = parentContent->GetPrimaryFrame();
+ }
+ }
}
- if (parentFrame->IsTableWrapperFrame() &&
+ if (parentFrame && parentFrame->IsTableWrapperFrame() &&
table->GetContent() == parentContent) {
newAcc = new HTMLTableRowAccessible(aContent, document);
}
}
break;
}
case eHTMLTextFieldType:
newAcc = new HTMLTextFieldAccessible(aContent, document);
--- a/accessible/tests/mochitest/elm/test_shadowroot_subframe.html
+++ b/accessible/tests/mochitest/elm/test_shadowroot_subframe.html
@@ -19,32 +19,50 @@
role: ROLE_PUSHBUTTON,
},
{
role: ROLE_LINK,
},
],
});
+ // Shadow root boundary between table and row
+ testElm("table", {
+ role: ROLE_TABLE,
+ children: [
+ {
+ role: ROLE_ROW,
+ },
+ ],
+ });
+
SimpleTest.finish();
}
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<div role="group" id="component"></div>
+ <div id="table" role="table" style="display: table;"></div>
+
<script>
var component = document.getElementById("component");
var shadow = component.attachShadow({mode: "open"});
var button = document.createElement("button");
button.append("Hello");
var a = document.createElement("a");
a.setAttribute("href", "#");
a.append(" World");
shadow.appendChild(button);
shadow.appendChild(a);
+
+ var table = document.getElementById("table");
+ shadow = table.attachShadow({mode: "open"});
+ shadow.innerHTML = "<div style='display: table-row'>" +
+ "<div style='display: table-cell'>hi</div>" +
+ "</div>";
</script>
</body>