commit f4a05b1359c5578967674126a5c8612481aef095
parent bbd365ae272c7f3968435df535b4e8b42a101523
Author: Eitan Isaacson <eitan@monotonous.org>
Date: Wed, 19 Nov 2025 23:45:21 +0000
Bug 1998255 - P3: Return eNameFromRelations when name was exclusively calculated from relations. r=morgan
In the case of a file input, never return eNameFromRelations in order to
force a cache of the name.
Depends on D272726
Differential Revision: https://phabricator.services.mozilla.com/D272727
Diffstat:
3 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp
@@ -2596,12 +2596,12 @@ ENameValueFlag LocalAccessible::ARIAName(nsString& aName) const {
return eNameOK;
}
// aria-labelledby now takes precedence over aria-label
- nsTextEquivUtils::GetTextEquivFromIDRefs(this, nsGkAtoms::aria_labelledby,
- aName);
+ bool usedHiddenContent = nsTextEquivUtils::GetTextEquivFromIDRefs(
+ this, nsGkAtoms::aria_labelledby, aName);
aName.CompressWhitespace();
if (!aName.IsEmpty()) {
- return eNameFromRelations;
+ return usedHiddenContent ? eNameOK : eNameFromRelations;
}
if (mContent->IsElement() &&
@@ -2663,14 +2663,15 @@ ENameValueFlag LocalAccessible::NativeName(nsString& aName) const {
if (mContent->IsHTMLElement()) {
LocalAccessible* label = nullptr;
HTMLLabelIterator iter(Document(), this);
+ bool usedHiddenContent = false;
while ((label = iter.Next())) {
- nsTextEquivUtils::AppendTextEquivFromContent(this, label->GetContent(),
- &aName);
+ usedHiddenContent |= nsTextEquivUtils::AppendTextEquivFromContent(
+ this, label->GetContent(), &aName);
aName.CompressWhitespace();
}
if (!aName.IsEmpty()) {
- return eNameFromRelations;
+ return usedHiddenContent ? eNameOK : eNameFromRelations;
}
NameFromAssociatedXULLabel(mDoc, mContent, aName);
diff --git a/accessible/html/HTMLFormControlAccessible.cpp b/accessible/html/HTMLFormControlAccessible.cpp
@@ -539,7 +539,11 @@ ENameValueFlag HTMLFileInputAccessible::DirectName(nsString& aName) const {
}
aName += leaf->Text();
}
- return flag;
+
+ // XXX: Return eNameOK even if we got the name from a label or subtree. This
+ // is to force us to cache the name, since the calculation of this type is out
+ // of spec and pretty nuanced.
+ return eNameOK;
}
bool HTMLFileInputAccessible::HasPrimaryAction() const { return true; }
@@ -683,11 +687,15 @@ ENameValueFlag HTMLGroupboxAccessible::NativeName(nsString& aName) const {
nsIContent* legendContent = GetLegend();
if (legendContent) {
- nsTextEquivUtils::AppendTextEquivFromContent(this, legendContent, &aName);
+ bool usedHiddenContent = nsTextEquivUtils::AppendTextEquivFromContent(
+ this, legendContent, &aName);
+ aName.CompressWhitespace();
+ if (!usedHiddenContent && !aName.IsEmpty()) {
+ return eNameFromRelations;
+ }
}
- aName.CompressWhitespace();
- return aName.IsEmpty() ? eNameOK : eNameFromRelations;
+ return eNameOK;
}
Relation HTMLGroupboxAccessible::RelationByType(RelationType aType) const {
@@ -732,11 +740,15 @@ ENameValueFlag HTMLFigureAccessible::NativeName(nsString& aName) const {
nsIContent* captionContent = Caption();
if (captionContent) {
- nsTextEquivUtils::AppendTextEquivFromContent(this, captionContent, &aName);
+ bool usedHiddenContent = nsTextEquivUtils::AppendTextEquivFromContent(
+ this, captionContent, &aName);
+ aName.CompressWhitespace();
+ if (!usedHiddenContent && !aName.IsEmpty()) {
+ return eNameFromRelations;
+ }
}
- aName.CompressWhitespace();
- return aName.IsEmpty() ? eNameOK : eNameFromRelations;
+ return eNameOK;
}
Relation HTMLFigureAccessible::RelationByType(RelationType aType) const {
diff --git a/accessible/html/HTMLTableAccessible.cpp b/accessible/html/HTMLTableAccessible.cpp
@@ -314,10 +314,11 @@ ENameValueFlag HTMLTableAccessible::NativeName(nsString& aName) const {
if (caption) {
nsIContent* captionContent = caption->GetContent();
if (captionContent) {
- nsTextEquivUtils::AppendTextEquivFromContent(this, captionContent,
- &aName);
+ bool usedHiddenContent = nsTextEquivUtils::AppendTextEquivFromContent(
+ this, captionContent, &aName);
+ aName.CompressWhitespace();
if (!aName.IsEmpty()) {
- return eNameFromRelations;
+ return usedHiddenContent ? eNameOK : eNameFromRelations;
}
}
}