| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 // Cap the number of nodes returned in an accessibility | 53 // Cap the number of nodes returned in an accessibility |
| 54 // tree snapshot to avoid outrageous memory or bandwidth | 54 // tree snapshot to avoid outrageous memory or bandwidth |
| 55 // usage. | 55 // usage. |
| 56 const size_t kMaxSnapshotNodeCount = 5000; | 56 const size_t kMaxSnapshotNodeCount = 5000; |
| 57 | 57 |
| 58 // static | 58 // static |
| 59 void RenderAccessibilityImpl::SnapshotAccessibilityTree( | 59 void RenderAccessibilityImpl::SnapshotAccessibilityTree( |
| 60 RenderFrameImpl* render_frame, | 60 RenderFrameImpl* render_frame, |
| 61 AXContentTreeUpdate* response) { | 61 AXContentTreeUpdate* response) { |
| 62 TRACE_EVENT0("accessibility", |
| 63 "RenderAccessibilityImpl::SnapshotAccessibilityTree"); |
| 64 |
| 62 DCHECK(render_frame); | 65 DCHECK(render_frame); |
| 63 DCHECK(response); | 66 DCHECK(response); |
| 64 if (!render_frame->GetWebFrame()) | 67 if (!render_frame->GetWebFrame()) |
| 65 return; | 68 return; |
| 66 | 69 |
| 67 WebDocument document = render_frame->GetWebFrame()->GetDocument(); | 70 WebDocument document = render_frame->GetWebFrame()->GetDocument(); |
| 68 WebScopedAXContext context(document); | 71 WebScopedAXContext context(document); |
| 69 WebAXObject root = context.Root(); | 72 WebAXObject root = context.Root(); |
| 70 if (!root.UpdateLayoutAndCheckValidity()) | 73 if (!root.UpdateLayoutAndCheckValidity()) |
| 71 return; | 74 return; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } | 338 } |
| 336 } | 339 } |
| 337 | 340 |
| 338 WebDocument RenderAccessibilityImpl::GetMainDocument() { | 341 WebDocument RenderAccessibilityImpl::GetMainDocument() { |
| 339 if (render_frame_ && render_frame_->GetWebFrame()) | 342 if (render_frame_ && render_frame_->GetWebFrame()) |
| 340 return render_frame_->GetWebFrame()->GetDocument(); | 343 return render_frame_->GetWebFrame()->GetDocument(); |
| 341 return WebDocument(); | 344 return WebDocument(); |
| 342 } | 345 } |
| 343 | 346 |
| 344 void RenderAccessibilityImpl::SendPendingAccessibilityEvents() { | 347 void RenderAccessibilityImpl::SendPendingAccessibilityEvents() { |
| 348 TRACE_EVENT0("accessibility", |
| 349 "RenderAccessibilityImpl::SendPendingAccessibilityEvents"); |
| 350 |
| 345 const WebDocument& document = GetMainDocument(); | 351 const WebDocument& document = GetMainDocument(); |
| 346 if (document.IsNull()) | 352 if (document.IsNull()) |
| 347 return; | 353 return; |
| 348 | 354 |
| 349 if (pending_events_.empty()) | 355 if (pending_events_.empty()) |
| 350 return; | 356 return; |
| 351 | 357 |
| 352 ack_pending_ = true; | 358 ack_pending_ = true; |
| 353 | 359 |
| 354 // Make a copy of the events, because it's possible that | 360 // Make a copy of the events, because it's possible that |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 426 |
| 421 Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs, reset_token_, | 427 Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs, reset_token_, |
| 422 ack_token_)); | 428 ack_token_)); |
| 423 reset_token_ = 0; | 429 reset_token_ = 0; |
| 424 | 430 |
| 425 if (had_layout_complete_messages) | 431 if (had_layout_complete_messages) |
| 426 SendLocationChanges(); | 432 SendLocationChanges(); |
| 427 } | 433 } |
| 428 | 434 |
| 429 void RenderAccessibilityImpl::SendLocationChanges() { | 435 void RenderAccessibilityImpl::SendLocationChanges() { |
| 436 TRACE_EVENT0("accessibility", "RenderAccessibilityImpl::SendLocationChanges"); |
| 437 |
| 430 std::vector<AccessibilityHostMsg_LocationChangeParams> messages; | 438 std::vector<AccessibilityHostMsg_LocationChangeParams> messages; |
| 431 | 439 |
| 432 // Update layout on the root of the tree. | 440 // Update layout on the root of the tree. |
| 433 ScopedFreezeBlinkAXTreeSource freeze(&tree_source_); | 441 ScopedFreezeBlinkAXTreeSource freeze(&tree_source_); |
| 434 WebAXObject root = tree_source_.GetRoot(); | 442 WebAXObject root = tree_source_.GetRoot(); |
| 435 if (!root.UpdateLayoutAndCheckValidity()) | 443 if (!root.UpdateLayoutAndCheckValidity()) |
| 436 return; | 444 return; |
| 437 | 445 |
| 438 // Do a breadth-first explore of the whole blink AX tree. | 446 // Do a breadth-first explore of the whole blink AX tree. |
| 439 base::hash_map<int, ui::AXRelativeBounds> new_locations; | 447 base::hash_map<int, ui::AXRelativeBounds> new_locations; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 | 717 |
| 710 const WebDocument& document = GetMainDocument(); | 718 const WebDocument& document = GetMainDocument(); |
| 711 if (document.IsNull()) | 719 if (document.IsNull()) |
| 712 return; | 720 return; |
| 713 | 721 |
| 714 document.AccessibilityObject().ScrollToMakeVisibleWithSubFocus( | 722 document.AccessibilityObject().ScrollToMakeVisibleWithSubFocus( |
| 715 WebRect(bounds.x(), bounds.y(), bounds.width(), bounds.height())); | 723 WebRect(bounds.x(), bounds.y(), bounds.width(), bounds.height())); |
| 716 } | 724 } |
| 717 | 725 |
| 718 } // namespace content | 726 } // namespace content |
| OLD | NEW |