| 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. | |
| 30 class AX_EXPORT AXPlatformNodeDelegate { | 18 class AX_EXPORT AXPlatformNodeDelegate { |
| 31 public: | 19 public: |
| 32 // Get the accessibility data that should be exposed for this node. | 20 // Get the accessibility data that should be exposed for this node. |
| 33 // Virtually all of the information is obtained from this structure | 21 virtual AXNodeData* GetData() = 0; |
| 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; | |
| 37 | 22 |
| 38 // Get the parent of the node, which may be an AXPlatformNode or it may | 23 // Get the parent of the node unless it's the root, then it returns NULL. |
| 39 // be a native accessible object implemented by another class. | |
| 40 virtual gfx::NativeViewAccessible GetParent() = 0; | 24 virtual gfx::NativeViewAccessible GetParent() = 0; |
| 41 | 25 |
| 42 // Get the number of children of this node. | 26 // Get the number of children of this node. |
| 43 virtual int GetChildCount() = 0; | 27 virtual int GetChildCount() = 0; |
| 44 | 28 |
| 45 // Get the child of a node given a 0-based index. | 29 // Get the child of a node from [0...GetChildCount() - 1] |
| 46 virtual gfx::NativeViewAccessible ChildAtIndex(int index) = 0; | 30 virtual gfx::NativeViewAccessible ChildAtIndex(int index) = 0; |
| 47 | 31 |
| 48 // Get the offset to convert local coordinates to screen global coordinates. | 32 // Get the offset to convert local coordinates to screen global coordinates. |
| 49 virtual gfx::Vector2d GetGlobalCoordinateOffset() = 0; | 33 virtual gfx::Vector2d GetGlobalCoordinateOffset() = 0; |
| 50 | 34 |
| 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 | |
| 68 // | 35 // |
| 69 // Events. | 36 // Events. |
| 70 // | 37 // |
| 38 virtual void NotifyAccessibilityEvent(ui::AXEvent event_type) = 0; |
| 71 | 39 |
| 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; | |
| 86 }; | 40 }; |
| 87 | 41 |
| 88 } // namespace ui | 42 } // namespace ui |
| 89 | 43 |
| 90 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_DELEGATE_H_ | 44 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_DELEGATE_H_ |
| OLD | NEW |