OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/accessibility/ax_node_data.h" | 5 #include "ui/accessibility/ax_node_data.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 FindInVectorOfPairs( | 51 FindInVectorOfPairs( |
52 FirstType first, | 52 FirstType first, |
53 const std::vector<std::pair<FirstType, SecondType>>& vector) { | 53 const std::vector<std::pair<FirstType, SecondType>>& vector) { |
54 return std::find_if(vector.begin(), | 54 return std::find_if(vector.begin(), |
55 vector.end(), | 55 vector.end(), |
56 FirstIs<FirstType, SecondType>(first)); | 56 FirstIs<FirstType, SecondType>(first)); |
57 } | 57 } |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
| 61 bool IsNodeIdIntAttribute(AXIntAttribute attr) { |
| 62 switch (attr) { |
| 63 case AX_ATTR_ACTIVEDESCENDANT_ID: |
| 64 case AX_ATTR_ERRORMESSAGE_ID: |
| 65 case AX_ATTR_MEMBER_OF_ID: |
| 66 case AX_ATTR_NEXT_ON_LINE_ID: |
| 67 case AX_ATTR_PREVIOUS_ON_LINE_ID: |
| 68 case AX_ATTR_TABLE_HEADER_ID: |
| 69 case AX_ATTR_TABLE_COLUMN_HEADER_ID: |
| 70 case AX_ATTR_TABLE_ROW_HEADER_ID: |
| 71 return true; |
| 72 |
| 73 // Note: all of the attributes are included here explicitly, |
| 74 // rather than using "default:", so that it's a compiler error to |
| 75 // add a new attribute without explicitly considering whether it's |
| 76 // a node id attribute or not. |
| 77 case AX_INT_ATTRIBUTE_NONE: |
| 78 case AX_ATTR_ACTION: |
| 79 case AX_ATTR_SCROLL_X: |
| 80 case AX_ATTR_SCROLL_X_MIN: |
| 81 case AX_ATTR_SCROLL_X_MAX: |
| 82 case AX_ATTR_SCROLL_Y: |
| 83 case AX_ATTR_SCROLL_Y_MIN: |
| 84 case AX_ATTR_SCROLL_Y_MAX: |
| 85 case AX_ATTR_TEXT_SEL_START: |
| 86 case AX_ATTR_TEXT_SEL_END: |
| 87 case AX_ATTR_TABLE_ROW_COUNT: |
| 88 case AX_ATTR_TABLE_COLUMN_COUNT: |
| 89 case AX_ATTR_TABLE_ROW_INDEX: |
| 90 case AX_ATTR_TABLE_COLUMN_INDEX: |
| 91 case AX_ATTR_TABLE_CELL_COLUMN_INDEX: |
| 92 case AX_ATTR_TABLE_CELL_COLUMN_SPAN: |
| 93 case AX_ATTR_TABLE_CELL_ROW_INDEX: |
| 94 case AX_ATTR_TABLE_CELL_ROW_SPAN: |
| 95 case AX_ATTR_SORT_DIRECTION: |
| 96 case AX_ATTR_HIERARCHICAL_LEVEL: |
| 97 case AX_ATTR_NAME_FROM: |
| 98 case AX_ATTR_DESCRIPTION_FROM: |
| 99 case AX_ATTR_CHILD_TREE_ID: |
| 100 case AX_ATTR_SET_SIZE: |
| 101 case AX_ATTR_POS_IN_SET: |
| 102 case AX_ATTR_COLOR_VALUE: |
| 103 case AX_ATTR_ARIA_CURRENT_STATE: |
| 104 case AX_ATTR_BACKGROUND_COLOR: |
| 105 case AX_ATTR_COLOR: |
| 106 case AX_ATTR_INVALID_STATE: |
| 107 case AX_ATTR_TEXT_DIRECTION: |
| 108 case AX_ATTR_TEXT_STYLE: |
| 109 return false; |
| 110 } |
| 111 |
| 112 NOTREACHED(); |
| 113 return false; |
| 114 } |
| 115 |
| 116 bool IsNodeIdIntListAttribute(AXIntListAttribute attr) { |
| 117 switch (attr) { |
| 118 case AX_ATTR_CELL_IDS: |
| 119 case AX_ATTR_CONTROLS_IDS: |
| 120 case AX_ATTR_DESCRIBEDBY_IDS: |
| 121 case AX_ATTR_DETAILS_IDS: |
| 122 case AX_ATTR_FLOWTO_IDS: |
| 123 case AX_ATTR_INDIRECT_CHILD_IDS: |
| 124 case AX_ATTR_LABELLEDBY_IDS: |
| 125 case AX_ATTR_UNIQUE_CELL_IDS: |
| 126 return true; |
| 127 |
| 128 // Note: all of the attributes are included here explicitly, |
| 129 // rather than using "default:", so that it's a compiler error to |
| 130 // add a new attribute without explicitly considering whether it's |
| 131 // a node id attribute or not. |
| 132 case AX_INT_LIST_ATTRIBUTE_NONE: |
| 133 case AX_ATTR_LINE_BREAKS: |
| 134 case AX_ATTR_MARKER_TYPES: |
| 135 case AX_ATTR_MARKER_STARTS: |
| 136 case AX_ATTR_MARKER_ENDS: |
| 137 case AX_ATTR_CHARACTER_OFFSETS: |
| 138 case AX_ATTR_CACHED_LINE_STARTS: |
| 139 case AX_ATTR_WORD_STARTS: |
| 140 case AX_ATTR_WORD_ENDS: |
| 141 return false; |
| 142 } |
| 143 |
| 144 NOTREACHED(); |
| 145 return false; |
| 146 } |
| 147 |
61 AXNodeData::AXNodeData() | 148 AXNodeData::AXNodeData() |
62 : id(-1), | 149 : id(-1), |
63 role(AX_ROLE_UNKNOWN), | 150 role(AX_ROLE_UNKNOWN), |
64 // Turn on all flags to more easily catch bugs where no flags are set. | 151 // Turn on all flags to more easily catch bugs where no flags are set. |
65 // This will be cleared back to a 0-state before use. | 152 // This will be cleared back to a 0-state before use. |
66 state(0xFFFFFFFF), | 153 state(0xFFFFFFFF), |
67 offset_container_id(-1) { | 154 offset_container_id(-1) { |
68 } | 155 } |
69 | 156 |
70 AXNodeData::~AXNodeData() { | 157 AXNodeData::~AXNodeData() { |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 ui::ToString(static_cast<AXNameFrom>(int_attributes[i].second)); | 570 ui::ToString(static_cast<AXNameFrom>(int_attributes[i].second)); |
484 break; | 571 break; |
485 case AX_ATTR_DESCRIPTION_FROM: | 572 case AX_ATTR_DESCRIPTION_FROM: |
486 result += " description_from=" + | 573 result += " description_from=" + |
487 ui::ToString( | 574 ui::ToString( |
488 static_cast<AXDescriptionFrom>(int_attributes[i].second)); | 575 static_cast<AXDescriptionFrom>(int_attributes[i].second)); |
489 break; | 576 break; |
490 case AX_ATTR_ACTIVEDESCENDANT_ID: | 577 case AX_ATTR_ACTIVEDESCENDANT_ID: |
491 result += " activedescendant=" + value; | 578 result += " activedescendant=" + value; |
492 break; | 579 break; |
| 580 case AX_ATTR_ERRORMESSAGE_ID: |
| 581 result += " errormessage=" + value; |
| 582 break; |
493 case AX_ATTR_MEMBER_OF_ID: | 583 case AX_ATTR_MEMBER_OF_ID: |
494 result += " member_of_id=" + value; | 584 result += " member_of_id=" + value; |
495 break; | 585 break; |
496 case AX_ATTR_NEXT_ON_LINE_ID: | 586 case AX_ATTR_NEXT_ON_LINE_ID: |
497 result += " next_on_line_id=" + value; | 587 result += " next_on_line_id=" + value; |
498 break; | 588 break; |
499 case AX_ATTR_PREVIOUS_ON_LINE_ID: | 589 case AX_ATTR_PREVIOUS_ON_LINE_ID: |
500 result += " previous_on_line_id=" + value; | 590 result += " previous_on_line_id=" + value; |
501 break; | 591 break; |
502 case AX_ATTR_CHILD_TREE_ID: | 592 case AX_ATTR_CHILD_TREE_ID: |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 case AX_ATTR_FONT_FAMILY: | 711 case AX_ATTR_FONT_FAMILY: |
622 result += " font-family=" + value; | 712 result += " font-family=" + value; |
623 break; | 713 break; |
624 case AX_ATTR_HTML_TAG: | 714 case AX_ATTR_HTML_TAG: |
625 result += " html_tag=" + value; | 715 result += " html_tag=" + value; |
626 break; | 716 break; |
627 case AX_ATTR_IMAGE_DATA_URL: | 717 case AX_ATTR_IMAGE_DATA_URL: |
628 result += " image_data_url=(" + | 718 result += " image_data_url=(" + |
629 IntToString(static_cast<int>(value.size())) + " bytes)"; | 719 IntToString(static_cast<int>(value.size())) + " bytes)"; |
630 break; | 720 break; |
| 721 case AX_ATTR_KEY_SHORTCUTS: |
| 722 result += " key_shortcuts=" + value; |
| 723 break; |
631 case AX_ATTR_LANGUAGE: | 724 case AX_ATTR_LANGUAGE: |
632 result += " language=" + value; | 725 result += " language=" + value; |
633 break; | 726 break; |
634 case AX_ATTR_LIVE_RELEVANT: | 727 case AX_ATTR_LIVE_RELEVANT: |
635 result += " relevant=" + value; | 728 result += " relevant=" + value; |
636 break; | 729 break; |
637 case AX_ATTR_LIVE_STATUS: | 730 case AX_ATTR_LIVE_STATUS: |
638 result += " live=" + value; | 731 result += " live=" + value; |
639 break; | 732 break; |
640 case AX_ATTR_CONTAINER_LIVE_RELEVANT: | 733 case AX_ATTR_CONTAINER_LIVE_RELEVANT: |
641 result += " container_relevant=" + value; | 734 result += " container_relevant=" + value; |
642 break; | 735 break; |
643 case AX_ATTR_CONTAINER_LIVE_STATUS: | 736 case AX_ATTR_CONTAINER_LIVE_STATUS: |
644 result += " container_live=" + value; | 737 result += " container_live=" + value; |
645 break; | 738 break; |
646 case AX_ATTR_PLACEHOLDER: | 739 case AX_ATTR_PLACEHOLDER: |
647 result += " placeholder=" + value; | 740 result += " placeholder=" + value; |
648 break; | 741 break; |
649 case AX_ATTR_ROLE: | 742 case AX_ATTR_ROLE: |
650 result += " role=" + value; | 743 result += " role=" + value; |
651 break; | 744 break; |
| 745 case AX_ATTR_ROLE_DESCRIPTION: |
| 746 result += " role_description=" + value; |
| 747 break; |
652 case AX_ATTR_SHORTCUT: | 748 case AX_ATTR_SHORTCUT: |
653 result += " shortcut=" + value; | 749 result += " shortcut=" + value; |
654 break; | 750 break; |
655 case AX_ATTR_URL: | 751 case AX_ATTR_URL: |
656 result += " url=" + value; | 752 result += " url=" + value; |
657 break; | 753 break; |
658 case AX_ATTR_NAME: | 754 case AX_ATTR_NAME: |
659 result += " name=" + value; | 755 result += " name=" + value; |
660 break; | 756 break; |
661 case AX_ATTR_VALUE: | 757 case AX_ATTR_VALUE: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 break; | 805 break; |
710 case AX_ATTR_CAN_SET_VALUE: | 806 case AX_ATTR_CAN_SET_VALUE: |
711 result += " can_set_value=" + value; | 807 result += " can_set_value=" + value; |
712 break; | 808 break; |
713 case AX_ATTR_UPDATE_LOCATION_ONLY: | 809 case AX_ATTR_UPDATE_LOCATION_ONLY: |
714 result += " update_location_only=" + value; | 810 result += " update_location_only=" + value; |
715 break; | 811 break; |
716 case AX_ATTR_CANVAS_HAS_FALLBACK: | 812 case AX_ATTR_CANVAS_HAS_FALLBACK: |
717 result += " has_fallback=" + value; | 813 result += " has_fallback=" + value; |
718 break; | 814 break; |
| 815 case AX_ATTR_MODAL: |
| 816 result += " modal=" + value; |
| 817 break; |
719 case AX_BOOL_ATTRIBUTE_NONE: | 818 case AX_BOOL_ATTRIBUTE_NONE: |
720 break; | 819 break; |
721 } | 820 } |
722 } | 821 } |
723 | 822 |
724 for (size_t i = 0; i < intlist_attributes.size(); ++i) { | 823 for (size_t i = 0; i < intlist_attributes.size(); ++i) { |
725 const std::vector<int32_t>& values = intlist_attributes[i].second; | 824 const std::vector<int32_t>& values = intlist_attributes[i].second; |
726 switch (intlist_attributes[i].first) { | 825 switch (intlist_attributes[i].first) { |
727 case AX_ATTR_INDIRECT_CHILD_IDS: | 826 case AX_ATTR_INDIRECT_CHILD_IDS: |
728 result += " indirect_child_ids=" + IntVectorToString(values); | 827 result += " indirect_child_ids=" + IntVectorToString(values); |
729 break; | 828 break; |
730 case AX_ATTR_CONTROLS_IDS: | 829 case AX_ATTR_CONTROLS_IDS: |
731 result += " controls_ids=" + IntVectorToString(values); | 830 result += " controls_ids=" + IntVectorToString(values); |
732 break; | 831 break; |
733 case AX_ATTR_DESCRIBEDBY_IDS: | 832 case AX_ATTR_DESCRIBEDBY_IDS: |
734 result += " describedby_ids=" + IntVectorToString(values); | 833 result += " describedby_ids=" + IntVectorToString(values); |
735 break; | 834 break; |
| 835 case AX_ATTR_DETAILS_IDS: |
| 836 result += " details_ids=" + IntVectorToString(values); |
| 837 break; |
736 case AX_ATTR_FLOWTO_IDS: | 838 case AX_ATTR_FLOWTO_IDS: |
737 result += " flowto_ids=" + IntVectorToString(values); | 839 result += " flowto_ids=" + IntVectorToString(values); |
738 break; | 840 break; |
739 case AX_ATTR_LABELLEDBY_IDS: | 841 case AX_ATTR_LABELLEDBY_IDS: |
740 result += " labelledby_ids=" + IntVectorToString(values); | 842 result += " labelledby_ids=" + IntVectorToString(values); |
741 break; | 843 break; |
742 case AX_ATTR_LINE_BREAKS: | 844 case AX_ATTR_LINE_BREAKS: |
743 result += " line_breaks=" + IntVectorToString(values); | 845 result += " line_breaks=" + IntVectorToString(values); |
744 break; | 846 break; |
745 case AX_ATTR_MARKER_TYPES: { | 847 case AX_ATTR_MARKER_TYPES: { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 } | 898 } |
797 } | 899 } |
798 | 900 |
799 if (!child_ids.empty()) | 901 if (!child_ids.empty()) |
800 result += " child_ids=" + IntVectorToString(child_ids); | 902 result += " child_ids=" + IntVectorToString(child_ids); |
801 | 903 |
802 return result; | 904 return result; |
803 } | 905 } |
804 | 906 |
805 } // namespace ui | 907 } // namespace ui |
OLD | NEW |