Bug 1796733 part 5: Add an overload of nsAccUtils::NormalizeARIAToken which takes an Element. r=avandolder

The next patch in this stack adds a method to retrieve aria-selected.
The easiest way to do this is using NormalizeARIAToken.
This overload takes an Element and checks both the Element and ElementInternals.

Differential Revision: https://phabricator.services.mozilla.com/D161241
This commit is contained in:
James Teh 2022-11-10 04:19:27 +00:00
Родитель 89c3a37a29
Коммит 78587c97ba
2 изменённых файлов: 15 добавлений и 0 удалений

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

@ -176,6 +176,19 @@ nsStaticAtom* nsAccUtils::NormalizeARIAToken(const AttrArray* aAttrs,
return nullptr;
}
nsStaticAtom* nsAccUtils::NormalizeARIAToken(dom::Element* aElement,
nsAtom* aAttr) {
if (auto* htmlElement = nsGenericHTMLElement::FromNode(aElement);
htmlElement && !aElement->HasAttr(aAttr)) {
const auto* defaults = GetARIADefaults(htmlElement);
if (!defaults) {
return nsGkAtoms::_empty;
}
return NormalizeARIAToken(defaults, aAttr);
}
return NormalizeARIAToken(&aElement->GetAttrs(), aAttr);
}
Accessible* nsAccUtils::GetSelectableContainer(const Accessible* aAccessible,
uint64_t aState) {
if (!aAccessible) return nullptr;

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

@ -68,6 +68,8 @@ class nsAccUtils {
*/
static nsStaticAtom* NormalizeARIAToken(const AttrArray* aAttrs,
nsAtom* aAttr);
static nsStaticAtom* NormalizeARIAToken(mozilla::dom::Element* aElement,
nsAtom* aAttr);
/**
* Return document accessible for the given DOM node.