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 +++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'accessible/html/HTMLElementAccessibles.cpp') 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; } -- cgit v1.2.3