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 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | 5 #include "content/renderer/accessibility/renderer_accessibility_complete.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" | 11 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" |
| 12 #include "content/renderer/render_frame_impl.h" |
12 #include "content/renderer/render_view_impl.h" | 13 #include "content/renderer/render_view_impl.h" |
13 #include "third_party/WebKit/public/web/WebAXObject.h" | 14 #include "third_party/WebKit/public/web/WebAXObject.h" |
14 #include "third_party/WebKit/public/web/WebDocument.h" | 15 #include "third_party/WebKit/public/web/WebDocument.h" |
15 #include "third_party/WebKit/public/web/WebInputElement.h" | 16 #include "third_party/WebKit/public/web/WebInputElement.h" |
16 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 17 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
17 #include "third_party/WebKit/public/web/WebNode.h" | 18 #include "third_party/WebKit/public/web/WebNode.h" |
18 #include "third_party/WebKit/public/web/WebView.h" | 19 #include "third_party/WebKit/public/web/WebView.h" |
19 #include "ui/accessibility/ax_tree.h" | 20 #include "ui/accessibility/ax_tree.h" |
20 | 21 |
21 using blink::WebAXObject; | 22 using blink::WebAXObject; |
22 using blink::WebDocument; | 23 using blink::WebDocument; |
23 using blink::WebNode; | 24 using blink::WebNode; |
24 using blink::WebPoint; | 25 using blink::WebPoint; |
25 using blink::WebRect; | 26 using blink::WebRect; |
26 using blink::WebView; | 27 using blink::WebView; |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 | 30 |
30 RendererAccessibilityComplete::RendererAccessibilityComplete( | 31 RendererAccessibilityComplete::RendererAccessibilityComplete( |
31 RenderViewImpl* render_view) | 32 RenderFrameImpl* render_frame) |
32 : RendererAccessibility(render_view), | 33 : RendererAccessibility(render_frame), |
33 weak_factory_(this), | 34 weak_factory_(this), |
34 tree_source_(render_view), | 35 tree_source_(render_frame), |
35 serializer_(&tree_source_), | 36 serializer_(&tree_source_), |
36 last_scroll_offset_(gfx::Size()), | 37 last_scroll_offset_(gfx::Size()), |
37 ack_pending_(false) { | 38 ack_pending_(false) { |
38 WebAXObject::enableAccessibility(); | 39 WebAXObject::enableAccessibility(); |
39 | 40 |
40 #if !defined(OS_ANDROID) | 41 #if !defined(OS_ANDROID) |
41 // Skip inline text boxes on Android - since there are no native Android | 42 // Skip inline text boxes on Android - since there are no native Android |
42 // APIs that compute the bounds of a range of text, it's a waste to | 43 // APIs that compute the bounds of a range of text, it's a waste to |
43 // include these in the AX tree. | 44 // include these in the AX tree. |
44 WebAXObject::enableInlineTextBoxAccessibility(); | 45 WebAXObject::enableInlineTextBoxAccessibility(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 if (document.isNull()) | 85 if (document.isNull()) |
85 return; | 86 return; |
86 | 87 |
87 if (node.isNull()) { | 88 if (node.isNull()) { |
88 // When focus is cleared, implicitly focus the document. | 89 // When focus is cleared, implicitly focus the document. |
89 // TODO(dmazzoni): Make Blink send this notification instead. | 90 // TODO(dmazzoni): Make Blink send this notification instead. |
90 HandleAXEvent(document.accessibilityObject(), ui::AX_EVENT_BLUR); | 91 HandleAXEvent(document.accessibilityObject(), ui::AX_EVENT_BLUR); |
91 } | 92 } |
92 } | 93 } |
93 | 94 |
94 void RendererAccessibilityComplete::DidFinishLoad(blink::WebLocalFrame* frame) { | |
95 const WebDocument& document = GetMainDocument(); | |
96 if (document.isNull()) | |
97 return; | |
98 } | |
99 | |
100 | |
101 void RendererAccessibilityComplete::HandleWebAccessibilityEvent( | 95 void RendererAccessibilityComplete::HandleWebAccessibilityEvent( |
102 const blink::WebAXObject& obj, blink::WebAXEvent event) { | 96 const blink::WebAXObject& obj, blink::WebAXEvent event) { |
103 HandleAXEvent(obj, AXEventFromBlink(event)); | 97 HandleAXEvent(obj, AXEventFromBlink(event)); |
104 } | 98 } |
105 | 99 |
106 void RendererAccessibilityComplete::HandleAXEvent( | 100 void RendererAccessibilityComplete::HandleAXEvent( |
107 const blink::WebAXObject& obj, ui::AXEvent event) { | 101 const blink::WebAXObject& obj, ui::AXEvent event) { |
108 const WebDocument& document = GetMainDocument(); | 102 const WebDocument& document = GetMainDocument(); |
109 if (document.isNull()) | 103 if (document.isNull()) |
110 return; | 104 return; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 } | 149 } |
156 | 150 |
157 void RendererAccessibilityComplete::SendPendingAccessibilityEvents() { | 151 void RendererAccessibilityComplete::SendPendingAccessibilityEvents() { |
158 const WebDocument& document = GetMainDocument(); | 152 const WebDocument& document = GetMainDocument(); |
159 if (document.isNull()) | 153 if (document.isNull()) |
160 return; | 154 return; |
161 | 155 |
162 if (pending_events_.empty()) | 156 if (pending_events_.empty()) |
163 return; | 157 return; |
164 | 158 |
165 if (render_view_->is_swapped_out()) | 159 if (render_frame_->is_swapped_out()) |
166 return; | 160 return; |
167 | 161 |
168 ack_pending_ = true; | 162 ack_pending_ = true; |
169 | 163 |
170 // Make a copy of the events, because it's possible that | 164 // Make a copy of the events, because it's possible that |
171 // actions inside this loop will cause more events to be | 165 // actions inside this loop will cause more events to be |
172 // queued up. | 166 // queued up. |
173 std::vector<AccessibilityHostMsg_EventParams> src_events = | 167 std::vector<AccessibilityHostMsg_EventParams> src_events = |
174 pending_events_; | 168 pending_events_; |
175 pending_events_.clear(); | 169 pending_events_.clear(); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 if (root.isDetached()) { | 374 if (root.isDetached()) { |
381 #ifndef NDEBUG | 375 #ifndef NDEBUG |
382 LOG(WARNING) << "OnSetAccessibilityFocus but root is invalid"; | 376 LOG(WARNING) << "OnSetAccessibilityFocus but root is invalid"; |
383 #endif | 377 #endif |
384 return; | 378 return; |
385 } | 379 } |
386 | 380 |
387 // By convention, calling SetFocus on the root of the tree should clear the | 381 // By convention, calling SetFocus on the root of the tree should clear the |
388 // current focus. Otherwise set the focus to the new node. | 382 // current focus. Otherwise set the focus to the new node. |
389 if (acc_obj_id == root.axID()) | 383 if (acc_obj_id == root.axID()) |
390 render_view()->GetWebView()->clearFocusedElement(); | 384 render_frame_->GetRenderView()->GetWebView()->clearFocusedElement(); |
391 else | 385 else |
392 obj.setFocused(true); | 386 obj.setFocused(true); |
393 } | 387 } |
394 | 388 |
395 void RendererAccessibilityComplete::OnFatalError() { | 389 void RendererAccessibilityComplete::OnFatalError() { |
396 CHECK(false) << "Invalid accessibility tree."; | 390 CHECK(false) << "Invalid accessibility tree."; |
397 } | 391 } |
398 | 392 |
399 } // namespace content | 393 } // namespace content |
OLD | NEW |