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