summaryrefslogtreecommitdiffstats
path: root/accessible/html/HTMLElementAccessibles.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /accessible/html/HTMLElementAccessibles.cpp
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/html/HTMLElementAccessibles.cpp')
-rw-r--r--accessible/html/HTMLElementAccessibles.cpp33
1 files changed, 30 insertions, 3 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;
}