Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: content/common/accessibility_node_data.h

Issue 10544099: Refactor all accessibility code out of webkit/glue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More Mac compile errors Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/accessibility_messages.h ('k') | content/common/accessibility_node_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:
27 // An enumeration of accessibility roles. 22 // An enumeration of accessibility roles.
28 enum Role { 23 enum Role {
29 ROLE_UNKNOWN = 0, 24 ROLE_UNKNOWN = 0,
30 25
31 // Used by Chromium to distinguish between the root of the tree 26 // 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. 27 // for this page, and a web area for a frame within this page.
33 ROLE_ROOT_WEB_AREA, 28 ROLE_ROOT_WEB_AREA,
34 29
35 // These roles all directly correspond to WebKit accessibility roles, 30 // These roles all directly correspond to WebKit accessibility roles,
36 // keep these alphabetical. 31 // keep these alphabetical.
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ATTR_LIVE_ATOMIC, 238 ATTR_LIVE_ATOMIC,
244 ATTR_LIVE_BUSY, 239 ATTR_LIVE_BUSY,
245 240
246 // ARIA readonly flag. 241 // ARIA readonly flag.
247 ATTR_ARIA_READONLY, 242 ATTR_ARIA_READONLY,
248 243
249 // Writeable attributes 244 // Writeable attributes
250 ATTR_CAN_SET_VALUE, 245 ATTR_CAN_SET_VALUE,
251 }; 246 };
252 247
253 enum IncludeChildren { 248 AccessibilityNodeData();
254 NO_CHILDREN, 249 ~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 250
279 #ifndef NDEBUG 251 #ifndef NDEBUG
280 std::string DebugString(bool recursive) const; 252 std::string DebugString(bool recursive) const;
281 #endif 253 #endif
282 254
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:
292 // This is a simple serializable struct. All member variables should be 255 // This is a simple serializable struct. All member variables should be
293 // copyable. 256 // public and copyable.
294 int32 id; 257 int32 id;
295 string16 name; 258 string16 name;
296 string16 value; 259 string16 value;
297 Role role; 260 Role role;
298 uint32 state; 261 uint32 state;
299 gfx::Rect location; 262 gfx::Rect location;
300 std::map<StringAttribute, string16> string_attributes; 263 std::map<StringAttribute, string16> string_attributes;
301 std::map<IntAttribute, int32> int_attributes; 264 std::map<IntAttribute, int32> int_attributes;
302 std::map<FloatAttribute, float> float_attributes; 265 std::map<FloatAttribute, float> float_attributes;
303 std::map<BoolAttribute, bool> bool_attributes; 266 std::map<BoolAttribute, bool> bool_attributes;
304 std::vector<WebAccessibility> children; 267 std::vector<AccessibilityNodeData> children;
305 std::vector<int32> indirect_child_ids; 268 std::vector<int32> indirect_child_ids;
306 std::vector<std::pair<string16, string16> > html_attributes; 269 std::vector<std::pair<string16, string16> > html_attributes;
307 std::vector<int32> line_breaks; 270 std::vector<int32> line_breaks;
308 271
309 // For a table, the cell ids in row-major order, with duplicate entries 272 // 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. 273 // when there's a rowspan or colspan, and with -1 for missing cells.
311 // There are always exactly rows * columns entries. 274 // There are always exactly rows * columns entries.
312 std::vector<int32> cell_ids; 275 std::vector<int32> cell_ids;
313 276
314 // For a table, the unique cell ids in row-major order of their first 277 // For a table, the unique cell ids in row-major order of their first
315 // occurrence. 278 // occurrence.
316 std::vector<int32> unique_cell_ids; 279 std::vector<int32> unique_cell_ids;
317 }; 280 };
318 281
319 } // namespace webkit_glue 282 } // namespace content
320 283
321 #endif // WEBKIT_GLUE_WEBACCESSIBILITY_H_ 284 #endif // CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_
OLDNEW
« no previous file with comments | « content/common/accessibility_messages.h ('k') | content/common/accessibility_node_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698