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