| 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 23 matching lines...) Expand all Loading... |
| 34 using blink::WebElement; | 34 using blink::WebElement; |
| 35 using blink::WebFloatRect; | 35 using blink::WebFloatRect; |
| 36 using blink::WebLocalFrame; | 36 using blink::WebLocalFrame; |
| 37 using blink::WebNode; | 37 using blink::WebNode; |
| 38 using blink::WebPoint; | 38 using blink::WebPoint; |
| 39 using blink::WebRect; | 39 using blink::WebRect; |
| 40 using blink::WebScopedAXContext; | 40 using blink::WebScopedAXContext; |
| 41 using blink::WebSettings; | 41 using blink::WebSettings; |
| 42 using blink::WebView; | 42 using blink::WebView; |
| 43 | 43 |
| 44 namespace { |
| 45 // The next token to use to distinguish between ack events sent to this |
| 46 // RenderAccessibilityImpl and a previous instance. |
| 47 static int g_next_ack_token = 1; |
| 48 } |
| 49 |
| 44 namespace content { | 50 namespace content { |
| 45 | 51 |
| 46 // Cap the number of nodes returned in an accessibility | 52 // Cap the number of nodes returned in an accessibility |
| 47 // tree snapshot to avoid outrageous memory or bandwidth | 53 // tree snapshot to avoid outrageous memory or bandwidth |
| 48 // usage. | 54 // usage. |
| 49 const size_t kMaxSnapshotNodeCount = 5000; | 55 const size_t kMaxSnapshotNodeCount = 5000; |
| 50 | 56 |
| 51 // static | 57 // static |
| 52 void RenderAccessibilityImpl::SnapshotAccessibilityTree( | 58 void RenderAccessibilityImpl::SnapshotAccessibilityTree( |
| 53 RenderFrameImpl* render_frame, | 59 RenderFrameImpl* render_frame, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 74 : RenderFrameObserver(render_frame), | 80 : RenderFrameObserver(render_frame), |
| 75 render_frame_(render_frame), | 81 render_frame_(render_frame), |
| 76 tree_source_(render_frame), | 82 tree_source_(render_frame), |
| 77 serializer_(&tree_source_), | 83 serializer_(&tree_source_), |
| 78 pdf_tree_source_(nullptr), | 84 pdf_tree_source_(nullptr), |
| 79 last_scroll_offset_(gfx::Size()), | 85 last_scroll_offset_(gfx::Size()), |
| 80 ack_pending_(false), | 86 ack_pending_(false), |
| 81 reset_token_(0), | 87 reset_token_(0), |
| 82 during_action_(false), | 88 during_action_(false), |
| 83 weak_factory_(this) { | 89 weak_factory_(this) { |
| 90 ack_token_ = g_next_ack_token++; |
| 84 WebView* web_view = render_frame_->GetRenderView()->GetWebView(); | 91 WebView* web_view = render_frame_->GetRenderView()->GetWebView(); |
| 85 WebSettings* settings = web_view->settings(); | 92 WebSettings* settings = web_view->settings(); |
| 86 settings->setAccessibilityEnabled(true); | 93 settings->setAccessibilityEnabled(true); |
| 87 | 94 |
| 88 #if defined(OS_ANDROID) | 95 #if defined(OS_ANDROID) |
| 89 // Password values are only passed through on Android. | 96 // Password values are only passed through on Android. |
| 90 settings->setAccessibilityPasswordValuesEnabled(true); | 97 settings->setAccessibilityPasswordValuesEnabled(true); |
| 91 #endif | 98 #endif |
| 92 | 99 |
| 93 #if !defined(OS_ANDROID) | 100 #if !defined(OS_ANDROID) |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 dst.transform.reset(nullptr); | 363 dst.transform.reset(nullptr); |
| 357 if (src.transform) | 364 if (src.transform) |
| 358 dst.transform.reset(new gfx::Transform(*src.transform)); | 365 dst.transform.reset(new gfx::Transform(*src.transform)); |
| 359 } | 366 } |
| 360 | 367 |
| 361 DVLOG(0) << "Accessibility event: " << ui::ToString(event.event_type) | 368 DVLOG(0) << "Accessibility event: " << ui::ToString(event.event_type) |
| 362 << " on node id " << event_msg.id | 369 << " on node id " << event_msg.id |
| 363 << "\n" << event_msg.update.ToString(); | 370 << "\n" << event_msg.update.ToString(); |
| 364 } | 371 } |
| 365 | 372 |
| 366 Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs, reset_token_)); | 373 Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs, reset_token_, |
| 374 ack_token_)); |
| 367 reset_token_ = 0; | 375 reset_token_ = 0; |
| 368 | 376 |
| 369 if (had_layout_complete_messages) | 377 if (had_layout_complete_messages) |
| 370 SendLocationChanges(); | 378 SendLocationChanges(); |
| 371 } | 379 } |
| 372 | 380 |
| 373 void RenderAccessibilityImpl::SendLocationChanges() { | 381 void RenderAccessibilityImpl::SendLocationChanges() { |
| 374 std::vector<AccessibilityHostMsg_LocationChangeParams> messages; | 382 std::vector<AccessibilityHostMsg_LocationChangeParams> messages; |
| 375 | 383 |
| 376 // Update layout on the root of the tree. | 384 // Update layout on the root of the tree. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 if (obj.isDetached()) { | 444 if (obj.isDetached()) { |
| 437 #ifndef NDEBUG | 445 #ifndef NDEBUG |
| 438 LOG(WARNING) << "DoDefaultAction on invalid object id " << acc_obj_id; | 446 LOG(WARNING) << "DoDefaultAction on invalid object id " << acc_obj_id; |
| 439 #endif | 447 #endif |
| 440 return; | 448 return; |
| 441 } | 449 } |
| 442 | 450 |
| 443 obj.performDefaultAction(); | 451 obj.performDefaultAction(); |
| 444 } | 452 } |
| 445 | 453 |
| 446 void RenderAccessibilityImpl::OnEventsAck() { | 454 void RenderAccessibilityImpl::OnEventsAck(int ack_token) { |
| 455 // Ignore acks intended for a different or previous instance. |
| 456 if (ack_token_ != ack_token) |
| 457 return; |
| 458 |
| 447 DCHECK(ack_pending_); | 459 DCHECK(ack_pending_); |
| 448 ack_pending_ = false; | 460 ack_pending_ = false; |
| 449 SendPendingAccessibilityEvents(); | 461 SendPendingAccessibilityEvents(); |
| 450 } | 462 } |
| 451 | 463 |
| 452 void RenderAccessibilityImpl::OnFatalError() { | 464 void RenderAccessibilityImpl::OnFatalError() { |
| 453 CHECK(false) << "Invalid accessibility tree."; | 465 CHECK(false) << "Invalid accessibility tree."; |
| 454 } | 466 } |
| 455 | 467 |
| 456 void RenderAccessibilityImpl::OnHitTest(gfx::Point point) { | 468 void RenderAccessibilityImpl::OnHitTest(gfx::Point point) { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 size_t new_count = pdf_update.nodes.size(); | 714 size_t new_count = pdf_update.nodes.size(); |
| 703 update->nodes.resize(old_count + new_count); | 715 update->nodes.resize(old_count + new_count); |
| 704 for (size_t i = 0; i < new_count; ++i) | 716 for (size_t i = 0; i < new_count; ++i) |
| 705 update->nodes[old_count + i] = pdf_update.nodes[i]; | 717 update->nodes[old_count + i] = pdf_update.nodes[i]; |
| 706 break; | 718 break; |
| 707 } | 719 } |
| 708 } | 720 } |
| 709 } | 721 } |
| 710 | 722 |
| 711 } // namespace content | 723 } // namespace content |
| OLD | NEW |