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

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

Issue 116293005: Refactor content/ to use ui::AXNodeData instead of blink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update content/DEPS instead of subdirs Created 6 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_
6 #define CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "base/strings/string16.h"
13 #include "content/common/content_export.h"
14 #include "third_party/WebKit/public/web/WebAXEnums.h"
15 #include "ui/gfx/rect.h"
16
17 namespace content {
18
19 // A compact representation of the accessibility information for a
20 // single web object, in a form that can be serialized and sent from
21 // the renderer process to the browser process.
22 struct CONTENT_EXPORT AccessibilityNodeData {
23 // Additional optional attributes that can be optionally attached to
24 // a node.
25 enum StringAttribute {
26 // Document attributes.
27 ATTR_DOC_URL,
28 ATTR_DOC_TITLE,
29 ATTR_DOC_MIMETYPE,
30 ATTR_DOC_DOCTYPE,
31
32 // Attributes that could apply to any node.
33 ATTR_ACCESS_KEY,
34 ATTR_ACTION,
35 ATTR_CONTAINER_LIVE_RELEVANT,
36 ATTR_CONTAINER_LIVE_STATUS,
37 ATTR_DESCRIPTION,
38 ATTR_DISPLAY,
39 ATTR_HELP,
40 ATTR_HTML_TAG,
41 ATTR_NAME,
42 ATTR_LIVE_RELEVANT,
43 ATTR_LIVE_STATUS,
44 ATTR_ROLE,
45 ATTR_SHORTCUT,
46 ATTR_URL,
47 ATTR_VALUE,
48 };
49
50 enum IntAttribute {
51 // Scrollable container attributes.
52 ATTR_SCROLL_X,
53 ATTR_SCROLL_X_MIN,
54 ATTR_SCROLL_X_MAX,
55 ATTR_SCROLL_Y,
56 ATTR_SCROLL_Y_MIN,
57 ATTR_SCROLL_Y_MAX,
58
59 // Editable text attributes.
60 ATTR_TEXT_SEL_START,
61 ATTR_TEXT_SEL_END,
62
63 // Table attributes.
64 ATTR_TABLE_ROW_COUNT,
65 ATTR_TABLE_COLUMN_COUNT,
66 ATTR_TABLE_HEADER_ID,
67
68 // Table row attributes.
69 ATTR_TABLE_ROW_INDEX,
70 ATTR_TABLE_ROW_HEADER_ID,
71
72 // Table column attributes.
73 ATTR_TABLE_COLUMN_INDEX,
74 ATTR_TABLE_COLUMN_HEADER_ID,
75
76 // Table cell attributes.
77 ATTR_TABLE_CELL_COLUMN_INDEX,
78 ATTR_TABLE_CELL_COLUMN_SPAN,
79 ATTR_TABLE_CELL_ROW_INDEX,
80 ATTR_TABLE_CELL_ROW_SPAN,
81
82 // Tree control attributes.
83 ATTR_HIERARCHICAL_LEVEL,
84
85 // Relationships between this element and other elements.
86 ATTR_TITLE_UI_ELEMENT,
87
88 // Color value for blink::WebAXRoleColorWell, each component is 0..255
89 ATTR_COLOR_VALUE_RED,
90 ATTR_COLOR_VALUE_GREEN,
91 ATTR_COLOR_VALUE_BLUE,
92
93 // Inline text attributes.
94 ATTR_TEXT_DIRECTION
95 };
96
97 enum FloatAttribute {
98 // Document attributes.
99 ATTR_DOC_LOADING_PROGRESS,
100
101 // Range attributes.
102 ATTR_VALUE_FOR_RANGE,
103 ATTR_MIN_VALUE_FOR_RANGE,
104 ATTR_MAX_VALUE_FOR_RANGE,
105 };
106
107 enum BoolAttribute {
108 // Document attributes.
109 ATTR_DOC_LOADED,
110
111 // True if a checkbox or radio button is in the "mixed" state.
112 ATTR_BUTTON_MIXED,
113
114 // Live region attributes.
115 ATTR_CONTAINER_LIVE_ATOMIC,
116 ATTR_CONTAINER_LIVE_BUSY,
117 ATTR_LIVE_ATOMIC,
118 ATTR_LIVE_BUSY,
119
120 // ARIA readonly flag.
121 ATTR_ARIA_READONLY,
122
123 // Writeable attributes
124 ATTR_CAN_SET_VALUE,
125
126 // Set on a canvas element if it has fallback content.
127 ATTR_CANVAS_HAS_FALLBACK,
128 };
129
130 enum IntListAttribute {
131 // Ids of nodes that are children of this node logically, but are
132 // not children of this node in the tree structure. As an example,
133 // a table cell is a child of a row, and an 'indirect' child of a
134 // column.
135 ATTR_INDIRECT_CHILD_IDS,
136
137 // Character indices where line breaks occur.
138 ATTR_LINE_BREAKS,
139
140 // For a table, the cell ids in row-major order, with duplicate entries
141 // when there's a rowspan or colspan, and with -1 for missing cells.
142 // There are always exactly rows * columns entries.
143 ATTR_CELL_IDS,
144
145 // For a table, the unique cell ids in row-major order of their first
146 // occurrence.
147 ATTR_UNIQUE_CELL_IDS,
148
149 // For inline text. This is the pixel position of the end of this
150 // character within the bounding rectangle of this object, in the
151 // direction given by ATTR_TEXT_DIRECTION. For example, for left-to-right
152 // text, the first offset is the right coordinate of the first character
153 // within the object's bounds, the second offset is the right coordinate
154 // of the second character, and so on.
155 ATTR_CHARACTER_OFFSETS,
156
157 // For inline text. These int lists must be the same size; they represent
158 // the start and end character index of each word within this text.
159 ATTR_WORD_STARTS,
160 ATTR_WORD_ENDS,
161 };
162
163 AccessibilityNodeData();
164 virtual ~AccessibilityNodeData();
165
166 void AddStringAttribute(StringAttribute attribute,
167 const std::string& value);
168 void AddIntAttribute(IntAttribute attribute, int value);
169 void AddFloatAttribute(FloatAttribute attribute, float value);
170 void AddBoolAttribute(BoolAttribute attribute, bool value);
171 void AddIntListAttribute(IntListAttribute attribute,
172 const std::vector<int32>& value);
173
174 // Convenience functions, mainly for writing unit tests.
175 // Equivalent to AddStringAttribute(ATTR_NAME, name).
176 void SetName(std::string name);
177 // Equivalent to AddStringAttribute(ATTR_VALUE, value).
178 void SetValue(std::string value);
179
180 #ifndef NDEBUG
181 virtual std::string DebugString(bool recursive) const;
182 #endif
183
184 // This is a simple serializable struct. All member variables should be
185 // public and copyable.
186 int32 id;
187 blink::WebAXRole role;
188 uint32 state;
189 gfx::Rect location;
190 std::vector<std::pair<StringAttribute, std::string> > string_attributes;
191 std::vector<std::pair<IntAttribute, int32> > int_attributes;
192 std::vector<std::pair<FloatAttribute, float> > float_attributes;
193 std::vector<std::pair<BoolAttribute, bool> > bool_attributes;
194 std::vector<std::pair<IntListAttribute, std::vector<int32> > >
195 intlist_attributes;
196 std::vector<std::pair<std::string, std::string> > html_attributes;
197 std::vector<int32> child_ids;
198 };
199
200 // For testing and debugging only: this subclass of AccessibilityNodeData
201 // is used to represent a whole tree of accessibility nodes, where each
202 // node owns its children. This makes it easy to print the tree structure
203 // or search it recursively.
204 struct CONTENT_EXPORT AccessibilityNodeDataTreeNode
205 : public AccessibilityNodeData {
206 AccessibilityNodeDataTreeNode();
207 virtual ~AccessibilityNodeDataTreeNode();
208
209 AccessibilityNodeDataTreeNode& operator=(const AccessibilityNodeData& src);
210
211 #ifndef NDEBUG
212 virtual std::string DebugString(bool recursive) const OVERRIDE;
213 #endif
214
215 std::vector<AccessibilityNodeDataTreeNode> children;
216 };
217
218 // Given a vector of accessibility nodes that represent a complete
219 // accessibility tree, where each node appears before its children,
220 // build a tree of AccessibilityNodeDataTreeNode objects for easier
221 // testing and debugging, where each node contains its children.
222 // The |dst| argument will become the root of the new tree.
223 void MakeAccessibilityNodeDataTree(
224 const std::vector<AccessibilityNodeData>& src,
225 AccessibilityNodeDataTreeNode* dst);
226
227 } // namespace content
228
229 #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