Index: content/renderer/render_frame_impl.cc |
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
index 9e432ba9394f11a708bce49a6d40d9c62c5f3a65..c05235557ab687f24074fb4b26c6eb0a896ef852 100644 |
--- a/content/renderer/render_frame_impl.cc |
+++ b/content/renderer/render_frame_impl.cc |
@@ -699,6 +699,9 @@ void RenderFrameImpl::CreateFrame( |
replicated_state.scope, WebString::fromUTF8(replicated_state.name), |
replicated_state.sandbox_flags, render_frame, |
previous_sibling_web_frame, frame_owner_properties); |
+ // Since the RenderFrame is created and inserted into the frame tree in the |
+ // above call to createLocalChild, ensure the state is set properly. |
Charlie Reis
2015/12/11 00:03:17
nit: Drop "Since" and "ensure the state is set pro
nasko
2015/12/11 00:47:25
Done.
|
+ render_frame->in_frame_tree_ = true; |
nasko
2015/12/10 21:26:52
Charlie: This is newly added code, which was promp
Charlie Reis
2015/12/11 00:03:17
Acknowledged.
|
} else { |
RenderFrameProxy* proxy = |
RenderFrameProxy::FromRoutingID(proxy_routing_id); |
@@ -736,6 +739,13 @@ void RenderFrameImpl::CreateFrame( |
} |
// static |
+void RenderFrameImpl::DetachFrame(int routing_id) { |
Charlie Reis
2015/12/11 00:03:17
Is this ever meant to be called when in_frame_tree
nasko
2015/12/11 00:47:25
With my latest change it is supposed to. It detach
Charlie Reis
2015/12/11 00:47:40
Nick had an idea for this. If we get here when is
Charlie Reis
2015/12/11 20:10:11
This sounds like it's still bad, right? We could
|
+ RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id); |
+ frame->set_in_browser_initiated_detach(); |
+ frame->GetWebFrame()->detach(); |
+} |
+ |
+// static |
RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { |
return RenderFrameImpl::FromWebFrame(web_frame); |
} |
@@ -797,6 +807,9 @@ blink::WebFrame* RenderFrameImpl::ResolveOpener(int opener_frame_routing_id, |
RenderFrameImpl::RenderFrameImpl(const CreateParams& params) |
: frame_(NULL), |
is_main_frame_(true), |
+ is_local_root_(false), |
+ in_browser_initiated_detach_(false), |
+ in_frame_tree_(false), |
render_view_(params.render_view->AsWeakPtr()), |
routing_id_(params.routing_id), |
is_swapped_out_(false), |
@@ -2438,6 +2451,7 @@ blink::WebFrame* RenderFrameImpl::createChildFrame( |
// Add the frame to the frame tree and initialize it. |
parent->appendChild(web_frame); |
+ child_render_frame->in_frame_tree_ = true; |
child_render_frame->Initialize(); |
return web_frame; |
@@ -2469,9 +2483,8 @@ void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) { |
FrameDetached(frame)); |
// We only notify the browser process when the frame is being detached for |
- // removal. If the frame is being detached for swap, we don't need to do this |
- // since we are not modifiying the frame tree. |
- if (type == DetachType::Remove) |
+ // removal and it was initiated from the renderer process. |
+ if (!in_browser_initiated_detach_ && type == DetachType::Remove) |
Send(new FrameHostMsg_Detach(routing_id_)); |
// The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be |
@@ -2494,10 +2507,13 @@ void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) { |
g_frame_map.Get().erase(it); |
// Only remove the frame from the renderer's frame tree if the frame is |
- // being detached for removal. In the case of a swap, the frame needs to |
- // remain in the tree so WebFrame::swap() can replace it with the new frame. |
- if (!is_main_frame_ && type == DetachType::Remove) |
+ // being detached for removal and is already inserted in the frame tree. |
+ // In the case of a swap, the frame needs to remain in the tree so |
+ // WebFrame::swap() can replace it with the new frame. |
+ if (!is_main_frame_ && in_frame_tree_ && |
+ type == DetachType::Remove) { |
frame->parent()->removeChild(frame); |
+ } |
// |frame| is invalid after here. Be sure to clear frame_ as well, since this |
// object may not be deleted immediately and other methods may try to access |
@@ -2926,6 +2942,7 @@ void RenderFrameImpl::didCommitProvisionalLoad( |
CHECK(proxy); |
proxy->web_frame()->swap(frame_); |
proxy_routing_id_ = MSG_ROUTING_NONE; |
+ in_frame_tree_ = true; |
// If this is the main frame going from a remote frame to a local frame, |
// it needs to set RenderViewImpl's pointer for the main frame to itself |