| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame_accessibility.h" | 5 #include "content/browser/frame_host/frame_accessibility.h" |
| 6 | 6 |
| 7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
| 8 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" |
| 9 #include "content/browser/frame_host/render_frame_host_delegate.h" | 9 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 10 #include "content/browser/frame_host/render_frame_host_impl.h" | 10 #include "content/browser/frame_host/render_frame_host_impl.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 child_frame_tree_node_id(0), | 23 child_frame_tree_node_id(0), |
| 24 browser_plugin_instance_id(0) {} | 24 browser_plugin_instance_id(0) {} |
| 25 | 25 |
| 26 FrameAccessibility::FrameAccessibility() {} | 26 FrameAccessibility::FrameAccessibility() {} |
| 27 | 27 |
| 28 FrameAccessibility::~FrameAccessibility() {} | 28 FrameAccessibility::~FrameAccessibility() {} |
| 29 | 29 |
| 30 void FrameAccessibility::AddChildFrame( | 30 void FrameAccessibility::AddChildFrame( |
| 31 RenderFrameHostImpl* parent_frame_host, | 31 RenderFrameHostImpl* parent_frame_host, |
| 32 int accessibility_node_id, | 32 int accessibility_node_id, |
| 33 int64 child_frame_tree_node_id) { | 33 int child_frame_tree_node_id) { |
| 34 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); | 34 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); |
| 35 iter != mappings_.end(); | 35 iter != mappings_.end(); |
| 36 ++iter) { | 36 ++iter) { |
| 37 // TODO(dmazzoni): the renderer should keep track of these mappings | 37 // TODO(dmazzoni): the renderer should keep track of these mappings |
| 38 // and clear an existing mapping before setting a new one, that would | 38 // and clear an existing mapping before setting a new one, that would |
| 39 // be safer than just updating existing mappings. http://crbug.com/413464 | 39 // be safer than just updating existing mappings. http://crbug.com/413464 |
| 40 if (iter->parent_frame_host == parent_frame_host && | 40 if (iter->parent_frame_host == parent_frame_host && |
| 41 (iter->accessibility_node_id == accessibility_node_id || | 41 (iter->accessibility_node_id == accessibility_node_id || |
| 42 iter->child_frame_tree_node_id == child_frame_tree_node_id)) { | 42 iter->child_frame_tree_node_id == child_frame_tree_node_id)) { |
| 43 iter->accessibility_node_id = accessibility_node_id; | 43 iter->accessibility_node_id = accessibility_node_id; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 return true; | 197 return true; |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 return false; | 202 return false; |
| 203 } | 203 } |
| 204 | 204 |
| 205 RenderFrameHostImpl* FrameAccessibility::GetRFHIFromFrameTreeNodeId( | 205 RenderFrameHostImpl* FrameAccessibility::GetRFHIFromFrameTreeNodeId( |
| 206 RenderFrameHostImpl* parent_frame_host, | 206 RenderFrameHostImpl* parent_frame_host, |
| 207 int64 child_frame_tree_node_id) { | 207 int child_frame_tree_node_id) { |
| 208 FrameTreeNode* child_node = | 208 FrameTreeNode* child_node = |
| 209 FrameTreeNode::GloballyFindByID(child_frame_tree_node_id); | 209 FrameTreeNode::GloballyFindByID(child_frame_tree_node_id); |
| 210 if (!child_node) | 210 if (!child_node) |
| 211 return nullptr; | 211 return nullptr; |
| 212 | 212 |
| 213 // Assert that the child node is a descendant of the parent frame in | 213 // Assert that the child node is a descendant of the parent frame in |
| 214 // the frame tree. It may not be a direct descendant because the | 214 // the frame tree. It may not be a direct descendant because the |
| 215 // parent frame's accessibility tree may span multiple frames from the | 215 // parent frame's accessibility tree may span multiple frames from the |
| 216 // same origin. | 216 // same origin. |
| 217 FrameTreeNode* parent_node = parent_frame_host->frame_tree_node(); | 217 FrameTreeNode* parent_node = parent_frame_host->frame_tree_node(); |
| 218 FrameTreeNode* child_node_ancestor = child_node->parent(); | 218 FrameTreeNode* child_node_ancestor = child_node->parent(); |
| 219 while (child_node_ancestor && child_node_ancestor != parent_node) | 219 while (child_node_ancestor && child_node_ancestor != parent_node) |
| 220 child_node_ancestor = child_node_ancestor->parent(); | 220 child_node_ancestor = child_node_ancestor->parent(); |
| 221 if (child_node_ancestor != parent_node) { | 221 if (child_node_ancestor != parent_node) { |
| 222 NOTREACHED(); | 222 NOTREACHED(); |
| 223 return nullptr; | 223 return nullptr; |
| 224 } | 224 } |
| 225 | 225 |
| 226 return child_node->current_frame_host(); | 226 return child_node->current_frame_host(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace content | 229 } // namespace content |
| OLD | NEW |