LibWeb: Remove special handling for the ARIA "switch" role

If we use the correct string for "switch", the special handling is not
necessary after 8961d5d2ce.
This commit is contained in:
Timothy Flynn 2024-12-28 08:54:47 -05:00 committed by Tim Flynn
commit 19567d96ec
Notes: github-actions[bot] 2024-12-28 16:34:59 +00:00
2 changed files with 6 additions and 15 deletions

View file

@ -11,12 +11,9 @@ namespace Web::ARIA {
StringView role_name(Role role) StringView role_name(Role role)
{ {
// Note: Role::switch_ is mapped to "switch" (due to C++ keyword clash)
switch (role) { switch (role) {
#define __ENUMERATE_ARIA_ROLE(name, attribute) \ #define __ENUMERATE_ARIA_ROLE(name, attribute) \
case Role::name: \ case Role::name: \
if constexpr (Role::name == Role::switch_) \
return "switch"sv; \
return attribute##sv; return attribute##sv;
ENUMERATE_ARIA_ROLES ENUMERATE_ARIA_ROLES
#undef __ENUMERATE_ARIA_ROLE #undef __ENUMERATE_ARIA_ROLE
@ -27,15 +24,9 @@ StringView role_name(Role role)
Optional<Role> role_from_string(StringView role_name) 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, attribute) \
#define __ENUMERATE_ARIA_ROLE(name, attribute) \ if (role_name.equals_ignoring_ascii_case(attribute##sv)) \
if constexpr (Role::name == Role::switch_) { \ return Role::name;
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 ENUMERATE_ARIA_ROLES
#undef __ENUMERATE_ARIA_ROLE #undef __ENUMERATE_ARIA_ROLE
return {}; return {};

View file

@ -98,7 +98,7 @@ namespace Web::ARIA {
__ENUMERATE_ARIA_ROLE(subscript, "subscript") \ __ENUMERATE_ARIA_ROLE(subscript, "subscript") \
__ENUMERATE_ARIA_ROLE(suggestion, "suggestion") \ __ENUMERATE_ARIA_ROLE(suggestion, "suggestion") \
__ENUMERATE_ARIA_ROLE(superscript, "superscript") \ __ENUMERATE_ARIA_ROLE(superscript, "superscript") \
__ENUMERATE_ARIA_ROLE(switch_, "switch_") \ __ENUMERATE_ARIA_ROLE(switch_, "switch") \
__ENUMERATE_ARIA_ROLE(tab, "tab") \ __ENUMERATE_ARIA_ROLE(tab, "tab") \
__ENUMERATE_ARIA_ROLE(table, "table") \ __ENUMERATE_ARIA_ROLE(table, "table") \
__ENUMERATE_ARIA_ROLE(tablist, "tablist") \ __ENUMERATE_ARIA_ROLE(tablist, "tablist") \