| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 std::vector<AXEventNotificationDetails> details; | 1623 std::vector<AXEventNotificationDetails> details; |
| 1624 details.reserve(params.size()); | 1624 details.reserve(params.size()); |
| 1625 for (size_t i = 0; i < params.size(); ++i) { | 1625 for (size_t i = 0; i < params.size(); ++i) { |
| 1626 const AccessibilityHostMsg_EventParams& param = params[i]; | 1626 const AccessibilityHostMsg_EventParams& param = params[i]; |
| 1627 AXEventNotificationDetails detail; | 1627 AXEventNotificationDetails detail; |
| 1628 detail.event_type = param.event_type; | 1628 detail.event_type = param.event_type; |
| 1629 detail.id = param.id; | 1629 detail.id = param.id; |
| 1630 detail.ax_tree_id = GetAXTreeID(); | 1630 detail.ax_tree_id = GetAXTreeID(); |
| 1631 if (param.update.has_tree_data) { | 1631 if (param.update.has_tree_data) { |
| 1632 detail.update.has_tree_data = true; | 1632 detail.update.has_tree_data = true; |
| 1633 AXContentTreeDataToAXTreeData(param.update.tree_data, | 1633 ax_content_tree_data_ = param.update.tree_data; |
| 1634 &detail.update.tree_data); | 1634 AXContentTreeDataToAXTreeData(&detail.update.tree_data); |
| 1635 } | 1635 } |
| 1636 detail.update.node_id_to_clear = param.update.node_id_to_clear; | 1636 detail.update.node_id_to_clear = param.update.node_id_to_clear; |
| 1637 detail.update.nodes.resize(param.update.nodes.size()); | 1637 detail.update.nodes.resize(param.update.nodes.size()); |
| 1638 for (size_t i = 0; i < param.update.nodes.size(); ++i) { | 1638 for (size_t i = 0; i < param.update.nodes.size(); ++i) { |
| 1639 AXContentNodeDataToAXNodeData(param.update.nodes[i], | 1639 AXContentNodeDataToAXNodeData(param.update.nodes[i], |
| 1640 &detail.update.nodes[i]); | 1640 &detail.update.nodes[i]); |
| 1641 } | 1641 } |
| 1642 details.push_back(detail); | 1642 details.push_back(detail); |
| 1643 } | 1643 } |
| 1644 | 1644 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1717 const AXContentTreeUpdate& snapshot) { | 1717 const AXContentTreeUpdate& snapshot) { |
| 1718 const auto& it = ax_tree_snapshot_callbacks_.find(callback_id); | 1718 const auto& it = ax_tree_snapshot_callbacks_.find(callback_id); |
| 1719 if (it != ax_tree_snapshot_callbacks_.end()) { | 1719 if (it != ax_tree_snapshot_callbacks_.end()) { |
| 1720 ui::AXTreeUpdate dst_snapshot; | 1720 ui::AXTreeUpdate dst_snapshot; |
| 1721 dst_snapshot.nodes.resize(snapshot.nodes.size()); | 1721 dst_snapshot.nodes.resize(snapshot.nodes.size()); |
| 1722 for (size_t i = 0; i < snapshot.nodes.size(); ++i) { | 1722 for (size_t i = 0; i < snapshot.nodes.size(); ++i) { |
| 1723 AXContentNodeDataToAXNodeData(snapshot.nodes[i], | 1723 AXContentNodeDataToAXNodeData(snapshot.nodes[i], |
| 1724 &dst_snapshot.nodes[i]); | 1724 &dst_snapshot.nodes[i]); |
| 1725 } | 1725 } |
| 1726 if (snapshot.has_tree_data) { | 1726 if (snapshot.has_tree_data) { |
| 1727 AXContentTreeDataToAXTreeData(snapshot.tree_data, | 1727 ax_content_tree_data_ = snapshot.tree_data; |
| 1728 &dst_snapshot.tree_data); | 1728 AXContentTreeDataToAXTreeData(&dst_snapshot.tree_data); |
| 1729 dst_snapshot.has_tree_data = true; | 1729 dst_snapshot.has_tree_data = true; |
| 1730 } | 1730 } |
| 1731 it->second.Run(dst_snapshot); | 1731 it->second.Run(dst_snapshot); |
| 1732 ax_tree_snapshot_callbacks_.erase(it); | 1732 ax_tree_snapshot_callbacks_.erase(it); |
| 1733 } else { | 1733 } else { |
| 1734 NOTREACHED() << "Received AX tree snapshot response for unknown id"; | 1734 NOTREACHED() << "Received AX tree snapshot response for unknown id"; |
| 1735 } | 1735 } |
| 1736 } | 1736 } |
| 1737 | 1737 |
| 1738 void RenderFrameHostImpl::OnToggleFullscreen(bool enter_fullscreen) { | 1738 void RenderFrameHostImpl::OnToggleFullscreen(bool enter_fullscreen) { |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2336 int callback_id = next_id++; | 2336 int callback_id = next_id++; |
| 2337 Send(new AccessibilityMsg_SnapshotTree(routing_id_, callback_id)); | 2337 Send(new AccessibilityMsg_SnapshotTree(routing_id_, callback_id)); |
| 2338 ax_tree_snapshot_callbacks_.insert(std::make_pair(callback_id, callback)); | 2338 ax_tree_snapshot_callbacks_.insert(std::make_pair(callback_id, callback)); |
| 2339 } | 2339 } |
| 2340 | 2340 |
| 2341 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( | 2341 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( |
| 2342 const base::Callback<void(ui::AXEvent, int)>& callback) { | 2342 const base::Callback<void(ui::AXEvent, int)>& callback) { |
| 2343 accessibility_testing_callback_ = callback; | 2343 accessibility_testing_callback_ = callback; |
| 2344 } | 2344 } |
| 2345 | 2345 |
| 2346 void RenderFrameHostImpl::UpdateAXTreeData() { |
| 2347 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
| 2348 if (accessibility_mode == AccessibilityModeOff || |
| 2349 !RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { |
| 2350 return; |
| 2351 } |
| 2352 |
| 2353 std::vector<AXEventNotificationDetails> details; |
| 2354 details.reserve(1U); |
| 2355 AXEventNotificationDetails detail; |
| 2356 detail.ax_tree_id = GetAXTreeID(); |
| 2357 detail.update.has_tree_data = true; |
| 2358 AXContentTreeDataToAXTreeData(&detail.update.tree_data); |
| 2359 details.push_back(detail); |
| 2360 |
| 2361 if (browser_accessibility_manager_) |
| 2362 browser_accessibility_manager_->OnAccessibilityEvents(details); |
| 2363 |
| 2364 delegate_->AccessibilityEventReceived(details); |
| 2365 } |
| 2366 |
| 2346 void RenderFrameHostImpl::SetTextTrackSettings( | 2367 void RenderFrameHostImpl::SetTextTrackSettings( |
| 2347 const FrameMsg_TextTrackSettings_Params& params) { | 2368 const FrameMsg_TextTrackSettings_Params& params) { |
| 2348 DCHECK(!GetParent()); | 2369 DCHECK(!GetParent()); |
| 2349 Send(new FrameMsg_SetTextTrackSettings(routing_id_, params)); | 2370 Send(new FrameMsg_SetTextTrackSettings(routing_id_, params)); |
| 2350 } | 2371 } |
| 2351 | 2372 |
| 2352 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { | 2373 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { |
| 2353 return ax_tree_for_testing_.get(); | 2374 return ax_tree_for_testing_.get(); |
| 2354 } | 2375 } |
| 2355 | 2376 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2618 BrowserPluginInstanceIDToAXTreeID(value))); | 2639 BrowserPluginInstanceIDToAXTreeID(value))); |
| 2619 break; | 2640 break; |
| 2620 case AX_CONTENT_INT_ATTRIBUTE_LAST: | 2641 case AX_CONTENT_INT_ATTRIBUTE_LAST: |
| 2621 NOTREACHED(); | 2642 NOTREACHED(); |
| 2622 break; | 2643 break; |
| 2623 } | 2644 } |
| 2624 } | 2645 } |
| 2625 } | 2646 } |
| 2626 | 2647 |
| 2627 void RenderFrameHostImpl::AXContentTreeDataToAXTreeData( | 2648 void RenderFrameHostImpl::AXContentTreeDataToAXTreeData( |
| 2628 const AXContentTreeData& src, | |
| 2629 ui::AXTreeData* dst) { | 2649 ui::AXTreeData* dst) { |
| 2650 const AXContentTreeData& src = ax_content_tree_data_; |
| 2651 |
| 2630 // Copy the common fields. | 2652 // Copy the common fields. |
| 2631 *dst = src; | 2653 *dst = src; |
| 2632 | 2654 |
| 2633 if (src.routing_id != -1) | 2655 if (src.routing_id != -1) |
| 2634 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); | 2656 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); |
| 2635 | 2657 |
| 2636 if (src.parent_routing_id != -1) | 2658 if (src.parent_routing_id != -1) |
| 2637 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); | 2659 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); |
| 2660 |
| 2661 // If this is not the root frame tree node, we're done. |
| 2662 if (frame_tree_node()->parent()) |
| 2663 return; |
| 2664 |
| 2665 // For the root frame tree node, also store the AXTreeID of the focused frame. |
| 2666 FrameTreeNode* focused_frame_tree_node = frame_tree_->GetFocusedFrame(); |
| 2667 if (!focused_frame_tree_node) |
| 2668 return; |
| 2669 RenderFrameHostImpl* focused_frame = |
| 2670 focused_frame_tree_node->current_frame_host(); |
| 2671 if (!focused_frame) |
| 2672 return; |
| 2673 dst->focused_tree_id = focused_frame->GetAXTreeID(); |
| 2638 } | 2674 } |
| 2639 | 2675 |
| 2640 } // namespace content | 2676 } // namespace content |
| OLD | NEW |