forked from mirrors/gecko-dev
Bug 1887789 part 3: Implement the UIA LocalizedLandmarkType property. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D209101
This commit is contained in:
parent
10a98f4e5f
commit
4ca5cb765e
4 changed files with 106 additions and 0 deletions
|
|
@ -387,3 +387,69 @@ addUiaTask(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the LocalizedLandmarkType property.
|
||||||
|
*/
|
||||||
|
addUiaTask(
|
||||||
|
`
|
||||||
|
<div id="main" role="main">main</div>
|
||||||
|
<div id="contentinfo" role="contentinfo">contentinfo</div>
|
||||||
|
<div id="region" role="region" aria-label="region">region</div>
|
||||||
|
<div id="unnamedRegion" role="region">unnamedRegion</div>
|
||||||
|
<main id="mainBanner" role="banner">mainBanner</main>
|
||||||
|
<div id="none">none</div>
|
||||||
|
`,
|
||||||
|
async function testLocalizedLandmarkType() {
|
||||||
|
await definePyVar("doc", `getDocUia()`);
|
||||||
|
// Provided by the system.
|
||||||
|
is(
|
||||||
|
await runPython(
|
||||||
|
`findUiaByDomId(doc, "main").CurrentLocalizedLandmarkType`
|
||||||
|
),
|
||||||
|
"main",
|
||||||
|
"main has correct LocalizedLandmarkType"
|
||||||
|
);
|
||||||
|
// The IA2 -> UIA proxy doesn't follow the Core AAM spec for this role.
|
||||||
|
if (gIsUiaEnabled) {
|
||||||
|
// Provided by us.
|
||||||
|
is(
|
||||||
|
await runPython(
|
||||||
|
`findUiaByDomId(doc, "contentinfo").CurrentLocalizedLandmarkType`
|
||||||
|
),
|
||||||
|
"content information",
|
||||||
|
"contentinfo has correct LocalizedLandmarkType"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
is(
|
||||||
|
await runPython(
|
||||||
|
`findUiaByDomId(doc, "region").CurrentLocalizedLandmarkType`
|
||||||
|
),
|
||||||
|
"region",
|
||||||
|
"region has correct LocalizedLandmarkType"
|
||||||
|
);
|
||||||
|
// Invalid landmark.
|
||||||
|
is(
|
||||||
|
await runPython(
|
||||||
|
`findUiaByDomId(doc, "unnamedRegion").CurrentLocalizedLandmarkType`
|
||||||
|
),
|
||||||
|
"",
|
||||||
|
"unnamedRegion has correct LocalizedLandmarkType"
|
||||||
|
);
|
||||||
|
// ARIA role takes precedence.
|
||||||
|
is(
|
||||||
|
await runPython(
|
||||||
|
`findUiaByDomId(doc, "mainBanner").CurrentLocalizedLandmarkType`
|
||||||
|
),
|
||||||
|
"banner",
|
||||||
|
"mainBanner has correct LocalizedLandmarkType"
|
||||||
|
);
|
||||||
|
is(
|
||||||
|
await runPython(
|
||||||
|
`findUiaByDomId(doc, "none").CurrentLocalizedLandmarkType`
|
||||||
|
),
|
||||||
|
"",
|
||||||
|
"none has correct LocalizedLandmarkType"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -649,6 +649,17 @@ uiaRawElmProvider::GetPropertyValue(PROPERTYID aPropertyId,
|
||||||
aPropertyValue->lVal = acc->GroupPosition().level;
|
aPropertyValue->lVal = acc->GroupPosition().level;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
|
case UIA_LocalizedLandmarkTypePropertyId: {
|
||||||
|
nsAutoString landmark;
|
||||||
|
GetLocalizedLandmarkType(landmark);
|
||||||
|
if (!landmark.IsEmpty()) {
|
||||||
|
aPropertyValue->vt = VT_BSTR;
|
||||||
|
aPropertyValue->bstrVal = ::SysAllocString(landmark.get());
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case UIA_NamePropertyId: {
|
case UIA_NamePropertyId: {
|
||||||
nsAutoString name;
|
nsAutoString name;
|
||||||
acc->Name(name);
|
acc->Name(name);
|
||||||
|
|
@ -1366,6 +1377,23 @@ long uiaRawElmProvider::GetLandmarkType() const {
|
||||||
return UIA_CustomLandmarkTypeId;
|
return UIA_CustomLandmarkTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiaRawElmProvider::GetLocalizedLandmarkType(nsAString& aLocalized) const {
|
||||||
|
Accessible* acc = Acc();
|
||||||
|
MOZ_ASSERT(acc);
|
||||||
|
nsStaticAtom* landmark = acc->LandmarkRole();
|
||||||
|
// The system provides strings for landmarks explicitly supported by the UIA
|
||||||
|
// LandmarkType property; i.e. form, main, navigation and search. We must
|
||||||
|
// provide strings for landmarks considered custom by UIA. For now, we only
|
||||||
|
// support landmarks in the core ARIA specification, not other ARIA modules
|
||||||
|
// such as DPub.
|
||||||
|
if (landmark == nsGkAtoms::banner || landmark == nsGkAtoms::complementary ||
|
||||||
|
landmark == nsGkAtoms::contentinfo || landmark == nsGkAtoms::region) {
|
||||||
|
nsAutoString unlocalized;
|
||||||
|
landmark->ToString(unlocalized);
|
||||||
|
Accessible::TranslateString(unlocalized, aLocalized);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SAFEARRAY* a11y::AccessibleArrayToUiaArray(const nsTArray<Accessible*>& aAccs) {
|
SAFEARRAY* a11y::AccessibleArrayToUiaArray(const nsTArray<Accessible*>& aAccs) {
|
||||||
if (aAccs.IsEmpty()) {
|
if (aAccs.IsEmpty()) {
|
||||||
// The UIA documentation is unclear about this, but the UIA client
|
// The UIA documentation is unclear about this, but the UIA client
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|
||||||
|
#include "nsString.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class nsTArray;
|
class nsTArray;
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
@ -193,6 +195,7 @@ class uiaRawElmProvider : public IAccessibleEx,
|
||||||
std::initializer_list<RelationType> aTypes) const;
|
std::initializer_list<RelationType> aTypes) const;
|
||||||
Accessible* GetLabeledBy() const;
|
Accessible* GetLabeledBy() const;
|
||||||
long GetLandmarkType() const;
|
long GetLandmarkType() const;
|
||||||
|
void GetLocalizedLandmarkType(nsAString& aLocalized) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
SAFEARRAY* AccessibleArrayToUiaArray(const nsTArray<Accessible*>& aAccs);
|
SAFEARRAY* AccessibleArrayToUiaArray(const nsTArray<Accessible*>& aAccs);
|
||||||
|
|
|
||||||
|
|
@ -19,3 +19,12 @@ cycle = Cycle
|
||||||
# them to click an element when the click will be handled by a container
|
# them to click an element when the click will be handled by a container
|
||||||
# (ancestor) element. This is not normally reported to users.
|
# (ancestor) element. This is not normally reported to users.
|
||||||
click ancestor = Click ancestor
|
click ancestor = Click ancestor
|
||||||
|
|
||||||
|
# These messages are reported by accessibility clients such as screen readers to
|
||||||
|
# indicate landmarks, which are significant sections of a document to which
|
||||||
|
# users might want to navigate quickly. See this page for more information:
|
||||||
|
# https://www.w3.org/WAI/ARIA/apg/patterns/landmarks/examples/general-principles.html
|
||||||
|
banner = banner
|
||||||
|
complementary = complementary
|
||||||
|
contentinfo = content information
|
||||||
|
region = region
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue