| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class BrowserAccessibility; | 25 class BrowserAccessibility; |
| 26 class BrowserAccessibilityManager; | 26 class BrowserAccessibilityManager; |
| 27 #if defined(OS_ANDROID) | 27 #if defined(OS_ANDROID) |
| 28 class BrowserAccessibilityManagerAndroid; | 28 class BrowserAccessibilityManagerAndroid; |
| 29 #elif defined(OS_WIN) | 29 #elif defined(OS_WIN) |
| 30 class BrowserAccessibilityManagerWin; | 30 class BrowserAccessibilityManagerWin; |
| 31 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11) | 31 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11) |
| 32 class BrowserAccessibilityManagerAuraLinux; | 32 class BrowserAccessibilityManagerAuraLinux; |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 using SimpleAXTreeUpdate = ui::AXTreeUpdate<ui::AXNodeData>; | |
| 36 | |
| 37 // For testing. | 35 // For testing. |
| 38 CONTENT_EXPORT SimpleAXTreeUpdate MakeAXTreeUpdate( | 36 CONTENT_EXPORT ui::AXTreeUpdate MakeAXTreeUpdate( |
| 39 const ui::AXNodeData& node, | 37 const ui::AXNodeData& node, |
| 40 const ui::AXNodeData& node2 = ui::AXNodeData(), | 38 const ui::AXNodeData& node2 = ui::AXNodeData(), |
| 41 const ui::AXNodeData& node3 = ui::AXNodeData(), | 39 const ui::AXNodeData& node3 = ui::AXNodeData(), |
| 42 const ui::AXNodeData& node4 = ui::AXNodeData(), | 40 const ui::AXNodeData& node4 = ui::AXNodeData(), |
| 43 const ui::AXNodeData& node5 = ui::AXNodeData(), | 41 const ui::AXNodeData& node5 = ui::AXNodeData(), |
| 44 const ui::AXNodeData& node6 = ui::AXNodeData(), | 42 const ui::AXNodeData& node6 = ui::AXNodeData(), |
| 45 const ui::AXNodeData& node7 = ui::AXNodeData(), | 43 const ui::AXNodeData& node7 = ui::AXNodeData(), |
| 46 const ui::AXNodeData& node8 = ui::AXNodeData(), | 44 const ui::AXNodeData& node8 = ui::AXNodeData(), |
| 47 const ui::AXNodeData& node9 = ui::AXNodeData()); | 45 const ui::AXNodeData& node9 = ui::AXNodeData()); |
| 48 | 46 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // to move screen reader focus to that event. | 109 // to move screen reader focus to that event. |
| 112 int active_request_id; | 110 int active_request_id; |
| 113 }; | 111 }; |
| 114 | 112 |
| 115 // Manages a tree of BrowserAccessibility objects. | 113 // Manages a tree of BrowserAccessibility objects. |
| 116 class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeDelegate { | 114 class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeDelegate { |
| 117 public: | 115 public: |
| 118 // Creates the platform-specific BrowserAccessibilityManager, but | 116 // Creates the platform-specific BrowserAccessibilityManager, but |
| 119 // with no parent window pointer. Only useful for unit tests. | 117 // with no parent window pointer. Only useful for unit tests. |
| 120 static BrowserAccessibilityManager* Create( | 118 static BrowserAccessibilityManager* Create( |
| 121 const SimpleAXTreeUpdate& initial_tree, | 119 const ui::AXTreeUpdate& initial_tree, |
| 122 BrowserAccessibilityDelegate* delegate, | 120 BrowserAccessibilityDelegate* delegate, |
| 123 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); | 121 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); |
| 124 | 122 |
| 125 static BrowserAccessibilityManager* FromID( | 123 static BrowserAccessibilityManager* FromID( |
| 126 AXTreeIDRegistry::AXTreeID ax_tree_id); | 124 AXTreeIDRegistry::AXTreeID ax_tree_id); |
| 127 | 125 |
| 128 ~BrowserAccessibilityManager() override; | 126 ~BrowserAccessibilityManager() override; |
| 129 | 127 |
| 130 void Initialize(const SimpleAXTreeUpdate& initial_tree); | 128 void Initialize(const ui::AXTreeUpdate& initial_tree); |
| 131 | 129 |
| 132 static SimpleAXTreeUpdate GetEmptyDocument(); | 130 static ui::AXTreeUpdate GetEmptyDocument(); |
| 133 | 131 |
| 134 virtual void NotifyAccessibilityEvent( | 132 virtual void NotifyAccessibilityEvent( |
| 135 ui::AXEvent event_type, BrowserAccessibility* node) { } | 133 ui::AXEvent event_type, BrowserAccessibility* node) { } |
| 136 | 134 |
| 137 // Return a pointer to the root of the tree, does not make a new reference. | 135 // Return a pointer to the root of the tree, does not make a new reference. |
| 138 BrowserAccessibility* GetRoot(); | 136 BrowserAccessibility* GetRoot(); |
| 139 | 137 |
| 140 // Returns a pointer to the BrowserAccessibility object for a given AXNode. | 138 // Returns a pointer to the BrowserAccessibility object for a given AXNode. |
| 141 BrowserAccessibility* GetFromAXNode(const ui::AXNode* node) const; | 139 BrowserAccessibility* GetFromAXNode(const ui::AXNode* node) const; |
| 142 | 140 |
| 143 // Return a pointer to the object corresponding to the given id, | 141 // Return a pointer to the object corresponding to the given id, |
| 144 // does not make a new reference. | 142 // does not make a new reference. |
| 145 BrowserAccessibility* GetFromID(int32 id) const; | 143 BrowserAccessibility* GetFromID(int32 id) const; |
| 146 | 144 |
| 147 // If this tree has a parent tree, return the parent node in that tree. | 145 // If this tree has a parent tree, return the parent node in that tree. |
| 148 BrowserAccessibility* GetParentNodeFromParentTree(); | 146 BrowserAccessibility* GetParentNodeFromParentTree(); |
| 149 | 147 |
| 148 // Get the AXTreeData for this frame. |
| 149 const ui::AXTreeData& GetTreeData(); |
| 150 |
| 150 // Called to notify the accessibility manager that its associated native | 151 // Called to notify the accessibility manager that its associated native |
| 151 // view got focused. | 152 // view got focused. |
| 152 virtual void OnWindowFocused(); | 153 virtual void OnWindowFocused(); |
| 153 | 154 |
| 154 // Called to notify the accessibility manager that its associated native | 155 // Called to notify the accessibility manager that its associated native |
| 155 // view lost focus. | 156 // view lost focus. |
| 156 virtual void OnWindowBlurred(); | 157 virtual void OnWindowBlurred(); |
| 157 | 158 |
| 158 // Notify the accessibility manager about page navigation. | 159 // Notify the accessibility manager about page navigation. |
| 159 void UserIsNavigatingAway(); | 160 void UserIsNavigatingAway(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 virtual bool UseRootScrollOffsetsWhenComputingBounds(); | 255 virtual bool UseRootScrollOffsetsWhenComputingBounds(); |
| 255 | 256 |
| 256 // Walk the tree. | 257 // Walk the tree. |
| 257 BrowserAccessibility* NextInTreeOrder(BrowserAccessibility* node) const; | 258 BrowserAccessibility* NextInTreeOrder(BrowserAccessibility* node) const; |
| 258 BrowserAccessibility* PreviousInTreeOrder(BrowserAccessibility* node) const; | 259 BrowserAccessibility* PreviousInTreeOrder(BrowserAccessibility* node) const; |
| 259 BrowserAccessibility* NextTextOnlyObject(BrowserAccessibility* node) const; | 260 BrowserAccessibility* NextTextOnlyObject(BrowserAccessibility* node) const; |
| 260 BrowserAccessibility* PreviousTextOnlyObject( | 261 BrowserAccessibility* PreviousTextOnlyObject( |
| 261 BrowserAccessibility* node) const; | 262 BrowserAccessibility* node) const; |
| 262 | 263 |
| 263 // AXTreeDelegate implementation. | 264 // AXTreeDelegate implementation. |
| 265 void OnTreeDataChanged(ui::AXTree* tree) override; |
| 264 void OnNodeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override; | 266 void OnNodeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override; |
| 265 void OnSubtreeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override; | 267 void OnSubtreeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override; |
| 266 void OnNodeCreated(ui::AXTree* tree, ui::AXNode* node) override; | 268 void OnNodeCreated(ui::AXTree* tree, ui::AXNode* node) override; |
| 267 void OnNodeChanged(ui::AXTree* tree, ui::AXNode* node) override; | 269 void OnNodeChanged(ui::AXTree* tree, ui::AXNode* node) override; |
| 268 void OnAtomicUpdateFinished( | 270 void OnAtomicUpdateFinished( |
| 269 ui::AXTree* tree, | 271 ui::AXTree* tree, |
| 270 bool root_changed, | 272 bool root_changed, |
| 271 const std::vector<ui::AXTreeDelegate::Change>& changes) override; | 273 const std::vector<ui::AXTreeDelegate::Change>& changes) override; |
| 272 | 274 |
| 273 BrowserAccessibilityDelegate* delegate() const { return delegate_; } | 275 BrowserAccessibilityDelegate* delegate() const { return delegate_; } |
| 274 void set_delegate(BrowserAccessibilityDelegate* delegate) { | 276 void set_delegate(BrowserAccessibilityDelegate* delegate) { |
| 275 delegate_ = delegate; | 277 delegate_ = delegate; |
| 276 } | 278 } |
| 277 | 279 |
| 278 // If this BrowserAccessibilityManager is a child frame or guest frame, | 280 // If this BrowserAccessibilityManager is a child frame or guest frame, |
| 279 // return the BrowserAccessibilityDelegate from the highest ancestor frame | 281 // return the BrowserAccessibilityDelegate from the highest ancestor frame |
| 280 // in the frame tree. | 282 // in the frame tree. |
| 281 BrowserAccessibilityDelegate* GetDelegateFromRootManager(); | 283 BrowserAccessibilityDelegate* GetDelegateFromRootManager(); |
| 282 | 284 |
| 283 // Get a snapshot of the current tree as an AXTreeUpdate. | 285 // Get a snapshot of the current tree as an AXTreeUpdate. |
| 284 SimpleAXTreeUpdate SnapshotAXTreeForTesting(); | 286 ui::AXTreeUpdate SnapshotAXTreeForTesting(); |
| 285 | 287 |
| 286 protected: | 288 protected: |
| 287 BrowserAccessibilityManager( | 289 BrowserAccessibilityManager( |
| 288 BrowserAccessibilityDelegate* delegate, | 290 BrowserAccessibilityDelegate* delegate, |
| 289 BrowserAccessibilityFactory* factory); | 291 BrowserAccessibilityFactory* factory); |
| 290 | 292 |
| 291 BrowserAccessibilityManager( | 293 BrowserAccessibilityManager( |
| 292 const SimpleAXTreeUpdate& initial_tree, | 294 const ui::AXTreeUpdate& initial_tree, |
| 293 BrowserAccessibilityDelegate* delegate, | 295 BrowserAccessibilityDelegate* delegate, |
| 294 BrowserAccessibilityFactory* factory); | 296 BrowserAccessibilityFactory* factory); |
| 295 | 297 |
| 296 private: | 298 private: |
| 297 // The following states keep track of whether or not the | 299 // The following states keep track of whether or not the |
| 298 // on-screen keyboard is allowed to be shown. | 300 // on-screen keyboard is allowed to be shown. |
| 299 enum OnScreenKeyboardState { | 301 enum OnScreenKeyboardState { |
| 300 // Never show the on-screen keyboard because this tab is hidden. | 302 // Never show the on-screen keyboard because this tab is hidden. |
| 301 OSK_DISALLOWED_BECAUSE_TAB_HIDDEN, | 303 OSK_DISALLOWED_BECAUSE_TAB_HIDDEN, |
| 302 | 304 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // node within that parent tree. It's computed as needed and cached for | 349 // node within that parent tree. It's computed as needed and cached for |
| 348 // speed so that it can be accessed quickly if it hasn't changed. | 350 // speed so that it can be accessed quickly if it hasn't changed. |
| 349 int parent_node_id_from_parent_tree_; | 351 int parent_node_id_from_parent_tree_; |
| 350 | 352 |
| 351 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); | 353 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); |
| 352 }; | 354 }; |
| 353 | 355 |
| 354 } // namespace content | 356 } // namespace content |
| 355 | 357 |
| 356 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 358 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
| OLD | NEW |