LibWeb: Support the “image” synonym for the “img” ARIA role

Additionally: For “img” elements with empty “alt” attributes, change the
default role to the newer, preferred “none” synonym for the older
“presentation” role; import https://wpt.fyi/results/html-aam/roles.html
(which provides test/regression coverage for these changes).
This commit is contained in:
sideshowbarker 2024-12-08 22:29:09 +09:00 committed by Tim Flynn
parent 6e24f23aa0
commit ccbc436e85
Notes: github-actions[bot] 2024-12-12 13:14:53 +00:00
5 changed files with 282 additions and 2 deletions

View file

@ -411,10 +411,15 @@ Optional<ARIA::Role> HTMLImageElement::default_role() const
{
// https://www.w3.org/TR/html-aria/#el-img
// https://www.w3.org/TR/html-aria/#el-img-no-alt
// https://w3c.github.io/aria/#image
// NOTE: The "image" role value is a synonym for the older "img" role value; however, the el-img test in
// https://wpt.fyi/results/html-aam/roles.html expects the value to be "image" (not "img").
if (!alt().is_empty())
return ARIA::Role::img;
return ARIA::Role::image;
// https://www.w3.org/TR/html-aria/#el-img-empty-alt
return ARIA::Role::presentation;
// NOTE: The "none" role value is a synonym for the older "presentation" role value; however, the el-img-alt-no-value
// test in https://wpt.fyi/results/html-aam/roles.html expects the value to be "none" (not "presentation").
return ARIA::Role::none;
}
// https://html.spec.whatwg.org/multipage/images.html#use-srcset-or-picture