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_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_ | 5 #ifndef CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_ |
6 #define CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_ | 6 #define CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "content/common/accessibility_node_data.h" | |
14 #include "content/public/renderer/render_view_observer.h" | 13 #include "content/public/renderer/render_view_observer.h" |
15 #include "content/renderer/accessibility/renderer_accessibility.h" | 14 #include "content/renderer/accessibility/renderer_accessibility.h" |
16 #include "third_party/WebKit/public/web/WebAXEnums.h" | 15 #include "third_party/WebKit/public/web/WebAXEnums.h" |
17 #include "third_party/WebKit/public/web/WebAXObject.h" | 16 #include "third_party/WebKit/public/web/WebAXObject.h" |
| 17 #include "ui/accessibility/ax_node_data.h" |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 class WebDocument; | 20 class WebDocument; |
21 class WebNode; | 21 class WebNode; |
22 }; | 22 }; |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 class RenderViewImpl; | 25 class RenderViewImpl; |
26 | 26 |
27 // This is the subclass of RendererAccessibility that implements | 27 // This is the subclass of RendererAccessibility that implements |
(...skipping 12 matching lines...) Expand all Loading... |
40 | 40 |
41 // RenderView::Observer implementation. | 41 // RenderView::Observer implementation. |
42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
43 virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE; | 43 virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE; |
44 virtual void DidFinishLoad(blink::WebFrame* frame) OVERRIDE; | 44 virtual void DidFinishLoad(blink::WebFrame* frame) OVERRIDE; |
45 | 45 |
46 // RendererAccessibility. | 46 // RendererAccessibility. |
47 virtual void HandleWebAccessibilityEvent( | 47 virtual void HandleWebAccessibilityEvent( |
48 const blink::WebAXObject& obj, blink::WebAXEvent event) OVERRIDE; | 48 const blink::WebAXObject& obj, blink::WebAXEvent event) OVERRIDE; |
49 | 49 |
| 50 void HandleAXEvent(const blink::WebAXObject& obj, ui::AXEvent event); |
| 51 |
50 // In order to keep track of what nodes the browser knows about, we keep a | 52 // In order to keep track of what nodes the browser knows about, we keep a |
51 // representation of the browser tree - just IDs and parent/child | 53 // representation of the browser tree - just IDs and parent/child |
52 // relationships. | 54 // relationships. |
53 struct CONTENT_EXPORT BrowserTreeNode { | 55 struct CONTENT_EXPORT BrowserTreeNode { |
54 BrowserTreeNode(); | 56 BrowserTreeNode(); |
55 virtual ~BrowserTreeNode(); | 57 virtual ~BrowserTreeNode(); |
56 int32 id; | 58 int32 id; |
57 gfx::Rect location; | 59 gfx::Rect location; |
58 BrowserTreeNode* parent; | 60 BrowserTreeNode* parent; |
59 std::vector<BrowserTreeNode*> children; | 61 std::vector<BrowserTreeNode*> children; |
(...skipping 10 matching lines...) Expand all Loading... |
70 // versions. If any have moved, send an IPC with the new locations. | 72 // versions. If any have moved, send an IPC with the new locations. |
71 void SendLocationChanges(); | 73 void SendLocationChanges(); |
72 | 74 |
73 private: | 75 private: |
74 // Serialize the given accessibility object |obj| and append it to | 76 // Serialize the given accessibility object |obj| and append it to |
75 // |dst|, and then recursively also serialize any *new* children of | 77 // |dst|, and then recursively also serialize any *new* children of |
76 // |obj|, based on what object ids we know the browser already has. | 78 // |obj|, based on what object ids we know the browser already has. |
77 // The set of ids serialized is added to |ids_serialized|, and any | 79 // The set of ids serialized is added to |ids_serialized|, and any |
78 // ids previously in that set are not serialized again. | 80 // ids previously in that set are not serialized again. |
79 void SerializeChangedNodes(const blink::WebAXObject& obj, | 81 void SerializeChangedNodes(const blink::WebAXObject& obj, |
80 std::vector<AccessibilityNodeData>* dst, | 82 std::vector<ui::AXNodeData>* dst, |
81 std::set<int>* ids_serialized); | 83 std::set<int>* ids_serialized); |
82 | 84 |
83 // Clear the given node and recursively delete all of its descendants | 85 // Clear the given node and recursively delete all of its descendants |
84 // from the browser tree. (Does not delete |browser_node|). | 86 // from the browser tree. (Does not delete |browser_node|). |
85 void ClearBrowserTreeNode(BrowserTreeNode* browser_node); | 87 void ClearBrowserTreeNode(BrowserTreeNode* browser_node); |
86 | 88 |
87 // Handlers for messages from the browser to the renderer. | 89 // Handlers for messages from the browser to the renderer. |
88 void OnDoDefaultAction(int acc_obj_id); | 90 void OnDoDefaultAction(int acc_obj_id); |
89 void OnEventsAck(); | 91 void OnEventsAck(); |
90 void OnChangeScrollPosition(int acc_obj_id, int scroll_x, int scroll_y); | 92 void OnChangeScrollPosition(int acc_obj_id, int scroll_x, int scroll_y); |
91 void OnScrollToMakeVisible(int acc_obj_id, gfx::Rect subfocus); | 93 void OnScrollToMakeVisible(int acc_obj_id, gfx::Rect subfocus); |
92 void OnScrollToPoint(int acc_obj_id, gfx::Point point); | 94 void OnScrollToPoint(int acc_obj_id, gfx::Point point); |
93 void OnSetFocus(int acc_obj_id); | 95 void OnSetFocus(int acc_obj_id); |
94 void OnSetTextSelection(int acc_obj_id, int start_offset, int end_offset); | 96 void OnSetTextSelection(int acc_obj_id, int start_offset, int end_offset); |
95 void OnFatalError(); | 97 void OnFatalError(); |
96 | 98 |
97 // Checks if a WebKit accessibility object is an editable text node. | 99 // Checks if a WebKit accessibility object is an editable text node. |
98 bool IsEditableText(const blink::WebAXObject& node); | 100 bool IsEditableText(const blink::WebAXObject& node); |
99 | 101 |
100 // Recursively explore the tree of WebKit accessibility objects rooted | 102 // Recursively explore the tree of WebKit accessibility objects rooted |
101 // at |src|, and for each editable text node encountered, add a | 103 // at |src|, and for each editable text node encountered, add a |
102 // corresponding WebAccessibility node as a child of |dst|. | 104 // corresponding WebAccessibility node as a child of |dst|. |
103 void RecursiveAddEditableTextNodesToTree( | 105 void RecursiveAddEditableTextNodesToTree( |
104 const blink::WebAXObject& src, | 106 const blink::WebAXObject& src, |
105 AccessibilityNodeData* dst); | 107 ui::AXNodeData* dst); |
106 | 108 |
107 // Build a tree of serializable AccessibilityNodeData nodes to send to the | 109 // Build a tree of serializable ui::AXNodeData nodes to send to the |
108 // browser process, given a WebAXObject node from WebKit. | 110 // browser process, given a WebAXObject node from WebKit. |
109 // Modifies |dst| in-place, it's assumed to be empty. | 111 // Modifies |dst| in-place, it's assumed to be empty. |
110 void BuildAccessibilityTree(const blink::WebAXObject& src, | 112 void BuildAccessibilityTree(const blink::WebAXObject& src, |
111 bool include_children, | 113 bool include_children, |
112 AccessibilityNodeData* dst); | 114 ui::AXNodeData* dst); |
113 | 115 |
114 // So we can queue up tasks to be executed later. | 116 // So we can queue up tasks to be executed later. |
115 base::WeakPtrFactory<RendererAccessibilityComplete> weak_factory_; | 117 base::WeakPtrFactory<RendererAccessibilityComplete> weak_factory_; |
116 | 118 |
117 // Events from WebKit are collected until they are ready to be | 119 // Events from WebKit are collected until they are ready to be |
118 // sent to the browser. | 120 // sent to the browser. |
119 std::vector<AccessibilityHostMsg_EventParams> pending_events_; | 121 std::vector<AccessibilityHostMsg_EventParams> pending_events_; |
120 | 122 |
121 // Our representation of the browser tree. | 123 // Our representation of the browser tree. |
122 BrowserTreeNode* browser_root_; | 124 BrowserTreeNode* browser_root_; |
123 | 125 |
124 // A map from IDs to nodes in the browser tree. | 126 // A map from IDs to nodes in the browser tree. |
125 base::hash_map<int32, BrowserTreeNode*> browser_id_map_; | 127 base::hash_map<int32, BrowserTreeNode*> browser_id_map_; |
126 | 128 |
127 // The most recently observed scroll offset of the root document element. | 129 // The most recently observed scroll offset of the root document element. |
128 // TODO(dmazzoni): remove once https://bugs.webkit.org/show_bug.cgi?id=73460 | 130 // TODO(dmazzoni): remove once https://bugs.webkit.org/show_bug.cgi?id=73460 |
129 // is fixed. | 131 // is fixed. |
130 gfx::Size last_scroll_offset_; | 132 gfx::Size last_scroll_offset_; |
131 | 133 |
132 // The current accessibility mode. | 134 // The current accessibility mode. |
133 AccessibilityMode mode_; | 135 AccessibilityMode mode_; |
134 | 136 |
135 // Set if we are waiting for an accessibility event ack. | 137 // Set if we are waiting for an accessibility event ack. |
136 bool ack_pending_; | 138 bool ack_pending_; |
137 | 139 |
138 // True if verbose logging of accessibility events is on. | |
139 bool logging_; | |
140 | |
141 DISALLOW_COPY_AND_ASSIGN(RendererAccessibilityComplete); | 140 DISALLOW_COPY_AND_ASSIGN(RendererAccessibilityComplete); |
142 }; | 141 }; |
143 | 142 |
144 #endif // CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_ | 143 #endif // CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_ |
145 | 144 |
146 } // namespace content | 145 } // namespace content |
OLD | NEW |