OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_ | 5 #ifndef UI_ACCESSIBILITY_AX_NODE_DATA_H_ |
6 #define CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_ | 6 #define UI_ACCESSIBILITY_AX_NODE_DATA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "content/common/content_export.h" | 13 #include "ui/accessibility/ax_enums.h" |
14 #include "third_party/WebKit/public/web/WebAXEnums.h" | 14 #include "ui/accessibility/ax_export.h" |
15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
16 | 16 |
17 namespace content { | 17 namespace ui { |
18 | 18 |
19 // A compact representation of the accessibility information for a | 19 // A compact representation of the accessibility information for a |
20 // single web object, in a form that can be serialized and sent from | 20 // single web object, in a form that can be serialized and sent from |
21 // the renderer process to the browser process. | 21 // one process to another. |
22 struct CONTENT_EXPORT AccessibilityNodeData { | 22 struct AX_EXPORT AXNodeData { |
23 // Additional optional attributes that can be optionally attached to | 23 // Additional optional attributes that can be optionally attached to |
24 // a node. | 24 // a node. |
25 enum StringAttribute { | 25 enum StringAttribute { |
26 // Document attributes. | 26 // Document attributes. |
27 ATTR_DOC_URL, | 27 ATTR_DOC_URL, |
28 ATTR_DOC_TITLE, | 28 ATTR_DOC_TITLE, |
29 ATTR_DOC_MIMETYPE, | 29 ATTR_DOC_MIMETYPE, |
30 ATTR_DOC_DOCTYPE, | 30 ATTR_DOC_DOCTYPE, |
31 | 31 |
32 // Attributes that could apply to any node. | 32 // Attributes that could apply to any node. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 ATTR_TABLE_CELL_COLUMN_SPAN, | 78 ATTR_TABLE_CELL_COLUMN_SPAN, |
79 ATTR_TABLE_CELL_ROW_INDEX, | 79 ATTR_TABLE_CELL_ROW_INDEX, |
80 ATTR_TABLE_CELL_ROW_SPAN, | 80 ATTR_TABLE_CELL_ROW_SPAN, |
81 | 81 |
82 // Tree control attributes. | 82 // Tree control attributes. |
83 ATTR_HIERARCHICAL_LEVEL, | 83 ATTR_HIERARCHICAL_LEVEL, |
84 | 84 |
85 // Relationships between this element and other elements. | 85 // Relationships between this element and other elements. |
86 ATTR_TITLE_UI_ELEMENT, | 86 ATTR_TITLE_UI_ELEMENT, |
87 | 87 |
88 // Color value for blink::WebAXRoleColorWell, each component is 0..255 | 88 // Color value for AX_ROLE_COLOR_WELL, each component is 0..255 |
89 ATTR_COLOR_VALUE_RED, | 89 ATTR_COLOR_VALUE_RED, |
90 ATTR_COLOR_VALUE_GREEN, | 90 ATTR_COLOR_VALUE_GREEN, |
91 ATTR_COLOR_VALUE_BLUE, | 91 ATTR_COLOR_VALUE_BLUE, |
92 | 92 |
93 // Inline text attributes. | 93 // Inline text attributes. |
94 ATTR_TEXT_DIRECTION | 94 ATTR_TEXT_DIRECTION |
95 }; | 95 }; |
96 | 96 |
97 enum FloatAttribute { | 97 enum FloatAttribute { |
98 // Document attributes. | 98 // Document attributes. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // within the object's bounds, the second offset is the right coordinate | 157 // within the object's bounds, the second offset is the right coordinate |
158 // of the second character, and so on. | 158 // of the second character, and so on. |
159 ATTR_CHARACTER_OFFSETS, | 159 ATTR_CHARACTER_OFFSETS, |
160 | 160 |
161 // For inline text. These int lists must be the same size; they represent | 161 // For inline text. These int lists must be the same size; they represent |
162 // the start and end character index of each word within this text. | 162 // the start and end character index of each word within this text. |
163 ATTR_WORD_STARTS, | 163 ATTR_WORD_STARTS, |
164 ATTR_WORD_ENDS, | 164 ATTR_WORD_ENDS, |
165 }; | 165 }; |
166 | 166 |
167 AccessibilityNodeData(); | 167 AXNodeData(); |
168 virtual ~AccessibilityNodeData(); | 168 virtual ~AXNodeData(); |
169 | 169 |
170 void AddStringAttribute(StringAttribute attribute, | 170 void AddStringAttribute(StringAttribute attribute, |
171 const std::string& value); | 171 const std::string& value); |
172 void AddIntAttribute(IntAttribute attribute, int value); | 172 void AddIntAttribute(IntAttribute attribute, int value); |
173 void AddFloatAttribute(FloatAttribute attribute, float value); | 173 void AddFloatAttribute(FloatAttribute attribute, float value); |
174 void AddBoolAttribute(BoolAttribute attribute, bool value); | 174 void AddBoolAttribute(BoolAttribute attribute, bool value); |
175 void AddIntListAttribute(IntListAttribute attribute, | 175 void AddIntListAttribute(IntListAttribute attribute, |
176 const std::vector<int32>& value); | 176 const std::vector<int32>& value); |
177 | 177 |
178 // Convenience functions, mainly for writing unit tests. | 178 // Convenience functions, mainly for writing unit tests. |
179 // Equivalent to AddStringAttribute(ATTR_NAME, name). | 179 // Equivalent to AddStringAttribute(ATTR_NAME, name). |
180 void SetName(std::string name); | 180 void SetName(std::string name); |
181 // Equivalent to AddStringAttribute(ATTR_VALUE, value). | 181 // Equivalent to AddStringAttribute(ATTR_VALUE, value). |
182 void SetValue(std::string value); | 182 void SetValue(std::string value); |
183 | 183 |
184 #ifndef NDEBUG | |
185 virtual std::string DebugString(bool recursive) const; | |
186 #endif | |
187 | |
188 // This is a simple serializable struct. All member variables should be | 184 // This is a simple serializable struct. All member variables should be |
189 // public and copyable. | 185 // public and copyable. |
190 int32 id; | 186 int32 id; |
191 blink::WebAXRole role; | 187 AXRole role; |
192 uint32 state; | 188 uint32 state; |
193 gfx::Rect location; | 189 gfx::Rect location; |
194 std::vector<std::pair<StringAttribute, std::string> > string_attributes; | 190 std::vector<std::pair<StringAttribute, std::string> > string_attributes; |
195 std::vector<std::pair<IntAttribute, int32> > int_attributes; | 191 std::vector<std::pair<IntAttribute, int32> > int_attributes; |
196 std::vector<std::pair<FloatAttribute, float> > float_attributes; | 192 std::vector<std::pair<FloatAttribute, float> > float_attributes; |
197 std::vector<std::pair<BoolAttribute, bool> > bool_attributes; | 193 std::vector<std::pair<BoolAttribute, bool> > bool_attributes; |
198 std::vector<std::pair<IntListAttribute, std::vector<int32> > > | 194 std::vector<std::pair<IntListAttribute, std::vector<int32> > > |
199 intlist_attributes; | 195 intlist_attributes; |
200 std::vector<std::pair<std::string, std::string> > html_attributes; | 196 std::vector<std::pair<std::string, std::string> > html_attributes; |
201 std::vector<int32> child_ids; | 197 std::vector<int32> child_ids; |
202 }; | 198 }; |
203 | 199 |
204 // For testing and debugging only: this subclass of AccessibilityNodeData | 200 } // namespace ui |
205 // is used to represent a whole tree of accessibility nodes, where each | |
206 // node owns its children. This makes it easy to print the tree structure | |
207 // or search it recursively. | |
208 struct CONTENT_EXPORT AccessibilityNodeDataTreeNode | |
209 : public AccessibilityNodeData { | |
210 AccessibilityNodeDataTreeNode(); | |
211 virtual ~AccessibilityNodeDataTreeNode(); | |
212 | 201 |
213 AccessibilityNodeDataTreeNode& operator=(const AccessibilityNodeData& src); | 202 #endif // UI_ACCESSIBILITY_AX_NODE_DATA_H_ |
214 | |
215 #ifndef NDEBUG | |
216 virtual std::string DebugString(bool recursive) const OVERRIDE; | |
217 #endif | |
218 | |
219 std::vector<AccessibilityNodeDataTreeNode> children; | |
220 }; | |
221 | |
222 // Given a vector of accessibility nodes that represent a complete | |
223 // accessibility tree, where each node appears before its children, | |
224 // build a tree of AccessibilityNodeDataTreeNode objects for easier | |
225 // testing and debugging, where each node contains its children. | |
226 // The |dst| argument will become the root of the new tree. | |
227 void MakeAccessibilityNodeDataTree( | |
228 const std::vector<AccessibilityNodeData>& src, | |
229 AccessibilityNodeDataTreeNode* dst); | |
230 | |
231 } // namespace content | |
232 | |
233 #endif // CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_ | |
OLD | NEW |