mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Compute default ARIA roles context-sensitively where required
This change implements spec-conformant computation of default ARIA roles for elements whose expected default role depends on the element’s context — specifically, either on the element’s ancestry, or on whether the element has an accessible name, or both. This affects the “aside”, “footer”, “header”, and “section” elements. Otherwise, without this change, “aside”, “footer”, “header”, and “section” elements may unexpectedly end up with the wrong default roles.
This commit is contained in:
parent
7a4a9cc7bc
commit
68894306e2
Notes:
github-actions[bot]
2024-12-06 18:32:42 +00:00
Author: https://github.com/sideshowbarker
Commit: 68894306e2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2779
Reviewed-by: https://github.com/tcl3 ✅
4 changed files with 140 additions and 14 deletions
|
@ -2228,7 +2228,17 @@ ErrorOr<String> Node::name_or_description(NameOrDescription target, Document con
|
|||
|
||||
if (is_element()) {
|
||||
auto const* element = static_cast<DOM::Element const*>(this);
|
||||
auto role = element->role_or_default();
|
||||
auto role = element->role_from_role_attribute_value();
|
||||
// Per https://w3c.github.io/html-aam/#el-aside and https://w3c.github.io/html-aam/#el-section, computing a
|
||||
// default role for an aside element or section element requires first computing its accessible name — that is,
|
||||
// calling into this name_or_description code. But if we then try to determine a default role for the aside
|
||||
// element or section element here, that’d then end up calling right back into this name_or_description code —
|
||||
// which would cause the calls to loop infinitely. So to avoid that, we only compute a default role here if this
|
||||
// isn’t an aside element or section element.
|
||||
// https://github.com/w3c/aria/issues/2391
|
||||
if (!role.has_value() && element->local_name() != HTML::TagNames::aside && element->local_name() != HTML::TagNames::section)
|
||||
role = element->default_role();
|
||||
|
||||
// 2. Compute the text alternative for the current node:
|
||||
|
||||
// A. Hidden Not Referenced: If the current node is hidden and is:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue