Bug 1331509 - Extract a helper function to initialize the RenderFrameParent from TabParent. r=dvander
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 17 Jan 2017 15:52:45 -0500
changeset 374861 4d8dfb30875e59a6d35b4b7c0915b08788ec724f
parent 374860 5b6e3ddaa0894dccf93c381eae4d83b74f29818e
child 374862 570f8327ea9a11a0b33c9dddf43303da655cf484
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1331509
milestone53.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 1331509 - Extract a helper function to initialize the RenderFrameParent from TabParent. r=dvander MozReview-Commit-ID: KMcpSQUax6z
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -616,44 +616,53 @@ TabParent::LoadURL(nsIURI* aURI)
         mDelayedURL = spec;
         return;
     }
 
     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<nsFrameLoader> 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)
 {
     mDimensions = size;
     if (mIsDestroyed) {
         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<nsFrameLoader> 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<nsISupports> container = mFrameElement->OwnerDoc()->GetContainer();
     nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container);
     nsCOMPtr<nsIWidget> mainWidget;
     baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
     mSizeMode = mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal;
 
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -363,16 +363,18 @@ public:
 
   /**
    * Return the top level doc accessible parent for this tab.
    */
   a11y::DocAccessibleParent* GetTopLevelDocAccessible() const;
 
   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
   void Show(const ScreenIntSize& aSize, bool aParentIsActive);
 
   void UpdateDimensions(const nsIntRect& aRect, const ScreenIntSize& aSize);
 
   void SizeModeChanged(const nsSizeMode& aSizeMode);