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

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

Issue 21269002: Make AccessibilityNodeData more compact. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win test Created 7 years, 4 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 CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_ 5 #ifndef CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_
6 #define CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_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>
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 // Attributes that could apply to any node. 185 // Attributes that could apply to any node.
186 ATTR_ACCESS_KEY, 186 ATTR_ACCESS_KEY,
187 ATTR_ACTION, 187 ATTR_ACTION,
188 ATTR_CONTAINER_LIVE_RELEVANT, 188 ATTR_CONTAINER_LIVE_RELEVANT,
189 ATTR_CONTAINER_LIVE_STATUS, 189 ATTR_CONTAINER_LIVE_STATUS,
190 ATTR_DESCRIPTION, 190 ATTR_DESCRIPTION,
191 ATTR_DISPLAY, 191 ATTR_DISPLAY,
192 ATTR_HELP, 192 ATTR_HELP,
193 ATTR_HTML_TAG, 193 ATTR_HTML_TAG,
194 ATTR_NAME,
194 ATTR_LIVE_RELEVANT, 195 ATTR_LIVE_RELEVANT,
195 ATTR_LIVE_STATUS, 196 ATTR_LIVE_STATUS,
196 ATTR_ROLE, 197 ATTR_ROLE,
197 ATTR_SHORTCUT, 198 ATTR_SHORTCUT,
198 ATTR_URL, 199 ATTR_URL,
200 ATTR_VALUE,
199 }; 201 };
200 202
201 enum IntAttribute { 203 enum IntAttribute {
202 // Scrollable container attributes. 204 // Scrollable container attributes.
203 ATTR_SCROLL_X, 205 ATTR_SCROLL_X,
204 ATTR_SCROLL_X_MIN, 206 ATTR_SCROLL_X_MIN,
205 ATTR_SCROLL_X_MAX, 207 ATTR_SCROLL_X_MAX,
206 ATTR_SCROLL_Y, 208 ATTR_SCROLL_Y,
207 ATTR_SCROLL_Y_MIN, 209 ATTR_SCROLL_Y_MIN,
208 ATTR_SCROLL_Y_MAX, 210 ATTR_SCROLL_Y_MAX,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 ATTR_ARIA_READONLY, 271 ATTR_ARIA_READONLY,
270 272
271 // Writeable attributes 273 // Writeable attributes
272 ATTR_CAN_SET_VALUE, 274 ATTR_CAN_SET_VALUE,
273 275
274 // If this is set, all of the other fields in this struct should 276 // If this is set, all of the other fields in this struct should
275 // be ignored and only the locations should change. 277 // be ignored and only the locations should change.
276 ATTR_UPDATE_LOCATION_ONLY, 278 ATTR_UPDATE_LOCATION_ONLY,
277 }; 279 };
278 280
281 enum IntListAttribute {
282 // Ids of nodes that are children of this node logically, but are
283 // not children of this node in the tree structure. As an example,
284 // a table cell is a child of a row, and an 'indirect' child of a
285 // column.
286 ATTR_INDIRECT_CHILD_IDS,
287
288 // Character indices where line breaks occur.
289 ATTR_LINE_BREAKS,
290
291 // For a table, the cell ids in row-major order, with duplicate entries
292 // when there's a rowspan or colspan, and with -1 for missing cells.
293 // There are always exactly rows * columns entries.
294 ATTR_CELL_IDS,
295
296 // For a table, the unique cell ids in row-major order of their first
297 // occurrence.
298 ATTR_UNIQUE_CELL_IDS
299 };
300
279 AccessibilityNodeData(); 301 AccessibilityNodeData();
280 virtual ~AccessibilityNodeData(); 302 virtual ~AccessibilityNodeData();
281 303
304 void AddStringAttribute(StringAttribute attribute,
305 const std::string& value);
306 void AddIntAttribute(IntAttribute attribute, int value);
307 void AddFloatAttribute(FloatAttribute attribute, float value);
308 void AddBoolAttribute(BoolAttribute attribute, bool value);
309 void AddIntListAttribute(IntListAttribute attribute,
310 const std::vector<int32>& value);
311
312 // Convenience function, mainly for writing unit tests.
313 // Equivalent to AddStringAttribute(ATTR_NAME, name).
314 void SetName(std::string name);
315
282 #ifndef NDEBUG 316 #ifndef NDEBUG
283 virtual std::string DebugString(bool recursive) const; 317 virtual std::string DebugString(bool recursive) const;
284 #endif 318 #endif
285 319
286 // This is a simple serializable struct. All member variables should be 320 // This is a simple serializable struct. All member variables should be
287 // public and copyable. 321 // public and copyable.
288 int32 id; 322 int32 id;
289 string16 name;
290 string16 value;
291 Role role; 323 Role role;
292 uint32 state; 324 uint32 state;
293 gfx::Rect location; 325 gfx::Rect location;
294 std::map<StringAttribute, string16> string_attributes; 326 std::vector<std::pair<StringAttribute, std::string> > string_attributes;
295 std::map<IntAttribute, int32> int_attributes; 327 std::vector<std::pair<IntAttribute, int32> > int_attributes;
296 std::map<FloatAttribute, float> float_attributes; 328 std::vector<std::pair<FloatAttribute, float> > float_attributes;
297 std::map<BoolAttribute, bool> bool_attributes; 329 std::vector<std::pair<BoolAttribute, bool> > bool_attributes;
330 std::vector<std::pair<IntListAttribute, std::vector<int32> > >
331 intlist_attributes;
332 std::vector<std::pair<std::string, std::string> > html_attributes;
298 std::vector<int32> child_ids; 333 std::vector<int32> child_ids;
299 std::vector<int32> indirect_child_ids;
300 std::vector<std::pair<string16, string16> > html_attributes;
301 std::vector<int32> line_breaks;
302
303 // For a table, the cell ids in row-major order, with duplicate entries
304 // when there's a rowspan or colspan, and with -1 for missing cells.
305 // There are always exactly rows * columns entries.
306 std::vector<int32> cell_ids;
307
308 // For a table, the unique cell ids in row-major order of their first
309 // occurrence.
310 std::vector<int32> unique_cell_ids;
311 }; 334 };
312 335
313 // For testing and debugging only: this subclass of AccessibilityNodeData 336 // For testing and debugging only: this subclass of AccessibilityNodeData
314 // is used to represent a whole tree of accessibility nodes, where each 337 // is used to represent a whole tree of accessibility nodes, where each
315 // node owns its children. This makes it easy to print the tree structure 338 // node owns its children. This makes it easy to print the tree structure
316 // or search it recursively. 339 // or search it recursively.
317 struct CONTENT_EXPORT AccessibilityNodeDataTreeNode 340 struct CONTENT_EXPORT AccessibilityNodeDataTreeNode
318 : public AccessibilityNodeData { 341 : public AccessibilityNodeData {
319 AccessibilityNodeDataTreeNode(); 342 AccessibilityNodeDataTreeNode();
320 virtual ~AccessibilityNodeDataTreeNode(); 343 virtual ~AccessibilityNodeDataTreeNode();
(...skipping 12 matching lines...) Expand all
333 // build a tree of AccessibilityNodeDataTreeNode objects for easier 356 // build a tree of AccessibilityNodeDataTreeNode objects for easier
334 // testing and debugging, where each node contains its children. 357 // testing and debugging, where each node contains its children.
335 // The |dst| argument will become the root of the new tree. 358 // The |dst| argument will become the root of the new tree.
336 void MakeAccessibilityNodeDataTree( 359 void MakeAccessibilityNodeDataTree(
337 const std::vector<AccessibilityNodeData>& src, 360 const std::vector<AccessibilityNodeData>& src,
338 AccessibilityNodeDataTreeNode* dst); 361 AccessibilityNodeDataTreeNode* dst);
339 362
340 } // namespace content 363 } // namespace content
341 364
342 #endif // CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_ 365 #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