LibWeb: Add support for ARIA Graphics roles

This change adds support for the graphics-document, graphics-object, and
graphics-symbol ARIA roles from the WAI-ARIA Graphics Module spec at
https://w3c.github.io/graphics-aria/#role_definitions
This commit is contained in:
sideshowbarker 2024-12-26 09:56:56 +09:00 committed by Tim Flynn
commit 8961d5d2ce
Notes: github-actions[bot] 2024-12-28 01:17:20 +00:00
6 changed files with 287 additions and 110 deletions

View file

@ -13,11 +13,11 @@ StringView role_name(Role role)
{
// Note: Role::switch_ is mapped to "switch" (due to C++ keyword clash)
switch (role) {
#define __ENUMERATE_ARIA_ROLE(name) \
#define __ENUMERATE_ARIA_ROLE(name, attribute) \
case Role::name: \
if constexpr (Role::name == Role::switch_) \
return "switch"sv; \
return #name##sv;
return attribute##sv;
ENUMERATE_ARIA_ROLES
#undef __ENUMERATE_ARIA_ROLE
default:
@ -28,13 +28,13 @@ StringView role_name(Role role)
Optional<Role> role_from_string(StringView role_name)
{
// Note: "switch" is mapped to Role::switch_ (due to C++ keyword clash)
#define __ENUMERATE_ARIA_ROLE(name) \
if constexpr (Role::name == Role::switch_) { \
if (role_name.equals_ignoring_ascii_case("switch"sv)) \
return Role::switch_; \
} else { \
if (role_name.equals_ignoring_ascii_case(#name##sv)) \
return Role::name; \
#define __ENUMERATE_ARIA_ROLE(name, attribute) \
if constexpr (Role::name == Role::switch_) { \
if (role_name.equals_ignoring_ascii_case("switch"sv)) \
return Role::switch_; \
} else { \
if (role_name.equals_ignoring_ascii_case(attribute##sv)) \
return Role::name; \
}
ENUMERATE_ARIA_ROLES
#undef __ENUMERATE_ARIA_ROLE