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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "third_party/WebKit/public/web/WebAXEnums.h" | 14 #include "third_party/WebKit/public/web/WebAXEnums.h" |
15 #include "ui/accessibility/ax_node_data.h" | 15 #include "ui/accessibility/ax_node_data.h" |
16 #include "ui/accessibility/ax_tree.h" | 16 #include "ui/accessibility/ax_serializable_tree.h" |
17 #include "ui/accessibility/ax_tree_update.h" | 17 #include "ui/accessibility/ax_tree_update.h" |
18 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
19 | 19 |
20 struct AccessibilityHostMsg_EventParams; | 20 struct AccessibilityHostMsg_EventParams; |
21 struct AccessibilityHostMsg_LocationChangeParams; | 21 struct AccessibilityHostMsg_LocationChangeParams; |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 class BrowserAccessibility; | 24 class BrowserAccessibility; |
25 class BrowserAccessibilityManager; | |
25 #if defined(OS_ANDROID) | 26 #if defined(OS_ANDROID) |
26 class BrowserAccessibilityManagerAndroid; | 27 class BrowserAccessibilityManagerAndroid; |
27 #endif | 28 #endif |
28 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
29 class BrowserAccessibilityManagerWin; | 30 class BrowserAccessibilityManagerWin; |
30 #endif | 31 #endif |
31 | 32 |
33 const int kNoFrameId = -1; | |
Charlie Reis
2014/08/21 19:23:27
This is a bit ambiguous for a content-wide constan
dmazzoni
2014/08/25 06:49:36
WIth the other changes, this is only needed in bro
| |
34 | |
32 // For testing. | 35 // For testing. |
33 CONTENT_EXPORT ui::AXTreeUpdate MakeAXTreeUpdate( | 36 CONTENT_EXPORT ui::AXTreeUpdate MakeAXTreeUpdate( |
34 const ui::AXNodeData& node, | 37 const ui::AXNodeData& node, |
35 const ui::AXNodeData& node2 = ui::AXNodeData(), | 38 const ui::AXNodeData& node2 = ui::AXNodeData(), |
36 const ui::AXNodeData& node3 = ui::AXNodeData(), | 39 const ui::AXNodeData& node3 = ui::AXNodeData(), |
37 const ui::AXNodeData& node4 = ui::AXNodeData(), | 40 const ui::AXNodeData& node4 = ui::AXNodeData(), |
38 const ui::AXNodeData& node5 = ui::AXNodeData(), | 41 const ui::AXNodeData& node5 = ui::AXNodeData(), |
39 const ui::AXNodeData& node6 = ui::AXNodeData(), | 42 const ui::AXNodeData& node6 = ui::AXNodeData(), |
40 const ui::AXNodeData& node7 = ui::AXNodeData(), | 43 const ui::AXNodeData& node7 = ui::AXNodeData(), |
41 const ui::AXNodeData& node8 = ui::AXNodeData(), | 44 const ui::AXNodeData& node8 = ui::AXNodeData(), |
(...skipping 14 matching lines...) Expand all Loading... | |
56 int acc_obj_id, int start_offset, int end_offset) = 0; | 59 int acc_obj_id, int start_offset, int end_offset) = 0; |
57 virtual bool AccessibilityViewHasFocus() const = 0; | 60 virtual bool AccessibilityViewHasFocus() const = 0; |
58 virtual gfx::Rect AccessibilityGetViewBounds() const = 0; | 61 virtual gfx::Rect AccessibilityGetViewBounds() const = 0; |
59 virtual gfx::Point AccessibilityOriginInScreen( | 62 virtual gfx::Point AccessibilityOriginInScreen( |
60 const gfx::Rect& bounds) const = 0; | 63 const gfx::Rect& bounds) const = 0; |
61 virtual void AccessibilityHitTest( | 64 virtual void AccessibilityHitTest( |
62 const gfx::Point& point) = 0; | 65 const gfx::Point& point) = 0; |
63 virtual void AccessibilityFatalError() = 0; | 66 virtual void AccessibilityFatalError() = 0; |
64 virtual gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() = 0; | 67 virtual gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() = 0; |
65 virtual gfx::NativeViewAccessible AccessibilityGetNativeViewAccessible() = 0; | 68 virtual gfx::NativeViewAccessible AccessibilityGetNativeViewAccessible() = 0; |
69 virtual BrowserAccessibilityManager* AccessibilityGetChildFrame( | |
70 int64 frame_id) = 0; | |
71 virtual BrowserAccessibilityManager* AccessibilityGetParentFrame() = 0; | |
66 }; | 72 }; |
67 | 73 |
68 class CONTENT_EXPORT BrowserAccessibilityFactory { | 74 class CONTENT_EXPORT BrowserAccessibilityFactory { |
69 public: | 75 public: |
70 virtual ~BrowserAccessibilityFactory() {} | 76 virtual ~BrowserAccessibilityFactory() {} |
71 | 77 |
72 // Create an instance of BrowserAccessibility and return a new | 78 // Create an instance of BrowserAccessibility and return a new |
73 // reference to it. | 79 // reference to it. |
74 virtual BrowserAccessibility* Create(); | 80 virtual BrowserAccessibility* Create(); |
75 }; | 81 }; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 virtual void OnNodeChanged(ui::AXNode* node) OVERRIDE; | 188 virtual void OnNodeChanged(ui::AXNode* node) OVERRIDE; |
183 virtual void OnNodeCreationFinished(ui::AXNode* node) OVERRIDE; | 189 virtual void OnNodeCreationFinished(ui::AXNode* node) OVERRIDE; |
184 virtual void OnNodeChangeFinished(ui::AXNode* node) OVERRIDE; | 190 virtual void OnNodeChangeFinished(ui::AXNode* node) OVERRIDE; |
185 virtual void OnRootChanged(ui::AXNode* new_root) OVERRIDE {} | 191 virtual void OnRootChanged(ui::AXNode* new_root) OVERRIDE {} |
186 | 192 |
187 BrowserAccessibilityDelegate* delegate() const { return delegate_; } | 193 BrowserAccessibilityDelegate* delegate() const { return delegate_; } |
188 void set_delegate(BrowserAccessibilityDelegate* delegate) { | 194 void set_delegate(BrowserAccessibilityDelegate* delegate) { |
189 delegate_ = delegate; | 195 delegate_ = delegate; |
190 } | 196 } |
191 | 197 |
198 // Get a snapshot of the current tree as an AXTreeUpdate. | |
199 ui::AXTreeUpdate SnapshotAXTreeForTesting(); | |
200 | |
201 // Frame tree support. | |
202 void SetNodeIdInParentFrame(int32 node_id); | |
203 void SetChildFrameId(int32 node_id, int64 child_frame_id); | |
204 BrowserAccessibility* GetCrossFrameParent(); | |
205 | |
192 protected: | 206 protected: |
193 BrowserAccessibilityManager( | 207 BrowserAccessibilityManager( |
194 BrowserAccessibilityDelegate* delegate, | 208 BrowserAccessibilityDelegate* delegate, |
195 BrowserAccessibilityFactory* factory); | 209 BrowserAccessibilityFactory* factory); |
196 | 210 |
197 BrowserAccessibilityManager( | 211 BrowserAccessibilityManager( |
198 const ui::AXTreeUpdate& initial_tree, | 212 const ui::AXTreeUpdate& initial_tree, |
199 BrowserAccessibilityDelegate* delegate, | 213 BrowserAccessibilityDelegate* delegate, |
200 BrowserAccessibilityFactory* factory); | 214 BrowserAccessibilityFactory* factory); |
201 | 215 |
(...skipping 16 matching lines...) Expand all Loading... | |
218 // touch event was within the bounds of the currently focused object. | 232 // touch event was within the bounds of the currently focused object. |
219 // Otherwise we'll just wait to see if focus changes. | 233 // Otherwise we'll just wait to see if focus changes. |
220 OSK_ALLOWED_WITHIN_FOCUSED_OBJECT, | 234 OSK_ALLOWED_WITHIN_FOCUSED_OBJECT, |
221 | 235 |
222 // Focus has changed within a tab that's already visible. Allow the | 236 // Focus has changed within a tab that's already visible. Allow the |
223 // on-screen keyboard to show anytime that a touch event leads to an | 237 // on-screen keyboard to show anytime that a touch event leads to an |
224 // editable text control getting focus. | 238 // editable text control getting focus. |
225 OSK_ALLOWED | 239 OSK_ALLOWED |
226 }; | 240 }; |
227 | 241 |
228 // Update a set of nodes using data received from the renderer | |
229 // process. | |
230 bool UpdateNodes(const std::vector<ui::AXNodeData>& nodes); | |
231 | |
232 // Update one node from the tree using data received from the renderer | |
233 // process. Returns true on success, false on fatal error. | |
234 bool UpdateNode(const ui::AXNodeData& src); | |
235 | |
236 void SetRoot(BrowserAccessibility* root); | |
237 | |
238 BrowserAccessibility* CreateNode( | |
239 BrowserAccessibility* parent, | |
240 int32 id, | |
241 int32 index_in_parent); | |
242 | |
243 protected: | 242 protected: |
244 // The object that can perform actions on our behalf. | 243 // The object that can perform actions on our behalf. |
245 BrowserAccessibilityDelegate* delegate_; | 244 BrowserAccessibilityDelegate* delegate_; |
246 | 245 |
247 // Factory to create BrowserAccessibility objects (for dependency injection). | 246 // Factory to create BrowserAccessibility objects (for dependency injection). |
248 scoped_ptr<BrowserAccessibilityFactory> factory_; | 247 scoped_ptr<BrowserAccessibilityFactory> factory_; |
249 | 248 |
250 // The underlying tree of accessibility objects. | 249 // The underlying tree of accessibility objects. |
251 scoped_ptr<ui::AXTree> tree_; | 250 scoped_ptr<ui::AXSerializableTree> tree_; |
252 | 251 |
253 // The node that currently has focus. | 252 // The node that currently has focus. |
254 ui::AXNode* focus_; | 253 ui::AXNode* focus_; |
255 | 254 |
256 // A mapping from a node id to its wrapper of type BrowserAccessibility. | 255 // A mapping from a node id to its wrapper of type BrowserAccessibility. |
257 base::hash_map<int32, BrowserAccessibility*> id_wrapper_map_; | 256 base::hash_map<int32, BrowserAccessibility*> id_wrapper_map_; |
258 | 257 |
258 // This is set if this tree's frame is the child of another frame. | |
259 // It's the id of the node in the parent frame that's the parent of this | |
260 // frame's root object. | |
Charlie Reis
2014/08/20 20:37:13
This comment is kind of hard to follow. Maybe it
dmazzoni
2014/08/20 20:57:17
Sure.
I'll work on the comment, but for purposes
dmazzoni
2014/08/25 06:49:36
This is gone now.
| |
261 uint32 node_id_in_parent_frame_; | |
262 | |
259 // The on-screen keyboard state. | 263 // The on-screen keyboard state. |
260 OnScreenKeyboardState osk_state_; | 264 OnScreenKeyboardState osk_state_; |
261 | 265 |
262 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); | 266 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); |
263 }; | 267 }; |
264 | 268 |
265 } // namespace content | 269 } // namespace content |
266 | 270 |
267 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 271 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
OLD | NEW |