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_DELEGATE_H_ | 5 #ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_DELEGATE_H_ |
6 #define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_DELEGATE_H_ | 6 #define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_DELEGATE_H_ |
7 | 7 |
8 #include "ui/accessibility/ax_enums.h" | 8 #include "ui/accessibility/ax_enums.h" |
9 #include "ui/accessibility/ax_export.h" | 9 #include "ui/accessibility/ax_export.h" |
10 #include "ui/gfx/geometry/vector2d.h" | 10 #include "ui/gfx/geometry/vector2d.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; | 15 struct AXNodeData; |
16 class AXPlatformNode; | 16 class AXPlatformNode; |
17 | 17 |
| 18 // An object that wants to be accessible should derive from this class. |
| 19 // AXPlatformNode subclasses use this interface to query all of the information |
| 20 // about the object in order to implement native accessibility APIs. |
| 21 // |
| 22 // Note that AXPlatformNode has support for accessibility trees where some |
| 23 // of the objects in the tree are not implemented using AXPlatformNode. |
| 24 // For example, you may have a native window with platform-native widgets |
| 25 // in it, but in that window you have custom controls that use AXPlatformNode |
| 26 // to provide accessibility. That's why GetParent, ChildAtIndex, HitTestSync, |
| 27 // and GetFocus all return a gfx::NativeViewAccessible - so you can return a |
| 28 // native accessible if necessary, and AXPlatformNode::GetNativeViewAccessible |
| 29 // otherwise. |
18 class AX_EXPORT AXPlatformNodeDelegate { | 30 class AX_EXPORT AXPlatformNodeDelegate { |
19 public: | 31 public: |
20 // Get the accessibility data that should be exposed for this node. | 32 // Get the accessibility data that should be exposed for this node. |
21 virtual AXNodeData* GetData() = 0; | 33 // Virtually all of the information is obtained from this structure |
| 34 // (role, state, name, cursor position, etc.) - the rest of this interface |
| 35 // is mostly to implement support for walking the accessibility tree. |
| 36 virtual const AXNodeData& GetData() = 0; |
22 | 37 |
23 // Get the parent of the node unless it's the root, then it returns NULL. | 38 // Get the parent of the node, which may be an AXPlatformNode or it may |
| 39 // be a native accessible object implemented by another class. |
24 virtual gfx::NativeViewAccessible GetParent() = 0; | 40 virtual gfx::NativeViewAccessible GetParent() = 0; |
25 | 41 |
26 // Get the number of children of this node. | 42 // Get the number of children of this node. |
27 virtual int GetChildCount() = 0; | 43 virtual int GetChildCount() = 0; |
28 | 44 |
29 // Get the child of a node from [0...GetChildCount() - 1] | 45 // Get the child of a node given a 0-based index. |
30 virtual gfx::NativeViewAccessible ChildAtIndex(int index) = 0; | 46 virtual gfx::NativeViewAccessible ChildAtIndex(int index) = 0; |
31 | 47 |
32 // Get the offset to convert local coordinates to screen global coordinates. | 48 // Get the offset to convert local coordinates to screen global coordinates. |
33 virtual gfx::Vector2d GetGlobalCoordinateOffset() = 0; | 49 virtual gfx::Vector2d GetGlobalCoordinateOffset() = 0; |
34 | 50 |
| 51 // Do a *synchronous* hit test of the given location in global screen |
| 52 // coordinates, and the node within this node's subtree (inclusive) that's |
| 53 // hit, if any. |
| 54 // |
| 55 // If the result is anything other than this object or NULL, it will be |
| 56 // hit tested again recursively - that allows hit testing to work across |
| 57 // implementation classes. It's okay to take advantage of this and return |
| 58 // only an immediate child and not the deepest descendant. |
| 59 // |
| 60 // This function is mainly used by accessibility debugging software. |
| 61 // Platforms with touch accessibility use a different asynchronous interface. |
| 62 virtual gfx::NativeViewAccessible HitTestSync(int x, int y) = 0; |
| 63 |
| 64 // Return the node within this node's subtree (inclusive) that currently |
| 65 // has focus. |
| 66 virtual gfx::NativeViewAccessible GetFocus() = 0; |
| 67 |
35 // | 68 // |
36 // Events. | 69 // Events. |
37 // | 70 // |
38 virtual void NotifyAccessibilityEvent(ui::AXEvent event_type) = 0; | |
39 | 71 |
| 72 // Return the platform-native GUI object that should be used as a target |
| 73 // for accessibility events. |
| 74 virtual gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() = 0; |
| 75 |
| 76 // |
| 77 // Actions. |
| 78 // |
| 79 |
| 80 // Perform the default action, e.g. click a button, follow a link, or |
| 81 // toggle a checkbox. |
| 82 virtual void DoDefaultAction() = 0; |
| 83 |
| 84 // Change the value of a control, such as the text content of a text field. |
| 85 virtual bool SetStringValue(const base::string16& new_value) = 0; |
40 }; | 86 }; |
41 | 87 |
42 } // namespace ui | 88 } // namespace ui |
43 | 89 |
44 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_DELEGATE_H_ | 90 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_DELEGATE_H_ |
OLD | NEW |