Bug 1678712 - Support AXLangauge. r=morgan

The important part here is to have the text leafs inherit their parents' language.

Differential Revision: https://phabricator.services.mozilla.com/D212604
This commit is contained in:
Eitan Isaacson
2024-06-11 19:41:20 +00:00
parent d2ad11815f
commit 872a6b8ba9
4 changed files with 33 additions and 0 deletions

View File

@@ -338,6 +338,9 @@
// AXPlaceholderValue
- (NSString* _Nullable)moxPlaceholderValue;
// AXLanguage
- (NSString* _Nullable)moxLanguage;
// AXMozDebugDescription
- (NSString* _Nullable)moxMozDebugDescription;

View File

@@ -245,6 +245,9 @@ enum CheckedState {
// override
- (id)moxFocusableAncestor;
// override
- (NSString*)moxLanguage;
#ifndef RELEASE_OR_BETA
// override
- (NSString*)moxMozDebugDescription;

View File

@@ -757,6 +757,15 @@ struct RoleDescrComparator {
return [self moxEditableAncestor];
}
- (NSString*)moxLanguage {
MOZ_ASSERT(mGeckoAccessible);
nsAutoString lang;
mGeckoAccessible->Language(lang);
return nsCocoaUtils::ToNSString(lang);
}
#ifndef RELEASE_OR_BETA
- (NSString*)moxMozDebugDescription {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;

View File

@@ -85,3 +85,21 @@ addAccessibleTask(
},
{ chrome: true, iframe: true, remoteIframe: true }
);
// Text leaf inherits container's AXLanguage, and container's default AXLanguage is the doc one.
addAccessibleTask(
`<p id="ar">العربية</p>
<p id="es" lang="es">Español</p>`,
async (browser, accDoc) => {
const es = getNativeInterface(accDoc, "es");
const ar = getNativeInterface(accDoc, "ar");
const firstChild = a => a.getAttributeValue("AXChildren")[0];
is(es.getAttributeValue("AXLanguage"), "es");
is(firstChild(es).getAttributeValue("AXLanguage"), "es");
is(ar.getAttributeValue("AXLanguage"), "ar");
is(firstChild(ar).getAttributeValue("AXLanguage"), "ar");
},
{ chrome: true, contentDocBodyAttrs: { lang: "ar" } }
);