diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /accessible/html | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/html')
-rw-r--r-- | accessible/html/HTMLElementAccessibles.cpp | 33 | ||||
-rw-r--r-- | accessible/html/HTMLElementAccessibles.h | 17 | ||||
-rw-r--r-- | accessible/html/HTMLFormControlAccessible.cpp | 6 | ||||
-rw-r--r-- | accessible/html/HTMLLinkAccessible.cpp | 11 | ||||
-rw-r--r-- | accessible/html/HTMLLinkAccessible.h | 2 | ||||
-rw-r--r-- | accessible/html/moz.build | 4 |
6 files changed, 66 insertions, 7 deletions
diff --git a/accessible/html/HTMLElementAccessibles.cpp b/accessible/html/HTMLElementAccessibles.cpp index e01de31ff2..135f997358 100644 --- a/accessible/html/HTMLElementAccessibles.cpp +++ b/accessible/html/HTMLElementAccessibles.cpp @@ -221,11 +221,38 @@ role HTMLHeaderOrFooterAccessible::NativeRole() const { } //////////////////////////////////////////////////////////////////////////////// +// HTMLAsideAccessible +//////////////////////////////////////////////////////////////////////////////// + +role HTMLAsideAccessible::NativeRole() const { + // Per the HTML-AAM spec, there are two cases for aside elements: + // 1. scoped to body or main elements -> 'complementary' role + // 2. scoped to sectioning content elements + // -> if the element has an accessible name, 'complementary' role + // -> otherwise, 'generic' role + // To implement this, walk ancestors until we find a sectioning content + // element, or a body/main element, then take actions based on the rules + // above. + nsIContent* parent = mContent->GetParent(); + while (parent) { + if (parent->IsAnyOfHTMLElements(nsGkAtoms::article, nsGkAtoms::aside, + nsGkAtoms::nav, nsGkAtoms::section)) { + return !NameIsEmpty() ? roles::LANDMARK : roles::SECTION; + } + if (parent->IsAnyOfHTMLElements(nsGkAtoms::main, nsGkAtoms::body)) { + return roles::LANDMARK; + } + parent = parent->GetParent(); + } + + // Fall back to landmark, though we always expect to find a body element. + return roles::LANDMARK; +} + +//////////////////////////////////////////////////////////////////////////////// // HTMLSectionAccessible //////////////////////////////////////////////////////////////////////////////// role HTMLSectionAccessible::NativeRole() const { - nsAutoString name; - const_cast<HTMLSectionAccessible*>(this)->Name(name); - return name.IsEmpty() ? roles::SECTION : roles::REGION; + return NameIsEmpty() ? roles::SECTION : roles::REGION; } diff --git a/accessible/html/HTMLElementAccessibles.h b/accessible/html/HTMLElementAccessibles.h index 5a3ec6cef8..520a38342c 100644 --- a/accessible/html/HTMLElementAccessibles.h +++ b/accessible/html/HTMLElementAccessibles.h @@ -136,6 +136,23 @@ class HTMLHeaderOrFooterAccessible : public HyperTextAccessible { }; /** + * Used for aside elements. + */ +class HTMLAsideAccessible : public HyperTextAccessible { + public: + HTMLAsideAccessible(nsIContent* aContent, DocAccessible* aDoc) + : HyperTextAccessible(aContent, aDoc) {} + + NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLAsideAccessible, HyperTextAccessible) + + // LocalAccessible + virtual a11y::role NativeRole() const override; + + protected: + virtual ~HTMLAsideAccessible() = default; +}; + +/** * Used for HTML section element. */ class HTMLSectionAccessible : public HyperTextAccessible { diff --git a/accessible/html/HTMLFormControlAccessible.cpp b/accessible/html/HTMLFormControlAccessible.cpp index 95d6fed7b3..5974cc2f7c 100644 --- a/accessible/html/HTMLFormControlAccessible.cpp +++ b/accessible/html/HTMLFormControlAccessible.cpp @@ -35,9 +35,7 @@ using namespace mozilla::a11y; //////////////////////////////////////////////////////////////////////////////// role HTMLFormAccessible::NativeRole() const { - nsAutoString name; - const_cast<HTMLFormAccessible*>(this)->Name(name); - return name.IsEmpty() ? roles::FORM : roles::FORM_LANDMARK; + return NameIsEmpty() ? roles::FORM : roles::FORM_LANDMARK; } void HTMLFormAccessible::DOMAttributeChanged(int32_t aNameSpaceID, @@ -293,7 +291,7 @@ already_AddRefed<AccAttributes> HTMLTextFieldAccessible::NativeAttributes() { nsString placeholderText; if (mContent->AsElement()->GetAttr(nsGkAtoms::placeholder, placeholderText)) { nsAutoString name; - const_cast<HTMLTextFieldAccessible*>(this)->Name(name); + Name(name); if (!name.Equals(placeholderText)) { attributes->SetAttribute(nsGkAtoms::placeholder, std::move(placeholderText)); diff --git a/accessible/html/HTMLLinkAccessible.cpp b/accessible/html/HTMLLinkAccessible.cpp index b3549996fc..89c5d8d51d 100644 --- a/accessible/html/HTMLLinkAccessible.cpp +++ b/accessible/html/HTMLLinkAccessible.cpp @@ -112,6 +112,17 @@ void HTMLLinkAccessible::DOMAttributeChanged(int32_t aNameSpaceID, } } +ENameValueFlag HTMLLinkAccessible::NativeName(nsString& aName) const { + if (mContent->IsSVGElement()) { + mContent->AsElement()->GetAttr(kNameSpaceID_XLink, nsGkAtoms::title, aName); + if (!aName.IsEmpty()) { + return eNameOK; + } + } + + return HyperTextAccessible::NativeName(aName); +} + //////////////////////////////////////////////////////////////////////////////// // HyperLinkAccessible diff --git a/accessible/html/HTMLLinkAccessible.h b/accessible/html/HTMLLinkAccessible.h index de5f903a3d..888df2f06c 100644 --- a/accessible/html/HTMLLinkAccessible.h +++ b/accessible/html/HTMLLinkAccessible.h @@ -46,6 +46,8 @@ class HTMLLinkAccessible : public HyperTextAccessible { const nsAttrValue* aOldValue, uint64_t aOldState) override; + virtual ENameValueFlag NativeName(nsString& aName) const override; + enum { eAction_Jump = 0 }; }; diff --git a/accessible/html/moz.build b/accessible/html/moz.build index 3a246373da..73b7737987 100644 --- a/accessible/html/moz.build +++ b/accessible/html/moz.build @@ -42,6 +42,10 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": LOCAL_INCLUDES += [ "/accessible/android", ] +elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "uikit": + LOCAL_INCLUDES += [ + "/accessible/ios", + ] else: LOCAL_INCLUDES += [ "/accessible/other", |