Chromium Code Reviews| 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/render_accessibility_impl.h" | 5 #include "content/renderer/accessibility/render_accessibility_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 using blink::WebElement; | 33 using blink::WebElement; |
| 34 using blink::WebFloatRect; | 34 using blink::WebFloatRect; |
| 35 using blink::WebLocalFrame; | 35 using blink::WebLocalFrame; |
| 36 using blink::WebNode; | 36 using blink::WebNode; |
| 37 using blink::WebPoint; | 37 using blink::WebPoint; |
| 38 using blink::WebRect; | 38 using blink::WebRect; |
| 39 using blink::WebScopedAXContext; | 39 using blink::WebScopedAXContext; |
| 40 using blink::WebSettings; | 40 using blink::WebSettings; |
| 41 using blink::WebView; | 41 using blink::WebView; |
| 42 | 42 |
| 43 namespace { | |
| 44 // The next token to use to distinguish between ack events sent to this | |
| 45 // RenderAccessibilityImpl and a previous instance. | |
| 46 static int g_next_ack_token = 1; | |
| 47 } | |
| 48 | |
| 43 namespace content { | 49 namespace content { |
| 44 | 50 |
| 45 // Cap the number of nodes returned in an accessibility | 51 // Cap the number of nodes returned in an accessibility |
| 46 // tree snapshot to avoid outrageous memory or bandwidth | 52 // tree snapshot to avoid outrageous memory or bandwidth |
| 47 // usage. | 53 // usage. |
| 48 const size_t kMaxSnapshotNodeCount = 5000; | 54 const size_t kMaxSnapshotNodeCount = 5000; |
| 49 | 55 |
| 50 // static | 56 // static |
| 51 void RenderAccessibilityImpl::SnapshotAccessibilityTree( | 57 void RenderAccessibilityImpl::SnapshotAccessibilityTree( |
| 52 RenderFrameImpl* render_frame, | 58 RenderFrameImpl* render_frame, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 72 RenderAccessibilityImpl::RenderAccessibilityImpl(RenderFrameImpl* render_frame) | 78 RenderAccessibilityImpl::RenderAccessibilityImpl(RenderFrameImpl* render_frame) |
| 73 : RenderFrameObserver(render_frame), | 79 : RenderFrameObserver(render_frame), |
| 74 render_frame_(render_frame), | 80 render_frame_(render_frame), |
| 75 tree_source_(render_frame), | 81 tree_source_(render_frame), |
| 76 serializer_(&tree_source_), | 82 serializer_(&tree_source_), |
| 77 pdf_tree_source_(nullptr), | 83 pdf_tree_source_(nullptr), |
| 78 last_scroll_offset_(gfx::Size()), | 84 last_scroll_offset_(gfx::Size()), |
| 79 ack_pending_(false), | 85 ack_pending_(false), |
| 80 reset_token_(0), | 86 reset_token_(0), |
| 81 weak_factory_(this) { | 87 weak_factory_(this) { |
| 88 ack_token_ = g_next_ack_token++; | |
|
David Tseng
2016/09/14 02:49:42
Perhaps dumb question, but is this global shared a
dmazzoni
2016/09/14 18:58:03
No, but it doesn't need to be. The only issue is w
| |
| 82 WebView* web_view = render_frame_->GetRenderView()->GetWebView(); | 89 WebView* web_view = render_frame_->GetRenderView()->GetWebView(); |
| 83 WebSettings* settings = web_view->settings(); | 90 WebSettings* settings = web_view->settings(); |
| 84 settings->setAccessibilityEnabled(true); | 91 settings->setAccessibilityEnabled(true); |
| 85 | 92 |
| 86 #if defined(OS_ANDROID) | 93 #if defined(OS_ANDROID) |
| 87 // Password values are only passed through on Android. | 94 // Password values are only passed through on Android. |
| 88 settings->setAccessibilityPasswordValuesEnabled(true); | 95 settings->setAccessibilityPasswordValuesEnabled(true); |
| 89 #endif | 96 #endif |
| 90 | 97 |
| 91 #if !defined(OS_ANDROID) | 98 #if !defined(OS_ANDROID) |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 dst.transform.reset(nullptr); | 351 dst.transform.reset(nullptr); |
| 345 if (src.transform) | 352 if (src.transform) |
| 346 dst.transform.reset(new gfx::Transform(*src.transform)); | 353 dst.transform.reset(new gfx::Transform(*src.transform)); |
| 347 } | 354 } |
| 348 | 355 |
| 349 DVLOG(0) << "Accessibility event: " << ui::ToString(event.event_type) | 356 DVLOG(0) << "Accessibility event: " << ui::ToString(event.event_type) |
| 350 << " on node id " << event_msg.id | 357 << " on node id " << event_msg.id |
| 351 << "\n" << event_msg.update.ToString(); | 358 << "\n" << event_msg.update.ToString(); |
| 352 } | 359 } |
| 353 | 360 |
| 354 Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs, reset_token_)); | 361 Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs, reset_token_, |
| 362 ack_token_)); | |
| 355 reset_token_ = 0; | 363 reset_token_ = 0; |
| 356 | 364 |
| 357 if (had_layout_complete_messages) | 365 if (had_layout_complete_messages) |
| 358 SendLocationChanges(); | 366 SendLocationChanges(); |
| 359 } | 367 } |
| 360 | 368 |
| 361 void RenderAccessibilityImpl::SendLocationChanges() { | 369 void RenderAccessibilityImpl::SendLocationChanges() { |
| 362 std::vector<AccessibilityHostMsg_LocationChangeParams> messages; | 370 std::vector<AccessibilityHostMsg_LocationChangeParams> messages; |
| 363 | 371 |
| 364 // Update layout on the root of the tree. | 372 // Update layout on the root of the tree. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 if (obj.isDetached()) { | 432 if (obj.isDetached()) { |
| 425 #ifndef NDEBUG | 433 #ifndef NDEBUG |
| 426 LOG(WARNING) << "DoDefaultAction on invalid object id " << acc_obj_id; | 434 LOG(WARNING) << "DoDefaultAction on invalid object id " << acc_obj_id; |
| 427 #endif | 435 #endif |
| 428 return; | 436 return; |
| 429 } | 437 } |
| 430 | 438 |
| 431 obj.performDefaultAction(); | 439 obj.performDefaultAction(); |
| 432 } | 440 } |
| 433 | 441 |
| 434 void RenderAccessibilityImpl::OnEventsAck() { | 442 void RenderAccessibilityImpl::OnEventsAck(int ack_token) { |
| 443 // Ignore acks intended for a different or previous instance. | |
| 444 if (ack_token_ != ack_token) | |
| 445 return; | |
| 446 | |
| 435 DCHECK(ack_pending_); | 447 DCHECK(ack_pending_); |
| 436 ack_pending_ = false; | 448 ack_pending_ = false; |
| 437 SendPendingAccessibilityEvents(); | 449 SendPendingAccessibilityEvents(); |
| 438 } | 450 } |
| 439 | 451 |
| 440 void RenderAccessibilityImpl::OnFatalError() { | 452 void RenderAccessibilityImpl::OnFatalError() { |
| 441 CHECK(false) << "Invalid accessibility tree."; | 453 CHECK(false) << "Invalid accessibility tree."; |
| 442 } | 454 } |
| 443 | 455 |
| 444 void RenderAccessibilityImpl::OnHitTest(gfx::Point point) { | 456 void RenderAccessibilityImpl::OnHitTest(gfx::Point point) { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 690 size_t new_count = pdf_update.nodes.size(); | 702 size_t new_count = pdf_update.nodes.size(); |
| 691 update->nodes.resize(old_count + new_count); | 703 update->nodes.resize(old_count + new_count); |
| 692 for (size_t i = 0; i < new_count; ++i) | 704 for (size_t i = 0; i < new_count; ++i) |
| 693 update->nodes[old_count + i] = pdf_update.nodes[i]; | 705 update->nodes[old_count + i] = pdf_update.nodes[i]; |
| 694 break; | 706 break; |
| 695 } | 707 } |
| 696 } | 708 } |
| 697 } | 709 } |
| 698 | 710 |
| 699 } // namespace content | 711 } // namespace content |
| OLD | NEW |