| 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_BASE_H_ | 5 #ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_BASE_H_ |
| 6 #define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_BASE_H_ | 6 #define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_BASE_H_ |
| 7 | 7 |
| 8 #include "ui/accessibility/ax_enums.h" | 8 #include "ui/accessibility/ax_enums.h" |
| 9 #include "ui/accessibility/platform/ax_platform_node.h" | 9 #include "ui/accessibility/platform/ax_platform_node.h" |
| 10 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
| 11 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 | 14 |
| 15 struct AXNodeData; | |
| 16 class AXPlatformNodeDelegate; | 15 class AXPlatformNodeDelegate; |
| 17 | 16 |
| 18 class AXPlatformNodeBase : public AXPlatformNode { | 17 class AXPlatformNodeBase : public AXPlatformNode { |
| 19 public: | 18 public: |
| 20 virtual void Init(AXPlatformNodeDelegate* delegate); | 19 virtual void Init(AXPlatformNodeDelegate* delegate); |
| 21 | 20 |
| 22 // These are simple wrappers to our delegate. | 21 // These are simple wrappers to our delegate. |
| 23 const AXNodeData& GetData() const; | 22 AXRole GetRole() const; |
| 24 gfx::Rect GetBoundsInScreen() const; | 23 gfx::Rect GetBoundsInScreen() const; |
| 25 gfx::NativeViewAccessible GetParent(); | 24 gfx::NativeViewAccessible GetParent(); |
| 26 int GetChildCount(); | 25 int GetChildCount(); |
| 27 gfx::NativeViewAccessible ChildAtIndex(int index); | 26 gfx::NativeViewAccessible ChildAtIndex(int index); |
| 28 | 27 |
| 29 // This needs to be implemented for each platform. | 28 // AXPlatformNode |
| 30 virtual int GetIndexInParent() = 0; | |
| 31 | |
| 32 // AXPlatformNode. | |
| 33 void Destroy() override; | 29 void Destroy() override; |
| 34 gfx::NativeViewAccessible GetNativeViewAccessible() override; | 30 gfx::NativeViewAccessible GetNativeViewAccessible() override; |
| 35 AXPlatformNodeDelegate* GetDelegate() const override; | |
| 36 | |
| 37 // Helpers. | |
| 38 AXPlatformNodeBase* GetPreviousSibling(); | |
| 39 AXPlatformNodeBase* GetNextSibling(); | |
| 40 bool IsDescendant(AXPlatformNodeBase* descendant); | |
| 41 | |
| 42 bool HasBoolAttribute(ui::AXBoolAttribute attr) const; | |
| 43 bool GetBoolAttribute(ui::AXBoolAttribute attr) const; | |
| 44 bool GetBoolAttribute(ui::AXBoolAttribute attr, bool* value) const; | |
| 45 | |
| 46 bool HasFloatAttribute(ui::AXFloatAttribute attr) const; | |
| 47 float GetFloatAttribute(ui::AXFloatAttribute attr) const; | |
| 48 bool GetFloatAttribute(ui::AXFloatAttribute attr, float* value) const; | |
| 49 | |
| 50 bool HasIntAttribute(ui::AXIntAttribute attribute) const; | |
| 51 int GetIntAttribute(ui::AXIntAttribute attribute) const; | |
| 52 bool GetIntAttribute(ui::AXIntAttribute attribute, int* value) const; | |
| 53 | |
| 54 bool HasStringAttribute( | |
| 55 ui::AXStringAttribute attribute) const; | |
| 56 const std::string& GetStringAttribute(ui::AXStringAttribute attribute) const; | |
| 57 bool GetStringAttribute(ui::AXStringAttribute attribute, | |
| 58 std::string* value) const; | |
| 59 bool GetString16Attribute(ui::AXStringAttribute attribute, | |
| 60 base::string16* value) const; | |
| 61 base::string16 GetString16Attribute( | |
| 62 ui::AXStringAttribute attribute) const; | |
| 63 | 31 |
| 64 protected: | 32 protected: |
| 65 AXPlatformNodeBase(); | 33 AXPlatformNodeBase(); |
| 66 ~AXPlatformNodeBase() override; | 34 ~AXPlatformNodeBase() override; |
| 67 | 35 |
| 68 // Cast a gfx::NativeViewAccessible to an AXPlatformNodeBase if it is one, | |
| 69 // or return NULL if it's not an instance of this class. | |
| 70 static AXPlatformNodeBase* FromNativeViewAccessible( | |
| 71 gfx::NativeViewAccessible accessible); | |
| 72 | |
| 73 AXPlatformNodeDelegate* delegate_; // Weak. Owns this. | 36 AXPlatformNodeDelegate* delegate_; // Weak. Owns this. |
| 74 | 37 |
| 75 private: | 38 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(AXPlatformNodeBase); | 39 DISALLOW_COPY_AND_ASSIGN(AXPlatformNodeBase); |
| 77 }; | 40 }; |
| 78 | 41 |
| 79 } // namespace ui | 42 } // namespace ui |
| 80 | 43 |
| 81 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_BASE_H_ | 44 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_BASE_H_ |
| OLD | NEW |