1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef UI_ACCESSIBILITY_AX_ROLE_PROPERTIES_H_
6 #define UI_ACCESSIBILITY_AX_ROLE_PROPERTIES_H_
7 
8 #include "ui/accessibility/ax_base_export.h"
9 #include "ui/accessibility/ax_enums.mojom-forward.h"
10 
11 namespace ui {
12 
13 // This file contains various helper functions that determine whether a
14 // specific accessibility role meets certain criteria.
15 //
16 // Please keep these functions in alphabetic order.
17 
18 // Returns true for objects which have the characteristic "Children
19 // Presentational: True". This concept is defined in the ARIA specification. See
20 // https://www.w3.org/TR/wai-aria-1.1/#childrenArePresentational.
21 AX_BASE_EXPORT bool HasPresentationalChildren(const ax::mojom::Role role);
22 
23 // Checks if the given role is an alert or alert-dialog type.
24 AX_BASE_EXPORT bool IsAlert(const ax::mojom::Role role);
25 
26 // Checks if the given role is a clickable type.
27 AX_BASE_EXPORT bool IsClickable(const ax::mojom::Role role);
28 
29 // Returns true if the provided role belongs to a cell or a table header.
30 AX_BASE_EXPORT bool IsCellOrTableHeader(const ax::mojom::Role role);
31 
32 // Returns true if the provided role belongs to a container with selectable
33 // children.
34 AX_BASE_EXPORT bool IsContainerWithSelectableChildren(
35     const ax::mojom::Role role);
36 
37 // Returns true if the provided role is a control.
38 AX_BASE_EXPORT bool IsControl(const ax::mojom::Role role);
39 
40 // Returns true if the provided role is a control on the Android platform.
41 AX_BASE_EXPORT bool IsControlOnAndroid(const ax::mojom::Role role,
42                                        bool isFocusable);
43 
44 // Returns true if the provided role belongs to a document.
45 AX_BASE_EXPORT bool IsDocument(const ax::mojom::Role role);
46 
47 // Returns true if the provided role represents a dialog.
48 AX_BASE_EXPORT bool IsDialog(const ax::mojom::Role role);
49 
50 // Returns true if the provided role is a form.
51 AX_BASE_EXPORT bool IsForm(const ax::mojom::Role role);
52 
53 // Returns true if crossing into or out of the provided role should count as
54 // crossing a format boundary.
55 AX_BASE_EXPORT bool IsFormatBoundary(const ax::mojom::Role role);
56 
57 // Returns true if the provided role belongs to a heading.
58 AX_BASE_EXPORT bool IsHeading(const ax::mojom::Role role);
59 
60 // Returns true if the provided role belongs to a heading or a table header.
61 AX_BASE_EXPORT bool IsHeadingOrTableHeader(const ax::mojom::Role role);
62 
63 // Returns true if the provided role belongs to an iframe.
64 AX_BASE_EXPORT bool IsIframe(const ax::mojom::Role role);
65 
66 // Returns true if the provided role is for any kind of image or video.
67 AX_BASE_EXPORT bool IsImageOrVideo(const ax::mojom::Role role);
68 
69 // Returns true if the provided role belongs to an image, graphic, canvas, etc.
70 AX_BASE_EXPORT bool IsImage(const ax::mojom::Role role);
71 
72 // Returns true if the provided role is item-like, specifically if it can hold
73 // pos_in_set and set_size values.
74 AX_BASE_EXPORT bool IsItemLike(const ax::mojom::Role role);
75 
76 // Returns true if the role is a subclass of the ARIA Landmark abstract role.
77 AX_BASE_EXPORT bool IsLandmark(const ax::mojom::Role role);
78 
79 // Returns true if the provided role belongs to a link.
80 AX_BASE_EXPORT bool IsLink(const ax::mojom::Role role);
81 
82 // Returns true if the provided role belongs to a list.
83 AX_BASE_EXPORT bool IsList(const ax::mojom::Role role);
84 
85 // Returns true if the provided role belongs to a list item.
86 AX_BASE_EXPORT bool IsListItem(const ax::mojom::Role role);
87 
88 // Returns true if the provided role belongs to a menu item, including menu item
89 // checkbox and menu item radio buttons.
90 AX_BASE_EXPORT bool IsMenuItem(ax::mojom::Role role);
91 
92 // Returns true if the provided role belongs to a menu or related control.
93 AX_BASE_EXPORT bool IsMenuRelated(const ax::mojom::Role role);
94 
95 // Returns true if this object supports readonly.
96 // Note: This returns false for table cells and headers, it is up to the
97 //       caller to make sure that they are included IFF they are within an
98 //       ARIA-1.1+ role='grid' or 'treegrid', and not role='table'.
99 AX_BASE_EXPORT bool IsReadOnlySupported(const ax::mojom::Role role);
100 
101 // Returns true if the provided role belongs to a widget that can contain a
102 // table or grid row.
103 AX_BASE_EXPORT bool IsRowContainer(const ax::mojom::Role role);
104 
105 // Returns true if the role is a subclass of the ARIA Section abstract role.
106 AX_BASE_EXPORT bool IsSection(const ax::mojom::Role role);
107 
108 // Returns true if the role is a subclass of the ARIA Sectionhead role.
109 AX_BASE_EXPORT bool IsSectionhead(const ax::mojom::Role role);
110 
111 // Returns true if the role is a subclass of the ARIA Select abstract role.
112 AX_BASE_EXPORT bool IsSelect(const ax::mojom::Role role);
113 
114 // Returns true if the provided role is ordered-set like, specifically if it
115 // can hold set_size values.
116 AX_BASE_EXPORT bool IsSetLike(const ax::mojom::Role role);
117 
118 // Returns true if the provided role belongs to a non-interactive list.
119 AX_BASE_EXPORT bool IsStaticList(const ax::mojom::Role role);
120 
121 // Returns true if the role is a subclass of the ARIA Structure abstract role.
122 AX_BASE_EXPORT bool IsStructure(const ax::mojom::Role role);
123 
124 // Returns true if the provided role belongs to a table or grid column, and the
125 // table is not used for layout purposes.
126 AX_BASE_EXPORT bool IsTableColumn(ax::mojom::Role role);
127 
128 // Returns true if the provided role belongs to a table header.
129 AX_BASE_EXPORT bool IsTableHeader(ax::mojom::Role role);
130 
131 // Returns true if the provided role belongs to a table, a grid or a treegrid.
132 AX_BASE_EXPORT bool IsTableLike(const ax::mojom::Role role);
133 
134 // Returns true if the provided role belongs to a table or grid row, and the
135 // table is not used for layout purposes.
136 AX_BASE_EXPORT bool IsTableRow(ax::mojom::Role role);
137 
138 // Returns true if it's a text-related node e.g. static text, line break, or
139 // inline text box node.
140 AX_BASE_EXPORT bool IsText(ax::mojom::Role role);
141 
142 // Returns true if it's a text-related node e.g. a static text or line break
143 // node.
144 AX_BASE_EXPORT bool IsTextOrLineBreak(ax::mojom::Role role);
145 
146 // Returns true if the role supports expand/collapse.
147 AX_BASE_EXPORT bool SupportsExpandCollapse(const ax::mojom::Role role);
148 
149 // Returns true if the role supports hierarchical level.
150 AX_BASE_EXPORT bool SupportsHierarchicalLevel(const ax::mojom::Role role);
151 
152 // Returns true if the provided role can have an orientation.
153 AX_BASE_EXPORT bool SupportsOrientation(const ax::mojom::Role role);
154 
155 // Returns true if the provided role supports toggle.
156 AX_BASE_EXPORT bool SupportsToggle(const ax::mojom::Role role);
157 
158 // Returns true if the node should be read only by default
159 AX_BASE_EXPORT bool ShouldHaveReadonlyStateByDefault(
160     const ax::mojom::Role role);
161 
162 }  // namespace ui
163 
164 #endif  // UI_ACCESSIBILITY_AX_ROLE_PROPERTIES_H_
165