зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
99afe5c014
Коммит
d2615d1719
|
@ -137,19 +137,6 @@ bool nsAccUtils::HasDefinedARIAToken(nsIContent* aContent, nsAtom* aAtom) {
|
||||||
return true;
|
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,
|
nsStaticAtom* nsAccUtils::NormalizeARIAToken(dom::Element* aElement,
|
||||||
nsAtom* aAttr) {
|
nsAtom* aAttr) {
|
||||||
if (!HasDefinedARIAToken(aElement, aAttr)) {
|
if (!HasDefinedARIAToken(aElement, aAttr)) {
|
||||||
|
@ -167,6 +154,14 @@ nsStaticAtom* nsAccUtils::NormalizeARIAToken(dom::Element* aElement,
|
||||||
return (idx >= 0) ? tokens[idx] : nsGkAtoms::_true;
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,12 +60,6 @@ class nsAccUtils {
|
||||||
*/
|
*/
|
||||||
static bool HasDefinedARIAToken(nsIContent* aContent, nsAtom* aAtom);
|
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 given ARIA attribute has a specific known token value, return it.
|
||||||
* If the specification demands for a fallback value for unknown attribute
|
* If the specification demands for a fallback value for unknown attribute
|
||||||
|
|
Загрузка…
Ссылка в новой задаче