From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- accessible/html/HTMLElementAccessibles.cpp | 33 ++++++++++++++++++++++++--- accessible/html/HTMLElementAccessibles.h | 17 ++++++++++++++ accessible/html/HTMLFormControlAccessible.cpp | 6 ++--- accessible/html/HTMLLinkAccessible.cpp | 11 +++++++++ accessible/html/HTMLLinkAccessible.h | 2 ++ accessible/html/moz.build | 4 ++++ 6 files changed, 66 insertions(+), 7 deletions(-) (limited to 'accessible/html') 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 @@ -220,12 +220,39 @@ role HTMLHeaderOrFooterAccessible::NativeRole() const { return roles::SECTION; } +//////////////////////////////////////////////////////////////////////////////// +// 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(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 @@ -135,6 +135,23 @@ class HTMLHeaderOrFooterAccessible : public HyperTextAccessible { virtual ~HTMLHeaderOrFooterAccessible() {} }; +/** + * 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. */ 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(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 HTMLTextFieldAccessible::NativeAttributes() { nsString placeholderText; if (mContent->AsElement()->GetAttr(nsGkAtoms::placeholder, placeholderText)) { nsAutoString name; - const_cast(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", -- cgit v1.2.3