mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibWeb: Align accname alt-vs-title behavior w/ HTML-AAM spec & WPT tests
The https://wpt.fyi/results/accname/name/comp_tooltip.tentative.html test was recently added by moving an existing subtest out from the test at https://wpt.fyi/results/accname/name/comp_tooltip.html, and changing the test expectations to match the HTML-AAM spec requirements at https://w3c.github.io/html-aam/#img-element-accessible-name-computation. See https://github.com/web-platform-tests/wpt/pull/49552. So this code change updates Ladybird to match the updated WPT test expectations — and to match the existing HTML-AAM spec requirements.
This commit is contained in:
parent
50733c564c
commit
966c68ae0e
Notes:
github-actions[bot]
2024-12-23 13:02:37 +00:00
Author: https://github.com/sideshowbarker
Commit: 966c68ae0e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3020
Reviewed-by: https://github.com/gmta ✅
5 changed files with 39 additions and 10 deletions
|
@ -2491,13 +2491,15 @@ ErrorOr<String> Node::name_or_description(NameOrDescription target, Document con
|
|||
|
||||
// E. Host Language Label: Otherwise, if the current node's native markup provides an attribute (e.g. alt) or
|
||||
// element (e.g. HTML label or SVG title) that defines a text alternative, return that alternative in the form
|
||||
// of a flat string as defined by the host language, unless the element is marked as presentational
|
||||
// (role="presentation" or role="none").
|
||||
//
|
||||
// of a flat string as defined by the host language.
|
||||
// TODO: Confirm (through existing WPT test cases) whether HTMLLabelElement is already handled (by the code for
|
||||
// step C. “Embedded Control” above) in conformance with the spec requirements — and if not, then add handling.
|
||||
if (role != ARIA::Role::presentation && role != ARIA::Role::none && is<HTML::HTMLImageElement>(*element))
|
||||
return element->alternative_text().release_value();
|
||||
//
|
||||
// https://w3c.github.io/html-aam/#img-element-accessible-name-computation
|
||||
// use alt attribute, even if its value is the empty string.
|
||||
// See also https://wpt.fyi/results/accname/name/comp_tooltip.tentative.html.
|
||||
if (is<HTML::HTMLImageElement>(*element) && element->has_attribute(HTML::AttributeNames::alt))
|
||||
return element->get_attribute(HTML::AttributeNames::alt).value();
|
||||
|
||||
// https://w3c.github.io/svg-aam/#mapping_additional_nd
|
||||
Optional<String> title_element_text;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue