| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // | 68 // |
| 69 //////////////////////////////////////////////////////////////////////////////// | 69 //////////////////////////////////////////////////////////////////////////////// |
| 70 class CONTENT_EXPORT BrowserAccessibility { | 70 class CONTENT_EXPORT BrowserAccessibility { |
| 71 public: | 71 public: |
| 72 // Creates a platform specific BrowserAccessibility. Ownership passes to the | 72 // Creates a platform specific BrowserAccessibility. Ownership passes to the |
| 73 // caller. | 73 // caller. |
| 74 static BrowserAccessibility* Create(); | 74 static BrowserAccessibility* Create(); |
| 75 | 75 |
| 76 virtual ~BrowserAccessibility(); | 76 virtual ~BrowserAccessibility(); |
| 77 | 77 |
| 78 static BrowserAccessibility* GetFromUniqueID(int32_t unique_id); |
| 79 |
| 78 // Called only once, immediately after construction. The constructor doesn't | 80 // Called only once, immediately after construction. The constructor doesn't |
| 79 // take any arguments because in the Windows subclass we use a special | 81 // take any arguments because in the Windows subclass we use a special |
| 80 // function to construct a COM object. | 82 // function to construct a COM object. |
| 81 virtual void Init(BrowserAccessibilityManager* manager, ui::AXNode* node); | 83 virtual void Init(BrowserAccessibilityManager* manager, ui::AXNode* node); |
| 82 | 84 |
| 83 // Called after the object is first initialized and again every time | 85 // Called after the object is first initialized and again every time |
| 84 // its data changes. | 86 // its data changes. |
| 85 virtual void OnDataChanged() {} | 87 virtual void OnDataChanged() {} |
| 86 | 88 |
| 87 virtual void OnSubtreeWillBeDeleted() {} | 89 virtual void OnSubtreeWillBeDeleted() {} |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // Subclasses should override this to support platform reference counting. | 189 // Subclasses should override this to support platform reference counting. |
| 188 virtual void NativeReleaseReference(); | 190 virtual void NativeReleaseReference(); |
| 189 | 191 |
| 190 // | 192 // |
| 191 // Accessors | 193 // Accessors |
| 192 // | 194 // |
| 193 | 195 |
| 194 BrowserAccessibilityManager* manager() const { return manager_; } | 196 BrowserAccessibilityManager* manager() const { return manager_; } |
| 195 bool instance_active() const { return node_ != NULL; } | 197 bool instance_active() const { return node_ != NULL; } |
| 196 ui::AXNode* node() const { return node_; } | 198 ui::AXNode* node() const { return node_; } |
| 199 int32_t unique_id() const { return unique_id_; } |
| 197 | 200 |
| 198 // These access the internal accessibility tree, which doesn't necessarily | 201 // These access the internal accessibility tree, which doesn't necessarily |
| 199 // reflect the accessibility tree that should be exposed on each platform. | 202 // reflect the accessibility tree that should be exposed on each platform. |
| 200 // Use PlatformChildCount and PlatformGetChild to implement platform | 203 // Use PlatformChildCount and PlatformGetChild to implement platform |
| 201 // accessibility APIs. | 204 // accessibility APIs. |
| 202 uint32_t InternalChildCount() const; | 205 uint32_t InternalChildCount() const; |
| 203 BrowserAccessibility* InternalGetChild(uint32_t child_index) const; | 206 BrowserAccessibility* InternalGetChild(uint32_t child_index) const; |
| 204 BrowserAccessibility* InternalGetParent() const; | 207 BrowserAccessibility* InternalGetParent() const; |
| 205 | 208 |
| 206 BrowserAccessibility* GetParent() const; | 209 BrowserAccessibility* GetParent() const; |
| 207 int32_t GetIndexInParent() const; | 210 int32_t GetIndexInParent() const; |
| 208 | 211 |
| 209 int32_t GetId() const; | 212 int32_t GetId() const; |
| 210 const ui::AXNodeData& GetData() const; | 213 const ui::AXNodeData& GetData() const; |
| 211 gfx::Rect GetLocation() const; | 214 gfx::Rect GetLocation() const; |
| 212 int32_t GetRole() const; | 215 int32_t GetRole() const; |
| 213 int32_t GetState() const; | 216 int32_t GetState() const; |
| 214 | 217 |
| 215 typedef base::StringPairs HtmlAttributes; | 218 typedef base::StringPairs HtmlAttributes; |
| 216 const HtmlAttributes& GetHtmlAttributes() const; | 219 const HtmlAttributes& GetHtmlAttributes() const; |
| 217 | 220 |
| 218 // Returns true if this is a native platform-specific object, vs a | 221 // Returns true if this is a native platform-specific object, vs a |
| 219 // cross-platform generic object. Don't call ToBrowserAccessibilityXXX if | 222 // cross-platform generic object. Don't call ToBrowserAccessibilityXXX if |
| 220 // IsNative returns false. | 223 // IsNative returns false. |
| 221 virtual bool IsNative() const; | 224 virtual bool IsNative() const; |
| 222 | 225 |
| 223 #if defined(OS_MACOSX) && __OBJC__ | |
| 224 const BrowserAccessibilityCocoa* ToBrowserAccessibilityCocoa() const; | |
| 225 BrowserAccessibilityCocoa* ToBrowserAccessibilityCocoa(); | |
| 226 #elif defined(OS_WIN) | |
| 227 const BrowserAccessibilityWin* ToBrowserAccessibilityWin() const; | |
| 228 BrowserAccessibilityWin* ToBrowserAccessibilityWin(); | |
| 229 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11) | |
| 230 const BrowserAccessibilityAuraLinux* ToBrowserAccessibilityAuraLinux() const; | |
| 231 BrowserAccessibilityAuraLinux* ToBrowserAccessibilityAuraLinux(); | |
| 232 #endif | |
| 233 | |
| 234 // Accessing accessibility attributes: | 226 // Accessing accessibility attributes: |
| 235 // | 227 // |
| 236 // There are dozens of possible attributes for an accessibility node, | 228 // There are dozens of possible attributes for an accessibility node, |
| 237 // but only a few tend to apply to any one object, so we store them | 229 // but only a few tend to apply to any one object, so we store them |
| 238 // in sparse arrays of <attribute id, attribute value> pairs, organized | 230 // in sparse arrays of <attribute id, attribute value> pairs, organized |
| 239 // by type (bool, int, float, string, int list). | 231 // by type (bool, int, float, string, int list). |
| 240 // | 232 // |
| 241 // There are three accessors for each type of attribute: one that returns | 233 // There are three accessors for each type of attribute: one that returns |
| 242 // true if the attribute is present and false if not, one that takes a | 234 // true if the attribute is present and false if not, one that takes a |
| 243 // pointer argument and returns true if the attribute is present (if you | 235 // pointer argument and returns true if the attribute is present (if you |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 313 |
| 322 protected: | 314 protected: |
| 323 BrowserAccessibility(); | 315 BrowserAccessibility(); |
| 324 | 316 |
| 325 // The manager of this tree of accessibility objects. | 317 // The manager of this tree of accessibility objects. |
| 326 BrowserAccessibilityManager* manager_; | 318 BrowserAccessibilityManager* manager_; |
| 327 | 319 |
| 328 // The underlying node. | 320 // The underlying node. |
| 329 ui::AXNode* node_; | 321 ui::AXNode* node_; |
| 330 | 322 |
| 323 // A unique ID, since node IDs are frame-local. |
| 324 int32_t unique_id_; |
| 325 |
| 331 private: | 326 private: |
| 332 // |GetInnerText| recursively includes all the text from descendants such as | 327 // |GetInnerText| recursively includes all the text from descendants such as |
| 333 // text found in any embedded object. In contrast, |GetText| might include a | 328 // text found in any embedded object. In contrast, |GetText| might include a |
| 334 // special character in the place of every embedded object instead of its | 329 // special character in the place of every embedded object instead of its |
| 335 // text, depending on the platform. | 330 // text, depending on the platform. |
| 336 base::string16 GetInnerText() const; | 331 base::string16 GetInnerText() const; |
| 337 | 332 |
| 338 // If a bounding rectangle is empty, compute it based on the union of its | 333 // If a bounding rectangle is empty, compute it based on the union of its |
| 339 // children, since most accessibility APIs don't like elements with no | 334 // children, since most accessibility APIs don't like elements with no |
| 340 // bounds, but "virtual" elements in the accessibility tree that don't | 335 // bounds, but "virtual" elements in the accessibility tree that don't |
| 341 // correspond to a layed-out element sometimes don't have bounds. | 336 // correspond to a layed-out element sometimes don't have bounds. |
| 342 void FixEmptyBounds(gfx::Rect* bounds) const; | 337 void FixEmptyBounds(gfx::Rect* bounds) const; |
| 343 | 338 |
| 344 // Convert the bounding rectangle of an element (which is relative to | 339 // Convert the bounding rectangle of an element (which is relative to |
| 345 // its nearest scrollable ancestor) to local bounds (which are relative | 340 // its nearest scrollable ancestor) to local bounds (which are relative |
| 346 // to the top of the web accessibility tree). | 341 // to the top of the web accessibility tree). |
| 347 gfx::Rect ElementBoundsToLocalBounds(gfx::Rect bounds) const; | 342 gfx::Rect ElementBoundsToLocalBounds(gfx::Rect bounds) const; |
| 348 | 343 |
| 349 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 344 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
| 350 }; | 345 }; |
| 351 | 346 |
| 352 } // namespace content | 347 } // namespace content |
| 353 | 348 |
| 354 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 349 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
| OLD | NEW |