Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / common / accessibility_node_data.h
blob34e93479c6a6891cc89d114719591790f5ca3907
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/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"
17 namespace content {
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,
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,
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,
59 // Editable text attributes.
60 ATTR_TEXT_SEL_START,
61 ATTR_TEXT_SEL_END,
63 // Table attributes.
64 ATTR_TABLE_ROW_COUNT,
65 ATTR_TABLE_COLUMN_COUNT,
66 ATTR_TABLE_HEADER_ID,
68 // Table row attributes.
69 ATTR_TABLE_ROW_INDEX,
70 ATTR_TABLE_ROW_HEADER_ID,
72 // Table column attributes.
73 ATTR_TABLE_COLUMN_INDEX,
74 ATTR_TABLE_COLUMN_HEADER_ID,
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,
82 // Tree control attributes.
83 ATTR_HIERARCHICAL_LEVEL,
85 // Relationships between this element and other elements.
86 ATTR_TITLE_UI_ELEMENT,
88 // Color value for WebKit::WebAXRoleColorWell, each component is 0..255
89 ATTR_COLOR_VALUE_RED,
90 ATTR_COLOR_VALUE_GREEN,
91 ATTR_COLOR_VALUE_BLUE
94 enum FloatAttribute {
95 // Document attributes.
96 ATTR_DOC_LOADING_PROGRESS,
98 // Range attributes.
99 ATTR_VALUE_FOR_RANGE,
100 ATTR_MIN_VALUE_FOR_RANGE,
101 ATTR_MAX_VALUE_FOR_RANGE,
104 enum BoolAttribute {
105 // Document attributes.
106 ATTR_DOC_LOADED,
108 // True if a checkbox or radio button is in the "mixed" state.
109 ATTR_BUTTON_MIXED,
111 // Live region attributes.
112 ATTR_CONTAINER_LIVE_ATOMIC,
113 ATTR_CONTAINER_LIVE_BUSY,
114 ATTR_LIVE_ATOMIC,
115 ATTR_LIVE_BUSY,
117 // ARIA readonly flag.
118 ATTR_ARIA_READONLY,
120 // Writeable attributes
121 ATTR_CAN_SET_VALUE,
123 // If this is set, all of the other fields in this struct should
124 // be ignored and only the locations should change.
125 ATTR_UPDATE_LOCATION_ONLY,
127 // Set on a canvas element if it has fallback content.
128 ATTR_CANVAS_HAS_FALLBACK,
131 enum IntListAttribute {
132 // Ids of nodes that are children of this node logically, but are
133 // not children of this node in the tree structure. As an example,
134 // a table cell is a child of a row, and an 'indirect' child of a
135 // column.
136 ATTR_INDIRECT_CHILD_IDS,
138 // Character indices where line breaks occur.
139 ATTR_LINE_BREAKS,
141 // For a table, the cell ids in row-major order, with duplicate entries
142 // when there's a rowspan or colspan, and with -1 for missing cells.
143 // There are always exactly rows * columns entries.
144 ATTR_CELL_IDS,
146 // For a table, the unique cell ids in row-major order of their first
147 // occurrence.
148 ATTR_UNIQUE_CELL_IDS
151 AccessibilityNodeData();
152 virtual ~AccessibilityNodeData();
154 void AddStringAttribute(StringAttribute attribute,
155 const std::string& value);
156 void AddIntAttribute(IntAttribute attribute, int value);
157 void AddFloatAttribute(FloatAttribute attribute, float value);
158 void AddBoolAttribute(BoolAttribute attribute, bool value);
159 void AddIntListAttribute(IntListAttribute attribute,
160 const std::vector<int32>& value);
162 // Convenience function, mainly for writing unit tests.
163 // Equivalent to AddStringAttribute(ATTR_NAME, name).
164 void SetName(std::string name);
166 #ifndef NDEBUG
167 virtual std::string DebugString(bool recursive) const;
168 #endif
170 // This is a simple serializable struct. All member variables should be
171 // public and copyable.
172 int32 id;
173 WebKit::WebAXRole role;
174 uint32 state;
175 gfx::Rect location;
176 std::vector<std::pair<StringAttribute, std::string> > string_attributes;
177 std::vector<std::pair<IntAttribute, int32> > int_attributes;
178 std::vector<std::pair<FloatAttribute, float> > float_attributes;
179 std::vector<std::pair<BoolAttribute, bool> > bool_attributes;
180 std::vector<std::pair<IntListAttribute, std::vector<int32> > >
181 intlist_attributes;
182 std::vector<std::pair<std::string, std::string> > html_attributes;
183 std::vector<int32> child_ids;
186 // For testing and debugging only: this subclass of AccessibilityNodeData
187 // is used to represent a whole tree of accessibility nodes, where each
188 // node owns its children. This makes it easy to print the tree structure
189 // or search it recursively.
190 struct CONTENT_EXPORT AccessibilityNodeDataTreeNode
191 : public AccessibilityNodeData {
192 AccessibilityNodeDataTreeNode();
193 virtual ~AccessibilityNodeDataTreeNode();
195 AccessibilityNodeDataTreeNode& operator=(const AccessibilityNodeData& src);
197 #ifndef NDEBUG
198 virtual std::string DebugString(bool recursive) const OVERRIDE;
199 #endif
201 std::vector<AccessibilityNodeDataTreeNode> children;
204 // Given a vector of accessibility nodes that represent a complete
205 // accessibility tree, where each node appears before its children,
206 // build a tree of AccessibilityNodeDataTreeNode objects for easier
207 // testing and debugging, where each node contains its children.
208 // The |dst| argument will become the root of the new tree.
209 void MakeAccessibilityNodeDataTree(
210 const std::vector<AccessibilityNodeData>& src,
211 AccessibilityNodeDataTreeNode* dst);
213 } // namespace content
215 #endif // CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_