OLD | NEW |
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> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 virtual void PostInitialize() {} | 59 virtual void PostInitialize() {} |
60 | 60 |
61 // Returns true if this is a native platform-specific object, vs a | 61 // Returns true if this is a native platform-specific object, vs a |
62 // cross-platform generic object. | 62 // cross-platform generic object. |
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 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 ui::AXNodeData& 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|. |
84 bool IsDescendantOf(BrowserAccessibility* ancestor); | 84 bool IsDescendantOf(BrowserAccessibility* ancestor); |
85 | 85 |
86 // Returns the parent of this object, or NULL if it's the root. | |
87 BrowserAccessibility* parent() const { return parent_; } | |
88 | |
89 // Returns the number of children of this object. | |
90 uint32 child_count() const { return children_.size(); } | |
91 | |
92 // Returns true if this is a leaf node on this platform, meaning any | 86 // Returns true if this is a leaf node on this platform, meaning any |
93 // children should not be exposed to this platform's native accessibility | 87 // children should not be exposed to this platform's native accessibility |
94 // layer. Each platform subclass should implement this itself. | 88 // layer. Each platform subclass should implement this itself. |
95 // The definition of a leaf may vary depending on the platform, | 89 // The definition of a leaf may vary depending on the platform, |
96 // but a leaf node should never have children that are focusable or | 90 // but a leaf node should never have children that are focusable or |
97 // that might send notifications. | 91 // that might send notifications. |
98 virtual bool PlatformIsLeaf() const; | 92 virtual bool PlatformIsLeaf() const; |
99 | 93 |
100 // Returns the number of children of this object, or 0 if PlatformIsLeaf() | 94 // Returns the number of children of this object, or 0 if PlatformIsLeaf() |
101 // returns true. | 95 // returns true. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // Subclasses should override this to support platform reference counting. | 141 // Subclasses should override this to support platform reference counting. |
148 virtual void NativeAddReference() { } | 142 virtual void NativeAddReference() { } |
149 | 143 |
150 // Subclasses should override this to support platform reference counting. | 144 // Subclasses should override this to support platform reference counting. |
151 virtual void NativeReleaseReference(); | 145 virtual void NativeReleaseReference(); |
152 | 146 |
153 // | 147 // |
154 // Accessors | 148 // Accessors |
155 // | 149 // |
156 | 150 |
157 const std::vector<BrowserAccessibility*>& children() const { | |
158 return children_; | |
159 } | |
160 const std::vector<std::pair<std::string, std::string> >& | |
161 html_attributes() const { | |
162 return html_attributes_; | |
163 } | |
164 int32 index_in_parent() const { return index_in_parent_; } | |
165 gfx::Rect location() const { return location_; } | |
166 BrowserAccessibilityManager* manager() const { return manager_; } | 151 BrowserAccessibilityManager* manager() const { return manager_; } |
| 152 bool instance_active() const { return instance_active_; } |
167 const std::string& name() const { return name_; } | 153 const std::string& name() const { return name_; } |
168 const std::string& value() const { return value_; } | 154 const std::string& value() const { return value_; } |
169 int32 renderer_id() const { return renderer_id_; } | |
170 int32 role() const { return role_; } | |
171 int32 state() const { return state_; } | |
172 bool instance_active() const { return instance_active_; } | |
173 | |
174 void set_name(const std::string& name) { name_ = name; } | 155 void set_name(const std::string& name) { name_ = name; } |
175 void set_value(const std::string& value) { value_ = value; } | 156 void set_value(const std::string& value) { value_ = value; } |
176 | 157 |
| 158 std::vector<BrowserAccessibility*>& deprecated_children() { |
| 159 return deprecated_children_; |
| 160 } |
| 161 |
| 162 // These access the internal accessibility tree, which doesn't necessarily |
| 163 // reflect the accessibility tree that should be exposed on each platform. |
| 164 // Use PlatformChildCount and PlatformGetChild to implement platform |
| 165 // accessibility APIs. |
| 166 uint32 InternalChildCount() const { return deprecated_children_.size(); } |
| 167 BrowserAccessibility* InternalGetChild(uint32 child_index) const { |
| 168 return deprecated_children_[child_index]; |
| 169 } |
| 170 |
| 171 BrowserAccessibility* GetParent() const { return deprecated_parent_; } |
| 172 int32 GetIndexInParent() const { return deprecated_index_in_parent_; } |
| 173 |
| 174 int32 GetId() const { return data_.id; } |
| 175 gfx::Rect GetLocation() const { return data_.location; } |
| 176 int32 GetRole() const { return data_.role; } |
| 177 int32 GetState() const { return data_.state; } |
| 178 const std::vector<std::pair<std::string, std::string> >& GetHtmlAttributes() |
| 179 const { |
| 180 return data_.html_attributes; |
| 181 } |
| 182 |
177 #if defined(OS_MACOSX) && __OBJC__ | 183 #if defined(OS_MACOSX) && __OBJC__ |
178 BrowserAccessibilityCocoa* ToBrowserAccessibilityCocoa(); | 184 BrowserAccessibilityCocoa* ToBrowserAccessibilityCocoa(); |
179 #elif defined(OS_WIN) | 185 #elif defined(OS_WIN) |
180 BrowserAccessibilityWin* ToBrowserAccessibilityWin(); | 186 BrowserAccessibilityWin* ToBrowserAccessibilityWin(); |
181 #elif defined(TOOLKIT_GTK) | 187 #elif defined(TOOLKIT_GTK) |
182 BrowserAccessibilityGtk* ToBrowserAccessibilityGtk(); | 188 BrowserAccessibilityGtk* ToBrowserAccessibilityGtk(); |
183 #endif | 189 #endif |
184 | 190 |
185 // Accessing accessibility attributes: | 191 // Accessing accessibility attributes: |
186 // | 192 // |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // Perform child independent initialization in this method. | 272 // Perform child independent initialization in this method. |
267 virtual void PreInitialize() {} | 273 virtual void PreInitialize() {} |
268 | 274 |
269 BrowserAccessibility(); | 275 BrowserAccessibility(); |
270 | 276 |
271 // The manager of this tree of accessibility objects; needed for | 277 // The manager of this tree of accessibility objects; needed for |
272 // global operations like focus tracking. | 278 // global operations like focus tracking. |
273 BrowserAccessibilityManager* manager_; | 279 BrowserAccessibilityManager* manager_; |
274 | 280 |
275 // The parent of this object, may be NULL if we're the root object. | 281 // The parent of this object, may be NULL if we're the root object. |
276 BrowserAccessibility* parent_; | 282 BrowserAccessibility* deprecated_parent_; |
277 | 283 |
278 private: | 284 private: |
279 // Return the sum of the lengths of all static text descendants, | 285 // Return the sum of the lengths of all static text descendants, |
280 // including this object if it's static text. | 286 // including this object if it's static text. |
281 int GetStaticTextLenRecursive() const; | 287 int GetStaticTextLenRecursive() const; |
282 | 288 |
283 // The index of this within its parent object. | 289 // The index of this within its parent object. |
284 int32 index_in_parent_; | 290 int32 deprecated_index_in_parent_; |
285 | |
286 // The ID of this object in the renderer process. | |
287 int32 renderer_id_; | |
288 | 291 |
289 // The children of this object. | 292 // The children of this object. |
290 std::vector<BrowserAccessibility*> children_; | 293 std::vector<BrowserAccessibility*> deprecated_children_; |
291 | 294 |
292 // Accessibility metadata from the renderer | 295 // Accessibility metadata from the renderer |
293 std::string name_; | 296 std::string name_; |
294 std::string value_; | 297 std::string value_; |
295 std::vector<std::pair< | 298 ui::AXNodeData data_; |
296 ui::AXBoolAttribute, bool> > bool_attributes_; | |
297 std::vector<std::pair< | |
298 ui::AXFloatAttribute, float> > float_attributes_; | |
299 std::vector<std::pair< | |
300 ui::AXIntAttribute, int> > int_attributes_; | |
301 std::vector<std::pair< | |
302 ui::AXStringAttribute, std::string> > string_attributes_; | |
303 std::vector<std::pair< | |
304 ui::AXIntListAttribute, std::vector<int32> > > | |
305 intlist_attributes_; | |
306 std::vector<std::pair<std::string, std::string> > html_attributes_; | |
307 int32 role_; | |
308 int32 state_; | |
309 gfx::Rect location_; | |
310 | 299 |
311 // BrowserAccessibility objects are reference-counted on some platforms. | 300 // BrowserAccessibility objects are reference-counted on some platforms. |
312 // When we're done with this object and it's removed from our accessibility | 301 // When we're done with this object and it's removed from our accessibility |
313 // tree, a client may still be holding onto a pointer to this object, so | 302 // tree, a client may still be holding onto a pointer to this object, so |
314 // we mark it as inactive so that calls to any of this object's methods | 303 // we mark it as inactive so that calls to any of this object's methods |
315 // immediately return failure. | 304 // immediately return failure. |
316 bool instance_active_; | 305 bool instance_active_; |
317 | 306 |
318 private: | 307 private: |
319 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 308 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
320 }; | 309 }; |
321 | 310 |
322 } // namespace content | 311 } // namespace content |
323 | 312 |
324 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 313 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
OLD | NEW |