зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1755817 - Move LandmarkRole to Accessible. r=Jamie
Current mochitests should prove the soundness of this. The only thing preventing this from becoming a non-virtual method is the reliance on TagName which is only available when cached is enabled. When it is disabled we need to fallback on the sync IPDL call. Differential Revision: https://phabricator.services.mozilla.com/D138964
This commit is contained in:
Родитель
cedb598cc3
Коммит
4fb238b0ec
|
@ -321,3 +321,56 @@ const Accessible* Accessible::ActionAncestor() const {
|
|||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsAtom* Accessible::LandmarkRole() const {
|
||||
nsAtom* tagName = TagName();
|
||||
if (!tagName) {
|
||||
// Either no associated content, or no cache.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (tagName == nsGkAtoms::nav) {
|
||||
return nsGkAtoms::navigation;
|
||||
}
|
||||
|
||||
if (tagName == nsGkAtoms::aside) {
|
||||
return nsGkAtoms::complementary;
|
||||
}
|
||||
|
||||
if (tagName == nsGkAtoms::main) {
|
||||
return nsGkAtoms::main;
|
||||
}
|
||||
|
||||
if (tagName == nsGkAtoms::header) {
|
||||
if (Role() == roles::LANDMARK) {
|
||||
return nsGkAtoms::banner;
|
||||
}
|
||||
}
|
||||
|
||||
if (tagName == nsGkAtoms::footer) {
|
||||
if (Role() == roles::LANDMARK) {
|
||||
return nsGkAtoms::contentinfo;
|
||||
}
|
||||
}
|
||||
|
||||
if (tagName == nsGkAtoms::section) {
|
||||
nsAutoString name;
|
||||
Name(name);
|
||||
if (!name.IsEmpty()) {
|
||||
return nsGkAtoms::region;
|
||||
}
|
||||
}
|
||||
|
||||
if (tagName == nsGkAtoms::form) {
|
||||
nsAutoString name;
|
||||
Name(name);
|
||||
if (!name.IsEmpty()) {
|
||||
return nsGkAtoms::form;
|
||||
}
|
||||
}
|
||||
|
||||
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
||||
return roleMapEntry && roleMapEntry->IsOfType(eLandmark)
|
||||
? roleMapEntry->roleAtom
|
||||
: nullptr;
|
||||
}
|
||||
|
|
|
@ -229,6 +229,11 @@ class Accessible {
|
|||
*/
|
||||
virtual nsAtom* TagName() const = 0;
|
||||
|
||||
/**
|
||||
* Return a landmark role if applied.
|
||||
*/
|
||||
virtual nsAtom* LandmarkRole() const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// ActionAccessible
|
||||
|
||||
|
|
|
@ -1427,26 +1427,6 @@ already_AddRefed<AccAttributes> HyperTextAccessible::NativeAttributes() {
|
|||
return attributes.forget();
|
||||
}
|
||||
|
||||
nsAtom* HyperTextAccessible::LandmarkRole() const {
|
||||
if (!HasOwnContent()) return nullptr;
|
||||
|
||||
// For the html landmark elements we expose them like we do ARIA landmarks to
|
||||
// make AT navigation schemes "just work".
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::nav)) {
|
||||
return nsGkAtoms::navigation;
|
||||
}
|
||||
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::aside)) {
|
||||
return nsGkAtoms::complementary;
|
||||
}
|
||||
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::main)) {
|
||||
return nsGkAtoms::main;
|
||||
}
|
||||
|
||||
return AccessibleWrap::LandmarkRole();
|
||||
}
|
||||
|
||||
int32_t HyperTextAccessible::OffsetAtPoint(int32_t aX, int32_t aY,
|
||||
uint32_t aCoordType) {
|
||||
nsIFrame* hyperFrame = GetFrame();
|
||||
|
|
|
@ -50,7 +50,6 @@ class HyperTextAccessible : public AccessibleWrap,
|
|||
NS_INLINE_DECL_REFCOUNTING_INHERITED(HyperTextAccessible, AccessibleWrap)
|
||||
|
||||
// LocalAccessible
|
||||
virtual nsAtom* LandmarkRole() const override;
|
||||
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
|
||||
virtual mozilla::a11y::role NativeRole() const override;
|
||||
virtual uint64_t NativeState() const override;
|
||||
|
|
|
@ -1804,13 +1804,6 @@ role LocalAccessible::ARIATransformRole(role aRole) const {
|
|||
return aRole;
|
||||
}
|
||||
|
||||
nsAtom* LocalAccessible::LandmarkRole() const {
|
||||
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
||||
return roleMapEntry && roleMapEntry->IsOfType(eLandmark)
|
||||
? roleMapEntry->roleAtom
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
role LocalAccessible::NativeRole() const { return roles::NOTHING; }
|
||||
|
||||
uint8_t LocalAccessible::ActionCount() const {
|
||||
|
|
|
@ -172,11 +172,6 @@ class LocalAccessible : public nsISupports, public Accessible {
|
|||
*/
|
||||
mozilla::a11y::role ARIARole();
|
||||
|
||||
/**
|
||||
* Return a landmark role if applied.
|
||||
*/
|
||||
virtual nsAtom* LandmarkRole() const;
|
||||
|
||||
/**
|
||||
* Returns enumerated accessible role from native markup (see constants in
|
||||
* Role.h). Doesn't take into account ARIA roles.
|
||||
|
|
|
@ -208,23 +208,6 @@ role HTMLHeaderOrFooterAccessible::NativeRole() const {
|
|||
return roles::SECTION;
|
||||
}
|
||||
|
||||
nsAtom* HTMLHeaderOrFooterAccessible::LandmarkRole() const {
|
||||
if (!HasOwnContent()) return nullptr;
|
||||
|
||||
a11y::role r = const_cast<HTMLHeaderOrFooterAccessible*>(this)->Role();
|
||||
if (r == roles::LANDMARK) {
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::header)) {
|
||||
return nsGkAtoms::banner;
|
||||
}
|
||||
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::footer)) {
|
||||
return nsGkAtoms::contentinfo;
|
||||
}
|
||||
}
|
||||
|
||||
return HyperTextAccessibleWrap::LandmarkRole();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HTMLSectionAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -235,14 +218,3 @@ role HTMLSectionAccessible::NativeRole() const {
|
|||
return name.IsEmpty() ? roles::SECTION : roles::REGION;
|
||||
}
|
||||
|
||||
nsAtom* HTMLSectionAccessible::LandmarkRole() const {
|
||||
if (!HasOwnContent()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Only return xml-roles "region" if the section has an accessible name.
|
||||
nsAutoString name;
|
||||
const_cast<HTMLSectionAccessible*>(this)->Name(name);
|
||||
return name.IsEmpty() ? HyperTextAccessibleWrap::LandmarkRole()
|
||||
: nsGkAtoms::region;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,6 @@ class HTMLHeaderOrFooterAccessible : public HyperTextAccessibleWrap {
|
|||
HyperTextAccessibleWrap)
|
||||
|
||||
// LocalAccessible
|
||||
virtual nsAtom* LandmarkRole() const override;
|
||||
virtual a11y::role NativeRole() const override;
|
||||
|
||||
protected:
|
||||
|
@ -144,7 +143,6 @@ class HTMLSectionAccessible : public HyperTextAccessibleWrap {
|
|||
HyperTextAccessibleWrap)
|
||||
|
||||
// LocalAccessible
|
||||
virtual nsAtom* LandmarkRole() const override;
|
||||
virtual a11y::role NativeRole() const override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -42,18 +42,6 @@ role HTMLFormAccessible::NativeRole() const {
|
|||
return name.IsEmpty() ? roles::FORM : roles::FORM_LANDMARK;
|
||||
}
|
||||
|
||||
nsAtom* HTMLFormAccessible::LandmarkRole() const {
|
||||
if (!HasOwnContent()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Only return xml-roles "form" if the form has an accessible name.
|
||||
nsAutoString name;
|
||||
const_cast<HTMLFormAccessible*>(this)->Name(name);
|
||||
return name.IsEmpty() ? HyperTextAccessibleWrap::LandmarkRole()
|
||||
: nsGkAtoms::form;
|
||||
}
|
||||
|
||||
void HTMLFormAccessible::DOMAttributeChanged(int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute,
|
||||
int32_t aModType,
|
||||
|
|
|
@ -244,7 +244,6 @@ class HTMLFormAccessible : public HyperTextAccessibleWrap {
|
|||
HyperTextAccessibleWrap)
|
||||
|
||||
// LocalAccessible
|
||||
virtual nsAtom* LandmarkRole() const override;
|
||||
virtual a11y::role NativeRole() const override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -61,8 +61,6 @@ void Relations(nsTArray<RelationType>* aTypes,
|
|||
|
||||
bool IsSearchbox() const;
|
||||
|
||||
nsAtom* LandmarkRole() const;
|
||||
|
||||
nsStaticAtom* ARIARoleAtom() const;
|
||||
|
||||
virtual mozilla::a11y::GroupPos GroupPosition() override;
|
||||
|
|
|
@ -129,6 +129,10 @@ bool RemoteAccessible::IsSearchbox() const {
|
|||
}
|
||||
|
||||
nsAtom* RemoteAccessible::LandmarkRole() const {
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
return RemoteAccessibleBase<RemoteAccessible>::LandmarkRole();
|
||||
}
|
||||
|
||||
nsString landmark;
|
||||
Unused << mDoc->SendLandmarkRole(mID, &landmark);
|
||||
return NS_GetStaticAtom(landmark);
|
||||
|
|
|
@ -59,6 +59,8 @@ class RemoteAccessible : public RemoteAccessibleBase<RemoteAccessible> {
|
|||
virtual bool SelectAll() override;
|
||||
virtual bool UnselectAll() override;
|
||||
|
||||
virtual nsAtom* LandmarkRole() const override;
|
||||
|
||||
protected:
|
||||
explicit RemoteAccessible(DocAccessibleParent* aThisAsDoc)
|
||||
: RemoteAccessibleBase(aThisAsDoc) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче