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

Side by Side Diff: content/public/common/ax_node_data.h

Issue 67283004: First step to move common accessibility code out of content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved out of public api Created 7 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_PUBLIC_COMMON_AX_NODE_DATA_H_
6 #define CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_ 6 #define CONTENT_PUBLIC_COMMON_AX_NODE_DATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "third_party/WebKit/public/web/WebAXEnums.h" 14 #include "third_party/WebKit/public/web/WebAXEnums.h"
15 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 // A compact representation of the accessibility information for a 19 // A compact representation of the accessibility information for a
20 // single web object, in a form that can be serialized and sent from 20 // single web object, in a form that can be serialized and sent from
21 // the renderer process to the browser process. 21 // the renderer process to the browser process.
David Tseng 2013/11/11 18:43:51 "from a source process to a receiver process" (sin
dmazzoni 2013/11/12 00:03:04 Done.
22 struct CONTENT_EXPORT AccessibilityNodeData { 22 struct CONTENT_EXPORT AXNodeData {
23 // Additional optional attributes that can be optionally attached to 23 // Additional optional attributes that can be optionally attached to
24 // a node. 24 // a node.
25 enum StringAttribute { 25 enum StringAttribute {
26 // Document attributes. 26 // Document attributes.
27 ATTR_DOC_URL, 27 ATTR_DOC_URL,
28 ATTR_DOC_TITLE, 28 ATTR_DOC_TITLE,
29 ATTR_DOC_MIMETYPE, 29 ATTR_DOC_MIMETYPE,
30 ATTR_DOC_DOCTYPE, 30 ATTR_DOC_DOCTYPE,
31 31
32 // Attributes that could apply to any node. 32 // Attributes that could apply to any node.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // within the object's bounds, the second offset is the right coordinate 157 // within the object's bounds, the second offset is the right coordinate
158 // of the second character, and so on. 158 // of the second character, and so on.
159 ATTR_CHARACTER_OFFSETS, 159 ATTR_CHARACTER_OFFSETS,
160 160
161 // For inline text. These int lists must be the same size; they represent 161 // For inline text. These int lists must be the same size; they represent
162 // the start and end character index of each word within this text. 162 // the start and end character index of each word within this text.
163 ATTR_WORD_STARTS, 163 ATTR_WORD_STARTS,
164 ATTR_WORD_ENDS, 164 ATTR_WORD_ENDS,
165 }; 165 };
166 166
167 AccessibilityNodeData(); 167 AXNodeData();
168 virtual ~AccessibilityNodeData(); 168 virtual ~AXNodeData();
169 169
170 void AddStringAttribute(StringAttribute attribute, 170 void AddStringAttribute(StringAttribute attribute,
171 const std::string& value); 171 const std::string& value);
172 void AddIntAttribute(IntAttribute attribute, int value); 172 void AddIntAttribute(IntAttribute attribute, int value);
173 void AddFloatAttribute(FloatAttribute attribute, float value); 173 void AddFloatAttribute(FloatAttribute attribute, float value);
174 void AddBoolAttribute(BoolAttribute attribute, bool value); 174 void AddBoolAttribute(BoolAttribute attribute, bool value);
175 void AddIntListAttribute(IntListAttribute attribute, 175 void AddIntListAttribute(IntListAttribute attribute,
176 const std::vector<int32>& value); 176 const std::vector<int32>& value);
177 177
178 // Convenience functions, mainly for writing unit tests. 178 // Convenience functions, mainly for writing unit tests.
179 // Equivalent to AddStringAttribute(ATTR_NAME, name). 179 // Equivalent to AddStringAttribute(ATTR_NAME, name).
180 void SetName(std::string name); 180 void SetName(std::string name);
181 // Equivalent to AddStringAttribute(ATTR_VALUE, value). 181 // Equivalent to AddStringAttribute(ATTR_VALUE, value).
182 void SetValue(std::string value); 182 void SetValue(std::string value);
183 183
184 #ifndef NDEBUG
185 virtual std::string DebugString(bool recursive) const;
186 #endif
187
188 // This is a simple serializable struct. All member variables should be 184 // This is a simple serializable struct. All member variables should be
189 // public and copyable. 185 // public and copyable.
190 int32 id; 186 int32 id;
191 WebKit::WebAXRole role; 187 WebKit::WebAXRole role;
192 uint32 state; 188 uint32 state;
193 gfx::Rect location; 189 gfx::Rect location;
194 std::vector<std::pair<StringAttribute, std::string> > string_attributes; 190 std::vector<std::pair<StringAttribute, std::string> > string_attributes;
195 std::vector<std::pair<IntAttribute, int32> > int_attributes; 191 std::vector<std::pair<IntAttribute, int32> > int_attributes;
196 std::vector<std::pair<FloatAttribute, float> > float_attributes; 192 std::vector<std::pair<FloatAttribute, float> > float_attributes;
197 std::vector<std::pair<BoolAttribute, bool> > bool_attributes; 193 std::vector<std::pair<BoolAttribute, bool> > bool_attributes;
198 std::vector<std::pair<IntListAttribute, std::vector<int32> > > 194 std::vector<std::pair<IntListAttribute, std::vector<int32> > >
199 intlist_attributes; 195 intlist_attributes;
200 std::vector<std::pair<std::string, std::string> > html_attributes; 196 std::vector<std::pair<std::string, std::string> > html_attributes;
201 std::vector<int32> child_ids; 197 std::vector<int32> child_ids;
202 }; 198 };
203 199
204 // For testing and debugging only: this subclass of AccessibilityNodeData
205 // is used to represent a whole tree of accessibility nodes, where each
206 // node owns its children. This makes it easy to print the tree structure
207 // or search it recursively.
208 struct CONTENT_EXPORT AccessibilityNodeDataTreeNode
209 : public AccessibilityNodeData {
210 AccessibilityNodeDataTreeNode();
211 virtual ~AccessibilityNodeDataTreeNode();
212
213 AccessibilityNodeDataTreeNode& operator=(const AccessibilityNodeData& src);
214
215 #ifndef NDEBUG
216 virtual std::string DebugString(bool recursive) const OVERRIDE;
217 #endif
218
219 std::vector<AccessibilityNodeDataTreeNode> children;
220 };
221
222 // Given a vector of accessibility nodes that represent a complete
223 // accessibility tree, where each node appears before its children,
224 // build a tree of AccessibilityNodeDataTreeNode objects for easier
225 // testing and debugging, where each node contains its children.
226 // The |dst| argument will become the root of the new tree.
227 void MakeAccessibilityNodeDataTree(
228 const std::vector<AccessibilityNodeData>& src,
229 AccessibilityNodeDataTreeNode* dst);
230
231 } // namespace content 200 } // namespace content
232 201
233 #endif // CONTENT_COMMON_ACCESSIBILITY_NODE_DATA_H_ 202 #endif // CONTENT_PUBLIC_COMMON_AX_NODE_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698