Bug 1525720, part 1 - Allow calling BrowserParent::InitRendering multiple times, and remove RenderFrame dependency from nsFrameLoader. r=kats
☠☠ backed out by f287bb6c1894 ☠ ☠
authorRyan Hunt <rhunt@eqrion.net>
Wed, 24 Apr 2019 22:36:27 -0500
changeset 474954 00d83f1d02e015735d580045524eceeeccdc4e28
parent 474953 bdd76368ddc15c25c10527bd1afd2b8e9c46dbee
child 474955 5f1c1b609ec1ecc28734e1b6daeeb3f6854ded38
push id113182
push userrhunt@eqrion.net
push dateWed, 22 May 2019 20:02:12 +0000
treeherdermozilla-inbound@9b79caa460a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1525720
milestone69.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 1525720, part 1 - Allow calling BrowserParent::InitRendering multiple times, and remove RenderFrame dependency from nsFrameLoader. r=kats This cleanup will simplify refactoring nsFrameLoader later. Differential Revision: https://phabricator.services.mozilla.com/D31429
dom/base/nsFrameLoader.cpp
dom/ipc/BrowserParent.cpp
dom/ipc/BrowserParent.h
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1058,25 +1058,20 @@ bool nsFrameLoader::ShowRemoteFrame(cons
           mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal;
 
       Unused << mBrowserBridgeChild->SendShow(
           size, ParentWindowIsActive(mOwnerContent->OwnerDoc()), sizeMode);
       mRemoteBrowserShown = true;
       return true;
     }
 
-    RenderFrame* rf =
-        mBrowserParent ? mBrowserParent->GetRenderFrame() : nullptr;
-
-    if (!rf || !rf->AttachLayerManager()) {
-      // This is just not going to work.
+    if (!mBrowserParent->Show(
+            size, ParentWindowIsActive(mOwnerContent->OwnerDoc()))) {
       return false;
     }
-
-    mBrowserParent->Show(size, ParentWindowIsActive(mOwnerContent->OwnerDoc()));
     mRemoteBrowserShown = true;
 
     nsCOMPtr<nsIObserverService> os = services::GetObserverService();
     if (os) {
       os->NotifyObservers(ToSupports(this), "remote-browser-shown", nullptr);
     }
   } else {
     nsIntRect dimensions;
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -879,19 +879,20 @@ void BrowserParent::ResumeLoad(uint64_t 
   if (NS_WARN_IF(mIsDestroyed)) {
     return;
   }
 
   Unused << SendResumeLoad(aPendingSwitchID, GetShowInfo());
 }
 
 void BrowserParent::InitRendering() {
-  MOZ_ASSERT(!mRenderFrame.IsInitialized());
+  if (mRenderFrame.IsInitialized()) {
+    return;
+  }
   mRenderFrame.Initialize(this);
-  MOZ_ASSERT(mRenderFrame.IsInitialized());
 
   layers::LayersId layersId = mRenderFrame.GetLayersId();
   AddBrowserParentToTable(layersId, this);
 
   TextureFactoryIdentifier textureFactoryIdentifier;
   mRenderFrame.GetTextureFactoryIdentifier(&textureFactoryIdentifier);
   Unused << SendInitRendering(textureFactoryIdentifier, layersId,
                               mRenderFrame.GetCompositorOptions(),
@@ -901,31 +902,35 @@ void BrowserParent::InitRendering() {
 void BrowserParent::MaybeShowFrame() {
   RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
   if (!frameLoader) {
     return;
   }
   frameLoader->MaybeShowFrame();
 }
 
-void BrowserParent::Show(const ScreenIntSize& size, bool aParentIsActive) {
+bool BrowserParent::Show(const ScreenIntSize& size, bool aParentIsActive) {
   mDimensions = size;
   if (mIsDestroyed) {
-    return;
+    return false;
   }
 
   MOZ_ASSERT(mRenderFrame.IsInitialized());
+  if (!mRenderFrame.AttachLayerManager()) {
+    return false;
+  }
 
   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;
 
   Unused << SendShow(size, GetShowInfo(), aParentIsActive, mSizeMode);
+  return true;
 }
 
 mozilla::ipc::IPCResult BrowserParent::RecvSetDimensions(const uint32_t& aFlags,
                                                          const int32_t& aX,
                                                          const int32_t& aY,
                                                          const int32_t& aCx,
                                                          const int32_t& aCy) {
   MOZ_ASSERT(!(aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER),
--- a/dom/ipc/BrowserParent.h
+++ b/dom/ipc/BrowserParent.h
@@ -458,20 +458,17 @@ class BrowserParent final : public PBrow
 
   void LoadURL(nsIURI* aURI);
 
   void ResumeLoad(uint64_t aPendingSwitchID);
 
   void InitRendering();
   void MaybeShowFrame();
 
-  // 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);
+  bool Show(const ScreenIntSize& aSize, bool aParentIsActive);
 
   void UpdateDimensions(const nsIntRect& aRect, const ScreenIntSize& aSize);
 
   DimensionInfo GetDimensionInfo();
 
   nsresult UpdatePosition();
 
   void SizeModeChanged(const nsSizeMode& aSizeMode);