[content shell] hook up testRunner.dumpEditingCallbacks
[chromium-blink-merge.git] / content / common / accessibility_node_data.h
blobbab81e39de657caafacb339a9ff90d151de8ab2d
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.
5 #ifndef CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_
6 #define CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/string16.h"
13 #include "content/common/content_export.h"
14 #include "ui/gfx/rect.h"
16 namespace content {
18 // A compact representation of the accessibility information for a
19 // single web object, in a form that can be serialized and sent from
20 // the renderer process to the browser process.
21 struct CONTENT_EXPORT AccessibilityNodeData {
22 // An enumeration of accessibility roles.
23 enum Role {
24 ROLE_UNKNOWN = 0,
26 // Used by Chromium to distinguish between the root of the tree
27 // for this page, and a web area for a frame within this page.
28 ROLE_ROOT_WEB_AREA,
30 // These roles all directly correspond to WebKit accessibility roles,
31 // keep these alphabetical.
32 ROLE_ALERT,
33 ROLE_ALERT_DIALOG,
34 ROLE_ANNOTATION,
35 ROLE_APPLICATION,
36 ROLE_ARTICLE,
37 ROLE_BROWSER,
38 ROLE_BUSY_INDICATOR,
39 ROLE_BUTTON,
40 ROLE_CANVAS,
41 ROLE_CANVAS_WITH_FALLBACK_CONTENT,
42 ROLE_CELL,
43 ROLE_CHECKBOX,
44 ROLE_COLOR_WELL,
45 ROLE_COLUMN,
46 ROLE_COLUMN_HEADER,
47 ROLE_COMBO_BOX,
48 ROLE_DEFINITION_LIST_DEFINITION,
49 ROLE_DEFINITION_LIST_TERM,
50 ROLE_DIALOG,
51 ROLE_DIRECTORY,
52 ROLE_DISCLOSURE_TRIANGLE,
53 ROLE_DIV,
54 ROLE_DOCUMENT,
55 ROLE_DRAWER,
56 ROLE_EDITABLE_TEXT,
57 ROLE_FOOTER,
58 ROLE_FORM,
59 ROLE_GRID,
60 ROLE_GROUP,
61 ROLE_GROW_AREA,
62 ROLE_HEADING,
63 ROLE_HELP_TAG,
64 ROLE_HORIZONTAL_RULE,
65 ROLE_IGNORED,
66 ROLE_IMAGE,
67 ROLE_IMAGE_MAP,
68 ROLE_IMAGE_MAP_LINK,
69 ROLE_INCREMENTOR,
70 ROLE_LABEL,
71 ROLE_LANDMARK_APPLICATION,
72 ROLE_LANDMARK_BANNER,
73 ROLE_LANDMARK_COMPLEMENTARY,
74 ROLE_LANDMARK_CONTENTINFO,
75 ROLE_LANDMARK_MAIN,
76 ROLE_LANDMARK_NAVIGATION,
77 ROLE_LANDMARK_SEARCH,
78 ROLE_LINK,
79 ROLE_LIST,
80 ROLE_LISTBOX,
81 ROLE_LISTBOX_OPTION,
82 ROLE_LIST_ITEM,
83 ROLE_LIST_MARKER,
84 ROLE_LOG,
85 ROLE_MARQUEE,
86 ROLE_MATH,
87 ROLE_MATTE,
88 ROLE_MENU,
89 ROLE_MENU_BAR,
90 ROLE_MENU_ITEM,
91 ROLE_MENU_BUTTON,
92 ROLE_MENU_LIST_OPTION,
93 ROLE_MENU_LIST_POPUP,
94 ROLE_NOTE,
95 ROLE_OUTLINE,
96 ROLE_PARAGRAPH,
97 ROLE_POPUP_BUTTON,
98 ROLE_PRESENTATIONAL,
99 ROLE_PROGRESS_INDICATOR,
100 ROLE_RADIO_BUTTON,
101 ROLE_RADIO_GROUP,
102 ROLE_REGION,
103 ROLE_ROW,
104 ROLE_ROW_HEADER,
105 ROLE_RULER,
106 ROLE_RULER_MARKER,
107 ROLE_SCROLLAREA,
108 ROLE_SCROLLBAR,
109 ROLE_SHEET,
110 ROLE_SLIDER,
111 ROLE_SLIDER_THUMB,
112 ROLE_SPIN_BUTTON,
113 ROLE_SPIN_BUTTON_PART,
114 ROLE_SPLITTER,
115 ROLE_SPLIT_GROUP,
116 ROLE_STATIC_TEXT,
117 ROLE_STATUS,
118 ROLE_SYSTEM_WIDE,
119 ROLE_TAB,
120 ROLE_TABLE,
121 ROLE_TABLE_HEADER_CONTAINER,
122 ROLE_TAB_GROUP_UNUSED, // WebKit doesn't use (uses ROLE_TAB_LIST)
123 ROLE_TAB_LIST,
124 ROLE_TAB_PANEL,
125 ROLE_TEXTAREA,
126 ROLE_TEXT_FIELD,
127 ROLE_TIMER,
128 ROLE_TOGGLE_BUTTON,
129 ROLE_TOOLBAR,
130 ROLE_TOOLTIP,
131 ROLE_TREE,
132 ROLE_TREE_GRID,
133 ROLE_TREE_ITEM,
134 ROLE_VALUE_INDICATOR,
135 ROLE_WEBCORE_LINK,
136 ROLE_WEB_AREA,
137 ROLE_WINDOW,
138 NUM_ROLES
141 // An alphabetical enumeration of accessibility states.
142 // A state bitmask is formed by shifting 1 to the left by each state,
143 // for example:
144 // int mask = (1 << STATE_CHECKED) | (1 << STATE_FOCUSED);
145 enum State {
146 STATE_BUSY,
147 STATE_CHECKED,
148 STATE_COLLAPSED,
149 STATE_EXPANDED,
150 STATE_FOCUSABLE,
151 STATE_FOCUSED,
152 STATE_HASPOPUP,
153 STATE_HOTTRACKED,
154 STATE_INDETERMINATE,
155 STATE_INVISIBLE,
156 STATE_LINKED,
157 STATE_MULTISELECTABLE,
158 STATE_OFFSCREEN,
159 STATE_PRESSED,
160 STATE_PROTECTED,
161 STATE_READONLY,
162 STATE_REQUIRED,
163 STATE_SELECTABLE,
164 STATE_SELECTED,
165 STATE_TRAVERSED,
166 STATE_UNAVAILABLE,
167 STATE_VERTICAL,
168 STATE_VISITED,
169 NUM_STATES
172 COMPILE_ASSERT(NUM_STATES <= 31, state_enum_not_too_large);
174 // Additional optional attributes that can be optionally attached to
175 // a node.
176 enum StringAttribute {
177 // Document attributes.
178 ATTR_DOC_URL,
179 ATTR_DOC_TITLE,
180 ATTR_DOC_MIMETYPE,
181 ATTR_DOC_DOCTYPE,
183 // Attributes that could apply to any node.
184 ATTR_ACCESS_KEY,
185 ATTR_ACTION,
186 ATTR_CONTAINER_LIVE_RELEVANT,
187 ATTR_CONTAINER_LIVE_STATUS,
188 ATTR_DESCRIPTION,
189 ATTR_DISPLAY,
190 ATTR_HELP,
191 ATTR_HTML_TAG,
192 ATTR_LIVE_RELEVANT,
193 ATTR_LIVE_STATUS,
194 ATTR_ROLE,
195 ATTR_SHORTCUT,
196 ATTR_URL,
199 enum IntAttribute {
200 // Scrollable container attributes.
201 ATTR_SCROLL_X,
202 ATTR_SCROLL_X_MIN,
203 ATTR_SCROLL_X_MAX,
204 ATTR_SCROLL_Y,
205 ATTR_SCROLL_Y_MIN,
206 ATTR_SCROLL_Y_MAX,
208 // Editable text attributes.
209 ATTR_TEXT_SEL_START,
210 ATTR_TEXT_SEL_END,
212 // Table attributes.
213 ATTR_TABLE_ROW_COUNT,
214 ATTR_TABLE_COLUMN_COUNT,
216 // Table cell attributes.
217 ATTR_TABLE_CELL_COLUMN_INDEX,
218 ATTR_TABLE_CELL_COLUMN_SPAN,
219 ATTR_TABLE_CELL_ROW_INDEX,
220 ATTR_TABLE_CELL_ROW_SPAN,
222 // Tree control attributes.
223 ATTR_HIERARCHICAL_LEVEL,
225 // Relationships between this element and other elements.
226 ATTR_TITLE_UI_ELEMENT,
229 enum FloatAttribute {
230 // Document attributes.
231 ATTR_DOC_LOADING_PROGRESS,
233 // Range attributes.
234 ATTR_VALUE_FOR_RANGE,
235 ATTR_MIN_VALUE_FOR_RANGE,
236 ATTR_MAX_VALUE_FOR_RANGE,
239 enum BoolAttribute {
240 // Document attributes.
241 ATTR_DOC_LOADED,
243 // True if a checkbox or radio button is in the "mixed" state.
244 ATTR_BUTTON_MIXED,
246 // Live region attributes.
247 ATTR_CONTAINER_LIVE_ATOMIC,
248 ATTR_CONTAINER_LIVE_BUSY,
249 ATTR_LIVE_ATOMIC,
250 ATTR_LIVE_BUSY,
252 // ARIA readonly flag.
253 ATTR_ARIA_READONLY,
255 // Writeable attributes
256 ATTR_CAN_SET_VALUE,
259 AccessibilityNodeData();
260 ~AccessibilityNodeData();
262 #ifndef NDEBUG
263 std::string DebugString(bool recursive) const;
264 #endif
266 // This is a simple serializable struct. All member variables should be
267 // public and copyable.
268 int32 id;
269 string16 name;
270 string16 value;
271 Role role;
272 uint32 state;
273 gfx::Rect location;
274 std::map<StringAttribute, string16> string_attributes;
275 std::map<IntAttribute, int32> int_attributes;
276 std::map<FloatAttribute, float> float_attributes;
277 std::map<BoolAttribute, bool> bool_attributes;
278 std::vector<AccessibilityNodeData> children;
279 std::vector<int32> indirect_child_ids;
280 std::vector<std::pair<string16, string16> > html_attributes;
281 std::vector<int32> line_breaks;
283 // For a table, the cell ids in row-major order, with duplicate entries
284 // when there's a rowspan or colspan, and with -1 for missing cells.
285 // There are always exactly rows * columns entries.
286 std::vector<int32> cell_ids;
288 // For a table, the unique cell ids in row-major order of their first
289 // occurrence.
290 std::vector<int32> unique_cell_ids;
293 } // namespace content
295 #endif // CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_