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 // Return true if |attr| is a node ID that would need to be mapped when |
| 62 // renumbering the ids in a combined tree. |
| 63 bool IsNodeIdIntAttribute(AXIntAttribute attr) { |
| 64 switch (attr) { |
| 65 case AX_ATTR_ACTIVEDESCENDANT_ID: |
| 66 case AX_ATTR_ERRORMESSAGE_ID: |
| 67 case AX_ATTR_MEMBER_OF_ID: |
| 68 case AX_ATTR_NEXT_ON_LINE_ID: |
| 69 case AX_ATTR_PREVIOUS_ON_LINE_ID: |
| 70 case AX_ATTR_TABLE_HEADER_ID: |
| 71 case AX_ATTR_TABLE_COLUMN_HEADER_ID: |
| 72 case AX_ATTR_TABLE_ROW_HEADER_ID: |
| 73 return true; |
| 74 |
| 75 // Note: all of the attributes are included here explicitly, |
| 76 // rather than using "default:", so that it's a compiler error to |
| 77 // add a new attribute without explicitly considering whether it's |
| 78 // a node id attribute or not. |
| 79 case AX_INT_ATTRIBUTE_NONE: |
| 80 case AX_ATTR_ACTION: |
| 81 case AX_ATTR_SCROLL_X: |
| 82 case AX_ATTR_SCROLL_X_MIN: |
| 83 case AX_ATTR_SCROLL_X_MAX: |
| 84 case AX_ATTR_SCROLL_Y: |
| 85 case AX_ATTR_SCROLL_Y_MIN: |
| 86 case AX_ATTR_SCROLL_Y_MAX: |
| 87 case AX_ATTR_TEXT_SEL_START: |
| 88 case AX_ATTR_TEXT_SEL_END: |
| 89 case AX_ATTR_TABLE_ROW_COUNT: |
| 90 case AX_ATTR_TABLE_COLUMN_COUNT: |
| 91 case AX_ATTR_TABLE_ROW_INDEX: |
| 92 case AX_ATTR_TABLE_COLUMN_INDEX: |
| 93 case AX_ATTR_TABLE_CELL_COLUMN_INDEX: |
| 94 case AX_ATTR_TABLE_CELL_COLUMN_SPAN: |
| 95 case AX_ATTR_TABLE_CELL_ROW_INDEX: |
| 96 case AX_ATTR_TABLE_CELL_ROW_SPAN: |
| 97 case AX_ATTR_SORT_DIRECTION: |
| 98 case AX_ATTR_HIERARCHICAL_LEVEL: |
| 99 case AX_ATTR_NAME_FROM: |
| 100 case AX_ATTR_DESCRIPTION_FROM: |
| 101 case AX_ATTR_CHILD_TREE_ID: |
| 102 case AX_ATTR_SET_SIZE: |
| 103 case AX_ATTR_POS_IN_SET: |
| 104 case AX_ATTR_COLOR_VALUE: |
| 105 case AX_ATTR_ARIA_CURRENT_STATE: |
| 106 case AX_ATTR_BACKGROUND_COLOR: |
| 107 case AX_ATTR_COLOR: |
| 108 case AX_ATTR_INVALID_STATE: |
| 109 case AX_ATTR_TEXT_DIRECTION: |
| 110 case AX_ATTR_TEXT_STYLE: |
| 111 case AX_ATTR_ARIA_COL_COUNT: |
| 112 case AX_ATTR_ARIA_COL_INDEX: |
| 113 case AX_ATTR_ARIA_ROW_COUNT: |
| 114 case AX_ATTR_ARIA_ROW_INDEX: |
| 115 return false; |
| 116 } |
| 117 |
| 118 NOTREACHED(); |
| 119 return false; |
| 120 } |
| 121 |
| 122 // Return true if |attr| contains a vector of node ids that would need |
| 123 // to be mapped when renumbering the ids in a combined tree. |
| 124 bool IsNodeIdIntListAttribute(AXIntListAttribute attr) { |
| 125 switch (attr) { |
| 126 case AX_ATTR_CELL_IDS: |
| 127 case AX_ATTR_CONTROLS_IDS: |
| 128 case AX_ATTR_DESCRIBEDBY_IDS: |
| 129 case AX_ATTR_DETAILS_IDS: |
| 130 case AX_ATTR_FLOWTO_IDS: |
| 131 case AX_ATTR_INDIRECT_CHILD_IDS: |
| 132 case AX_ATTR_LABELLEDBY_IDS: |
| 133 case AX_ATTR_UNIQUE_CELL_IDS: |
| 134 return true; |
| 135 |
| 136 // Note: all of the attributes are included here explicitly, |
| 137 // rather than using "default:", so that it's a compiler error to |
| 138 // add a new attribute without explicitly considering whether it's |
| 139 // a node id attribute or not. |
| 140 case AX_INT_LIST_ATTRIBUTE_NONE: |
| 141 case AX_ATTR_LINE_BREAKS: |
| 142 case AX_ATTR_MARKER_TYPES: |
| 143 case AX_ATTR_MARKER_STARTS: |
| 144 case AX_ATTR_MARKER_ENDS: |
| 145 case AX_ATTR_CHARACTER_OFFSETS: |
| 146 case AX_ATTR_CACHED_LINE_STARTS: |
| 147 case AX_ATTR_WORD_STARTS: |
| 148 case AX_ATTR_WORD_ENDS: |
| 149 return false; |
| 150 } |
| 151 |
| 152 NOTREACHED(); |
| 153 return false; |
| 154 } |
| 155 |
61 AXNodeData::AXNodeData() | 156 AXNodeData::AXNodeData() |
62 : id(-1), | 157 : id(-1), |
63 role(AX_ROLE_UNKNOWN), | 158 role(AX_ROLE_UNKNOWN), |
64 // Turn on all flags to more easily catch bugs where no flags are set. | 159 // 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. | 160 // This will be cleared back to a 0-state before use. |
66 state(0xFFFFFFFF), | 161 state(0xFFFFFFFF), |
67 offset_container_id(-1) { | 162 offset_container_id(-1) { |
68 } | 163 } |
69 | 164 |
70 AXNodeData::~AXNodeData() { | 165 AXNodeData::~AXNodeData() { |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 ui::ToString(static_cast<AXNameFrom>(int_attributes[i].second)); | 590 ui::ToString(static_cast<AXNameFrom>(int_attributes[i].second)); |
496 break; | 591 break; |
497 case AX_ATTR_DESCRIPTION_FROM: | 592 case AX_ATTR_DESCRIPTION_FROM: |
498 result += " description_from=" + | 593 result += " description_from=" + |
499 ui::ToString( | 594 ui::ToString( |
500 static_cast<AXDescriptionFrom>(int_attributes[i].second)); | 595 static_cast<AXDescriptionFrom>(int_attributes[i].second)); |
501 break; | 596 break; |
502 case AX_ATTR_ACTIVEDESCENDANT_ID: | 597 case AX_ATTR_ACTIVEDESCENDANT_ID: |
503 result += " activedescendant=" + value; | 598 result += " activedescendant=" + value; |
504 break; | 599 break; |
| 600 case AX_ATTR_ERRORMESSAGE_ID: |
| 601 result += " errormessage=" + value; |
| 602 break; |
505 case AX_ATTR_MEMBER_OF_ID: | 603 case AX_ATTR_MEMBER_OF_ID: |
506 result += " member_of_id=" + value; | 604 result += " member_of_id=" + value; |
507 break; | 605 break; |
508 case AX_ATTR_NEXT_ON_LINE_ID: | 606 case AX_ATTR_NEXT_ON_LINE_ID: |
509 result += " next_on_line_id=" + value; | 607 result += " next_on_line_id=" + value; |
510 break; | 608 break; |
511 case AX_ATTR_PREVIOUS_ON_LINE_ID: | 609 case AX_ATTR_PREVIOUS_ON_LINE_ID: |
512 result += " previous_on_line_id=" + value; | 610 result += " previous_on_line_id=" + value; |
513 break; | 611 break; |
514 case AX_ATTR_CHILD_TREE_ID: | 612 case AX_ATTR_CHILD_TREE_ID: |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 case AX_ATTR_FONT_FAMILY: | 734 case AX_ATTR_FONT_FAMILY: |
637 result += " font-family=" + value; | 735 result += " font-family=" + value; |
638 break; | 736 break; |
639 case AX_ATTR_HTML_TAG: | 737 case AX_ATTR_HTML_TAG: |
640 result += " html_tag=" + value; | 738 result += " html_tag=" + value; |
641 break; | 739 break; |
642 case AX_ATTR_IMAGE_DATA_URL: | 740 case AX_ATTR_IMAGE_DATA_URL: |
643 result += " image_data_url=(" + | 741 result += " image_data_url=(" + |
644 IntToString(static_cast<int>(value.size())) + " bytes)"; | 742 IntToString(static_cast<int>(value.size())) + " bytes)"; |
645 break; | 743 break; |
| 744 case AX_ATTR_KEY_SHORTCUTS: |
| 745 result += " key_shortcuts=" + value; |
| 746 break; |
646 case AX_ATTR_LANGUAGE: | 747 case AX_ATTR_LANGUAGE: |
647 result += " language=" + value; | 748 result += " language=" + value; |
648 break; | 749 break; |
649 case AX_ATTR_LIVE_RELEVANT: | 750 case AX_ATTR_LIVE_RELEVANT: |
650 result += " relevant=" + value; | 751 result += " relevant=" + value; |
651 break; | 752 break; |
652 case AX_ATTR_LIVE_STATUS: | 753 case AX_ATTR_LIVE_STATUS: |
653 result += " live=" + value; | 754 result += " live=" + value; |
654 break; | 755 break; |
655 case AX_ATTR_CONTAINER_LIVE_RELEVANT: | 756 case AX_ATTR_CONTAINER_LIVE_RELEVANT: |
656 result += " container_relevant=" + value; | 757 result += " container_relevant=" + value; |
657 break; | 758 break; |
658 case AX_ATTR_CONTAINER_LIVE_STATUS: | 759 case AX_ATTR_CONTAINER_LIVE_STATUS: |
659 result += " container_live=" + value; | 760 result += " container_live=" + value; |
660 break; | 761 break; |
661 case AX_ATTR_PLACEHOLDER: | 762 case AX_ATTR_PLACEHOLDER: |
662 result += " placeholder=" + value; | 763 result += " placeholder=" + value; |
663 break; | 764 break; |
664 case AX_ATTR_ROLE: | 765 case AX_ATTR_ROLE: |
665 result += " role=" + value; | 766 result += " role=" + value; |
666 break; | 767 break; |
| 768 case AX_ATTR_ROLE_DESCRIPTION: |
| 769 result += " role_description=" + value; |
| 770 break; |
667 case AX_ATTR_SHORTCUT: | 771 case AX_ATTR_SHORTCUT: |
668 result += " shortcut=" + value; | 772 result += " shortcut=" + value; |
669 break; | 773 break; |
670 case AX_ATTR_URL: | 774 case AX_ATTR_URL: |
671 result += " url=" + value; | 775 result += " url=" + value; |
672 break; | 776 break; |
673 case AX_ATTR_NAME: | 777 case AX_ATTR_NAME: |
674 result += " name=" + value; | 778 result += " name=" + value; |
675 break; | 779 break; |
676 case AX_ATTR_VALUE: | 780 case AX_ATTR_VALUE: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 break; | 828 break; |
725 case AX_ATTR_CAN_SET_VALUE: | 829 case AX_ATTR_CAN_SET_VALUE: |
726 result += " can_set_value=" + value; | 830 result += " can_set_value=" + value; |
727 break; | 831 break; |
728 case AX_ATTR_UPDATE_LOCATION_ONLY: | 832 case AX_ATTR_UPDATE_LOCATION_ONLY: |
729 result += " update_location_only=" + value; | 833 result += " update_location_only=" + value; |
730 break; | 834 break; |
731 case AX_ATTR_CANVAS_HAS_FALLBACK: | 835 case AX_ATTR_CANVAS_HAS_FALLBACK: |
732 result += " has_fallback=" + value; | 836 result += " has_fallback=" + value; |
733 break; | 837 break; |
| 838 case AX_ATTR_MODAL: |
| 839 result += " modal=" + value; |
| 840 break; |
734 case AX_BOOL_ATTRIBUTE_NONE: | 841 case AX_BOOL_ATTRIBUTE_NONE: |
735 break; | 842 break; |
736 } | 843 } |
737 } | 844 } |
738 | 845 |
739 for (size_t i = 0; i < intlist_attributes.size(); ++i) { | 846 for (size_t i = 0; i < intlist_attributes.size(); ++i) { |
740 const std::vector<int32_t>& values = intlist_attributes[i].second; | 847 const std::vector<int32_t>& values = intlist_attributes[i].second; |
741 switch (intlist_attributes[i].first) { | 848 switch (intlist_attributes[i].first) { |
742 case AX_ATTR_INDIRECT_CHILD_IDS: | 849 case AX_ATTR_INDIRECT_CHILD_IDS: |
743 result += " indirect_child_ids=" + IntVectorToString(values); | 850 result += " indirect_child_ids=" + IntVectorToString(values); |
744 break; | 851 break; |
745 case AX_ATTR_CONTROLS_IDS: | 852 case AX_ATTR_CONTROLS_IDS: |
746 result += " controls_ids=" + IntVectorToString(values); | 853 result += " controls_ids=" + IntVectorToString(values); |
747 break; | 854 break; |
748 case AX_ATTR_DESCRIBEDBY_IDS: | 855 case AX_ATTR_DESCRIBEDBY_IDS: |
749 result += " describedby_ids=" + IntVectorToString(values); | 856 result += " describedby_ids=" + IntVectorToString(values); |
750 break; | 857 break; |
| 858 case AX_ATTR_DETAILS_IDS: |
| 859 result += " details_ids=" + IntVectorToString(values); |
| 860 break; |
751 case AX_ATTR_FLOWTO_IDS: | 861 case AX_ATTR_FLOWTO_IDS: |
752 result += " flowto_ids=" + IntVectorToString(values); | 862 result += " flowto_ids=" + IntVectorToString(values); |
753 break; | 863 break; |
754 case AX_ATTR_LABELLEDBY_IDS: | 864 case AX_ATTR_LABELLEDBY_IDS: |
755 result += " labelledby_ids=" + IntVectorToString(values); | 865 result += " labelledby_ids=" + IntVectorToString(values); |
756 break; | 866 break; |
757 case AX_ATTR_LINE_BREAKS: | 867 case AX_ATTR_LINE_BREAKS: |
758 result += " line_breaks=" + IntVectorToString(values); | 868 result += " line_breaks=" + IntVectorToString(values); |
759 break; | 869 break; |
760 case AX_ATTR_MARKER_TYPES: { | 870 case AX_ATTR_MARKER_TYPES: { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 } | 921 } |
812 } | 922 } |
813 | 923 |
814 if (!child_ids.empty()) | 924 if (!child_ids.empty()) |
815 result += " child_ids=" + IntVectorToString(child_ids); | 925 result += " child_ids=" + IntVectorToString(child_ids); |
816 | 926 |
817 return result; | 927 return result; |
818 } | 928 } |
819 | 929 |
820 } // namespace ui | 930 } // namespace ui |
OLD | NEW |