Pulp
1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
aria_roles.hpp
Go to the documentation of this file.
1
#pragma once
2
3
// ARIA role token -> View::AccessRole.
4
//
5
// The JS/html-compat layer calls setAccessibilityRole(id, role) when a script
6
// does `el.setAttribute('role', ...)`. This is the single parser for that
7
// token; it lives in a header (rather than inside
8
// widget_bridge/accessibility_api.cpp) so it is unit-testable without spinning
9
// up a QuickJS engine, and so any future non-bridge caller reuses the same
10
// table.
11
//
12
// Previously the bridge collapsed every role outside a 7-value enum onto
13
// `group` — button, link, listbox, menu, tab, dialog, navigation all became
14
// "group", so a screen-reader user heard "group" for a button. Now the enum
15
// covers the roles Pulp's widgets actually are, and only genuinely
16
// container-ish ARIA roles (region, navigation, form, ...) land on `group`.
17
18
#include <
pulp/view/view.hpp
>
19
20
#include <string_view>
21
22
namespace
pulp::view
{
23
36
inline
View::AccessRole
access_role_from_aria
(std::string_view role) {
37
using
R =
View::AccessRole
;
38
if
(role.empty() || role ==
"none"
|| role ==
"presentation"
)
return
R::none;
39
40
if
(role ==
"slider"
)
return
R::slider;
41
if
(role ==
"switch"
)
return
R::toggle;
42
if
(role ==
"checkbox"
)
return
R::checkbox;
43
if
(role ==
"radio"
)
return
R::radio;
44
if
(role ==
"button"
)
return
R::button;
45
if
(role ==
"link"
)
return
R::link;
46
if
(role ==
"textbox"
|| role ==
"searchbox"
||
47
role ==
"text_field"
)
return
R::text_field;
48
if
(role ==
"combobox"
)
return
R::combo_box;
49
if
(role ==
"list"
|| role ==
"listbox"
)
return
R::list;
50
if
(role ==
"listitem"
|| role ==
"option"
)
return
R::list_item;
51
if
(role ==
"table"
|| role ==
"grid"
||
52
role ==
"treegrid"
)
return
R::table;
53
if
(role ==
"row"
)
return
R::row;
54
if
(role ==
"cell"
|| role ==
"gridcell"
||
55
role ==
"columnheader"
||
56
role ==
"rowheader"
)
return
R::cell;
57
if
(role ==
"tab"
)
return
R::tab;
58
if
(role ==
"tablist"
)
return
R::tab_list;
59
if
(role ==
"menu"
|| role ==
"menubar"
)
return
R::menu;
60
if
(role ==
"menuitem"
||
61
role ==
"menuitemcheckbox"
||
62
role ==
"menuitemradio"
)
return
R::menu_item;
63
if
(role ==
"progressbar"
)
return
R::progress_bar;
64
if
(role ==
"meter"
)
return
R::meter;
65
if
(role ==
"dialog"
|| role ==
"alertdialog"
)
return
R::dialog;
66
if
(role ==
"heading"
)
return
R::heading;
67
if
(role ==
"scrollbar"
)
return
R::scroll_bar;
68
if
(role ==
"img"
|| role ==
"image"
)
return
R::image;
69
if
(role ==
"text"
|| role ==
"paragraph"
||
70
role ==
"caption"
)
return
R::label;
71
72
// Container-ish and not-yet-modeled roles: expose as a generic group.
73
return
R::group;
74
}
75
76
}
// namespace pulp::view
pulp::view::View::AccessRole
AccessRole
Screen-reader role.
Definition
view.hpp:988
pulp::view
Hover-cursor tracking for platform window hosts.
Definition
fwd.hpp:27
pulp::view::access_role_from_aria
View::AccessRole access_role_from_aria(std::string_view role)
Map an ARIA role token to a Pulp AccessRole.
Definition
aria_roles.hpp:36
view.hpp
core
view
include
pulp
view
aria_roles.hpp
Generated by
1.15.0