mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
LibWeb: Fix parsing/to_string for "switch" ARIA role
I accidentally regressed this in 890b4d7
, this role needs to be
handled specially due to the clash with the C++ 'switch' keyword.
This commit is contained in:
parent
476d4b4963
commit
489fe49321
1 changed files with 14 additions and 5 deletions
|
@ -11,9 +11,12 @@ 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) \
|
#define __ENUMERATE_ARIA_ROLE(name) \
|
||||||
case Role::name: \
|
case Role::name: \
|
||||||
|
if constexpr (Role::name == Role::switch_) \
|
||||||
|
return "switch"sv; \
|
||||||
return #name##sv;
|
return #name##sv;
|
||||||
ENUMERATE_ARIA_ROLES
|
ENUMERATE_ARIA_ROLES
|
||||||
#undef __ENUMERATE_ARIA_ROLE
|
#undef __ENUMERATE_ARIA_ROLE
|
||||||
|
@ -24,9 +27,15 @@ 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) \
|
#define __ENUMERATE_ARIA_ROLE(name) \
|
||||||
|
if constexpr (Role::name == Role::switch_) { \
|
||||||
|
if (role_name.equals_ignoring_case("switch"sv)) \
|
||||||
|
return Role::switch_; \
|
||||||
|
} else { \
|
||||||
if (role_name.equals_ignoring_case(#name##sv)) \
|
if (role_name.equals_ignoring_case(#name##sv)) \
|
||||||
return Role::name;
|
return Role::name; \
|
||||||
|
}
|
||||||
ENUMERATE_ARIA_ROLES
|
ENUMERATE_ARIA_ROLES
|
||||||
#undef __ENUMERATE_ARIA_ROLE
|
#undef __ENUMERATE_ARIA_ROLE
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue