mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Fix accessible-name computation for “encapsulation” cases
This change makes Ladybird correctly handle all “encapsulation” tests in the https://wpt.fyi/results/accname/name/comp_host_language_label.html set of tests in WPT. Those all test the requirement that when computing the accessible name for a <label>-ed form control, then any content (text content or attribute values) from the control itself that would otherwise be included in the accessible-name computation for it ancestor <label> must instead be skipped and not included. The HTML-AAM spec seems to try to achieve that result by expressing specific steps for each particular type of form control. But what all that reduces/optimizes/simplifies down to is just, “skip over self”. Otherwise, without this change, Ladybird includes that “self” content from those “encapsulated” elements when doing accessible-name computation for the elements — which results in AT users hearing unexpected extra content in the accessible names for those elements.
This commit is contained in:
parent
7a6813cdea
commit
db29d248ad
Notes:
github-actions[bot]
2024-11-25 10:22:21 +00:00
Author: https://github.com/sideshowbarker
Commit: db29d248ad
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2438
Reviewed-by: https://github.com/gmta ✅
3 changed files with 263 additions and 0 deletions
|
@ -2290,6 +2290,15 @@ ErrorOr<String> Node::name_or_description(NameOrDescription target, Document con
|
|||
for (u32 i = 0; i < labels->length(); i++) {
|
||||
auto nodes = labels->item(i)->children_as_vector();
|
||||
for (auto const& node : nodes) {
|
||||
// AD-HOC: https://wpt.fyi/results/accname/name/comp_host_language_label.html has “encapsulation”
|
||||
// tests, from which can be induced a requirement that when computing the accessible name for a
|
||||
// <label>-ed form control (“embedded control”), then any content (text content or attribute values)
|
||||
// from the control itself that would otherwise be included in the accessible-name computation for
|
||||
// it ancestor <label> must instead be skipped and not included. The HTML-AAM spec seems to maybe
|
||||
// be trying to achieve that result by expressing specific steps for each particular type of form
|
||||
// control. But what all that reduces/optimizes/simplifies down to is just, “skip over self”.
|
||||
if (node == this)
|
||||
continue;
|
||||
if (node->is_element()) {
|
||||
auto const& element = static_cast<DOM::Element const&>(*node);
|
||||
auto role = element.role_or_default();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue