From fc3ee471ed9ce2eb18b6da47953d3918ac534fe3 Mon Sep 17 00:00:00 2001 From: Jonah Date: Sun, 5 Feb 2023 11:20:16 -0600 Subject: LibWeb: Add ARIA::allows_name_from_content This is required to implement accessible name and description calculation. --- Userland/Libraries/LibWeb/ARIA/Roles.cpp | 25 +++++++++++++++++++++++++ Userland/Libraries/LibWeb/ARIA/Roles.h | 1 + 2 files changed, 26 insertions(+) (limited to 'Userland/Libraries/LibWeb') diff --git a/Userland/Libraries/LibWeb/ARIA/Roles.cpp b/Userland/Libraries/LibWeb/ARIA/Roles.cpp index b032e0351f..0748563ae0 100644 --- a/Userland/Libraries/LibWeb/ARIA/Roles.cpp +++ b/Userland/Libraries/LibWeb/ARIA/Roles.cpp @@ -178,4 +178,29 @@ bool is_non_abstract_role(Role role) || is_windows_role(role); } +// https://www.w3.org/TR/wai-aria-1.2/#namefromcontent +bool allows_name_from_content(Role role) +{ + return first_is_one_of(role, + Role::button, + Role::cell, + Role::checkbox, + Role::columnheader, + Role::gridcell, + Role::heading, + Role::link, + Role::menuitem, + Role::menuitemcheckbox, + Role::menuitemradio, + Role::option, + Role::radio, + Role::row, + Role::rowheader, + Role::sectionhead, + Role::switch_, + Role::tab, + Role::tooltip, + Role::treeitem); +} + } diff --git a/Userland/Libraries/LibWeb/ARIA/Roles.h b/Userland/Libraries/LibWeb/ARIA/Roles.h index 630bcdac71..b8562d2560 100644 --- a/Userland/Libraries/LibWeb/ARIA/Roles.h +++ b/Userland/Libraries/LibWeb/ARIA/Roles.h @@ -124,5 +124,6 @@ bool is_live_region_role(Role); bool is_windows_role(Role); bool is_non_abstract_role(Role); +bool allows_name_from_content(Role); } -- cgit v1.2.3