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 CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_ |
6 #define CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_ | 6 #define CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_ |
7 | 7 |
8 #include "content/common/ax_content_node_data.h" | 8 #include "content/common/ax_content_node_data.h" |
9 #include "third_party/WebKit/public/web/WebAXObject.h" | 9 #include "third_party/WebKit/public/web/WebAXObject.h" |
10 #include "ui/accessibility/ax_node_data.h" | 10 #include "ui/accessibility/ax_node_data.h" |
11 #include "ui/accessibility/ax_tree_source.h" | 11 #include "ui/accessibility/ax_tree_source.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 class RenderFrameImpl; | 15 class RenderFrameImpl; |
16 | 16 |
17 class BlinkAXTreeSource | 17 class BlinkAXTreeSource |
18 : public ui::AXTreeSource<blink::WebAXObject, AXContentNodeData> { | 18 : public ui::AXTreeSource<blink::WebAXObject, |
| 19 AXContentNodeData, |
| 20 AXContentTreeData> { |
19 public: | 21 public: |
20 BlinkAXTreeSource(RenderFrameImpl* render_frame); | 22 BlinkAXTreeSource(RenderFrameImpl* render_frame); |
21 ~BlinkAXTreeSource() override; | 23 ~BlinkAXTreeSource() override; |
22 | 24 |
23 // It may be necessary to call SetRoot if you're using a WebScopedAXContext, | 25 // It may be necessary to call SetRoot if you're using a WebScopedAXContext, |
24 // because BlinkAXTreeSource can't get the root of the tree from the | 26 // because BlinkAXTreeSource can't get the root of the tree from the |
25 // WebDocument if accessibility isn't enabled globally. | 27 // WebDocument if accessibility isn't enabled globally. |
26 void SetRoot(blink::WebAXObject root); | 28 void SetRoot(blink::WebAXObject root); |
27 | 29 |
28 // Walks up the ancestor chain to see if this is a descendant of the root. | 30 // Walks up the ancestor chain to see if this is a descendant of the root. |
29 bool IsInTree(blink::WebAXObject node) const; | 31 bool IsInTree(blink::WebAXObject node) const; |
30 | 32 |
31 // Set the id of the node with accessibility focus. The node with | 33 // Set the id of the node with accessibility focus. The node with |
32 // accessibility focus will force loading inline text box children, | 34 // accessibility focus will force loading inline text box children, |
33 // which aren't always loaded by default on all platforms. | 35 // which aren't always loaded by default on all platforms. |
34 int accessibility_focus_id() { return accessibility_focus_id_; } | 36 int accessibility_focus_id() { return accessibility_focus_id_; } |
35 void set_accessibility_focus_id(int id) { accessibility_focus_id_ = id; } | 37 void set_accessibility_focus_id(int id) { accessibility_focus_id_ = id; } |
36 | 38 |
37 // AXTreeSource implementation. | 39 // AXTreeSource implementation. |
| 40 AXContentTreeData GetTreeData() const override; |
38 blink::WebAXObject GetRoot() const override; | 41 blink::WebAXObject GetRoot() const override; |
39 blink::WebAXObject GetFromId(int32 id) const override; | 42 blink::WebAXObject GetFromId(int32 id) const override; |
40 int32 GetId(blink::WebAXObject node) const override; | 43 int32 GetId(blink::WebAXObject node) const override; |
41 void GetChildren( | 44 void GetChildren( |
42 blink::WebAXObject node, | 45 blink::WebAXObject node, |
43 std::vector<blink::WebAXObject>* out_children) const override; | 46 std::vector<blink::WebAXObject>* out_children) const override; |
44 blink::WebAXObject GetParent(blink::WebAXObject node) const override; | 47 blink::WebAXObject GetParent(blink::WebAXObject node) const override; |
45 void SerializeNode(blink::WebAXObject node, | 48 void SerializeNode(blink::WebAXObject node, |
46 AXContentNodeData* out_data) const override; | 49 AXContentNodeData* out_data) const override; |
47 bool IsValid(blink::WebAXObject node) const override; | 50 bool IsValid(blink::WebAXObject node) const override; |
48 bool IsEqual(blink::WebAXObject node1, | 51 bool IsEqual(blink::WebAXObject node1, |
49 blink::WebAXObject node2) const override; | 52 blink::WebAXObject node2) const override; |
50 blink::WebAXObject GetNull() const override; | 53 blink::WebAXObject GetNull() const override; |
51 | 54 |
52 blink::WebDocument GetMainDocument() const; | 55 blink::WebDocument GetMainDocument() const; |
53 | 56 |
54 private: | 57 private: |
55 RenderFrameImpl* render_frame_; | 58 RenderFrameImpl* render_frame_; |
56 blink::WebAXObject root_; | 59 blink::WebAXObject root_; |
57 | 60 |
58 int accessibility_focus_id_; | 61 int accessibility_focus_id_; |
59 }; | 62 }; |
60 | 63 |
61 } // namespace content | 64 } // namespace content |
62 | 65 |
63 #endif // CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_ | 66 #endif // CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_ |
OLD | NEW |