LibWeb: Compute roles for SVG graphics-symbol elements and foreignObject

This change adds computation of ARIA roles for a number of SVG elements
for which, if the element meets the SVG spec criteria for inclusion in
the accessibility tree, the computed ARIA role should be
“graphics-symbol”, and should otherwise be “generic”.

This change also adds similar role computation for the SVG foreignObject
element (the role for which, if the element meets the SVG spec criteria
for inclusion in the accessibility tree, should be “group”, and should
otherwise be “generic”).
This commit is contained in:
sideshowbarker 2024-12-26 11:32:13 +09:00 committed by Tim Flynn
commit 2983a17ea6
Notes: github-actions[bot] 2024-12-28 01:17:12 +00:00
3 changed files with 64 additions and 2 deletions

View file

@ -55,11 +55,17 @@ Optional<ARIA::Role> SVGElement::default_role() const
// https://w3c.github.io/svg-aam/#mapping_role_table
if (local_name() == TagNames::a && (has_attribute(SVG::AttributeNames::href) || has_attribute(AttributeNames::xlink_href)))
return ARIA::Role::link;
if (local_name() == TagNames::g && should_include_in_accessibility_tree())
if (local_name().is_one_of(TagNames::foreignObject, TagNames::g)
&& should_include_in_accessibility_tree())
return ARIA::Role::group;
if (local_name() == TagNames::image && should_include_in_accessibility_tree())
return ARIA::Role::image;
return {};
if (local_name() == TagNames::circle && should_include_in_accessibility_tree())
return ARIA::Role::graphicssymbol;
if (local_name().is_one_of(TagNames::ellipse, TagNames::path, TagNames::polygon, TagNames::polyline)
&& should_include_in_accessibility_tree())
return ARIA::Role::graphicssymbol;
return ARIA::Role::generic;
}
void SVGElement::visit_edges(Cell::Visitor& visitor)