Chromium Code Reviews| Index: content/browser/frame_host/render_frame_host_impl.cc |
| diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc |
| index b6282abb783303809d986e8b4df9d4bff13f412c..4f9ff91a721312666aeb280894578a736991d967 100644 |
| --- a/content/browser/frame_host/render_frame_host_impl.cc |
| +++ b/content/browser/frame_host/render_frame_host_impl.cc |
| @@ -301,6 +301,15 @@ void NotifyForEachFrameFromUI( |
| base::Passed(std::move(routing_ids)))); |
| } |
| +void LookupRenderFrameHostOrProxy(int process_id, |
| + int routing_id, |
| + RenderFrameHostImpl** rfh, |
| + RenderFrameProxyHost** rfph) { |
| + *rfph = RenderFrameProxyHost::FromID(process_id, routing_id); |
|
Charlie Reis
2017/05/05 21:03:08
nit: Let's swap the order and do rfh first, just b
lpz
2017/05/10 14:21:09
Done.
|
| + if (*rfph == nullptr) |
| + *rfh = RenderFrameHostImpl::FromID(process_id, routing_id); |
| +} |
| + |
| } // namespace |
| // static |
| @@ -3528,32 +3537,43 @@ bool RenderFrameHostImpl::CanExecuteJavaScript() { |
| (delegate_->GetAsWebContents() == nullptr); |
| } |
| +// static |
| +int RenderFrameHost::GetFrameTreeNodeIdForRoutingId(int process_id, |
| + int routing_id) { |
| + RenderFrameHostImpl* rfh = nullptr; |
| + RenderFrameProxyHost* rfph = nullptr; |
| + LookupRenderFrameHostOrProxy(process_id, routing_id, &rfh, &rfph); |
| + if (rfph) { |
| + return rfph->frame_tree_node()->frame_tree_node_id(); |
| + } else if (rfh) { |
|
Charlie Reis
2017/05/05 21:03:08
nit: Let's swap the order and do the rfh branch fi
lpz
2017/05/10 14:21:09
Done.
|
| + return rfh->GetFrameTreeNodeId(); |
| + } |
| + |
| + return kNoFrameTreeNodeId; |
| +} |
| + |
| ui::AXTreeIDRegistry::AXTreeID RenderFrameHostImpl::RoutingIDToAXTreeID( |
| int routing_id) { |
| RenderFrameHostImpl* rfh = nullptr; |
| - RenderFrameProxyHost* rfph = RenderFrameProxyHost::FromID( |
| - GetProcess()->GetID(), routing_id); |
| + RenderFrameProxyHost* rfph = nullptr; |
| + LookupRenderFrameHostOrProxy(GetProcess()->GetID(), routing_id, &rfh, &rfph); |
| if (rfph) { |
| FrameTree* frame_tree = rfph->frame_tree_node()->frame_tree(); |
| FrameTreeNode* frame_tree_node = frame_tree->FindByRoutingID( |
| GetProcess()->GetID(), routing_id); |
| rfh = frame_tree_node->render_manager()->current_frame_host(); |
|
Charlie Reis
2017/05/05 21:03:08
Seems like we can clean up these 4 lines quite a b
lpz
2017/05/10 14:21:09
Done.
|
| - } else { |
| - rfh = RenderFrameHostImpl::FromID(GetProcess()->GetID(), routing_id); |
| - |
| - // As a sanity check, make sure we're within the same frame tree and |
| - // crash the renderer if not. |
| - if (rfh && |
| - rfh->frame_tree_node()->frame_tree() != |
| - frame_tree_node()->frame_tree()) { |
| - AccessibilityFatalError(); |
| - return ui::AXTreeIDRegistry::kNoAXTreeID; |
| - } |
| } |
| if (!rfh) |
| return ui::AXTreeIDRegistry::kNoAXTreeID; |
| + // As a sanity check, make sure we're within the same frame tree and |
| + // crash the renderer if not. |
| + if (rfh->frame_tree_node()->frame_tree() != frame_tree_node()->frame_tree()) { |
| + AccessibilityFatalError(); |
| + return ui::AXTreeIDRegistry::kNoAXTreeID; |
| + } |
| + |
| return rfh->GetAXTreeID(); |
| } |