| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "content/browser/accessibility/ax_tree_id_registry.h" | 17 #include "content/browser/accessibility/ax_tree_id_registry.h" |
| 18 #include "content/browser/accessibility/browser_accessibility_event.h" | 18 #include "content/browser/accessibility/browser_accessibility_event.h" |
| 19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "content/public/browser/ax_event_notification_details.h" | 20 #include "content/public/browser/ax_event_notification_details.h" |
| 21 #include "third_party/WebKit/public/web/WebAXEnums.h" | 21 #include "third_party/WebKit/public/web/WebAXEnums.h" |
| 22 #include "ui/accessibility/ax_action_data.h" | |
| 23 #include "ui/accessibility/ax_node_data.h" | 22 #include "ui/accessibility/ax_node_data.h" |
| 24 #include "ui/accessibility/ax_serializable_tree.h" | 23 #include "ui/accessibility/ax_serializable_tree.h" |
| 25 #include "ui/accessibility/ax_tree_update.h" | 24 #include "ui/accessibility/ax_tree_update.h" |
| 26 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
| 27 | 26 |
| 28 struct AccessibilityHostMsg_LocationChangeParams; | 27 struct AccessibilityHostMsg_LocationChangeParams; |
| 29 | 28 |
| 30 namespace content { | 29 namespace content { |
| 31 class BrowserAccessibility; | 30 class BrowserAccessibility; |
| 32 class BrowserAccessibilityManager; | 31 class BrowserAccessibilityManager; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 58 // Class that can perform actions on behalf of the BrowserAccessibilityManager. | 57 // Class that can perform actions on behalf of the BrowserAccessibilityManager. |
| 59 // Note: BrowserAccessibilityManager should never cache any of the return | 58 // Note: BrowserAccessibilityManager should never cache any of the return |
| 60 // values from any of these interfaces, especially those that return pointers. | 59 // values from any of these interfaces, especially those that return pointers. |
| 61 // They may only be valid within this call stack. That policy eliminates any | 60 // They may only be valid within this call stack. That policy eliminates any |
| 62 // concerns about ownership and lifecycle issues; none of these interfaces | 61 // concerns about ownership and lifecycle issues; none of these interfaces |
| 63 // transfer ownership and no return values are guaranteed to be valid outside | 62 // transfer ownership and no return values are guaranteed to be valid outside |
| 64 // of the current call stack. | 63 // of the current call stack. |
| 65 class CONTENT_EXPORT BrowserAccessibilityDelegate { | 64 class CONTENT_EXPORT BrowserAccessibilityDelegate { |
| 66 public: | 65 public: |
| 67 virtual ~BrowserAccessibilityDelegate() {} | 66 virtual ~BrowserAccessibilityDelegate() {} |
| 68 | 67 virtual void AccessibilitySetFocus(int acc_obj_id) = 0; |
| 69 virtual void AccessibilityPerformAction(const ui::AXActionData& data) = 0; | 68 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0; |
| 69 virtual void AccessibilityShowContextMenu(int acc_obj_id) = 0; |
| 70 virtual void AccessibilityScrollToMakeVisible( |
| 71 int acc_obj_id, const gfx::Rect& subfocus) = 0; |
| 72 virtual void AccessibilityScrollToPoint( |
| 73 int acc_obj_id, const gfx::Point& point) = 0; |
| 74 virtual void AccessibilitySetScrollOffset( |
| 75 int acc_obj_id, const gfx::Point& offset) = 0; |
| 76 virtual void AccessibilitySetSelection(int anchor_obj_id, |
| 77 int anchor_offset, |
| 78 int focus_obj_id, |
| 79 int focus_offset) = 0; |
| 80 virtual void AccessibilitySetValue( |
| 81 int acc_obj_id, const base::string16& value) = 0; |
| 70 virtual bool AccessibilityViewHasFocus() const = 0; | 82 virtual bool AccessibilityViewHasFocus() const = 0; |
| 71 virtual gfx::Rect AccessibilityGetViewBounds() const = 0; | 83 virtual gfx::Rect AccessibilityGetViewBounds() const = 0; |
| 72 virtual gfx::Point AccessibilityOriginInScreen( | 84 virtual gfx::Point AccessibilityOriginInScreen( |
| 73 const gfx::Rect& bounds) const = 0; | 85 const gfx::Rect& bounds) const = 0; |
| 86 virtual void AccessibilityHitTest( |
| 87 const gfx::Point& point) = 0; |
| 88 virtual void AccessibilitySetAccessibilityFocus(int acc_obj_id) = 0; |
| 74 virtual void AccessibilityFatalError() = 0; | 89 virtual void AccessibilityFatalError() = 0; |
| 75 virtual gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() = 0; | 90 virtual gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() = 0; |
| 76 virtual gfx::NativeViewAccessible AccessibilityGetNativeViewAccessible() = 0; | 91 virtual gfx::NativeViewAccessible AccessibilityGetNativeViewAccessible() = 0; |
| 77 }; | 92 }; |
| 78 | 93 |
| 79 class CONTENT_EXPORT BrowserAccessibilityFactory { | 94 class CONTENT_EXPORT BrowserAccessibilityFactory { |
| 80 public: | 95 public: |
| 81 virtual ~BrowserAccessibilityFactory() {} | 96 virtual ~BrowserAccessibilityFactory() {} |
| 82 | 97 |
| 83 // Create an instance of BrowserAccessibility and return a new | 98 // Create an instance of BrowserAccessibility and return a new |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // communicate with the renderer and doesn't fire any events. | 194 // communicate with the renderer and doesn't fire any events. |
| 180 void SetFocusLocallyForTesting(BrowserAccessibility* node); | 195 void SetFocusLocallyForTesting(BrowserAccessibility* node); |
| 181 | 196 |
| 182 // For testing only, register a function to be called when focus changes | 197 // For testing only, register a function to be called when focus changes |
| 183 // in any BrowserAccessibilityManager. | 198 // in any BrowserAccessibilityManager. |
| 184 static void SetFocusChangeCallbackForTesting(const base::Closure& callback); | 199 static void SetFocusChangeCallbackForTesting(const base::Closure& callback); |
| 185 | 200 |
| 186 // Tell the renderer to do the default action for this node. | 201 // Tell the renderer to do the default action for this node. |
| 187 void DoDefaultAction(const BrowserAccessibility& node); | 202 void DoDefaultAction(const BrowserAccessibility& node); |
| 188 | 203 |
| 189 // Tell the renderer to show the context menu for a given node. | |
| 190 void ShowContextMenu(const BrowserAccessibility& node); | |
| 191 | |
| 192 // Tell the renderer to scroll to make |node| visible. | 204 // Tell the renderer to scroll to make |node| visible. |
| 193 // In addition, if it's not possible to make the entire object visible, | 205 // In addition, if it's not possible to make the entire object visible, |
| 194 // scroll so that the |subfocus| rect is visible at least. The subfocus | 206 // scroll so that the |subfocus| rect is visible at least. The subfocus |
| 195 // rect is in local coordinates of the object itself. | 207 // rect is in local coordinates of the object itself. |
| 196 void ScrollToMakeVisible( | 208 void ScrollToMakeVisible( |
| 197 const BrowserAccessibility& node, gfx::Rect subfocus); | 209 const BrowserAccessibility& node, gfx::Rect subfocus); |
| 198 | 210 |
| 199 // Tell the renderer to scroll such that |node| is at |point|, | 211 // Tell the renderer to scroll such that |node| is at |point|, |
| 200 // where |point| is in global coordinates of the WebContents. | 212 // where |point| is in global coordinates of the WebContents. |
| 201 void ScrollToPoint( | 213 void ScrollToPoint( |
| 202 const BrowserAccessibility& node, gfx::Point point); | 214 const BrowserAccessibility& node, gfx::Point point); |
| 203 | 215 |
| 204 // If |node| is itself a scrollable container, set its scroll | 216 // If |node| is itself a scrollable container, set its scroll |
| 205 // offset to |offset|. | 217 // offset to |offset|. |
| 206 void SetScrollOffset(const BrowserAccessibility& node, gfx::Point offset); | 218 void SetScrollOffset(const BrowserAccessibility& node, gfx::Point offset); |
| 207 | 219 |
| 208 // Tell the renderer to set the value of an editable text node. | 220 // Tell the renderer to set the value of an editable text node. |
| 209 void SetValue( | 221 void SetValue( |
| 210 const BrowserAccessibility& node, const base::string16& value); | 222 const BrowserAccessibility& node, const base::string16& value); |
| 211 | 223 |
| 212 // Tell the renderer to set the text selection on a node. | 224 // Tell the renderer to set the text selection on a node. |
| 213 void SetTextSelection( | 225 void SetTextSelection( |
| 214 const BrowserAccessibility& node, int start_offset, int end_offset); | 226 const BrowserAccessibility& node, int start_offset, int end_offset); |
| 215 | 227 |
| 216 // Tell the renderer to set accessibility focus to this node. | |
| 217 void SetAccessibilityFocus(const BrowserAccessibility& node); | |
| 218 | |
| 219 // Tell the renderer to do a hit test on a point in global screen coordinates | |
| 220 // and fire a HOVER event on the node that's hit. | |
| 221 void HitTest(const gfx::Point& point); | |
| 222 | |
| 223 // Retrieve the bounds of the parent View in screen coordinates. | 228 // Retrieve the bounds of the parent View in screen coordinates. |
| 224 gfx::Rect GetViewBounds(); | 229 gfx::Rect GetViewBounds(); |
| 225 | 230 |
| 226 // Fire an event telling native assistive technology to move focus to the | 231 // Fire an event telling native assistive technology to move focus to the |
| 227 // given find in page result. | 232 // given find in page result. |
| 228 void ActivateFindInPageResult(int request_id, int match_index); | 233 void ActivateFindInPageResult(int request_id, int match_index); |
| 229 | 234 |
| 230 // Called when the renderer process has notified us of about tree changes. | 235 // Called when the renderer process has notified us of about tree changes. |
| 231 virtual void OnAccessibilityEvents( | 236 virtual void OnAccessibilityEvents( |
| 232 const std::vector<AXEventNotificationDetails>& details); | 237 const std::vector<AXEventNotificationDetails>& details); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 // node within that parent tree. It's computed as needed and cached for | 483 // node within that parent tree. It's computed as needed and cached for |
| 479 // speed so that it can be accessed quickly if it hasn't changed. | 484 // speed so that it can be accessed quickly if it hasn't changed. |
| 480 int parent_node_id_from_parent_tree_; | 485 int parent_node_id_from_parent_tree_; |
| 481 | 486 |
| 482 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); | 487 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); |
| 483 }; | 488 }; |
| 484 | 489 |
| 485 } // namespace content | 490 } // namespace content |
| 486 | 491 |
| 487 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 492 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
| OLD | NEW |