Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ax_role_properties.cc
Go to the documentation of this file.
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
6
8
9#include "ax_enums.h"
10
11namespace ui {
12
13namespace {
14
15#if defined(OS_WIN) || defined(OS_CHROMEOS)
16constexpr bool kExposeLayoutTableAsDataTable = true;
17#else
18constexpr bool kExposeLayoutTableAsDataTable = false;
19#endif // defined(OS_WIN)
20
21} // namespace
22
24 // See http://www.w3.org/TR/core-aam-1.1/#exclude_elements2.
25 if (IsImage(role))
26 return true;
27
28 switch (role) {
40 return true;
41 default:
42 return false;
43 }
44}
45
46bool IsAlert(const ax::mojom::Role role) {
47 switch (role) {
50 return true;
51 default:
52 return false;
53 }
54}
55
56bool IsButton(const ax::mojom::Role role) {
57 // According to the WAI-ARIA spec, native button or role="button"
58 // supports |aria-expanded| and |aria-pressed|.
59 // If the button has |aria-expanded| set, then it takes on
60 // Role::kPopUpButton.
61 // If the button has |aria-pressed| set, then it takes on
62 // Role::kToggleButton.
63 // https://www.w3.org/TR/wai-aria-1.1/#button
64 return role == ax::mojom::Role::kButton ||
67}
68
109
111 switch (role) {
115 return true;
117 return kExposeLayoutTableAsDataTable;
118 default:
119 return false;
120 }
121}
122
143
178
179bool IsControlOnAndroid(const ax::mojom::Role role, bool isFocusable) {
180 switch (role) {
182 return isFocusable;
192 return true;
200 return false;
201 default:
202 return IsControl(role);
203 }
204}
205
206bool IsDocument(const ax::mojom::Role role) {
207 switch (role) {
211 return true;
212 default:
213 return false;
214 }
215}
216
217bool IsDialog(const ax::mojom::Role role) {
218 switch (role) {
221 return true;
222 default:
223 return false;
224 }
225}
226
227bool IsForm(const ax::mojom::Role role) {
228 switch (role) {
230 return true;
231 default:
232 return false;
233 }
234}
235
237 return IsControl(role) || IsHeading(role) || IsImageOrVideo(role);
238}
239
240bool IsHeading(const ax::mojom::Role role) {
241 switch (role) {
244 return true;
245 default:
246 return false;
247 }
248}
249
251 switch (role) {
256 return true;
257 default:
258 return false;
259 }
260}
261
263 switch (role) {
266 return true;
267 default:
268 return false;
269 }
270}
271
273 return IsImage(role) || role == ax::mojom::Role::kVideo;
274}
275
276bool IsImage(const ax::mojom::Role role) {
277 switch (role) {
284 return true;
285 default:
286 return false;
287 }
288}
289
310
311bool IsLandmark(const ax::mojom::Role role) {
312 switch (role) {
321 return true;
322 default:
323 return false;
324 }
325}
326
327bool IsLink(const ax::mojom::Role role) {
328 switch (role) {
334 return true;
335 default:
336 return false;
337 }
338}
339
340bool IsList(const ax::mojom::Role role) {
341 switch (role) {
348 return true;
349 default:
350 return false;
351 }
352}
353
354bool IsListItem(const ax::mojom::Role role) {
355 switch (role) {
362 return true;
363 default:
364 return false;
365 }
366}
367
369 switch (role) {
373 return true;
374 default:
375 return false;
376 }
377}
378
380 switch (role) {
388 return true;
389 default:
390 return false;
391 }
392}
393
395 switch (role) {
398 return true;
399 default:
400 return false;
401 }
402}
403
404bool IsRadio(const ax::mojom::Role role) {
405 switch (role) {
408 return true;
409 default:
410 return false;
411 }
412}
413
415 // https://www.w3.org/TR/wai-aria-1.1/#aria-valuenow
416 // https://www.w3.org/TR/wai-aria-1.1/#aria-valuetext
417 // Roles that support aria-valuetext / aria-valuenow
418 switch (role) {
425 return true;
426 default:
427 return false;
428 }
429}
430
432 // https://www.w3.org/TR/wai-aria-1.1/#aria-readonly
433 // Roles that support aria-readonly
434 switch (role) {
458 return true;
459
460 // https://www.w3.org/TR/wai-aria-1.1/#aria-readonly
461 // ARIA-1.1+ 'gridcell', supports aria-readonly, but 'cell' does not.
462 //
463 // https://www.w3.org/TR/wai-aria-1.1/#columnheader
464 // https://www.w3.org/TR/wai-aria-1.1/#rowheader
465 // While the [columnheader|rowheader] role can be used in both interactive
466 // grids and non-interactive tables, the use of aria-readonly and
467 // aria-required is only applicable to interactive elements.
468 // Therefore, [...] user agents SHOULD NOT expose either property to
469 // assistive technologies unless the columnheader descends from a grid.
473 return false;
474 default:
475 return false;
476 }
477}
478
480 switch (role) {
486 return true;
488 return kExposeLayoutTableAsDataTable;
489 default:
490 return false;
491 }
492}
493
494bool IsSection(const ax::mojom::Role role) {
495 if (IsLandmark(role) || IsSelect(role))
496 return true;
497
498 switch (role) {
500 case ax::mojom::Role::kAlertDialog: // Subclass of kAlert.
502 case ax::mojom::Role::kColumnHeader: // Subclass of kCell.
504 case ax::mojom::Role::kDirectory: // Subclass of kList.
505 case ax::mojom::Role::kFeed: // Subclass of kList.
507 case ax::mojom::Role::kGrid: // Subclass of kTable.
516 case ax::mojom::Role::kProgressIndicator: // Subclass of kStatus.
517 case ax::mojom::Role::kRow: // Subclass of kGroup.
518 case ax::mojom::Role::kRowHeader: // Subclass of kCell.
524 case ax::mojom::Role::kTimer: // Subclass of kStatus.
525 case ax::mojom::Role::kToolbar: // Subclass of kGroup.
527 case ax::mojom::Role::kTreeItem: // Subclass of kListItem.
528 return true;
529 default:
530 return false;
531 }
532}
533
535 switch (role) {
540 return true;
541 default:
542 return false;
543 }
544}
545
546bool IsSelect(const ax::mojom::Role role) {
547 switch (role) {
551 case ax::mojom::Role::kMenuBar: // Subclass of kMenu.
554 case ax::mojom::Role::kTreeGrid: // Subclass of kTree.
555 return true;
556 default:
557 return false;
558 }
559}
560
583
585 switch (role) {
588 return true;
589 default:
590 return false;
591 }
592}
593
594bool IsStructure(const ax::mojom::Role role) {
595 if (IsSection(role) || IsSectionhead(role))
596 return true;
597
598 switch (role) {
601 case ax::mojom::Role::kArticle: // Subclass of kDocument.
605 // Dpub roles.
640 return true;
641 default:
642 return false;
643 }
644}
645
647 return role == ax::mojom::Role::kColumn;
648}
649
651 switch (role) {
654 return true;
655 default:
656 return false;
657 }
658}
659
660bool IsTableLike(const ax::mojom::Role role) {
661 switch (role) {
666 return true;
668 return kExposeLayoutTableAsDataTable;
669 default:
670 return false;
671 }
672}
673
675 switch (role) {
677 return true;
679 return kExposeLayoutTableAsDataTable;
680 default:
681 return false;
682 }
683}
684
686 switch (role) {
693 return true;
694 default:
695 return false;
696 }
697}
698
700 switch (role) {
706 return true;
707 default:
708 return false;
709 }
710}
711
713 switch (role) {
719 return true;
720 default:
721 return false;
722 }
723}
724
745
747 switch (role) {
756 return true;
757 default:
758 return false;
759 }
760}
761
763 switch (role) {
768 return true;
769 default:
770 return false;
771 }
772}
773
775 switch (role) {
793 return true;
794
796 // TODO(aleventhal) this changed between ARIA 1.0 and 1.1,
797 // need to determine whether grids/treegrids should really be readonly
798 // or editable by default
799 break;
800
801 default:
802 break;
803 }
804 return false;
805}
806
807} // namespace ui
bool IsImage(const ax::mojom::Role role)
bool IsTableColumn(ax::mojom::Role role)
bool IsForm(const ax::mojom::Role role)
bool IsSelect(const ax::mojom::Role role)
bool SupportsSelected(const ax::mojom::Role role)
bool IsRangeValueSupported(const ax::mojom::Role role)
bool IsContainerWithSelectableChildren(const ax::mojom::Role role)
bool IsControl(const ax::mojom::Role role)
bool IsMenuRelated(const ax::mojom::Role role)
bool IsReadOnlySupported(const ax::mojom::Role role)
bool IsSection(const ax::mojom::Role role)
bool IsLink(const ax::mojom::Role role)
bool IsStructure(const ax::mojom::Role role)
bool IsCellOrTableHeader(const ax::mojom::Role role)
bool IsRowContainer(const ax::mojom::Role role)
bool HasPresentationalChildren(const ax::mojom::Role role)
bool IsHeadingOrTableHeader(const ax::mojom::Role role)
bool IsMenuItem(ax::mojom::Role role)
bool SupportsHierarchicalLevel(const ax::mojom::Role role)
bool IsTableRow(ax::mojom::Role role)
bool IsImageOrVideo(const ax::mojom::Role role)
bool IsItemLike(const ax::mojom::Role role)
bool IsTableLike(const ax::mojom::Role role)
bool SupportsExpandCollapse(const ax::mojom::Role role)
bool IsIframe(ax::mojom::Role role)
bool IsRadio(const ax::mojom::Role role)
bool SupportsOrientation(const ax::mojom::Role role)
bool IsTableHeader(ax::mojom::Role role)
bool IsSectionhead(const ax::mojom::Role role)
bool IsListItem(const ax::mojom::Role role)
bool IsSetLike(const ax::mojom::Role role)
bool SupportsToggle(const ax::mojom::Role role)
bool IsFormatBoundary(const ax::mojom::Role role)
bool ShouldHaveReadonlyStateByDefault(const ax::mojom::Role role)
bool IsLandmark(const ax::mojom::Role role)
bool IsClickable(const ax::mojom::Role role)
bool IsList(const ax::mojom::Role role)
bool IsDialog(const ax::mojom::Role role)
bool IsStaticList(const ax::mojom::Role role)
bool IsButton(const ax::mojom::Role role)
bool IsControlOnAndroid(const ax::mojom::Role role, bool isFocusable)
bool IsHeading(const ax::mojom::Role role)
bool IsText(ax::mojom::Role role)
bool IsPresentational(const ax::mojom::Role role)
bool IsAlert(const ax::mojom::Role role)
bool IsDocument(const ax::mojom::Role role)