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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_
6 #define CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_
8 #include "content/common/ax_content_node_data.h"
9 #include "third_party/WebKit/public/web/WebAXObject.h"
10 #include "ui/accessibility/ax_node_data.h"
11 #include "ui/accessibility/ax_tree_source.h"
15 class RenderFrameImpl
;
17 class BlinkAXTreeSource
18 : public ui::AXTreeSource
<blink::WebAXObject
, AXContentNodeData
> {
20 BlinkAXTreeSource(RenderFrameImpl
* render_frame
);
21 ~BlinkAXTreeSource() override
;
23 // 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
25 // WebDocument if accessibility isn't enabled globally.
26 void SetRoot(blink::WebAXObject root
);
28 // Walks up the ancestor chain to see if this is a descendant of the root.
29 bool IsInTree(blink::WebAXObject node
) const;
31 // Set the id of the node with accessibility focus. The node with
32 // accessibility focus will force loading inline text box children,
33 // which aren't always loaded by default on all platforms.
34 int accessibility_focus_id() { return accessibility_focus_id_
; }
35 void set_accessiblity_focus_id(int id
) { accessibility_focus_id_
= id
; }
37 // AXTreeSource implementation.
38 blink::WebAXObject
GetRoot() const override
;
39 blink::WebAXObject
GetFromId(int32 id
) const override
;
40 int32
GetId(blink::WebAXObject node
) const override
;
42 blink::WebAXObject node
,
43 std::vector
<blink::WebAXObject
>* out_children
) const override
;
44 blink::WebAXObject
GetParent(blink::WebAXObject node
) const override
;
45 void SerializeNode(blink::WebAXObject node
,
46 AXContentNodeData
* out_data
) const override
;
47 bool IsValid(blink::WebAXObject node
) const override
;
48 bool IsEqual(blink::WebAXObject node1
,
49 blink::WebAXObject node2
) const override
;
50 blink::WebAXObject
GetNull() const override
;
52 blink::WebDocument
GetMainDocument() const;
55 RenderFrameImpl
* render_frame_
;
56 blink::WebAXObject root_
;
58 int accessibility_focus_id_
;
61 } // namespace content
63 #endif // CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_