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> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/browser/accessibility/ax_platform_position.h" | 18 #include "content/browser/accessibility/ax_platform_position.h" |
19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
20 #include "third_party/WebKit/public/web/WebAXEnums.h" | 20 #include "third_party/WebKit/public/web/WebAXEnums.h" |
21 #include "ui/accessibility/ax_node.h" | 21 #include "ui/accessibility/ax_node.h" |
22 #include "ui/accessibility/ax_node_data.h" | 22 #include "ui/accessibility/ax_node_data.h" |
23 #include "ui/accessibility/ax_range.h" | 23 #include "ui/accessibility/ax_range.h" |
24 #include "ui/accessibility/ax_text_utils.h" | 24 #include "ui/accessibility/ax_text_utils.h" |
| 25 #include "ui/accessibility/platform/ax_platform_node_delegate.h" |
25 | 26 |
26 // Set PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL if this platform has | 27 // Set PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL if this platform has |
27 // a platform-specific subclass of BrowserAccessibility and | 28 // a platform-specific subclass of BrowserAccessibility and |
28 // BrowserAccessibilityManager. | 29 // BrowserAccessibilityManager. |
29 #undef PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL | 30 #undef PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL |
30 | 31 |
31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
32 #define PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL 1 | 33 #define PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL 1 |
33 #endif | 34 #endif |
34 | 35 |
(...skipping 22 matching lines...) Expand all Loading... |
57 // | 58 // |
58 // A BrowserAccessibility object represents one node in the accessibility | 59 // A BrowserAccessibility object represents one node in the accessibility |
59 // tree on the browser side. It exactly corresponds to one WebAXObject from | 60 // tree on the browser side. It exactly corresponds to one WebAXObject from |
60 // Blink. It's owned by a BrowserAccessibilityManager. | 61 // Blink. It's owned by a BrowserAccessibilityManager. |
61 // | 62 // |
62 // There are subclasses of BrowserAccessibility for each platform where | 63 // There are subclasses of BrowserAccessibility for each platform where |
63 // we implement native accessibility APIs. This base class is used occasionally | 64 // we implement native accessibility APIs. This base class is used occasionally |
64 // for tests. | 65 // for tests. |
65 // | 66 // |
66 //////////////////////////////////////////////////////////////////////////////// | 67 //////////////////////////////////////////////////////////////////////////////// |
67 class CONTENT_EXPORT BrowserAccessibility { | 68 class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { |
68 public: | 69 public: |
69 // Creates a platform specific BrowserAccessibility. Ownership passes to the | 70 // Creates a platform specific BrowserAccessibility. Ownership passes to the |
70 // caller. | 71 // caller. |
71 static BrowserAccessibility* Create(); | 72 static BrowserAccessibility* Create(); |
72 | 73 |
73 virtual ~BrowserAccessibility(); | 74 virtual ~BrowserAccessibility(); |
74 | 75 |
75 static BrowserAccessibility* GetFromUniqueID(int32_t unique_id); | 76 static BrowserAccessibility* GetFromUniqueID(int32_t unique_id); |
76 | 77 |
77 // Called only once, immediately after construction. The constructor doesn't | 78 // Called only once, immediately after construction. The constructor doesn't |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // Use PlatformChildCount and PlatformGetChild to implement platform | 230 // Use PlatformChildCount and PlatformGetChild to implement platform |
230 // accessibility APIs. | 231 // accessibility APIs. |
231 uint32_t InternalChildCount() const; | 232 uint32_t InternalChildCount() const; |
232 BrowserAccessibility* InternalGetChild(uint32_t child_index) const; | 233 BrowserAccessibility* InternalGetChild(uint32_t child_index) const; |
233 BrowserAccessibility* InternalGetParent() const; | 234 BrowserAccessibility* InternalGetParent() const; |
234 | 235 |
235 BrowserAccessibility* PlatformGetParent() const; | 236 BrowserAccessibility* PlatformGetParent() const; |
236 int32_t GetIndexInParent() const; | 237 int32_t GetIndexInParent() const; |
237 | 238 |
238 int32_t GetId() const; | 239 int32_t GetId() const; |
239 const ui::AXNodeData& GetData() const; | |
240 gfx::RectF GetLocation() const; | 240 gfx::RectF GetLocation() const; |
241 ui::AXRole GetRole() const; | 241 ui::AXRole GetRole() const; |
242 int32_t GetState() const; | 242 int32_t GetState() const; |
243 | 243 |
244 typedef base::StringPairs HtmlAttributes; | 244 typedef base::StringPairs HtmlAttributes; |
245 const HtmlAttributes& GetHtmlAttributes() const; | 245 const HtmlAttributes& GetHtmlAttributes() const; |
246 | 246 |
247 // Returns true if this is a native platform-specific object, vs a | 247 // Returns true if this is a native platform-specific object, vs a |
248 // cross-platform generic object. Don't call ToBrowserAccessibilityXXX if | 248 // cross-platform generic object. Don't call ToBrowserAccessibilityXXX if |
249 // IsNative returns false. | 249 // IsNative returns false. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 358 |
359 // Creates a position rooted at this object. | 359 // Creates a position rooted at this object. |
360 // This is a text position on all platforms except IA2 and ATK, where tree | 360 // This is a text position on all platforms except IA2 and ATK, where tree |
361 // positions are created for non-text objects representing hypertext offsets. | 361 // positions are created for non-text objects representing hypertext offsets. |
362 virtual AXPlatformPosition::AXPositionInstance CreatePositionAt( | 362 virtual AXPlatformPosition::AXPositionInstance CreatePositionAt( |
363 int offset) const; | 363 int offset) const; |
364 | 364 |
365 // Gets the text offsets where new lines start. | 365 // Gets the text offsets where new lines start. |
366 std::vector<int> GetLineStartOffsets() const; | 366 std::vector<int> GetLineStartOffsets() const; |
367 | 367 |
| 368 // AXPlatformNodeDelegate. |
| 369 const ui::AXNodeData& GetData() const override; |
| 370 gfx::NativeWindow GetTopLevelWidget() override; |
| 371 gfx::NativeViewAccessible GetParent() override; |
| 372 int GetChildCount() override; |
| 373 gfx::NativeViewAccessible ChildAtIndex(int index) override; |
| 374 gfx::Vector2d GetGlobalCoordinateOffset() override; |
| 375 gfx::NativeViewAccessible HitTestSync(int x, int y) override; |
| 376 gfx::NativeViewAccessible GetFocus() override; |
| 377 gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; |
| 378 bool AccessibilityPerformAction(const ui::AXActionData& data) override; |
| 379 void DoDefaultAction() override; |
| 380 |
368 protected: | 381 protected: |
369 using AXPlatformPositionInstance = AXPlatformPosition::AXPositionInstance; | 382 using AXPlatformPositionInstance = AXPlatformPosition::AXPositionInstance; |
370 using AXPlatformRange = ui::AXRange<AXPlatformPositionInstance::element_type>; | 383 using AXPlatformRange = ui::AXRange<AXPlatformPositionInstance::element_type>; |
371 | 384 |
372 BrowserAccessibility(); | 385 BrowserAccessibility(); |
373 | 386 |
374 // The manager of this tree of accessibility objects. | 387 // The manager of this tree of accessibility objects. |
375 BrowserAccessibilityManager* manager_; | 388 BrowserAccessibilityManager* manager_; |
376 | 389 |
377 // The underlying node. | 390 // The underlying node. |
(...skipping 14 matching lines...) Expand all Loading... |
392 // bounds, but "virtual" elements in the accessibility tree that don't | 405 // bounds, but "virtual" elements in the accessibility tree that don't |
393 // correspond to a layed-out element sometimes don't have bounds. | 406 // correspond to a layed-out element sometimes don't have bounds. |
394 void FixEmptyBounds(gfx::RectF* bounds) const; | 407 void FixEmptyBounds(gfx::RectF* bounds) const; |
395 | 408 |
396 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 409 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
397 }; | 410 }; |
398 | 411 |
399 } // namespace content | 412 } // namespace content |
400 | 413 |
401 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 414 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
OLD | NEW |