ax_role_properties.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. #ifndef UI_ACCESSIBILITY_AX_ROLE_PROPERTIES_H_
  5. #define UI_ACCESSIBILITY_AX_ROLE_PROPERTIES_H_
  6. #include "ui/accessibility/ax_base_export.h"
  7. #include "ui/accessibility/ax_enums.mojom-forward.h"
  8. namespace ui {
  9. // This file contains various helper functions that determine whether a
  10. // specific accessibility role meets certain criteria.
  11. //
  12. // Please keep these functions in alphabetic order.
  13. // When using these functions in Blink, it's necessary to add the function names
  14. // to third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py, in
  15. // order to pass presubmit.
  16. // Returns true for text parents that can have inline text box children.
  17. AX_BASE_EXPORT bool CanHaveInlineTextBoxChildren(ax::mojom::Role role);
  18. // Returns true for object roles that have the attribute "Children
  19. // Presentational: True" as defined in the ARIA Specification.
  20. // https://www.w3.org/TR/wai-aria-1.1/#childrenArePresentational.
  21. AX_BASE_EXPORT bool HasPresentationalChildren(const ax::mojom::Role role);
  22. // Returns true if the given role is an alert or alert-dialog type.
  23. AX_BASE_EXPORT bool IsAlert(const ax::mojom::Role role);
  24. // Returns true if the given role is a candidate to be labeled with a classname
  25. // of TextView on Android.
  26. AX_BASE_EXPORT bool IsAndroidTextViewCandidate(const ax::mojom::Role role);
  27. // Returns true if the provided role belongs to a native or an ARIA button.
  28. AX_BASE_EXPORT bool IsButton(const ax::mojom::Role role);
  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. // Returns true if the role is expected to be the parent of a child tree.
  32. // Can return false for a child tree owner if an ARIA role was used, e.g.
  33. // <iframe role="region">.
  34. AX_BASE_EXPORT bool IsChildTreeOwner(const ax::mojom::Role role);
  35. // Returns true if the provided role belongs to an object on which a click
  36. // handler is commonly attached, or to an object that carries out an action when
  37. // clicked, such as activating itself, opening a dialog or closing a menu.
  38. //
  39. // A button and a checkbox fall in the first category, whilst a color well and a
  40. // list menu option in the second. Note that a text field, or a similar element,
  41. // also carries out an action when clicked. It focuses itself, so the action
  42. // verb is "activate". Not all roles that inherently support a click handler or
  43. // that can potentially be focused are included, because in that case even a div
  44. // could be made clickable or focusable.
  45. //
  46. // The reason for the existence of this function is that certain screen readers,
  47. // such as Jaws, might need to report such objects as clickable to their users,
  48. // so that users will know that they could activate them if they so choose.
  49. AX_BASE_EXPORT bool IsClickable(const ax::mojom::Role role);
  50. // Returns true if the provided role is any of the checkbox-related roles.
  51. AX_BASE_EXPORT bool IsCheckBox(ax::mojom::Role role);
  52. // Returns true if the provided role is any of the combobox-related roles.
  53. AX_BASE_EXPORT bool IsComboBox(ax::mojom::Role role);
  54. // Returns true if the provided role is a container that can hold the choices
  55. // for a combobox. For example, a dialog could pop up a list of choices for a
  56. // user, and so a dialog is a potential combobox container.
  57. AX_BASE_EXPORT bool IsComboBoxContainer(const ax::mojom::Role role);
  58. // Returns true if the provided role belongs to a container with selectable
  59. // children.
  60. AX_BASE_EXPORT bool IsContainerWithSelectableChildren(
  61. const ax::mojom::Role role);
  62. // Returns true if the provided role is a control.
  63. AX_BASE_EXPORT bool IsControl(const ax::mojom::Role role);
  64. // Returns true if the provided role is a control on the Android platform.
  65. AX_BASE_EXPORT bool IsControlOnAndroid(const ax::mojom::Role role,
  66. bool isFocusable);
  67. // Returns true for an <input> used for a date or time.
  68. AX_BASE_EXPORT bool IsDateOrTimeInput(const ax::mojom::Role role);
  69. // Returns true if the provided role represents a dialog.
  70. AX_BASE_EXPORT bool IsDialog(const ax::mojom::Role role);
  71. // Returns true if the provided role is a form.
  72. AX_BASE_EXPORT bool IsForm(const ax::mojom::Role role);
  73. // Returns true if crossing into or out of the provided role should count as
  74. // crossing a format boundary.
  75. AX_BASE_EXPORT bool IsFormatBoundary(const ax::mojom::Role role);
  76. // Returns true if the provided role belongs to a grid, treegrid, listgrid
  77. // or tree. Returns false for table.
  78. AX_BASE_EXPORT bool IsGridLike(const ax::mojom::Role role);
  79. // Returns true if the provided role belongs to a heading.
  80. AX_BASE_EXPORT bool IsHeading(const ax::mojom::Role role);
  81. // Returns true if the provided role belongs to a heading or a table header.
  82. AX_BASE_EXPORT bool IsHeadingOrTableHeader(const ax::mojom::Role role);
  83. // Returns true if the provided role belongs to an iframe.
  84. AX_BASE_EXPORT bool IsIframe(const ax::mojom::Role role);
  85. // Returns true if the provided role belongs to an image, graphic, canvas, etc.
  86. AX_BASE_EXPORT bool IsImage(const ax::mojom::Role role);
  87. // Returns true if the provided role is for any kind of image or video.
  88. AX_BASE_EXPORT bool IsImageOrVideo(const ax::mojom::Role role);
  89. // Returns true if the provided role is item-like, specifically if it can hold
  90. // pos_in_set and set_size values. Roles that are item-like are not set-like.
  91. AX_BASE_EXPORT bool IsItemLike(const ax::mojom::Role role);
  92. // Returns true if the role is a subclass of the ARIA Landmark abstract role.
  93. AX_BASE_EXPORT bool IsLandmark(const ax::mojom::Role role);
  94. // Returns true if the provided role belongs to a link.
  95. AX_BASE_EXPORT bool IsLink(const ax::mojom::Role role);
  96. // Returns true if the provided role belongs to a list.
  97. AX_BASE_EXPORT bool IsList(const ax::mojom::Role role);
  98. // Returns true if the provided role belongs to a list item.
  99. AX_BASE_EXPORT bool IsListItem(const ax::mojom::Role role);
  100. // Returns true if the provided role belongs to a menu item, including menu item
  101. // checkbox and menu item radio buttons.
  102. AX_BASE_EXPORT bool IsMenuItem(ax::mojom::Role role);
  103. // Returns true if the provided role belongs to a menu or related control.
  104. AX_BASE_EXPORT bool IsMenuRelated(const ax::mojom::Role role);
  105. // Returns true if the provided role belongs to a node that is at the root of
  106. // what most accessibility APIs consider to be a document, such as the root of a
  107. // webpage, an iframe, or a PDF.
  108. AX_BASE_EXPORT bool IsPlatformDocument(const ax::mojom::Role role);
  109. // Returns true if the provided role is presentational in nature, i.e. a node
  110. // whose implicit native role semantics will not be mapped to the accessibility
  111. // API.
  112. AX_BASE_EXPORT bool IsPresentational(const ax::mojom::Role role);
  113. // Returns true if the provided role belongs to a radio.
  114. AX_BASE_EXPORT bool IsRadio(const ax::mojom::Role role);
  115. // Returns true if the provided role supports a range-based value, such as a
  116. // slider.
  117. AX_BASE_EXPORT bool IsRangeValueSupported(const ax::mojom::Role role);
  118. // Returns true if this object supports readonly.
  119. //
  120. // Note: This returns false for table cells and headers, it is up to the
  121. // caller to make sure that they are included IFF they are within an
  122. // ARIA-1.1+ role='grid' or 'treegrid', and not role='table'.
  123. AX_BASE_EXPORT bool IsReadOnlySupported(const ax::mojom::Role role);
  124. // Returns true if the provided role is at the root of a window-like container,
  125. // (AKA a widget in Views terminology), such as the root of the web contents, a
  126. // window, a dialog or the whole desktop.
  127. AX_BASE_EXPORT bool IsRootLike(ax::mojom::Role role);
  128. // Returns true if the provided role belongs to a widget that can contain a
  129. // table or grid row.
  130. AX_BASE_EXPORT bool IsRowContainer(const ax::mojom::Role role);
  131. // Returns true if the role is a subclass of the ARIA Section abstract role.
  132. AX_BASE_EXPORT bool IsSection(const ax::mojom::Role role);
  133. // Returns true if the role is a subclass of the ARIA Sectionhead role.
  134. AX_BASE_EXPORT bool IsSectionhead(const ax::mojom::Role role);
  135. // Returns true if the role is a subclass of the ARIA Select abstract role.
  136. AX_BASE_EXPORT bool IsSelect(const ax::mojom::Role role);
  137. // Returns true if the role is one of those exposed by the HTML <select>
  138. // element.
  139. AX_BASE_EXPORT bool IsSelectElement(const ax::mojom::Role role);
  140. // Returns true if the provided role either requires or has an implicit value
  141. // for aria-selected state.
  142. AX_BASE_EXPORT bool IsSelectRequiredOrImplicit(const ax::mojom::Role role);
  143. // Returns true if the provided role supports aria-selected state.
  144. AX_BASE_EXPORT bool IsSelectSupported(const ax::mojom::Role role);
  145. // Returns true if the provided role is ordered-set like, specifically if it
  146. // can hold set_size values. Roles that are set-like are not item-like.
  147. AX_BASE_EXPORT bool IsSetLike(const ax::mojom::Role role);
  148. // Returns true if the provided role belongs to a non-interactive list.
  149. AX_BASE_EXPORT bool IsStaticList(const ax::mojom::Role role);
  150. // Returns true if the role is a subclass of the ARIA Structure abstract role.
  151. AX_BASE_EXPORT bool IsStructure(const ax::mojom::Role role);
  152. // Returns true if the provided role belongs to a table or grid column, and the
  153. // table is not used for layout purposes.
  154. AX_BASE_EXPORT bool IsTableColumn(ax::mojom::Role role);
  155. // Returns true if the provided role belongs to a table header.
  156. AX_BASE_EXPORT bool IsTableHeader(ax::mojom::Role role);
  157. // Returns true if the provided role belongs to an item that could be contained
  158. // in a table-like container. For example, a cell or a column header.
  159. AX_BASE_EXPORT bool IsTableItem(ax::mojom::Role role);
  160. // Returns true if the provided role belongs to a table, a grid or a treegrid.
  161. // On Android this also returns true for the roles: lists, list boxes,
  162. // trees, description lists and directories.
  163. AX_BASE_EXPORT bool IsTableLike(const ax::mojom::Role role);
  164. // Returns true if the provided role belongs to a table or grid row, and the
  165. // table is not used for layout purposes.
  166. AX_BASE_EXPORT bool IsTableRow(ax::mojom::Role role);
  167. // Returns true if the provided role is text-related, e.g., static text, line
  168. // break, or inline text box.
  169. AX_BASE_EXPORT bool IsText(ax::mojom::Role role);
  170. // Returns true if the provided role belongs to a native text field, i.e.
  171. // <input> or <textarea>.
  172. AX_BASE_EXPORT bool IsTextField(ax::mojom::Role role);
  173. // Returns true if the provided role fits the description of a UIA embedded
  174. // objects. See the method definition for more details.
  175. AX_BASE_EXPORT bool IsUIAEmbeddedObject(ax::mojom::Role role);
  176. // Returns false if |role| is a layout table, or whatever `IsTableLike` returns.
  177. AX_BASE_EXPORT bool IsUIATableLike(ax::mojom::Role role);
  178. // Returns false if |role| is a layout table cell, or whatever
  179. // `IsCellOrTableHeader` returns.
  180. AX_BASE_EXPORT bool IsUIACellOrTableHeader(ax::mojom::Role role);
  181. // Returns true if the provided role represents a window.
  182. AX_BASE_EXPORT bool IsWindow(const ax::mojom::Role role);
  183. // Returns true if the node should be read only by default
  184. AX_BASE_EXPORT bool ShouldHaveReadonlyStateByDefault(
  185. const ax::mojom::Role role);
  186. // Returns true if the role supports expand/collapse.
  187. AX_BASE_EXPORT bool SupportsExpandCollapse(const ax::mojom::Role role);
  188. // Returns true if the role supports hierarchical level.
  189. AX_BASE_EXPORT bool SupportsHierarchicalLevel(const ax::mojom::Role role);
  190. // Returns true if the provided role can have an orientation.
  191. AX_BASE_EXPORT bool SupportsOrientation(const ax::mojom::Role role);
  192. // Returns true if the provided role can have the required attribute,
  193. // e.g. <div contenteditable aria-required></div> or <input required>
  194. AX_BASE_EXPORT bool SupportsRequired(const ax::mojom::Role role);
  195. // Returns true if the provided role supports toggle.
  196. AX_BASE_EXPORT bool SupportsToggle(const ax::mojom::Role role);
  197. } // namespace ui
  198. #endif // UI_ACCESSIBILITY_AX_ROLE_PROPERTIES_H_