OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_tree.h" | 5 #include "ui/accessibility/ax_tree.h" |
6 #include "ui/accessibility/ax_tree_combiner.h" | 6 #include "ui/accessibility/ax_tree_combiner.h" |
7 #include "ui/gfx/geometry/rect_f.h" | 7 #include "ui/gfx/geometry/rect_f.h" |
8 | 8 |
9 namespace ui { | 9 namespace ui { |
10 namespace { | |
11 | |
12 // Return true if |attr| is a node ID that would need to be mapped when | |
13 // renumbering the ids in a combined tree. | |
14 bool IsNodeIdIntAttribute(AXIntAttribute attr) { | |
15 switch (attr) { | |
16 case AX_ATTR_ACTIVEDESCENDANT_ID: | |
17 case AX_ATTR_MEMBER_OF_ID: | |
18 case AX_ATTR_NEXT_ON_LINE_ID: | |
19 case AX_ATTR_PREVIOUS_ON_LINE_ID: | |
20 case AX_ATTR_TABLE_HEADER_ID: | |
21 case AX_ATTR_TABLE_COLUMN_HEADER_ID: | |
22 case AX_ATTR_TABLE_ROW_HEADER_ID: | |
23 return true; | |
24 | |
25 // Note: all of the attributes are included here explicitly, | |
26 // rather than using "default:", so that it's a compiler error to | |
27 // add a new attribute without explicitly considering whether it's | |
28 // a node id attribute or not. | |
29 case AX_INT_ATTRIBUTE_NONE: | |
30 case AX_ATTR_ACTION: | |
31 case AX_ATTR_SCROLL_X: | |
32 case AX_ATTR_SCROLL_X_MIN: | |
33 case AX_ATTR_SCROLL_X_MAX: | |
34 case AX_ATTR_SCROLL_Y: | |
35 case AX_ATTR_SCROLL_Y_MIN: | |
36 case AX_ATTR_SCROLL_Y_MAX: | |
37 case AX_ATTR_TEXT_SEL_START: | |
38 case AX_ATTR_TEXT_SEL_END: | |
39 case AX_ATTR_TABLE_ROW_COUNT: | |
40 case AX_ATTR_TABLE_COLUMN_COUNT: | |
41 case AX_ATTR_TABLE_ROW_INDEX: | |
42 case AX_ATTR_TABLE_COLUMN_INDEX: | |
43 case AX_ATTR_TABLE_CELL_COLUMN_INDEX: | |
44 case AX_ATTR_TABLE_CELL_COLUMN_SPAN: | |
45 case AX_ATTR_TABLE_CELL_ROW_INDEX: | |
46 case AX_ATTR_TABLE_CELL_ROW_SPAN: | |
47 case AX_ATTR_SORT_DIRECTION: | |
48 case AX_ATTR_HIERARCHICAL_LEVEL: | |
49 case AX_ATTR_NAME_FROM: | |
50 case AX_ATTR_DESCRIPTION_FROM: | |
51 case AX_ATTR_CHILD_TREE_ID: | |
52 case AX_ATTR_SET_SIZE: | |
53 case AX_ATTR_POS_IN_SET: | |
54 case AX_ATTR_COLOR_VALUE: | |
55 case AX_ATTR_ARIA_CURRENT_STATE: | |
56 case AX_ATTR_BACKGROUND_COLOR: | |
57 case AX_ATTR_COLOR: | |
58 case AX_ATTR_INVALID_STATE: | |
59 case AX_ATTR_TEXT_DIRECTION: | |
60 case AX_ATTR_TEXT_STYLE: | |
61 return false; | |
62 } | |
63 | |
64 NOTREACHED(); | |
65 return false; | |
66 } | |
67 | |
68 // Return true if |attr| contains a vector of node ids that would need | |
69 // to be mapped when renumbering the ids in a combined tree. | |
70 bool IsNodeIdIntListAttribute(AXIntListAttribute attr) { | |
71 switch (attr) { | |
72 case AX_ATTR_CELL_IDS: | |
73 case AX_ATTR_CONTROLS_IDS: | |
74 case AX_ATTR_DESCRIBEDBY_IDS: | |
75 case AX_ATTR_FLOWTO_IDS: | |
76 case AX_ATTR_INDIRECT_CHILD_IDS: | |
77 case AX_ATTR_LABELLEDBY_IDS: | |
78 case AX_ATTR_UNIQUE_CELL_IDS: | |
79 return true; | |
80 | |
81 // Note: all of the attributes are included here explicitly, | |
82 // rather than using "default:", so that it's a compiler error to | |
83 // add a new attribute without explicitly considering whether it's | |
84 // a node id attribute or not. | |
85 case AX_INT_LIST_ATTRIBUTE_NONE: | |
86 case AX_ATTR_LINE_BREAKS: | |
87 case AX_ATTR_MARKER_TYPES: | |
88 case AX_ATTR_MARKER_STARTS: | |
89 case AX_ATTR_MARKER_ENDS: | |
90 case AX_ATTR_CHARACTER_OFFSETS: | |
91 case AX_ATTR_CACHED_LINE_STARTS: | |
92 case AX_ATTR_WORD_STARTS: | |
93 case AX_ATTR_WORD_ENDS: | |
94 return false; | |
95 } | |
96 | |
97 NOTREACHED(); | |
98 return false; | |
99 } | |
100 | |
101 } // namespace | |
102 | 10 |
103 AXTreeCombiner::AXTreeCombiner() { | 11 AXTreeCombiner::AXTreeCombiner() { |
104 } | 12 } |
105 | 13 |
106 AXTreeCombiner::~AXTreeCombiner() { | 14 AXTreeCombiner::~AXTreeCombiner() { |
107 } | 15 } |
108 | 16 |
109 void AXTreeCombiner::AddTree(const AXTreeUpdate& tree, bool is_root) { | 17 void AXTreeCombiner::AddTree(const AXTreeUpdate& tree, bool is_root) { |
110 trees_.push_back(tree); | 18 trees_.push_back(tree); |
111 if (is_root) { | 19 if (is_root) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // Put the rewritten AXNodeData into the output data structure. | 132 // Put the rewritten AXNodeData into the output data structure. |
225 combined_.nodes.push_back(node); | 133 combined_.nodes.push_back(node); |
226 | 134 |
227 // Recurse into the child tree now, if any. | 135 // Recurse into the child tree now, if any. |
228 if (child_tree) | 136 if (child_tree) |
229 ProcessTree(child_tree); | 137 ProcessTree(child_tree); |
230 } | 138 } |
231 } | 139 } |
232 | 140 |
233 } // namespace ui | 141 } // namespace ui |
OLD | NEW |