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

Side by Side Diff: webkit/glue/webaccessibility.h

Issue 7745035: Add a big grab bag of missing web accessibility functionality... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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/renderer/render_view.cc ('k') | webkit/glue/webaccessibility.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 WEBKIT_GLUE_WEBACCESSIBILITY_H_
6 #define WEBKIT_GLUE_WEBACCESSIBILITY_H_ 6 #define WEBKIT_GLUE_WEBACCESSIBILITY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/string16.h" 12 #include "base/string16.h"
12 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
13 14
14 namespace WebKit { 15 namespace WebKit {
15 class WebAccessibilityCache; 16 class WebAccessibilityCache;
16 class WebAccessibilityObject; 17 class WebAccessibilityObject;
17 } 18 }
18 19
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ROLE_WEB_AREA, 125 ROLE_WEB_AREA,
125 ROLE_WINDOW, 126 ROLE_WINDOW,
126 NUM_ROLES 127 NUM_ROLES
127 }; 128 };
128 129
129 // An alphabetical enumeration of accessibility states. 130 // An alphabetical enumeration of accessibility states.
130 // A state bitmask is formed by shifting 1 to the left by each state, 131 // A state bitmask is formed by shifting 1 to the left by each state,
131 // for example: 132 // for example:
132 // int mask = (1 << STATE_CHECKED) | (1 << STATE_FOCUSED); 133 // int mask = (1 << STATE_CHECKED) | (1 << STATE_FOCUSED);
133 enum State { 134 enum State {
135 STATE_BUSY,
134 STATE_CHECKED, 136 STATE_CHECKED,
135 STATE_COLLAPSED, 137 STATE_COLLAPSED,
136 STATE_EXPANDED, 138 STATE_EXPANDED,
137 STATE_FOCUSABLE, 139 STATE_FOCUSABLE,
138 STATE_FOCUSED, 140 STATE_FOCUSED,
139 STATE_HASPOPUP, 141 STATE_HASPOPUP,
140 STATE_HOTTRACKED, 142 STATE_HOTTRACKED,
141 STATE_INDETERMINATE, 143 STATE_INDETERMINATE,
142 STATE_INVISIBLE, 144 STATE_INVISIBLE,
143 STATE_LINKED, 145 STATE_LINKED,
144 STATE_MULTISELECTABLE, 146 STATE_MULTISELECTABLE,
145 STATE_OFFSCREEN, 147 STATE_OFFSCREEN,
146 STATE_PRESSED, 148 STATE_PRESSED,
147 STATE_PROTECTED, 149 STATE_PROTECTED,
148 STATE_READONLY, 150 STATE_READONLY,
151 STATE_REQUIRED,
149 STATE_SELECTABLE, 152 STATE_SELECTABLE,
150 STATE_SELECTED, 153 STATE_SELECTED,
151 STATE_TRAVERSED, 154 STATE_TRAVERSED,
152 STATE_BUSY, 155 STATE_UNAVAILABLE,
153 STATE_UNAVAILABLE 156 STATE_VERTICAL,
157 STATE_VISITED,
158 NUM_STATES
154 }; 159 };
155 160
161 COMPILE_ASSERT(NUM_STATES <= 31, state_enum_not_too_large);
162
156 // Additional optional attributes that can be optionally attached to 163 // Additional optional attributes that can be optionally attached to
157 // a node. 164 // a node.
158 enum StringAttribute { 165 enum StringAttribute {
159 // Document attributes. 166 // Document attributes.
160 ATTR_DOC_URL, 167 ATTR_DOC_URL,
161 ATTR_DOC_TITLE, 168 ATTR_DOC_TITLE,
162 ATTR_DOC_MIMETYPE, 169 ATTR_DOC_MIMETYPE,
163 ATTR_DOC_DOCTYPE, 170 ATTR_DOC_DOCTYPE,
164 171
165 // Attributes that could apply to any node. 172 // Attributes that could apply to any node.
173 ATTR_ACCESS_KEY,
166 ATTR_ACTION, 174 ATTR_ACTION,
175 ATTR_CONTAINER_LIVE_RELEVANT,
176 ATTR_CONTAINER_LIVE_STATUS,
167 ATTR_DESCRIPTION, 177 ATTR_DESCRIPTION,
168 ATTR_DISPLAY, 178 ATTR_DISPLAY,
169 ATTR_HELP, 179 ATTR_HELP,
170 ATTR_HTML_TAG, 180 ATTR_HTML_TAG,
181 ATTR_LIVE_RELEVANT,
182 ATTR_LIVE_STATUS,
183 ATTR_ROLE,
171 ATTR_SHORTCUT, 184 ATTR_SHORTCUT,
172 ATTR_URL, 185 ATTR_URL,
173 NUM_STRING_ATTRIBUTES
174 }; 186 };
175 187
176 enum IntAttribute { 188 enum IntAttribute {
177 // Document attributes. 189 // Document attributes.
178 ATTR_DOC_SCROLLX, 190 ATTR_DOC_SCROLLX,
179 ATTR_DOC_SCROLLY, 191 ATTR_DOC_SCROLLY,
180 192
181 // Editable text attributes. 193 // Editable text attributes.
182 ATTR_TEXT_SEL_START, 194 ATTR_TEXT_SEL_START,
183 ATTR_TEXT_SEL_END, 195 ATTR_TEXT_SEL_END,
184 196
185 // Table attributes. 197 // Table attributes.
186 ATTR_TABLE_ROW_COUNT, 198 ATTR_TABLE_ROW_COUNT,
187 ATTR_TABLE_COLUMN_COUNT, 199 ATTR_TABLE_COLUMN_COUNT,
188 200
189 // Table cell attributes. 201 // Table cell attributes.
190 ATTR_TABLE_CELL_COLUMN_INDEX, 202 ATTR_TABLE_CELL_COLUMN_INDEX,
191 ATTR_TABLE_CELL_COLUMN_SPAN, 203 ATTR_TABLE_CELL_COLUMN_SPAN,
192 ATTR_TABLE_CELL_ROW_INDEX, 204 ATTR_TABLE_CELL_ROW_INDEX,
193 ATTR_TABLE_CELL_ROW_SPAN, 205 ATTR_TABLE_CELL_ROW_SPAN,
194 206
195 NUM_INT_ATTRIBUTES 207 // Tree control attributes.
208 ATTR_HIERARCHICAL_LEVEL,
209 };
210
211 enum FloatAttribute {
212 // Document attributes.
213 ATTR_DOC_LOADING_PROGRESS,
214
215 // Range attributes.
216 ATTR_VALUE_FOR_RANGE,
217 ATTR_MIN_VALUE_FOR_RANGE,
218 ATTR_MAX_VALUE_FOR_RANGE,
219 };
220
221 enum BoolAttribute {
222 // Document attributes.
223 ATTR_DOC_LOADED,
224
225 // True if a checkbox or radio button is in the "mixed" state.
226 ATTR_BUTTON_MIXED,
227
228 // Live region attributes.
229 ATTR_CONTAINER_LIVE_ATOMIC,
230 ATTR_CONTAINER_LIVE_BUSY,
231 ATTR_LIVE_ATOMIC,
232 ATTR_LIVE_BUSY,
196 }; 233 };
197 234
198 // Empty constructor, for serialization. 235 // Empty constructor, for serialization.
199 WebAccessibility(); 236 WebAccessibility();
200 237
201 // Construct from a WebAccessibilityObject. Recursively creates child 238 // Construct from a WebAccessibilityObject. Recursively creates child
202 // nodes as needed to complete the tree. Adds |src| to |cache| and 239 // nodes as needed to complete the tree. Adds |src| to |cache| and
203 // stores its cache ID. 240 // stores its cache ID.
204 WebAccessibility(const WebKit::WebAccessibilityObject& src, 241 WebAccessibility(const WebKit::WebAccessibilityObject& src,
205 WebKit::WebAccessibilityCache* cache, 242 WebKit::WebAccessibilityCache* cache,
206 bool include_children); 243 bool include_children);
207 244
208 ~WebAccessibility(); 245 ~WebAccessibility();
209 246
247 #ifndef NDEBUG
248 std::string DebugString(bool recursive);
249 #endif
250
210 private: 251 private:
211 // Initialize an already-created struct, same as the constructor above. 252 // Initialize an already-created struct, same as the constructor above.
212 void Init(const WebKit::WebAccessibilityObject& src, 253 void Init(const WebKit::WebAccessibilityObject& src,
213 WebKit::WebAccessibilityCache* cache, 254 WebKit::WebAccessibilityCache* cache,
214 bool include_children); 255 bool include_children);
215 256
216 // Returns true if |ancestor| is the first unignored parent of |child|, 257 // Returns true if |ancestor| is the first unignored parent of |child|,
217 // which means that when walking up the parent chain from |child|, 258 // which means that when walking up the parent chain from |child|,
218 // |ancestor| is the *first* ancestor that isn't marked as 259 // |ancestor| is the *first* ancestor that isn't marked as
219 // accessibilityIsIgnored(). 260 // accessibilityIsIgnored().
220 bool IsParentUnignoredOf(const WebKit::WebAccessibilityObject& ancestor, 261 bool IsParentUnignoredOf(const WebKit::WebAccessibilityObject& ancestor,
221 const WebKit::WebAccessibilityObject& child); 262 const WebKit::WebAccessibilityObject& child);
222 263
223 public: 264 public:
224 // This is a simple serializable struct. All member variables should be 265 // This is a simple serializable struct. All member variables should be
225 // copyable. 266 // copyable.
226 int32 id; 267 int32 id;
227 string16 name; 268 string16 name;
228 string16 value; 269 string16 value;
229 Role role; 270 Role role;
230 uint32 state; 271 uint32 state;
231 gfx::Rect location; 272 gfx::Rect location;
232 std::map<StringAttribute, string16> string_attributes; 273 std::map<StringAttribute, string16> string_attributes;
233 std::map<IntAttribute, int32> int_attributes; 274 std::map<IntAttribute, int32> int_attributes;
275 std::map<FloatAttribute, float> float_attributes;
276 std::map<BoolAttribute, bool> bool_attributes;
234 std::vector<WebAccessibility> children; 277 std::vector<WebAccessibility> children;
235 std::vector<int32> indirect_child_ids; 278 std::vector<int32> indirect_child_ids;
236 std::vector<std::pair<string16, string16> > html_attributes; 279 std::vector<std::pair<string16, string16> > html_attributes;
237 std::vector<int32> line_breaks; 280 std::vector<int32> line_breaks;
238 std::vector<int32> cell_ids; // For a table, the cell ids in row-major order. 281
282 // For a table, the cell ids in row-major order, with duplicate entries
283 // when there's a rowspan or colspan, and with -1 for missing cells.
284 // There are always exactly rows * columns entries.
285 std::vector<int32> cell_ids;
286
287 // For a table, the unique cell ids in row-major order of their first
288 // occurrence.
289 std::vector<int32> unique_cell_ids;
239 }; 290 };
240 291
241 } // namespace webkit_glue 292 } // namespace webkit_glue
242 293
243 #endif // WEBKIT_GLUE_WEBACCESSIBILITY_H_ 294 #endif // WEBKIT_GLUE_WEBACCESSIBILITY_H_
OLDNEW
« no previous file with comments | « content/renderer/render_view.cc ('k') | webkit/glue/webaccessibility.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698