OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_GLUE_WEBACCESSIBILITY_H_ | 5 #ifndef CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_ |
6 #define WEBKIT_GLUE_WEBACCESSIBILITY_H_ | 6 #define CONTENT_COMMON_ACCESSIBILITY_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/string16.h" | 12 #include "base/string16.h" |
13 #include "content/common/content_export.h" | |
13 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
14 #include "webkit/glue/webkit_glue_export.h" | |
15 | 15 |
16 namespace WebKit { | 16 namespace content { |
17 class WebAccessibilityObject; | |
18 } | |
19 | |
20 namespace webkit_glue { | |
21 | 17 |
22 // A compact representation of the accessibility information for a | 18 // A compact representation of the accessibility information for a |
23 // single web object, in a form that can be serialized and sent from | 19 // single web object, in a form that can be serialized and sent from |
24 // the renderer process to the browser process. | 20 // the renderer process to the browser process. |
25 struct WEBKIT_GLUE_EXPORT WebAccessibility { | 21 struct CONTENT_EXPORT AccessibilityNodeData { |
26 public: | 22 public: |
jam
2012/06/12 00:00:42
nit: unnecessary
dmazzoni
2012/06/12 18:35:33
Done.
| |
27 // An enumeration of accessibility roles. | 23 // An enumeration of accessibility roles. |
28 enum Role { | 24 enum Role { |
29 ROLE_UNKNOWN = 0, | 25 ROLE_UNKNOWN = 0, |
30 | 26 |
31 // Used by Chromium to distinguish between the root of the tree | 27 // Used by Chromium to distinguish between the root of the tree |
32 // for this page, and a web area for a frame within this page. | 28 // for this page, and a web area for a frame within this page. |
33 ROLE_ROOT_WEB_AREA, | 29 ROLE_ROOT_WEB_AREA, |
34 | 30 |
35 // These roles all directly correspond to WebKit accessibility roles, | 31 // These roles all directly correspond to WebKit accessibility roles, |
36 // keep these alphabetical. | 32 // keep these alphabetical. |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 ATTR_LIVE_ATOMIC, | 239 ATTR_LIVE_ATOMIC, |
244 ATTR_LIVE_BUSY, | 240 ATTR_LIVE_BUSY, |
245 | 241 |
246 // ARIA readonly flag. | 242 // ARIA readonly flag. |
247 ATTR_ARIA_READONLY, | 243 ATTR_ARIA_READONLY, |
248 | 244 |
249 // Writeable attributes | 245 // Writeable attributes |
250 ATTR_CAN_SET_VALUE, | 246 ATTR_CAN_SET_VALUE, |
251 }; | 247 }; |
252 | 248 |
253 enum IncludeChildren { | 249 AccessibilityNodeData(); |
254 NO_CHILDREN, | 250 ~AccessibilityNodeData(); |
255 INCLUDE_CHILDREN | |
256 }; | |
257 | |
258 enum IncludeLineBreaks { | |
259 NO_LINE_BREAKS, | |
260 INCLUDE_LINE_BREAKS | |
261 }; | |
262 | |
263 // Empty constructor, for serialization. | |
264 WebAccessibility(); | |
265 | |
266 // Construct from a WebAccessibilityObject. Recursively creates child | |
267 // nodes as needed to complete the tree. | |
268 WebAccessibility(const WebKit::WebAccessibilityObject& src, | |
269 IncludeChildren include_children, | |
270 IncludeLineBreaks include_line_breaks); | |
271 | |
272 ~WebAccessibility(); | |
273 | |
274 // Initialize an already-created struct, same as the constructor above. | |
275 void Init(const WebKit::WebAccessibilityObject& src, | |
276 IncludeChildren include_children, | |
277 IncludeLineBreaks include_line_breaks); | |
278 | 251 |
279 #ifndef NDEBUG | 252 #ifndef NDEBUG |
280 std::string DebugString(bool recursive) const; | 253 std::string DebugString(bool recursive) const; |
281 #endif | 254 #endif |
282 | 255 |
283 private: | |
284 // Returns true if |ancestor| is the first unignored parent of |child|, | |
285 // which means that when walking up the parent chain from |child|, | |
286 // |ancestor| is the *first* ancestor that isn't marked as | |
287 // accessibilityIsIgnored(). | |
288 bool IsParentUnignoredOf(const WebKit::WebAccessibilityObject& ancestor, | |
289 const WebKit::WebAccessibilityObject& child); | |
290 | |
291 public: | 256 public: |
jam
2012/06/12 00:00:42
ditto
dmazzoni
2012/06/12 18:35:33
Done.
| |
292 // This is a simple serializable struct. All member variables should be | 257 // This is a simple serializable struct. All member variables should be |
293 // copyable. | 258 // public and copyable. |
294 int32 id; | 259 int32 id; |
295 string16 name; | 260 string16 name; |
296 string16 value; | 261 string16 value; |
297 Role role; | 262 Role role; |
298 uint32 state; | 263 uint32 state; |
299 gfx::Rect location; | 264 gfx::Rect location; |
300 std::map<StringAttribute, string16> string_attributes; | 265 std::map<StringAttribute, string16> string_attributes; |
301 std::map<IntAttribute, int32> int_attributes; | 266 std::map<IntAttribute, int32> int_attributes; |
302 std::map<FloatAttribute, float> float_attributes; | 267 std::map<FloatAttribute, float> float_attributes; |
303 std::map<BoolAttribute, bool> bool_attributes; | 268 std::map<BoolAttribute, bool> bool_attributes; |
304 std::vector<WebAccessibility> children; | 269 std::vector<AccessibilityNodeData> children; |
305 std::vector<int32> indirect_child_ids; | 270 std::vector<int32> indirect_child_ids; |
306 std::vector<std::pair<string16, string16> > html_attributes; | 271 std::vector<std::pair<string16, string16> > html_attributes; |
307 std::vector<int32> line_breaks; | 272 std::vector<int32> line_breaks; |
308 | 273 |
309 // For a table, the cell ids in row-major order, with duplicate entries | 274 // For a table, the cell ids in row-major order, with duplicate entries |
310 // when there's a rowspan or colspan, and with -1 for missing cells. | 275 // when there's a rowspan or colspan, and with -1 for missing cells. |
311 // There are always exactly rows * columns entries. | 276 // There are always exactly rows * columns entries. |
312 std::vector<int32> cell_ids; | 277 std::vector<int32> cell_ids; |
313 | 278 |
314 // For a table, the unique cell ids in row-major order of their first | 279 // For a table, the unique cell ids in row-major order of their first |
315 // occurrence. | 280 // occurrence. |
316 std::vector<int32> unique_cell_ids; | 281 std::vector<int32> unique_cell_ids; |
317 }; | 282 }; |
318 | 283 |
319 } // namespace webkit_glue | 284 } // namespace content |
320 | 285 |
321 #endif // WEBKIT_GLUE_WEBACCESSIBILITY_H_ | 286 #endif // CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_ |
OLD | NEW |