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

Side by Side Diff: content/browser/accessibility/browser_accessibility.h

Issue 116293005: Refactor content/ to use ui::AXNodeData instead of blink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update content/DEPS instead of subdirs Created 6 years, 11 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
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_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_
6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "content/common/accessibility_node_data.h"
16 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
17 #include "third_party/WebKit/public/web/WebAXEnums.h" 16 #include "third_party/WebKit/public/web/WebAXEnums.h"
17 #include "ui/accessibility/ax_node_data.h"
18 18
19 #if defined(OS_MACOSX) && __OBJC__ 19 #if defined(OS_MACOSX) && __OBJC__
20 @class BrowserAccessibilityCocoa; 20 @class BrowserAccessibilityCocoa;
21 #endif 21 #endif
22 22
23 namespace content { 23 namespace content {
24 class BrowserAccessibilityManager; 24 class BrowserAccessibilityManager;
25 #if defined(OS_WIN) 25 #if defined(OS_WIN)
26 class BrowserAccessibilityWin; 26 class BrowserAccessibilityWin;
27 #elif defined(TOOLKIT_GTK) 27 #elif defined(TOOLKIT_GTK)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 virtual bool IsNative() const; 63 virtual bool IsNative() const;
64 64
65 // Initialize the tree structure of this object. 65 // Initialize the tree structure of this object.
66 void InitializeTreeStructure( 66 void InitializeTreeStructure(
67 BrowserAccessibilityManager* manager, 67 BrowserAccessibilityManager* manager,
68 BrowserAccessibility* parent, 68 BrowserAccessibility* parent,
69 int32 renderer_id, 69 int32 renderer_id,
70 int32 index_in_parent); 70 int32 index_in_parent);
71 71
72 // Initialize this object's data. 72 // Initialize this object's data.
73 void InitializeData(const AccessibilityNodeData& src); 73 void InitializeData(const ui::AXNodeData& src);
74 74
75 virtual void SwapChildren(std::vector<BrowserAccessibility*>& children); 75 virtual void SwapChildren(std::vector<BrowserAccessibility*>& children);
76 76
77 // Update the parent and index in parent if this node has been moved. 77 // Update the parent and index in parent if this node has been moved.
78 void UpdateParent(BrowserAccessibility* parent, int index_in_parent); 78 void UpdateParent(BrowserAccessibility* parent, int index_in_parent);
79 79
80 // Update this node's location, leaving everything else the same. 80 // Update this node's location, leaving everything else the same.
81 virtual void SetLocation(const gfx::Rect& new_location); 81 virtual void SetLocation(const gfx::Rect& new_location);
82 82
83 // Return true if this object is equal to or a descendant of |ancestor|. 83 // Return true if this object is equal to or a descendant of |ancestor|.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // by type (bool, int, float, string, int list). 190 // by type (bool, int, float, string, int list).
191 // 191 //
192 // There are three accessors for each type of attribute: one that returns 192 // There are three accessors for each type of attribute: one that returns
193 // true if the attribute is present and false if not, one that takes a 193 // true if the attribute is present and false if not, one that takes a
194 // pointer argument and returns true if the attribute is present (if you 194 // pointer argument and returns true if the attribute is present (if you
195 // need to distinguish between the default value and a missing attribute), 195 // need to distinguish between the default value and a missing attribute),
196 // and another that returns the default value for that type if the 196 // and another that returns the default value for that type if the
197 // attribute is not present. In addition, strings can be returned as 197 // attribute is not present. In addition, strings can be returned as
198 // either std::string or base::string16, for convenience. 198 // either std::string or base::string16, for convenience.
199 199
200 bool HasBoolAttribute(AccessibilityNodeData::BoolAttribute attr) const; 200 bool HasBoolAttribute(ui::AXBoolAttribute attr) const;
201 bool GetBoolAttribute(AccessibilityNodeData::BoolAttribute attr) const; 201 bool GetBoolAttribute(ui::AXBoolAttribute attr) const;
202 bool GetBoolAttribute(AccessibilityNodeData::BoolAttribute attr, 202 bool GetBoolAttribute(ui::AXBoolAttribute attr, bool* value) const;
203 bool* value) const;
204 203
205 bool HasFloatAttribute(AccessibilityNodeData::FloatAttribute attr) const; 204 bool HasFloatAttribute(ui::AXFloatAttribute attr) const;
206 float GetFloatAttribute(AccessibilityNodeData::FloatAttribute attr) const; 205 float GetFloatAttribute(ui::AXFloatAttribute attr) const;
207 bool GetFloatAttribute(AccessibilityNodeData::FloatAttribute attr, 206 bool GetFloatAttribute(ui::AXFloatAttribute attr, float* value) const;
208 float* value) const;
209 207
210 bool HasIntAttribute(AccessibilityNodeData::IntAttribute attribute) const; 208 bool HasIntAttribute(ui::AXIntAttribute attribute) const;
211 int GetIntAttribute(AccessibilityNodeData::IntAttribute attribute) const; 209 int GetIntAttribute(ui::AXIntAttribute attribute) const;
212 bool GetIntAttribute(AccessibilityNodeData::IntAttribute attribute, 210 bool GetIntAttribute(ui::AXIntAttribute attribute, int* value) const;
213 int* value) const;
214 211
215 bool HasStringAttribute( 212 bool HasStringAttribute(
216 AccessibilityNodeData::StringAttribute attribute) const; 213 ui::AXStringAttribute attribute) const;
217 const std::string& GetStringAttribute( 214 const std::string& GetStringAttribute(ui::AXStringAttribute attribute) const;
218 AccessibilityNodeData::StringAttribute attribute) const; 215 bool GetStringAttribute(ui::AXStringAttribute attribute,
219 bool GetStringAttribute(AccessibilityNodeData::StringAttribute attribute,
220 std::string* value) const; 216 std::string* value) const;
221 217
222 bool GetString16Attribute(AccessibilityNodeData::StringAttribute attribute, 218 bool GetString16Attribute(ui::AXStringAttribute attribute,
223 base::string16* value) const; 219 base::string16* value) const;
224 base::string16 GetString16Attribute( 220 base::string16 GetString16Attribute(
225 AccessibilityNodeData::StringAttribute attribute) const; 221 ui::AXStringAttribute attribute) const;
226 222
227 bool HasIntListAttribute( 223 bool HasIntListAttribute(ui::AXIntListAttribute attribute) const;
228 AccessibilityNodeData::IntListAttribute attribute) const;
229 const std::vector<int32>& GetIntListAttribute( 224 const std::vector<int32>& GetIntListAttribute(
230 AccessibilityNodeData::IntListAttribute attribute) const; 225 ui::AXIntListAttribute attribute) const;
231 bool GetIntListAttribute(AccessibilityNodeData::IntListAttribute attribute, 226 bool GetIntListAttribute(ui::AXIntListAttribute attribute,
232 std::vector<int32>* value) const; 227 std::vector<int32>* value) const;
233 228
234 void SetStringAttribute( 229 void SetStringAttribute(ui::AXStringAttribute attribute,
235 AccessibilityNodeData::StringAttribute attribute, 230 const std::string& value);
236 const std::string& value);
237 231
238 // Retrieve the value of a html attribute from the attribute map and 232 // Retrieve the value of a html attribute from the attribute map and
239 // returns true if found. 233 // returns true if found.
240 bool GetHtmlAttribute(const char* attr, base::string16* value) const; 234 bool GetHtmlAttribute(const char* attr, base::string16* value) const;
241 bool GetHtmlAttribute(const char* attr, std::string* value) const; 235 bool GetHtmlAttribute(const char* attr, std::string* value) const;
242 236
243 // Utility method to handle special cases for ARIA booleans, tristates and 237 // Utility method to handle special cases for ARIA booleans, tristates and
244 // booleans which have a "mixed" state. 238 // booleans which have a "mixed" state.
245 // 239 //
246 // Warning: the term "Tristate" is used loosely by the spec and here, 240 // Warning: the term "Tristate" is used loosely by the spec and here,
247 // as some attributes support a 4th state. 241 // as some attributes support a 4th state.
248 // 242 //
249 // The following attributes are appropriate to use with this method: 243 // The following attributes are appropriate to use with this method:
250 // aria-selected (selectable) 244 // aria-selected (selectable)
251 // aria-grabbed (grabbable) 245 // aria-grabbed (grabbable)
252 // aria-expanded (expandable) 246 // aria-expanded (expandable)
253 // aria-pressed (toggleable/pressable) -- supports 4th "mixed" state 247 // aria-pressed (toggleable/pressable) -- supports 4th "mixed" state
254 // aria-checked (checkable) -- supports 4th "mixed state" 248 // aria-checked (checkable) -- supports 4th "mixed state"
255 bool GetAriaTristate(const char* attr_name, 249 bool GetAriaTristate(const char* attr_name,
256 bool* is_defined, 250 bool* is_defined,
257 bool* is_mixed) const; 251 bool* is_mixed) const;
258 252
259 // Returns true if the bit corresponding to the given state enum is 1. 253 // Returns true if the bit corresponding to the given state enum is 1.
260 bool HasState(blink::WebAXState state_enum) const; 254 bool HasState(ui::AXState state_enum) const;
261 255
262 // Returns true if this node is an editable text field of any kind. 256 // Returns true if this node is an editable text field of any kind.
263 bool IsEditableText() const; 257 bool IsEditableText() const;
264 258
265 // Append the text from this node and its children. 259 // Append the text from this node and its children.
266 std::string GetTextRecursive() const; 260 std::string GetTextRecursive() const;
267 261
268 protected: 262 protected:
269 // Perform platform specific initialization. This can be called multiple times 263 // Perform platform specific initialization. This can be called multiple times
270 // during the lifetime of this instance after the members of this base object 264 // during the lifetime of this instance after the members of this base object
(...skipping 21 matching lines...) Expand all
292 // The ID of this object in the renderer process. 286 // The ID of this object in the renderer process.
293 int32 renderer_id_; 287 int32 renderer_id_;
294 288
295 // The children of this object. 289 // The children of this object.
296 std::vector<BrowserAccessibility*> children_; 290 std::vector<BrowserAccessibility*> children_;
297 291
298 // Accessibility metadata from the renderer 292 // Accessibility metadata from the renderer
299 std::string name_; 293 std::string name_;
300 std::string value_; 294 std::string value_;
301 std::vector<std::pair< 295 std::vector<std::pair<
302 AccessibilityNodeData::BoolAttribute, bool> > bool_attributes_; 296 ui::AXBoolAttribute, bool> > bool_attributes_;
303 std::vector<std::pair< 297 std::vector<std::pair<
304 AccessibilityNodeData::FloatAttribute, float> > float_attributes_; 298 ui::AXFloatAttribute, float> > float_attributes_;
305 std::vector<std::pair< 299 std::vector<std::pair<
306 AccessibilityNodeData::IntAttribute, int> > int_attributes_; 300 ui::AXIntAttribute, int> > int_attributes_;
307 std::vector<std::pair< 301 std::vector<std::pair<
308 AccessibilityNodeData::StringAttribute, std::string> > string_attributes_; 302 ui::AXStringAttribute, std::string> > string_attributes_;
309 std::vector<std::pair< 303 std::vector<std::pair<
310 AccessibilityNodeData::IntListAttribute, std::vector<int32> > > 304 ui::AXIntListAttribute, std::vector<int32> > >
311 intlist_attributes_; 305 intlist_attributes_;
312 std::vector<std::pair<std::string, std::string> > html_attributes_; 306 std::vector<std::pair<std::string, std::string> > html_attributes_;
313 int32 role_; 307 int32 role_;
314 int32 state_; 308 int32 state_;
315 gfx::Rect location_; 309 gfx::Rect location_;
316 310
317 // BrowserAccessibility objects are reference-counted on some platforms. 311 // BrowserAccessibility objects are reference-counted on some platforms.
318 // When we're done with this object and it's removed from our accessibility 312 // When we're done with this object and it's removed from our accessibility
319 // tree, a client may still be holding onto a pointer to this object, so 313 // tree, a client may still be holding onto a pointer to this object, so
320 // we mark it as inactive so that calls to any of this object's methods 314 // we mark it as inactive so that calls to any of this object's methods
321 // immediately return failure. 315 // immediately return failure.
322 bool instance_active_; 316 bool instance_active_;
323 317
324 private: 318 private:
325 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); 319 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility);
326 }; 320 };
327 321
328 } // namespace content 322 } // namespace content
329 323
330 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ 324 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_
OLDNEW
« no previous file with comments | « content/browser/accessibility/accessibility_win_browsertest.cc ('k') | content/browser/accessibility/browser_accessibility.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698