Chromium Code Reviews| 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, |
|
aboxhall
2014/04/04 22:18:10
I assume this is mostly for clarification? It was
dmazzoni
2014/04/04 23:27:39
Yeah, this is to match AXNode. The "other" ID has
| |
| 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 BrowserAccessibility* GetParent() const { return deprecated_parent_; } | |
|
aboxhall
2014/04/04 22:18:10
How will the traversing logic work after the switc
dmazzoni
2014/04/04 23:27:39
Afterwards, each BrowserAccessibility will have a
| |
| 163 int32 GetIndexInParent() const { return deprecated_index_in_parent_; } | |
| 164 uint32 InternalChildCount() const { return deprecated_children_.size(); } | |
|
aboxhall
2014/04/04 22:18:10
Why are this and the below method named 'Internal*
dmazzoni
2014/04/04 23:27:39
To contrast with PlatformChildCount and PlatformGe
| |
| 165 BrowserAccessibility* InternalGetChild(uint32 child_index) const { | |
| 166 return deprecated_children_[child_index]; | |
| 167 } | |
| 168 | |
| 169 int32 GetId() const { return data_.id; } | |
| 170 gfx::Rect GetLocation() const { return data_.location; } | |
| 171 int32 GetRole() const { return data_.role; } | |
| 172 int32 GetState() const { return data_.state; } | |
| 173 const std::vector<std::pair<std::string, std::string> >& GetHtmlAttributes() | |
| 174 const { | |
| 175 return data_.html_attributes; | |
| 176 } | |
| 177 | |
| 177 #if defined(OS_MACOSX) && __OBJC__ | 178 #if defined(OS_MACOSX) && __OBJC__ |
| 178 BrowserAccessibilityCocoa* ToBrowserAccessibilityCocoa(); | 179 BrowserAccessibilityCocoa* ToBrowserAccessibilityCocoa(); |
| 179 #elif defined(OS_WIN) | 180 #elif defined(OS_WIN) |
| 180 BrowserAccessibilityWin* ToBrowserAccessibilityWin(); | 181 BrowserAccessibilityWin* ToBrowserAccessibilityWin(); |
| 181 #elif defined(TOOLKIT_GTK) | 182 #elif defined(TOOLKIT_GTK) |
| 182 BrowserAccessibilityGtk* ToBrowserAccessibilityGtk(); | 183 BrowserAccessibilityGtk* ToBrowserAccessibilityGtk(); |
| 183 #endif | 184 #endif |
| 184 | 185 |
| 185 // Accessing accessibility attributes: | 186 // Accessing accessibility attributes: |
| 186 // | 187 // |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 // Perform child independent initialization in this method. | 267 // Perform child independent initialization in this method. |
| 267 virtual void PreInitialize() {} | 268 virtual void PreInitialize() {} |
| 268 | 269 |
| 269 BrowserAccessibility(); | 270 BrowserAccessibility(); |
| 270 | 271 |
| 271 // The manager of this tree of accessibility objects; needed for | 272 // The manager of this tree of accessibility objects; needed for |
| 272 // global operations like focus tracking. | 273 // global operations like focus tracking. |
| 273 BrowserAccessibilityManager* manager_; | 274 BrowserAccessibilityManager* manager_; |
| 274 | 275 |
| 275 // The parent of this object, may be NULL if we're the root object. | 276 // The parent of this object, may be NULL if we're the root object. |
| 276 BrowserAccessibility* parent_; | 277 BrowserAccessibility* deprecated_parent_; |
| 277 | 278 |
| 278 private: | 279 private: |
| 279 // Return the sum of the lengths of all static text descendants, | 280 // Return the sum of the lengths of all static text descendants, |
| 280 // including this object if it's static text. | 281 // including this object if it's static text. |
| 281 int GetStaticTextLenRecursive() const; | 282 int GetStaticTextLenRecursive() const; |
| 282 | 283 |
| 283 // The index of this within its parent object. | 284 // The index of this within its parent object. |
| 284 int32 index_in_parent_; | 285 int32 deprecated_index_in_parent_; |
| 285 | |
| 286 // The ID of this object in the renderer process. | |
| 287 int32 renderer_id_; | |
| 288 | 286 |
| 289 // The children of this object. | 287 // The children of this object. |
| 290 std::vector<BrowserAccessibility*> children_; | 288 std::vector<BrowserAccessibility*> deprecated_children_; |
| 291 | 289 |
| 292 // Accessibility metadata from the renderer | 290 // Accessibility metadata from the renderer |
| 293 std::string name_; | 291 std::string name_; |
| 294 std::string value_; | 292 std::string value_; |
| 295 std::vector<std::pair< | 293 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 | 294 |
| 311 // BrowserAccessibility objects are reference-counted on some platforms. | 295 // BrowserAccessibility objects are reference-counted on some platforms. |
| 312 // When we're done with this object and it's removed from our accessibility | 296 // 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 | 297 // 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 | 298 // we mark it as inactive so that calls to any of this object's methods |
| 315 // immediately return failure. | 299 // immediately return failure. |
| 316 bool instance_active_; | 300 bool instance_active_; |
| 317 | 301 |
| 318 private: | 302 private: |
| 319 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 303 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
| 320 }; | 304 }; |
| 321 | 305 |
| 322 } // namespace content | 306 } // namespace content |
| 323 | 307 |
| 324 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 308 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
| OLD | NEW |