diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index fba6f69abbb1cba2cae032e880d64f98f41c8711..a663dfffebe354a45135dc58da784eca22deca9f 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -227,9 +227,12 @@ parent: * Create a layout frame (encapsulating a remote layer tree) for * the page that is currently loaded in the <browser>. */ - sync PRenderFrame() + sync PRenderFrame(); + + sync InitRenderFrame(PRenderFrame aFrame) returns (ScrollingBehavior scrolling, - TextureFactoryIdentifier textureFactoryIdentifier, uint64_t layersId); + TextureFactoryIdentifier textureFactoryIdentifier, uint64_t layersId, + bool success); /** * Starts an offline application cache update. diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 40af3079f3d5f3be79087212d2163b7a59031e0f..104e4090fc58fddb58c27166d5d8fcced78e3b50 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -2195,9 +2195,7 @@ TabChild::RecvSetUpdateHitRegion(const bool& aEnabled) } PRenderFrameChild* -TabChild::AllocPRenderFrameChild(ScrollingBehavior* aScrolling, - TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aLayersId) +TabChild::AllocPRenderFrameChild() { return new RenderFrameChild(); } @@ -2254,12 +2252,18 @@ TabChild::InitRenderingState() static_cast<PuppetWidget*>(mWidget.get())->InitIMEState(); uint64_t id; + bool success; RenderFrameChild* remoteFrame = - static_cast<RenderFrameChild*>(SendPRenderFrameConstructor( - &mScrolling, &mTextureFactoryIdentifier, &id)); + static_cast<RenderFrameChild*>(SendPRenderFrameConstructor()); if (!remoteFrame) { - NS_WARNING("failed to construct RenderFrame"); - return false; + NS_WARNING("failed to construct RenderFrame"); + return false; + } + SendInitRenderFrame(remoteFrame, &mScrolling, &mTextureFactoryIdentifier, &id, &success); + if (!success) { + NS_WARNING("failed to construct RenderFrame"); + PRenderFrameChild::Send__delete__(remoteFrame); + return false; } PLayerTransactionChild* shadowManager = nullptr; diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index a4542ce97ff9aba57c2c26ef73dc91ea08e7be6e..abad7d9a6246ecde6e5c9524875ee1b4eaa39364 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -367,9 +367,7 @@ public: } protected: - virtual PRenderFrameChild* AllocPRenderFrameChild(ScrollingBehavior* aScrolling, - TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aLayersId) MOZ_OVERRIDE; + virtual PRenderFrameChild* AllocPRenderFrameChild() MOZ_OVERRIDE; virtual bool DeallocPRenderFrameChild(PRenderFrameChild* aFrame) MOZ_OVERRIDE; virtual bool RecvDestroy() MOZ_OVERRIDE; virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) MOZ_OVERRIDE; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 16dcea38413b38600baa48f308114d25e1707afe..9a3aa6bbab3b680fba7a314d1e1ed8b2b2f10704 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -1525,23 +1525,36 @@ TabParent::HandleDelayedDialogs() } } -PRenderFrameParent* -TabParent::AllocPRenderFrameParent(ScrollingBehavior* aScrolling, - TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aLayersId) +bool +TabParent::RecvInitRenderFrame(PRenderFrameParent* aFrame, + ScrollingBehavior* aScrolling, + TextureFactoryIdentifier* aTextureFactoryIdentifier, + uint64_t* aLayersId, + bool *aSuccess) { - MOZ_ASSERT(ManagedPRenderFrameParent().IsEmpty()); + *aScrolling = UseAsyncPanZoom() ? ASYNC_PAN_ZOOM : DEFAULT_SCROLLING; + *aTextureFactoryIdentifier = TextureFactoryIdentifier(); + *aLayersId = 0; nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader(); if (!frameLoader) { - NS_WARNING("Can't allocate graphics resources, aborting subprocess"); - return nullptr; + NS_WARNING("Can't allocate graphics resources. May already be shutting down."); + *aSuccess = false; + return true; } - *aScrolling = UseAsyncPanZoom() ? ASYNC_PAN_ZOOM : DEFAULT_SCROLLING; - return new RenderFrameParent(frameLoader, - *aScrolling, - aTextureFactoryIdentifier, aLayersId); + static_cast<RenderFrameParent*>(aFrame)->Init(frameLoader, *aScrolling, + aTextureFactoryIdentifier, aLayersId); + + *aSuccess = true; + return true; +} + +PRenderFrameParent* +TabParent::AllocPRenderFrameParent() +{ + MOZ_ASSERT(ManagedPRenderFrameParent().IsEmpty()); + return new RenderFrameParent(); } bool @@ -1692,10 +1705,7 @@ TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener, } bool -TabParent::RecvPRenderFrameConstructor(PRenderFrameParent* actor, - ScrollingBehavior* scrolling, - TextureFactoryIdentifier* factoryIdentifier, - uint64_t* layersId) +TabParent::RecvPRenderFrameConstructor(PRenderFrameParent* actor) { return true; } diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 88361ad35b5836afb75cba839098e77fa1a4e050..1b38e567c33053c74624c91bd48c5a0270515e96 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -112,10 +112,12 @@ public: virtual bool RecvMoveFocus(const bool& aForward); virtual bool RecvEvent(const RemoteDOMEvent& aEvent); - virtual bool RecvPRenderFrameConstructor(PRenderFrameParent* actor, - ScrollingBehavior* scrolling, - TextureFactoryIdentifier* identifier, - uint64_t* layersId); + virtual bool RecvPRenderFrameConstructor(PRenderFrameParent* actor); + virtual bool RecvInitRenderFrame(PRenderFrameParent* aFrame, + ScrollingBehavior* scrolling, + TextureFactoryIdentifier* identifier, + uint64_t* layersId, + bool *aSuccess); virtual bool RecvBrowserFrameOpenWindow(PBrowserParent* aOpener, const nsString& aURL, const nsString& aName, @@ -312,9 +314,7 @@ protected: bool ShouldDelayDialogs(); bool AllowContentIME(); - virtual PRenderFrameParent* AllocPRenderFrameParent(ScrollingBehavior* aScrolling, - TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aLayersId) MOZ_OVERRIDE; + virtual PRenderFrameParent* AllocPRenderFrameParent() MOZ_OVERRIDE; virtual bool DeallocPRenderFrameParent(PRenderFrameParent* aFrame) MOZ_OVERRIDE; // IME diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index 077a5ddd22973649d99fc3b0a8260b46dd2c0349..5a11edfeee73606771b1d657c81d378bd73c60de 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -670,15 +670,21 @@ private: ZoomConstraints mZoomConstraints; }; -RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader, - ScrollingBehavior aScrollingBehavior, - TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aId) +RenderFrameParent::RenderFrameParent() : mLayersId(0) - , mFrameLoader(aFrameLoader) , mFrameLoaderDestroyed(false) , mBackgroundColor(gfxRGBA(1, 1, 1)) { +} + +void +RenderFrameParent::Init(nsFrameLoader* aFrameLoader, + ScrollingBehavior aScrollingBehavior, + TextureFactoryIdentifier* aTextureFactoryIdentifier, + uint64_t* aId) +{ + mFrameLoader = aFrameLoader; + *aId = 0; nsRefPtr<LayerManager> lm = GetFrom(mFrameLoader); diff --git a/layout/ipc/RenderFrameParent.h b/layout/ipc/RenderFrameParent.h index 9289db955ecd9470a4c823591c025dc1db54e183..365ebb0daa6bae2f3c667dd9bb1c3a8b47683682 100644 --- a/layout/ipc/RenderFrameParent.h +++ b/layout/ipc/RenderFrameParent.h @@ -55,16 +55,20 @@ class RenderFrameParent : public PRenderFrameParent, public: typedef std::map<ViewID, nsRefPtr<nsContentView> > ViewMap; + /* Init should be called immediately after allocation. */ + RenderFrameParent(); + virtual ~RenderFrameParent(); + /** * Select the desired scrolling behavior. If ASYNC_PAN_ZOOM is * chosen, then RenderFrameParent will watch input events and use * them to asynchronously pan and zoom. */ - RenderFrameParent(nsFrameLoader* aFrameLoader, - ScrollingBehavior aScrollingBehavior, - TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aId); - virtual ~RenderFrameParent(); + void + Init(nsFrameLoader* aFrameLoader, + ScrollingBehavior aScrollingBehavior, + TextureFactoryIdentifier* aTextureFactoryIdentifier, + uint64_t* aId); void Destroy();