1use std::sync::LazyLock;
6
7use accesskit::Role;
8use bitflags::bitflags;
9use rustc_hash::{FxHashMap, FxHashSet};
10use style::Atom;
11
12bitflags! {
13 #[derive(Clone, Copy, Default, Debug, Eq, PartialEq)]
14 pub struct AccessibilityDamage: u16 {
15 const Node = 1 << 0;
17 const Children = 1 << 1;
19 const Layout = 1 << 2;
21 }
22}
23malloc_size_of::malloc_size_of_is_0!(AccessibilityDamage);
24
25pub static SUPPORTED_ARIA_ROLES: LazyLock<FxHashSet<Atom>> = LazyLock::new(|| {
34 [
35 Atom::from("alert"),
36 Atom::from("article"),
37 Atom::from("banner"),
38 Atom::from("blockquote"),
39 Atom::from("caption"),
40 Atom::from("code"),
41 Atom::from("complementary"),
42 Atom::from("contentinfo"),
43 Atom::from("definition"),
44 Atom::from("deletion"),
45 Atom::from("directory"),
46 Atom::from("document"),
47 Atom::from("emphasis"),
48 Atom::from("feed"),
49 Atom::from("figure"),
50 Atom::from("generic"),
51 Atom::from("heading"),
52 Atom::from("insertion"),
53 Atom::from("link"),
54 Atom::from("list"),
55 Atom::from("log"),
56 Atom::from("main"),
57 Atom::from("math"),
58 Atom::from("navigation"),
59 Atom::from("none"),
60 Atom::from("note"),
61 Atom::from("paragraph"),
62 Atom::from("presentation"),
63 Atom::from("rowgroup"),
64 Atom::from("search"),
65 Atom::from("status"),
66 Atom::from("strong"),
67 Atom::from("term"),
68 Atom::from("time"),
69 Atom::from("timer"),
70 ]
71 .into_iter()
72 .collect()
73});
74
75pub static ARIA_ROLE_TO_ACCESSKIT_ROLE: LazyLock<FxHashMap<Atom, Role>> = LazyLock::new(|| {
77 [
78 (Atom::from("alert"), Role::Alert),
79 (Atom::from("article"), Role::Article),
80 (Atom::from("banner"), Role::Banner),
81 (Atom::from("blockquote"), Role::Blockquote),
82 (Atom::from("caption"), Role::Caption),
83 (Atom::from("code"), Role::Code),
84 (Atom::from("complementary"), Role::Complementary),
85 (Atom::from("contentinfo"), Role::ContentInfo),
86 (Atom::from("definition"), Role::Definition),
87 (Atom::from("deletion"), Role::ContentDeletion),
88 (Atom::from("directory"), Role::Unknown),
89 (Atom::from("document"), Role::Document),
90 (Atom::from("emphasis"), Role::Emphasis),
91 (Atom::from("feed"), Role::Feed),
92 (Atom::from("figure"), Role::Figure),
93 (Atom::from("generic"), Role::Section),
94 (Atom::from("heading"), Role::Heading),
95 (Atom::from("insertion"), Role::ContentInsertion),
96 (Atom::from("link"), Role::Link),
97 (Atom::from("list"), Role::List),
98 (Atom::from("log"), Role::Log),
99 (Atom::from("main"), Role::Main),
100 (Atom::from("math"), Role::Math),
101 (Atom::from("navigation"), Role::Navigation),
102 (Atom::from("none"), Role::GenericContainer),
103 (Atom::from("note"), Role::Note),
104 (Atom::from("paragraph"), Role::Paragraph),
105 (Atom::from("presentation"), Role::GenericContainer),
106 (Atom::from("rowgroup"), Role::RowGroup),
107 (Atom::from("search"), Role::Search),
108 (Atom::from("separator"), Role::Splitter),
109 (Atom::from("status"), Role::Status),
110 (Atom::from("strong"), Role::Strong),
111 (Atom::from("term"), Role::Term),
114 (Atom::from("time"), Role::Time),
115 (Atom::from("timer"), Role::Timer),
116 ]
117 .into_iter()
118 .collect()
119});
120
121pub static ACCESSKIT_ROLE_TO_ARIA_ROLE: LazyLock<FxHashMap<Role, Atom>> = LazyLock::new(|| {
127 let mut accesskit_to_aria: FxHashMap<Role, Atom> = ARIA_ROLE_TO_ACCESSKIT_ROLE
128 .iter()
129 .map(|(aria_role, accesskit_role)| (*accesskit_role, aria_role.clone()))
130 .collect();
131 accesskit_to_aria.insert(Role::GenericContainer, Atom::from("none"));
134 accesskit_to_aria
135});