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