tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit dbe3c2b95412f2849fbcc3f18e0557663115b020
parent f30cc8c2c8553665a04cf9a5cc03bf599bc810f6
Author: Eitan Isaacson <eitan@monotonous.org>
Date:   Fri, 21 Nov 2025 06:38:07 +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:
Maccessible/generic/LocalAccessible.cpp | 13+++++++------
Maccessible/html/HTMLFormControlAccessible.cpp | 26+++++++++++++++++++-------
Maccessible/html/HTMLTableAccessible.cpp | 7++++---
3 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp @@ -2601,12 +2601,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() && @@ -2668,14 +2668,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; } } }