Bug 1251032 - Make it possible to assign a frameloader to RenderFrameParent after construction. r=kanru
authorMike Conley <mconley@mozilla.com>
Tue, 29 Mar 2016 12:49:07 -0400
changeset 291881 736edb6b89247066c7131852e965bb4ca3986695
parent 291880 797ae7f4a0b147d7171380379751ca4c9a288a00
child 291882 31f191d9708903fe6403539e4b7ace0f7551f2f5
push id74708
push usermconley@mozilla.com
push dateWed, 06 Apr 2016 13:24:03 +0000
treeherdermozilla-inbound@5acaba393ffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskanru
bugs1251032
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1251032 - Make it possible to assign a frameloader to RenderFrameParent after construction. r=kanru MozReview-Commit-ID: 4a8fzR7Vpac
layout/ipc/RenderFrameParent.cpp
layout/ipc/RenderFrameParent.h
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -86,43 +86,60 @@ GetFrom(nsFrameLoader* aFrameLoader)
   return nsContentUtils::LayerManagerForDocument(doc);
 }
 
 RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader, bool* aSuccess)
   : mLayersId(0)
   , mFrameLoader(aFrameLoader)
   , mFrameLoaderDestroyed(false)
   , mAsyncPanZoomEnabled(false)
+  , mInitted(false)
 {
-  *aSuccess = false;
-  if (!mFrameLoader) {
-    return;
+  mInitted = Init(aFrameLoader);
+  *aSuccess = mInitted;
+}
+
+RenderFrameParent::~RenderFrameParent()
+{}
+
+bool
+RenderFrameParent::Init(nsFrameLoader* aFrameLoader)
+{
+  if (mInitted || !aFrameLoader) {
+    return false;
   }
 
+  mFrameLoader = aFrameLoader;
+
   RefPtr<LayerManager> lm = GetFrom(mFrameLoader);
 
   mAsyncPanZoomEnabled = lm && lm->AsyncPanZoomEnabled();
 
   TabParent* browser = TabParent::GetFrom(mFrameLoader);
   if (XRE_IsParentProcess()) {
     // Our remote frame will push layers updates to the compositor,
     // and we'll keep an indirect reference to that tree.
     browser->Manager()->AsContentParent()->AllocateLayerTreeId(browser, &mLayersId);
     if (lm && lm->AsClientLayerManager()) {
       lm->AsClientLayerManager()->GetRemoteRenderer()->SendNotifyChildCreated(mLayersId);
     }
   } else if (XRE_IsContentProcess()) {
     ContentChild::GetSingleton()->SendAllocateLayerTreeId(browser->Manager()->ChildID(), browser->GetTabId(), &mLayersId);
     CompositorBridgeChild::Get()->SendNotifyChildCreated(mLayersId);
   }
-  *aSuccess = true;
+
+  mInitted = true;
+  return true;
 }
 
-RenderFrameParent::~RenderFrameParent()
-{}
+bool
+RenderFrameParent::IsInitted()
+{
+  return mInitted;
+}
 
 void
 RenderFrameParent::Destroy()
 {
   mFrameLoaderDestroyed = true;
 }
 
 already_AddRefed<Layer>
--- a/layout/ipc/RenderFrameParent.h
+++ b/layout/ipc/RenderFrameParent.h
@@ -54,16 +54,18 @@ public:
   /**
    * 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, bool* aSuccess);
   virtual ~RenderFrameParent();
 
+  bool Init(nsFrameLoader* aFrameLoader);
+  bool IsInitted();
   void Destroy();
 
   void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                         nsSubDocumentFrame* aFrame,
                         const nsRect& aDirtyRect,
                         const nsDisplayListSet& aLists);
 
   already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
@@ -120,16 +122,17 @@ private:
   // 
   // It's possible for mFrameLoader==null and
   // mFrameLoaderDestroyed==false.
   bool mFrameLoaderDestroyed;
 
   nsRegion mTouchRegion;
 
   bool mAsyncPanZoomEnabled;
+  bool mInitted;
 };
 
 } // namespace layout
 } // namespace mozilla
 
 /**
  * A DisplayRemote exists solely to graft a child process's shadow
  * layer tree (for a given RenderFrameParent) into its parent