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

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

Issue 7745035: Add a big grab bag of missing web accessibility functionality... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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) 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 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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "webkit/glue/webaccessibility.h" 15 #include "webkit/glue/webaccessibility.h"
16 16
17 class BrowserAccessibilityManager; 17 class BrowserAccessibilityManager;
18 #if defined(OS_MACOSX) && __OBJC__ 18 #if defined(OS_MACOSX) && __OBJC__
19 @class BrowserAccessibilityCocoa; 19 @class BrowserAccessibilityCocoa;
20 #elif defined(OS_WIN) 20 #elif defined(OS_WIN)
21 class BrowserAccessibilityWin; 21 class BrowserAccessibilityWin;
22 #endif 22 #endif
23 23
24 using webkit_glue::WebAccessibility; 24 using webkit_glue::WebAccessibility;
25 typedef std::map<WebAccessibility::BoolAttribute, bool> BoolAttrMap;
Chris Guillory 2011/08/31 02:14:53 Optional: Attr -> Attribute
26 typedef std::map<WebAccessibility::FloatAttribute, float> FloatAttrMap;
27 typedef std::map<WebAccessibility::IntAttribute, int> IntAttrMap;
28 typedef std::map<WebAccessibility::StringAttribute, string16> StringAttrMap;
25 29
26 //////////////////////////////////////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////////////////////////
27 // 31 //
28 // BrowserAccessibility 32 // BrowserAccessibility
29 // 33 //
30 // Class implementing the cross platform interface for the Browser-Renderer 34 // Class implementing the cross platform interface for the Browser-Renderer
31 // communication of accessibility information, providing accessibility 35 // communication of accessibility information, providing accessibility
32 // to be used by screen readers and other assistive technology (AT). 36 // to be used by screen readers and other assistive technology (AT).
33 // 37 //
34 // An implementation for each platform handles platform specific accessibility 38 // An implementation for each platform handles platform specific accessibility
(...skipping 10 matching lines...) Expand all
45 49
46 // Detach all descendants of this subtree and push all of the node pointers, 50 // Detach all descendants of this subtree and push all of the node pointers,
47 // including this node, onto the end of |nodes|. 51 // including this node, onto the end of |nodes|.
48 virtual void DetachTree(std::vector<BrowserAccessibility*>* nodes); 52 virtual void DetachTree(std::vector<BrowserAccessibility*>* nodes);
49 53
50 // Perform platform specific initialization. This can be called multiple times 54 // Perform platform specific initialization. This can be called multiple times
51 // during the lifetime of this instance after the members of this base object 55 // during the lifetime of this instance after the members of this base object
52 // have been reset with new values from the renderer process. 56 // have been reset with new values from the renderer process.
53 virtual void Initialize(); 57 virtual void Initialize();
54 58
59 // Optionally send events triggered simply by the fact that this node
60 // has been created or modified (and has been attached to the tree).
61 // This can include "show" events, "text changed" events in live regions,
62 // or "alert" events.
63 virtual void SendNodeUpdateEvents() {}
64
55 // Initialize this object, reading attributes from |src|. Does not 65 // Initialize this object, reading attributes from |src|. Does not
56 // recurse into children of |src| and build the whole subtree. 66 // recurse into children of |src| and build the whole subtree.
57 void Initialize(BrowserAccessibilityManager* manager, 67 void Initialize(BrowserAccessibilityManager* manager,
58 BrowserAccessibility* parent, 68 BrowserAccessibility* parent,
59 int32 child_id, 69 int32 child_id,
60 int32 index_in_parent, 70 int32 index_in_parent,
61 const WebAccessibility& src); 71 const WebAccessibility& src);
62 72
63 // Add a child of this object. 73 // Add a child of this object.
64 void AddChild(BrowserAccessibility* child); 74 void AddChild(BrowserAccessibility* child);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // Subclasses should override this to support platform reference counting. 132 // Subclasses should override this to support platform reference counting.
123 virtual void NativeAddReference() { } 133 virtual void NativeAddReference() { }
124 134
125 // Subclasses should override this to support platform reference counting. 135 // Subclasses should override this to support platform reference counting.
126 virtual void NativeReleaseReference(); 136 virtual void NativeReleaseReference();
127 137
128 // 138 //
129 // Accessors 139 // Accessors
130 // 140 //
131 141
132 const std::map<WebAccessibility::StringAttribute, string16>& 142 const BoolAttrMap& bool_attributes() const {
133 string_attributes() const { 143 return bool_attributes_;
134 return string_attributes_;
135 } 144 }
136 145
137 const std::map<WebAccessibility::IntAttribute, int32>& 146 const FloatAttrMap& float_attributes() const {
138 int_attributes() const { 147 return float_attributes_;
148 }
149
150 const IntAttrMap& int_attributes() const {
139 return int_attributes_; 151 return int_attributes_;
140 } 152 }
141 153
154 const StringAttrMap& string_attributes() const {
155 return string_attributes_;
156 }
157
142 int32 child_id() const { return child_id_; } 158 int32 child_id() const { return child_id_; }
143 const std::vector<BrowserAccessibility*>& children() const { 159 const std::vector<BrowserAccessibility*>& children() const {
144 return children_; 160 return children_;
145 } 161 }
146 const std::vector<std::pair<string16, string16> >& html_attributes() const { 162 const std::vector<std::pair<string16, string16> >& html_attributes() const {
147 return html_attributes_; 163 return html_attributes_;
148 } 164 }
149 int32 index_in_parent() const { return index_in_parent_; } 165 int32 index_in_parent() const { return index_in_parent_; }
150 const std::vector<int32>& indirect_child_ids() const { 166 const std::vector<int32>& indirect_child_ids() const {
151 return indirect_child_ids_; 167 return indirect_child_ids_;
152 } 168 }
153 const std::vector<int32>& line_breaks() const { 169 const std::vector<int32>& line_breaks() const {
154 return line_breaks_; 170 return line_breaks_;
155 } 171 }
156 const std::vector<int32>& cell_ids() const { 172 const std::vector<int32>& cell_ids() const {
157 return cell_ids_; 173 return cell_ids_;
158 } 174 }
175 const std::vector<int32>& unique_cell_ids() const {
176 return unique_cell_ids_;
177 }
159 gfx::Rect location() const { return location_; } 178 gfx::Rect location() const { return location_; }
160 BrowserAccessibilityManager* manager() const { return manager_; } 179 BrowserAccessibilityManager* manager() const { return manager_; }
161 const string16& name() const { return name_; } 180 const string16& name() const { return name_; }
162 int32 renderer_id() const { return renderer_id_; } 181 int32 renderer_id() const { return renderer_id_; }
163 int32 role() const { return role_; } 182 int32 role() const { return role_; }
164 const string16& role_name() const { return role_name_; } 183 const string16& role_name() const { return role_name_; }
165 int32 state() const { return state_; } 184 int32 state() const { return state_; }
166 const string16& value() const { return value_; } 185 const string16& value() const { return value_; }
167 bool instance_active() const { return instance_active_; } 186 bool instance_active() const { return instance_active_; }
168 int32 ref_count() const { return ref_count_; } 187 int32 ref_count() const { return ref_count_; }
169 188
170 #if defined(OS_MACOSX) && __OBJC__ 189 #if defined(OS_MACOSX) && __OBJC__
171 BrowserAccessibilityCocoa* toBrowserAccessibilityCocoa(); 190 BrowserAccessibilityCocoa* toBrowserAccessibilityCocoa();
172 #elif defined(OS_WIN) 191 #elif defined(OS_WIN)
173 BrowserAccessibilityWin* toBrowserAccessibilityWin(); 192 BrowserAccessibilityWin* toBrowserAccessibilityWin();
174 #endif 193 #endif
175 194
195 // Retrieve the value of a bool attribute from the bool attribute
196 // map and returns true if found.
197 bool GetBoolAttribute(WebAccessibility::BoolAttribute attr, bool* value)
198 const;
199
200 // Retrieve the value of a float attribute from the float attribute
201 // map and returns true if found.
202 bool GetFloatAttribute(WebAccessibility::FloatAttribute attr, float* value)
203 const;
204
205 // Retrieve the value of an integer attribute from the integer attribute
206 // map and returns true if found.
207 bool GetIntAttribute(WebAccessibility::IntAttribute attribute, int* value)
208 const;
209
176 // Retrieve the value of a string attribute from the attribute map and 210 // Retrieve the value of a string attribute from the attribute map and
177 // returns true if found. 211 // returns true if found.
178 bool GetStringAttribute(WebAccessibility::StringAttribute attribute, 212 bool GetStringAttribute(WebAccessibility::StringAttribute attribute,
179 string16* value); 213 string16* value) const;
180 214
181 // Retrieve the value of an integer attribute from the integer attribute 215 // Retrieve the value of a html attribute from the attribute map and
182 // map and returns true if found. 216 // returns true if found.
183 bool GetIntAttribute(WebAccessibility::IntAttribute attribute, int* value); 217 bool GetHtmlAttribute(const char* attr, string16* value) const;
218
219 // Returns true if this node is an editable text field of any kind.
220 bool IsEditableText() const;
184 221
185 protected: 222 protected:
186 BrowserAccessibility(); 223 BrowserAccessibility();
187 224
188 // The manager of this tree of accessibility objects; needed for 225 // The manager of this tree of accessibility objects; needed for
189 // global operations like focus tracking. 226 // global operations like focus tracking.
190 BrowserAccessibilityManager* manager_; 227 BrowserAccessibilityManager* manager_;
191 228
192 // The parent of this object, may be NULL if we're the root object. 229 // The parent of this object, may be NULL if we're the root object.
193 BrowserAccessibility* parent_; 230 BrowserAccessibility* parent_;
194 231
195 // The ID of this object; globally unique within the browser process. 232 // The ID of this object; globally unique within the browser process.
196 int32 child_id_; 233 int32 child_id_;
197 234
198 // The index of this within its parent object. 235 // The index of this within its parent object.
199 int32 index_in_parent_; 236 int32 index_in_parent_;
200 237
201 // The ID of this object in the renderer process. 238 // The ID of this object in the renderer process.
202 int32 renderer_id_; 239 int32 renderer_id_;
203 240
204 // The children of this object. 241 // The children of this object.
205 std::vector<BrowserAccessibility*> children_; 242 std::vector<BrowserAccessibility*> children_;
206 243
207 // The number of internal references to this object. 244 // The number of internal references to this object.
208 int32 ref_count_; 245 int32 ref_count_;
209 246
210 // Accessibility metadata from the renderer 247 // Accessibility metadata from the renderer
211 string16 name_; 248 string16 name_;
212 string16 value_; 249 string16 value_;
213 std::map<WebAccessibility::StringAttribute, string16> string_attributes_; 250 BoolAttrMap bool_attributes_;
214 std::map<WebAccessibility::IntAttribute, int32> int_attributes_; 251 IntAttrMap int_attributes_;
252 FloatAttrMap float_attributes_;
253 StringAttrMap string_attributes_;
215 std::vector<std::pair<string16, string16> > html_attributes_; 254 std::vector<std::pair<string16, string16> > html_attributes_;
216 int32 role_; 255 int32 role_;
217 int32 state_; 256 int32 state_;
218 string16 role_name_; 257 string16 role_name_;
219 gfx::Rect location_; 258 gfx::Rect location_;
220 std::vector<int32> indirect_child_ids_; 259 std::vector<int32> indirect_child_ids_;
221 std::vector<int32> line_breaks_; 260 std::vector<int32> line_breaks_;
222 std::vector<int32> cell_ids_; 261 std::vector<int32> cell_ids_;
262 std::vector<int32> unique_cell_ids_;
223 263
224 // BrowserAccessibility objects are reference-counted on some platforms. 264 // BrowserAccessibility objects are reference-counted on some platforms.
225 // When we're done with this object and it's removed from our accessibility 265 // When we're done with this object and it's removed from our accessibility
226 // tree, a client may still be holding onto a pointer to this object, so 266 // tree, a client may still be holding onto a pointer to this object, so
227 // we mark it as inactive so that calls to any of this object's methods 267 // we mark it as inactive so that calls to any of this object's methods
228 // immediately return failure. 268 // immediately return failure.
229 bool instance_active_; 269 bool instance_active_;
230 270
231 private: 271 private:
232 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); 272 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility);
233 }; 273 };
234 274
235 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ 275 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698