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 "ui/accessibility/ax_export.h" | 8 #include "ui/accessibility/ax_export.h" |
9 #include "ui/accessibility/ax_node_data.h" | 9 #include "ui/accessibility/platform/ax_platform_node_base.h" |
10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
11 | 11 |
12 namespace ui { | 12 namespace ui { |
13 | 13 |
14 class AXPlatformNodeDelegate; | 14 class AX_EXPORT AXPlatformNode : public AXPlatformNodeBase { |
| 15 public: |
| 16 // Create a platform appropriate instance. |
| 17 static AXPlatformNode* Create(AXPlatformNodeDelegate* delegate); |
15 | 18 |
16 class AX_EXPORT AXPlatformNode { | 19 // Call Destroy rather than deleting this, because the subclass may |
17 public: | 20 // use reference counting. |
18 static AXPlatformNode* Create(AXPlatformNodeDelegate* delegate); | 21 virtual void Destroy(); |
19 virtual ~AXPlatformNode(); | |
20 virtual void Detach(); | |
21 | 22 |
22 virtual gfx::NativeViewAccessible GetNativeViewAccessible(); | 23 virtual gfx::NativeViewAccessible GetNativeViewAccessible(); |
23 | 24 |
24 AXPlatformNode* NextSibling(); | |
25 AXPlatformNode* PreviousSibling(); | |
26 | |
27 protected: | 25 protected: |
28 AXPlatformNode(); | 26 AXPlatformNode(); |
29 | 27 virtual ~AXPlatformNode(); |
30 virtual void Init(AXPlatformNodeDelegate* delegate); | |
31 | |
32 bool IsAncestor | |
33 | |
34 // Accessing accessibility attributes: | |
35 // | |
36 // There are dozens of possible attributes for an accessibility node, | |
37 // but only a few tend to apply to any one object, so we store them | |
38 // in sparse arrays of <attribute id, attribute value> pairs, organized | |
39 // by type (bool, int, float, string, int list). | |
40 // | |
41 // There are three accessors for each type of attribute: one that returns | |
42 // true if the attribute is present and false if not, one that takes a | |
43 // pointer argument and returns true if the attribute is present (if you | |
44 // need to distinguish between the default value and a missing attribute), | |
45 // and another that returns the default value for that type if the | |
46 // attribute is not present. In addition, strings can be returned as | |
47 // either std::string or base::string16, for convenience. | |
48 | |
49 bool HasBoolAttribute(ui::AXBoolAttribute attr) const; | |
50 bool GetBoolAttribute(ui::AXBoolAttribute attr) const; | |
51 bool GetBoolAttribute(ui::AXBoolAttribute attr, bool* value) const; | |
52 | |
53 bool HasFloatAttribute(ui::AXFloatAttribute attr) const; | |
54 float GetFloatAttribute(ui::AXFloatAttribute attr) const; | |
55 bool GetFloatAttribute(ui::AXFloatAttribute attr, float* value) const; | |
56 | |
57 bool HasIntAttribute(ui::AXIntAttribute attribute) const; | |
58 int GetIntAttribute(ui::AXIntAttribute attribute) const; | |
59 bool GetIntAttribute(ui::AXIntAttribute attribute, int* value) const; | |
60 | |
61 bool HasStringAttribute( | |
62 ui::AXStringAttribute attribute) const; | |
63 const std::string& GetStringAttribute(ui::AXStringAttribute attribute) const; | |
64 bool GetStringAttribute(ui::AXStringAttribute attribute, | |
65 std::string* value) const; | |
66 | |
67 bool GetString16Attribute(ui::AXStringAttribute attribute, | |
68 base::string16* value) const; | |
69 base::string16 GetString16Attribute( | |
70 ui::AXStringAttribute attribute) const; | |
71 | |
72 bool HasIntListAttribute(ui::AXIntListAttribute attribute) const; | |
73 const std::vector<int32>& GetIntListAttribute( | |
74 ui::AXIntListAttribute attribute) const; | |
75 bool GetIntListAttribute(ui::AXIntListAttribute attribute, | |
76 std::vector<int32>* value) const; | |
77 | |
78 // Retrieve the value of a html attribute from the attribute map and | |
79 // returns true if found. | |
80 bool GetHtmlAttribute(const char* attr, base::string16* value) const; | |
81 bool GetHtmlAttribute(const char* attr, std::string* value) const; | |
82 | |
83 AXPlatformNodeDelegate* delegate_; | |
84 }; | 28 }; |
85 | 29 |
86 } // namespace ui | 30 } // namespace ui |
87 | 31 |
88 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_H_ | 32 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_H_ |
OLD | NEW |