| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_H_ | 5 #ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_H_ |
| 6 #define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_H_ | 6 #define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ui/accessibility/ax_enums.h" | 9 #include "ui/accessibility/ax_enums.h" |
| 10 #include "ui/accessibility/ax_export.h" | 10 #include "ui/accessibility/ax_export.h" |
| 11 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 12 | 12 |
| 13 // Set PLATFORM_HAS_AX_PLATFORM_NODE_IMPL if this platform has a specific | |
| 14 // implementation of AXPlatformNode::Create(). | |
| 15 #undef PLATFORM_HAS_AX_PLATFORM_NODE_IMPL | |
| 16 | |
| 17 #if defined(OS_WIN) | |
| 18 #define PLATFORM_HAS_AX_PLATFORM_NODE_IMPL 1 | |
| 19 #endif | |
| 20 | |
| 21 #if defined(OS_MACOSX) | |
| 22 #define PLATFORM_HAS_AX_PLATFORM_NODE_IMPL 1 | |
| 23 #endif | |
| 24 | |
| 25 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11) | |
| 26 #define PLATFORM_HAS_AX_PLATFORM_NODE_IMPL 1 | |
| 27 #endif | |
| 28 | |
| 29 namespace ui { | 13 namespace ui { |
| 30 | 14 |
| 31 class AXPlatformNodeDelegate; | 15 class AXPlatformNodeDelegate; |
| 32 | 16 |
| 33 // AXPlatformNode is the abstract base class for an implementation of | 17 // AXPlatformNode is the abstract base class for an implementation of |
| 34 // native accessibility APIs on supported platforms (e.g. Windows, Mac OS X). | 18 // native accessibility APIs on supported platforms (e.g. Windows, Mac OS X). |
| 35 // An object that wants to be accessible can derive from AXPlatformNodeDelegate | 19 // An object that wants to be accessible can derive from AXPlatformNodeDelegate |
| 36 // and then call AXPlatformNode::Create. The delegate implementation should | 20 // and then call AXPlatformNode::Create. The delegate implementation should |
| 37 // own the AXPlatformNode instance (or otherwise manage its lifecycle). | 21 // own the AXPlatformNode instance (or otherwise manage its lifecycle). |
| 38 class AX_EXPORT AXPlatformNode { | 22 class AX_EXPORT AXPlatformNode { |
| 39 public: | 23 public: |
| 40 // Create an appropriate platform-specific instance. The delegate owns the | 24 // Create an appropriate platform-specific instance. The delegate owns the |
| 41 // AXPlatformNode instance (or manages its lifecycle in some other way). | 25 // AXPlatformNode instance (or manages its lifecycle in some other way). |
| 42 static AXPlatformNode* Create(AXPlatformNodeDelegate* delegate); | 26 static AXPlatformNode* Create(AXPlatformNodeDelegate* delegate); |
| 43 | 27 |
| 44 // Cast a gfx::NativeViewAccessible to an AXPlatformNode if it is one, | 28 // Cast a gfx::NativeViewAccessible to an AXPlatformNode if it is one, |
| 45 // or return NULL if it's not an instance of this class. | 29 // or return NULL if it's not an instance of this class. |
| 46 static AXPlatformNode* FromNativeViewAccessible( | 30 static AXPlatformNode* FromNativeViewAccessible( |
| 47 gfx::NativeViewAccessible accessible); | 31 gfx::NativeViewAccessible accessible); |
| 48 | 32 |
| 49 // Each platform accessibility object has a unique id that's guaranteed | |
| 50 // to be a positive number. (It's stored in an int32_t as opposed to | |
| 51 // uint32_t because some platforms want to negate it, so we want to ensure | |
| 52 // the range is below the signed int max.) This can be used when the | |
| 53 // id has to be unique across multiple frames, since node ids are | |
| 54 // only unique within one tree. | |
| 55 static int32_t GetNextUniqueId(); | |
| 56 | |
| 57 // Call Destroy rather than deleting this, because the subclass may | 33 // Call Destroy rather than deleting this, because the subclass may |
| 58 // use reference counting. | 34 // use reference counting. |
| 59 virtual void Destroy(); | 35 virtual void Destroy(); |
| 60 | 36 |
| 61 // Get the platform-specific accessible object type for this instance. | 37 // Get the platform-specific accessible object type for this instance. |
| 62 // On some platforms this is just a type cast, on others it may be a | 38 // On some platforms this is just a type cast, on others it may be a |
| 63 // wrapper object or handle. | 39 // wrapper object or handle. |
| 64 virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0; | 40 virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0; |
| 65 | 41 |
| 66 // Fire a platform-specific notification that an event has occurred on | 42 // Fire a platform-specific notification that an event has occurred on |
| 67 // this object. | 43 // this object. |
| 68 virtual void NotifyAccessibilityEvent(ui::AXEvent event_type) = 0; | 44 virtual void NotifyAccessibilityEvent(ui::AXEvent event_type) = 0; |
| 69 | 45 |
| 70 // Return this object's delegate. | 46 // Return this object's delegate. |
| 71 virtual AXPlatformNodeDelegate* GetDelegate() const = 0; | 47 virtual AXPlatformNodeDelegate* GetDelegate() const = 0; |
| 72 | 48 |
| 73 protected: | 49 protected: |
| 74 AXPlatformNode(); | 50 AXPlatformNode(); |
| 75 virtual ~AXPlatformNode(); | 51 virtual ~AXPlatformNode(); |
| 76 | 52 |
| 77 AXPlatformNode* GetFromUniqueId(int32_t unique_id); | 53 AXPlatformNode* GetFromUniqueId(int32_t unique_id); |
| 78 | 54 |
| 79 int32_t unique_id_; | 55 int32_t unique_id_; |
| 80 }; | 56 }; |
| 81 | 57 |
| 82 } // namespace ui | 58 } // namespace ui |
| 83 | 59 |
| 84 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_H_ | 60 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_H_ |
| OLD | NEW |