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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 RenderFrameHostImpl** out_parent_frame_host, | 154 RenderFrameHostImpl** out_parent_frame_host, |
155 int* out_accessibility_node_id) { | 155 int* out_accessibility_node_id) { |
156 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); | 156 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); |
157 iter != mappings_.end(); | 157 iter != mappings_.end(); |
158 ++iter) { | 158 ++iter) { |
159 if (iter->child_frame_tree_node_id) { | 159 if (iter->child_frame_tree_node_id) { |
160 FrameTreeNode* child_node = | 160 FrameTreeNode* child_node = |
161 FrameTree::GloballyFindByID(iter->child_frame_tree_node_id); | 161 FrameTree::GloballyFindByID(iter->child_frame_tree_node_id); |
162 if (child_node && | 162 if (child_node && |
163 child_node->current_frame_host() == child_frame_host) { | 163 child_node->current_frame_host() == child_frame_host) { |
164 // We should have gotten a *direct* child of the parent frame. | 164 // Assert that the child node is a descendant of the parent frame in |
165 if (child_node->parent() != | 165 // the frame tree. It may not be a direct descendant because the |
166 iter->parent_frame_host->frame_tree_node()) { | 166 // parent frame's accessibility tree may span multiple frames from the |
| 167 // same origin. |
| 168 FrameTreeNode* parent_node = iter->parent_frame_host->frame_tree_node(); |
| 169 FrameTreeNode* child_node_ancestor = child_node->parent(); |
| 170 while (child_node_ancestor && child_node_ancestor != parent_node) |
| 171 child_node_ancestor = child_node_ancestor->parent(); |
| 172 if (child_node_ancestor != parent_node) { |
167 NOTREACHED(); | 173 NOTREACHED(); |
168 return false; | 174 return false; |
169 } | 175 } |
170 | 176 |
171 if (out_parent_frame_host) | 177 if (out_parent_frame_host) |
172 *out_parent_frame_host = iter->parent_frame_host; | 178 *out_parent_frame_host = iter->parent_frame_host; |
173 if (out_accessibility_node_id) | 179 if (out_accessibility_node_id) |
174 *out_accessibility_node_id = iter->accessibility_node_id; | 180 *out_accessibility_node_id = iter->accessibility_node_id; |
175 return true; | 181 return true; |
176 } | 182 } |
(...skipping 17 matching lines...) Expand all Loading... |
194 } | 200 } |
195 | 201 |
196 RenderFrameHostImpl* FrameAccessibility::GetRFHIFromFrameTreeNodeId( | 202 RenderFrameHostImpl* FrameAccessibility::GetRFHIFromFrameTreeNodeId( |
197 RenderFrameHostImpl* parent_frame_host, | 203 RenderFrameHostImpl* parent_frame_host, |
198 int64 child_frame_tree_node_id) { | 204 int64 child_frame_tree_node_id) { |
199 FrameTreeNode* child_node = | 205 FrameTreeNode* child_node = |
200 FrameTree::GloballyFindByID(child_frame_tree_node_id); | 206 FrameTree::GloballyFindByID(child_frame_tree_node_id); |
201 if (!child_node) | 207 if (!child_node) |
202 return nullptr; | 208 return nullptr; |
203 | 209 |
204 // We should have gotten a *direct* child of the parent frame. | 210 // Assert that the child node is a descendant of the parent frame in |
205 if (child_node->parent() != parent_frame_host->frame_tree_node()) { | 211 // the frame tree. It may not be a direct descendant because the |
| 212 // parent frame's accessibility tree may span multiple frames from the |
| 213 // same origin. |
| 214 FrameTreeNode* parent_node = parent_frame_host->frame_tree_node(); |
| 215 FrameTreeNode* child_node_ancestor = child_node->parent(); |
| 216 while (child_node_ancestor && child_node_ancestor != parent_node) |
| 217 child_node_ancestor = child_node_ancestor->parent(); |
| 218 if (child_node_ancestor != parent_node) { |
206 NOTREACHED(); | 219 NOTREACHED(); |
207 return nullptr; | 220 return nullptr; |
208 } | 221 } |
209 | 222 |
210 return child_node->current_frame_host(); | 223 return child_node->current_frame_host(); |
211 } | 224 } |
212 | 225 |
213 } // namespace content | 226 } // namespace content |
OLD | NEW |