Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1920)

Side by Side Diff: content/renderer/accessibility/renderer_accessibility_complete.cc

Issue 625443002: Reset accessibility if it gets out of sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed flakiness Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/accessibility/renderer_accessibility_complete.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 for (size_t i = 0; i < event_msg.update.nodes.size(); ++i) { 242 for (size_t i = 0; i < event_msg.update.nodes.size(); ++i) {
241 locations_[event_msg.update.nodes[i].id] = 243 locations_[event_msg.update.nodes[i].id] =
242 event_msg.update.nodes[i].location; 244 event_msg.update.nodes[i].location;
243 } 245 }
244 246
245 VLOG(0) << "Accessibility event: " << ui::ToString(event.event_type) 247 VLOG(0) << "Accessibility event: " << ui::ToString(event.event_type)
246 << " on node id " << event_msg.id 248 << " on node id " << event_msg.id
247 << "\n" << event_msg.update.ToString(); 249 << "\n" << event_msg.update.ToString();
248 } 250 }
249 251
250 Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs)); 252 Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs, reset_token_));
253 reset_token_ = 0;
251 254
252 if (had_layout_complete_messages) 255 if (had_layout_complete_messages)
253 SendLocationChanges(); 256 SendLocationChanges();
254 } 257 }
255 258
256 void RendererAccessibilityComplete::SendLocationChanges() { 259 void RendererAccessibilityComplete::SendLocationChanges() {
257 std::vector<AccessibilityHostMsg_LocationChangeParams> messages; 260 std::vector<AccessibilityHostMsg_LocationChangeParams> messages;
258 261
259 // Do a breadth-first explore of the whole blink AX tree. 262 // Do a breadth-first explore of the whole blink AX tree.
260 base::hash_map<int, gfx::Rect> new_locations; 263 base::hash_map<int, gfx::Rect> new_locations;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 430 }
428 431
429 // By convention, calling SetFocus on the root of the tree should clear the 432 // By convention, calling SetFocus on the root of the tree should clear the
430 // current focus. Otherwise set the focus to the new node. 433 // current focus. Otherwise set the focus to the new node.
431 if (acc_obj_id == root.axID()) 434 if (acc_obj_id == root.axID())
432 render_frame_->GetRenderView()->GetWebView()->clearFocusedElement(); 435 render_frame_->GetRenderView()->GetWebView()->clearFocusedElement();
433 else 436 else
434 obj.setFocused(true); 437 obj.setFocused(true);
435 } 438 }
436 439
440 void RendererAccessibilityComplete::OnReset(int reset_token) {
441 reset_token_ = reset_token;
442 serializer_.Reset();
443 pending_events_.clear();
444
445 const WebDocument& document = GetMainDocument();
446 if (!document.isNull())
447 HandleAXEvent(document.accessibilityObject(), ui::AX_EVENT_LAYOUT_COMPLETE);
448 }
449
437 void RendererAccessibilityComplete::OnFatalError() { 450 void RendererAccessibilityComplete::OnFatalError() {
438 CHECK(false) << "Invalid accessibility tree."; 451 CHECK(false) << "Invalid accessibility tree.";
439 } 452 }
440 453
441 } // namespace content 454 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/accessibility/renderer_accessibility_complete.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698