diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index e5ab5ece00e2..bcc9310b3d5b 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -620,6 +620,29 @@ TabParent::LoadURL(nsIURI* aURI) Unused << SendLoadURL(spec, GetShowInfo()); } +void +TabParent::InitRenderFrame() +{ + if (IsInitedByParent()) { + // If TabParent is initialized by parent side then the RenderFrame must also + // be created here. If TabParent is initialized by child side, + // child side will create RenderFrame. + MOZ_ASSERT(!GetRenderFrame()); + RefPtr frameLoader = GetFrameLoader(); + if (frameLoader) { + bool success; + RenderFrameParent* renderFrame = new RenderFrameParent(frameLoader, &success); + uint64_t layersId = renderFrame->GetLayersId(); + AddTabParentToTable(layersId, this); + Unused << SendPRenderFrameConstructor(renderFrame); + } + } else { + // Otherwise, the child should have constructed the RenderFrame, + // and we should already know about it. + MOZ_ASSERT(GetRenderFrame()); + } +} + void TabParent::Show(const ScreenIntSize& size, bool aParentIsActive) { @@ -628,27 +651,13 @@ TabParent::Show(const ScreenIntSize& size, bool aParentIsActive) return; } + InitRenderFrame(); + + RenderFrameParent* renderFrame = IsInitedByParent() ? GetRenderFrame() : nullptr; + uint64_t layersId = renderFrame ? renderFrame->GetLayersId() : 0; TextureFactoryIdentifier textureFactoryIdentifier; - uint64_t layersId = 0; - bool success = false; - RenderFrameParent* renderFrame = nullptr; - if (IsInitedByParent()) { - // If TabParent is initialized by parent side then the RenderFrame must also - // be created here. If TabParent is initialized by child side, - // child side will create RenderFrame. - MOZ_ASSERT(!GetRenderFrame()); - RefPtr frameLoader = GetFrameLoader(); - if (frameLoader) { - renderFrame = new RenderFrameParent(frameLoader, &success); - layersId = renderFrame->GetLayersId(); - renderFrame->GetTextureFactoryIdentifier(&textureFactoryIdentifier); - AddTabParentToTable(layersId, this); - Unused << SendPRenderFrameConstructor(renderFrame); - } - } else { - // Otherwise, the child should have constructed the RenderFrame, - // and we should already know about it. - MOZ_ASSERT(GetRenderFrame()); + if (renderFrame) { + renderFrame->GetTextureFactoryIdentifier(&textureFactoryIdentifier); } nsCOMPtr container = mFrameElement->OwnerDoc()->GetContainer(); diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 6ad81196d0b7..a212b7686827 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -368,6 +368,8 @@ public: void LoadURL(nsIURI* aURI); + void InitRenderFrame(); + // XXX/cjones: it's not clear what we gain by hiding these // message-sending functions under a layer of indirection and // eating the return values