Bug 1836823: If we create an Accessible for SVG <foreignObject> due to an ARIA role, etc., use a HyperTextAccessible. r=morgan

We don't normally create an Accessible for <foreignObject>.
However, if there's an ARIA role or similar, we forceably create one.
Previously, if we ever did this for an SVG element, we would use an AccessibleWrap, which doesn't support HyperText.
This is normally correct because most SVG elements can't contain text.
However, a <foreignObject> can most definitely contain text, so we must use HyperTextAccessible.
This fixes assertions and text attributes.

Differential Revision: https://phabricator.services.mozilla.com/D195387
This commit is contained in:
James Teh 2023-12-11 00:39:25 +00:00
Родитель 0f01c0dc05
Коммит 583b9dc159
2 изменённых файлов: 9 добавлений и 4 удалений

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

@ -1409,11 +1409,12 @@ LocalAccessible* nsAccessibilityService::CreateAccessible(
// accessibility property. If it's interesting we need it in the
// accessibility hierarchy so that events or other accessibles can point to
// it, or so that it can hold a state, etc.
if (content->IsHTMLElement() || content->IsMathMLElement()) {
// Interesting HTML/MathML container which may have selectable text and/or
// embedded objects
if (content->IsHTMLElement() || content->IsMathMLElement() ||
content->IsSVGElement(nsGkAtoms::foreignObject)) {
// Interesting container which may have selectable text and/or embedded
// objects.
newAcc = new HyperTextAccessible(content, document);
} else { // XUL, SVG, etc.
} else { // XUL, other SVG, etc.
// Interesting generic non-HTML container
newAcc = new AccessibleWrap(content, document);
}

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

@ -25,6 +25,9 @@
const aDefAttrs = buildDefaultTextAttrs(a, "10pt");
testTextAttrs(a, 0, {}, aDefAttrs, 0, 1);
const f3 = getNode("f3");
testTextAttrs(f3, 0, {}, defAttrs, 0, 2);
SimpleTest.finish();
}
@ -46,6 +49,7 @@
<foreignobject>f2</foreignobject>
</g>
<text><a href="#" id="a">a</a></text>
<foreignobject id="f3" role="button"><body>f3</body></foreignobject>
</svg>
</body>