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 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 std::vector<AXEventNotificationDetails> details; | 1602 std::vector<AXEventNotificationDetails> details; |
1603 details.reserve(params.size()); | 1603 details.reserve(params.size()); |
1604 for (size_t i = 0; i < params.size(); ++i) { | 1604 for (size_t i = 0; i < params.size(); ++i) { |
1605 const AccessibilityHostMsg_EventParams& param = params[i]; | 1605 const AccessibilityHostMsg_EventParams& param = params[i]; |
1606 AXEventNotificationDetails detail; | 1606 AXEventNotificationDetails detail; |
1607 detail.event_type = param.event_type; | 1607 detail.event_type = param.event_type; |
1608 detail.id = param.id; | 1608 detail.id = param.id; |
1609 detail.ax_tree_id = GetAXTreeID(); | 1609 detail.ax_tree_id = GetAXTreeID(); |
1610 if (param.update.has_tree_data) { | 1610 if (param.update.has_tree_data) { |
1611 detail.update.has_tree_data = true; | 1611 detail.update.has_tree_data = true; |
1612 AXContentTreeDataToAXTreeData(param.update.tree_data, | 1612 ax_content_tree_data_ = param.update.tree_data; |
1613 &detail.update.tree_data); | 1613 AXContentTreeDataToAXTreeData(&detail.update.tree_data); |
1614 } | 1614 } |
1615 detail.update.node_id_to_clear = param.update.node_id_to_clear; | 1615 detail.update.node_id_to_clear = param.update.node_id_to_clear; |
1616 detail.update.nodes.resize(param.update.nodes.size()); | 1616 detail.update.nodes.resize(param.update.nodes.size()); |
1617 for (size_t i = 0; i < param.update.nodes.size(); ++i) { | 1617 for (size_t i = 0; i < param.update.nodes.size(); ++i) { |
1618 AXContentNodeDataToAXNodeData(param.update.nodes[i], | 1618 AXContentNodeDataToAXNodeData(param.update.nodes[i], |
1619 &detail.update.nodes[i]); | 1619 &detail.update.nodes[i]); |
1620 } | 1620 } |
1621 details.push_back(detail); | 1621 details.push_back(detail); |
1622 } | 1622 } |
1623 | 1623 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 const AXContentTreeUpdate& snapshot) { | 1696 const AXContentTreeUpdate& snapshot) { |
1697 const auto& it = ax_tree_snapshot_callbacks_.find(callback_id); | 1697 const auto& it = ax_tree_snapshot_callbacks_.find(callback_id); |
1698 if (it != ax_tree_snapshot_callbacks_.end()) { | 1698 if (it != ax_tree_snapshot_callbacks_.end()) { |
1699 ui::AXTreeUpdate dst_snapshot; | 1699 ui::AXTreeUpdate dst_snapshot; |
1700 dst_snapshot.nodes.resize(snapshot.nodes.size()); | 1700 dst_snapshot.nodes.resize(snapshot.nodes.size()); |
1701 for (size_t i = 0; i < snapshot.nodes.size(); ++i) { | 1701 for (size_t i = 0; i < snapshot.nodes.size(); ++i) { |
1702 AXContentNodeDataToAXNodeData(snapshot.nodes[i], | 1702 AXContentNodeDataToAXNodeData(snapshot.nodes[i], |
1703 &dst_snapshot.nodes[i]); | 1703 &dst_snapshot.nodes[i]); |
1704 } | 1704 } |
1705 if (snapshot.has_tree_data) { | 1705 if (snapshot.has_tree_data) { |
1706 AXContentTreeDataToAXTreeData(snapshot.tree_data, | 1706 ax_content_tree_data_ = snapshot.tree_data; |
1707 &dst_snapshot.tree_data); | 1707 AXContentTreeDataToAXTreeData(&dst_snapshot.tree_data); |
1708 dst_snapshot.has_tree_data = true; | 1708 dst_snapshot.has_tree_data = true; |
1709 } | 1709 } |
1710 it->second.Run(dst_snapshot); | 1710 it->second.Run(dst_snapshot); |
1711 ax_tree_snapshot_callbacks_.erase(it); | 1711 ax_tree_snapshot_callbacks_.erase(it); |
1712 } else { | 1712 } else { |
1713 NOTREACHED() << "Received AX tree snapshot response for unknown id"; | 1713 NOTREACHED() << "Received AX tree snapshot response for unknown id"; |
1714 } | 1714 } |
1715 } | 1715 } |
1716 | 1716 |
1717 void RenderFrameHostImpl::OnToggleFullscreen(bool enter_fullscreen) { | 1717 void RenderFrameHostImpl::OnToggleFullscreen(bool enter_fullscreen) { |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2314 int callback_id = next_id++; | 2314 int callback_id = next_id++; |
2315 Send(new AccessibilityMsg_SnapshotTree(routing_id_, callback_id)); | 2315 Send(new AccessibilityMsg_SnapshotTree(routing_id_, callback_id)); |
2316 ax_tree_snapshot_callbacks_.insert(std::make_pair(callback_id, callback)); | 2316 ax_tree_snapshot_callbacks_.insert(std::make_pair(callback_id, callback)); |
2317 } | 2317 } |
2318 | 2318 |
2319 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( | 2319 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( |
2320 const base::Callback<void(ui::AXEvent, int)>& callback) { | 2320 const base::Callback<void(ui::AXEvent, int)>& callback) { |
2321 accessibility_testing_callback_ = callback; | 2321 accessibility_testing_callback_ = callback; |
2322 } | 2322 } |
2323 | 2323 |
| 2324 void RenderFrameHostImpl::UpdateAXTreeData() { |
| 2325 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
| 2326 if (accessibility_mode == AccessibilityModeOff || |
| 2327 !RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { |
| 2328 return; |
| 2329 } |
| 2330 |
| 2331 std::vector<AXEventNotificationDetails> details; |
| 2332 details.reserve(1U); |
| 2333 AXEventNotificationDetails detail; |
| 2334 detail.ax_tree_id = GetAXTreeID(); |
| 2335 detail.update.has_tree_data = true; |
| 2336 AXContentTreeDataToAXTreeData(&detail.update.tree_data); |
| 2337 details.push_back(detail); |
| 2338 |
| 2339 if (browser_accessibility_manager_) |
| 2340 browser_accessibility_manager_->OnAccessibilityEvents(details); |
| 2341 |
| 2342 delegate_->AccessibilityEventReceived(details); |
| 2343 } |
| 2344 |
2324 void RenderFrameHostImpl::SetTextTrackSettings( | 2345 void RenderFrameHostImpl::SetTextTrackSettings( |
2325 const FrameMsg_TextTrackSettings_Params& params) { | 2346 const FrameMsg_TextTrackSettings_Params& params) { |
2326 DCHECK(!GetParent()); | 2347 DCHECK(!GetParent()); |
2327 Send(new FrameMsg_SetTextTrackSettings(routing_id_, params)); | 2348 Send(new FrameMsg_SetTextTrackSettings(routing_id_, params)); |
2328 } | 2349 } |
2329 | 2350 |
2330 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { | 2351 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { |
2331 return ax_tree_for_testing_.get(); | 2352 return ax_tree_for_testing_.get(); |
2332 } | 2353 } |
2333 | 2354 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2596 BrowserPluginInstanceIDToAXTreeID(value))); | 2617 BrowserPluginInstanceIDToAXTreeID(value))); |
2597 break; | 2618 break; |
2598 case AX_CONTENT_INT_ATTRIBUTE_LAST: | 2619 case AX_CONTENT_INT_ATTRIBUTE_LAST: |
2599 NOTREACHED(); | 2620 NOTREACHED(); |
2600 break; | 2621 break; |
2601 } | 2622 } |
2602 } | 2623 } |
2603 } | 2624 } |
2604 | 2625 |
2605 void RenderFrameHostImpl::AXContentTreeDataToAXTreeData( | 2626 void RenderFrameHostImpl::AXContentTreeDataToAXTreeData( |
2606 const AXContentTreeData& src, | |
2607 ui::AXTreeData* dst) { | 2627 ui::AXTreeData* dst) { |
| 2628 const AXContentTreeData& src = ax_content_tree_data_; |
| 2629 |
2608 // Copy the common fields. | 2630 // Copy the common fields. |
2609 *dst = src; | 2631 *dst = src; |
2610 | 2632 |
2611 if (src.routing_id != -1) | 2633 if (src.routing_id != -1) |
2612 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); | 2634 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); |
2613 | 2635 |
2614 if (src.parent_routing_id != -1) | 2636 if (src.parent_routing_id != -1) |
2615 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); | 2637 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); |
| 2638 |
| 2639 // If this is not the root frame tree node, we're done. |
| 2640 if (frame_tree_node()->parent()) |
| 2641 return; |
| 2642 |
| 2643 // For the root frame tree node, also store the AXTreeID of the focused frame. |
| 2644 FrameTreeNode* focused_frame_tree_node = frame_tree_->GetFocusedFrame(); |
| 2645 if (!focused_frame_tree_node) |
| 2646 return; |
| 2647 RenderFrameHostImpl* focused_frame = |
| 2648 focused_frame_tree_node->current_frame_host(); |
| 2649 if (!focused_frame) |
| 2650 return; |
| 2651 dst->focused_tree_id = focused_frame->GetAXTreeID(); |
2616 } | 2652 } |
2617 | 2653 |
2618 } // namespace content | 2654 } // namespace content |
OLD | NEW |