Bug 1757121 part 3: Normalize true/false/mixed ARIA tokens to atoms. r=morgan

This will be needed for easier checking of aria-atomic.
It is also more efficient in terms of cache storage, since we previously pushed strings for these values.
This moves the code from GetARIAToken into NormalizeARIAToken, since GetARIAToken isn't used any more and it makes sense to handle normalization in one place.

Differential Revision: https://phabricator.services.mozilla.com/D150379
This commit is contained in:
James Teh 2022-07-12 02:45:57 +00:00
Родитель 99afe5c014
Коммит d2615d1719
2 изменённых файлов: 8 добавлений и 19 удалений

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

@ -137,19 +137,6 @@ bool nsAccUtils::HasDefinedARIAToken(nsIContent* aContent, nsAtom* aAtom) {
return true;
}
nsStaticAtom* nsAccUtils::GetARIAToken(dom::Element* aElement, nsAtom* aAttr) {
if (!HasDefinedARIAToken(aElement, aAttr)) return nsGkAtoms::_empty;
static dom::Element::AttrValuesArray tokens[] = {
nsGkAtoms::_false, nsGkAtoms::_true, nsGkAtoms::mixed, nullptr};
int32_t idx =
aElement->FindAttrValueIn(kNameSpaceID_None, aAttr, tokens, eCaseMatters);
if (idx >= 0) return tokens[idx];
return nullptr;
}
nsStaticAtom* nsAccUtils::NormalizeARIAToken(dom::Element* aElement,
nsAtom* aAttr) {
if (!HasDefinedARIAToken(aElement, aAttr)) {
@ -167,6 +154,14 @@ nsStaticAtom* nsAccUtils::NormalizeARIAToken(dom::Element* aElement,
return (idx >= 0) ? tokens[idx] : nsGkAtoms::_true;
}
static dom::Element::AttrValuesArray tokens[] = {
nsGkAtoms::_false, nsGkAtoms::_true, nsGkAtoms::mixed, nullptr};
int32_t idx =
aElement->FindAttrValueIn(kNameSpaceID_None, aAttr, tokens, eCaseMatters);
if (idx >= 0) {
return tokens[idx];
}
return nullptr;
}

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

@ -60,12 +60,6 @@ class nsAccUtils {
*/
static bool HasDefinedARIAToken(nsIContent* aContent, nsAtom* aAtom);
/**
* Return atomic value of ARIA attribute of boolean or NMTOKEN type.
*/
static nsStaticAtom* GetARIAToken(mozilla::dom::Element* aElement,
nsAtom* aAttr);
/**
* If the given ARIA attribute has a specific known token value, return it.
* If the specification demands for a fallback value for unknown attribute