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