| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 namespace content { | 33 namespace content { |
| 34 | 34 |
| 35 RendererAccessibilityComplete::RendererAccessibilityComplete( | 35 RendererAccessibilityComplete::RendererAccessibilityComplete( |
| 36 RenderFrameImpl* render_frame) | 36 RenderFrameImpl* render_frame) |
| 37 : RendererAccessibility(render_frame), | 37 : RendererAccessibility(render_frame), |
| 38 tree_source_(render_frame), | 38 tree_source_(render_frame), |
| 39 serializer_(&tree_source_), | 39 serializer_(&tree_source_), |
| 40 last_scroll_offset_(gfx::Size()), | 40 last_scroll_offset_(gfx::Size()), |
| 41 ack_pending_(false), | 41 ack_pending_(false), |
| 42 reset_token_(0), | |
| 43 weak_factory_(this) { | 42 weak_factory_(this) { |
| 44 WebView* web_view = render_frame_->GetRenderView()->GetWebView(); | 43 WebView* web_view = render_frame_->GetRenderView()->GetWebView(); |
| 45 WebSettings* settings = web_view->settings(); | 44 WebSettings* settings = web_view->settings(); |
| 46 settings->setAccessibilityEnabled(true); | 45 settings->setAccessibilityEnabled(true); |
| 47 | 46 |
| 48 #if !defined(OS_ANDROID) | 47 #if !defined(OS_ANDROID) |
| 49 // Skip inline text boxes on Android - since there are no native Android | 48 // Skip inline text boxes on Android - since there are no native Android |
| 50 // APIs that compute the bounds of a range of text, it's a waste to | 49 // APIs that compute the bounds of a range of text, it's a waste to |
| 51 // include these in the AX tree. | 50 // include these in the AX tree. |
| 52 settings->setInlineTextBoxAccessibilityEnabled(true); | 51 settings->setInlineTextBoxAccessibilityEnabled(true); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 74 OnDoDefaultAction) | 73 OnDoDefaultAction) |
| 75 IPC_MESSAGE_HANDLER(AccessibilityMsg_Events_ACK, | 74 IPC_MESSAGE_HANDLER(AccessibilityMsg_Events_ACK, |
| 76 OnEventsAck) | 75 OnEventsAck) |
| 77 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToMakeVisible, | 76 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToMakeVisible, |
| 78 OnScrollToMakeVisible) | 77 OnScrollToMakeVisible) |
| 79 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToPoint, | 78 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToPoint, |
| 80 OnScrollToPoint) | 79 OnScrollToPoint) |
| 81 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetTextSelection, | 80 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetTextSelection, |
| 82 OnSetTextSelection) | 81 OnSetTextSelection) |
| 83 IPC_MESSAGE_HANDLER(AccessibilityMsg_HitTest, OnHitTest) | 82 IPC_MESSAGE_HANDLER(AccessibilityMsg_HitTest, OnHitTest) |
| 84 IPC_MESSAGE_HANDLER(AccessibilityMsg_Reset, OnReset) | |
| 85 IPC_MESSAGE_HANDLER(AccessibilityMsg_FatalError, OnFatalError) | 83 IPC_MESSAGE_HANDLER(AccessibilityMsg_FatalError, OnFatalError) |
| 86 IPC_MESSAGE_UNHANDLED(handled = false) | 84 IPC_MESSAGE_UNHANDLED(handled = false) |
| 87 IPC_END_MESSAGE_MAP() | 85 IPC_END_MESSAGE_MAP() |
| 88 return handled; | 86 return handled; |
| 89 } | 87 } |
| 90 | 88 |
| 91 void RendererAccessibilityComplete::FocusedNodeChanged(const WebNode& node) { | 89 void RendererAccessibilityComplete::FocusedNodeChanged(const WebNode& node) { |
| 92 const WebDocument& document = GetMainDocument(); | 90 const WebDocument& document = GetMainDocument(); |
| 93 if (document.isNull()) | 91 if (document.isNull()) |
| 94 return; | 92 return; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 for (size_t i = 0; i < event_msg.update.nodes.size(); ++i) { | 220 for (size_t i = 0; i < event_msg.update.nodes.size(); ++i) { |
| 223 locations_[event_msg.update.nodes[i].id] = | 221 locations_[event_msg.update.nodes[i].id] = |
| 224 event_msg.update.nodes[i].location; | 222 event_msg.update.nodes[i].location; |
| 225 } | 223 } |
| 226 | 224 |
| 227 VLOG(0) << "Accessibility event: " << ui::ToString(event.event_type) | 225 VLOG(0) << "Accessibility event: " << ui::ToString(event.event_type) |
| 228 << " on node id " << event_msg.id | 226 << " on node id " << event_msg.id |
| 229 << "\n" << event_msg.update.ToString(); | 227 << "\n" << event_msg.update.ToString(); |
| 230 } | 228 } |
| 231 | 229 |
| 232 Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs, reset_token_)); | 230 Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs)); |
| 233 reset_token_ = 0; | |
| 234 | 231 |
| 235 if (had_layout_complete_messages) | 232 if (had_layout_complete_messages) |
| 236 SendLocationChanges(); | 233 SendLocationChanges(); |
| 237 } | 234 } |
| 238 | 235 |
| 239 void RendererAccessibilityComplete::SendLocationChanges() { | 236 void RendererAccessibilityComplete::SendLocationChanges() { |
| 240 std::vector<AccessibilityHostMsg_LocationChangeParams> messages; | 237 std::vector<AccessibilityHostMsg_LocationChangeParams> messages; |
| 241 | 238 |
| 242 // Do a breadth-first explore of the whole blink AX tree. | 239 // Do a breadth-first explore of the whole blink AX tree. |
| 243 base::hash_map<int, gfx::Rect> new_locations; | 240 base::hash_map<int, gfx::Rect> new_locations; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 } | 407 } |
| 411 | 408 |
| 412 // By convention, calling SetFocus on the root of the tree should clear the | 409 // By convention, calling SetFocus on the root of the tree should clear the |
| 413 // current focus. Otherwise set the focus to the new node. | 410 // current focus. Otherwise set the focus to the new node. |
| 414 if (acc_obj_id == root.axID()) | 411 if (acc_obj_id == root.axID()) |
| 415 render_frame_->GetRenderView()->GetWebView()->clearFocusedElement(); | 412 render_frame_->GetRenderView()->GetWebView()->clearFocusedElement(); |
| 416 else | 413 else |
| 417 obj.setFocused(true); | 414 obj.setFocused(true); |
| 418 } | 415 } |
| 419 | 416 |
| 420 void RendererAccessibilityComplete::OnReset(int reset_token) { | |
| 421 reset_token_ = reset_token; | |
| 422 serializer_.Reset(); | |
| 423 pending_events_.clear(); | |
| 424 | |
| 425 const WebDocument& document = GetMainDocument(); | |
| 426 if (!document.isNull()) | |
| 427 HandleAXEvent(document.accessibilityObject(), ui::AX_EVENT_LAYOUT_COMPLETE); | |
| 428 } | |
| 429 | |
| 430 void RendererAccessibilityComplete::OnFatalError() { | 417 void RendererAccessibilityComplete::OnFatalError() { |
| 431 CHECK(false) << "Invalid accessibility tree."; | 418 CHECK(false) << "Invalid accessibility tree."; |
| 432 } | 419 } |
| 433 | 420 |
| 434 } // namespace content | 421 } // namespace content |
| OLD | NEW |