Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / renderer / accessibility / blink_ax_tree_source.h
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.
4
5 #ifndef CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_
6 #define CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_
7
8 #include "third_party/WebKit/public/web/WebAXObject.h"
9 #include "ui/accessibility/ax_node_data.h"
10 #include "ui/accessibility/ax_tree_source.h"
11
12 namespace content {
13
14 class RenderFrameImpl;
15
16 class BlinkAXTreeSource
17     : public ui::AXTreeSource<blink::WebAXObject> {
18  public:
19   BlinkAXTreeSource(RenderFrameImpl* render_frame);
20   ~BlinkAXTreeSource() override;
21
22   // Call this to have BlinkAXTreeSource collect a mapping from
23   // node ids to the frame routing id for an out-of-process iframe during
24   // calls to SerializeNode.
25   void CollectChildFrameIdMapping(
26       std::map<int32, int>* node_to_frame_routing_id_map,
27       std::map<int32, int>* node_to_browser_plugin_instance_id_map);
28
29   // Walks up the ancestor chain to see if this is a descendant of the root.
30   bool IsInTree(blink::WebAXObject node) const;
31
32   // Set the id of the node with accessibility focus. The node with
33   // accessibility focus will force loading inline text box children,
34   // which aren't always loaded by default on all platforms.
35   int accessibility_focus_id() { return accessibility_focus_id_; }
36   void set_accessiblity_focus_id(int id) { accessibility_focus_id_ = id; }
37
38   // AXTreeSource implementation.
39   blink::WebAXObject GetRoot() const override;
40   blink::WebAXObject GetFromId(int32 id) const override;
41   int32 GetId(blink::WebAXObject node) const override;
42   void GetChildren(
43       blink::WebAXObject node,
44       std::vector<blink::WebAXObject>* out_children) const override;
45   blink::WebAXObject GetParent(blink::WebAXObject node) const override;
46   void SerializeNode(blink::WebAXObject node,
47                      ui::AXNodeData* out_data) const override;
48   bool IsValid(blink::WebAXObject node) const override;
49   bool IsEqual(blink::WebAXObject node1,
50                blink::WebAXObject node2) const override;
51   blink::WebAXObject GetNull() const override;
52
53   blink::WebDocument GetMainDocument() const;
54
55  private:
56   RenderFrameImpl* render_frame_;
57   std::map<int32, int>* node_to_frame_routing_id_map_;
58   std::map<int32, int>* node_to_browser_plugin_instance_id_map_;
59   int accessibility_focus_id_;
60 };
61
62 }  // namespace content
63
64 #endif  // CONTENT_RENDERER_ACCESSIBILITY_BLINK_AX_TREE_SOURCE_H_