From 4a2b6d05a14836ef2bf811c6985e11e1d53b4c48 Mon Sep 17 00:00:00 2001 From: Ting-Yu Chou Date: Tue, 7 Apr 2015 10:56:10 +0800 Subject: [PATCH] Bug 1121905 - Reorder frame loading sequence to send content process the URL earlier. r=kanru --- dom/base/nsFrameLoader.cpp | 76 +++++++++++++++++++------------------- dom/ipc/TabChild.cpp | 4 ++ dom/ipc/TabParent.cpp | 10 ----- dom/ipc/TabParent.h | 1 - 4 files changed, 41 insertions(+), 50 deletions(-) diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 32710efbe26..207bc5a215f 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -340,19 +340,18 @@ nsFrameLoader::ReallyStartLoadingInternal() } if (mRemoteFrame) { - if (!mRemoteBrowser) { - TryRemoteBrowser(); - - if (!mRemoteBrowser) { + if (!mRemoteBrowser && !TryRemoteBrowser()) { NS_WARNING("Couldn't create child process for iframe."); return NS_ERROR_FAILURE; - } } - if (mRemoteBrowserShown || ShowRemoteFrame(ScreenIntSize(0, 0))) { - // FIXME get error codes from child - mRemoteBrowser->LoadURL(mURIToLoad); - } else { + // Execute pending frame scripts before loading URL + EnsureMessageManager(); + + // FIXME get error codes from child + mRemoteBrowser->LoadURL(mURIToLoad); + + if (!mRemoteBrowserShown && !ShowRemoteFrame(ScreenIntSize(0, 0))) { NS_WARNING("[nsFrameLoader] ReallyStartLoadingInternal tried but couldn't show remote browser.\n"); } @@ -832,13 +831,9 @@ nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size, { NS_ASSERTION(mRemoteFrame, "ShowRemote only makes sense on remote frames."); - if (!mRemoteBrowser) { - TryRemoteBrowser(); - - if (!mRemoteBrowser) { - NS_ERROR("Couldn't create child process."); - return false; - } + if (!mRemoteBrowser && !TryRemoteBrowser()) { + NS_ERROR("Couldn't create child process."); + return false; } // FIXME/bug 589337: Show()/Hide() is pretty expensive for @@ -2262,28 +2257,31 @@ nsFrameLoader::TryRemoteBrowser() nsCOMPtr ownerElement = mOwnerContent; mRemoteBrowser = ContentParent::CreateBrowserOrApp(context, ownerElement, openerContentParent); - if (mRemoteBrowser) { - mChildID = mRemoteBrowser->Manager()->ChildID(); - nsCOMPtr rootItem; - parentDocShell->GetRootTreeItem(getter_AddRefs(rootItem)); - nsCOMPtr rootWin = rootItem->GetWindow(); - nsCOMPtr rootChromeWin = do_QueryInterface(rootWin); - - if (rootChromeWin) { - nsCOMPtr browserDOMWin; - rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin)); - mRemoteBrowser->SetBrowserDOMWindow(browserDOMWin); - } - - mContentParent = mRemoteBrowser->Manager(); - - if (mOwnerContent->AttrValueIs(kNameSpaceID_None, - nsGkAtoms::mozpasspointerevents, - nsGkAtoms::_true, - eCaseMatters)) { - unused << mRemoteBrowser->SendSetUpdateHitRegion(true); - } + if (!mRemoteBrowser) { + return false; } + + mContentParent = mRemoteBrowser->Manager(); + mChildID = mRemoteBrowser->Manager()->ChildID(); + + nsCOMPtr rootItem; + parentDocShell->GetRootTreeItem(getter_AddRefs(rootItem)); + nsCOMPtr rootWin = rootItem->GetWindow(); + nsCOMPtr rootChromeWin = do_QueryInterface(rootWin); + + if (rootChromeWin) { + nsCOMPtr browserDOMWin; + rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin)); + mRemoteBrowser->SetBrowserDOMWindow(browserDOMWin); + } + + if (mOwnerContent->AttrValueIs(kNameSpaceID_None, + nsGkAtoms::mozpasspointerevents, + nsGkAtoms::_true, + eCaseMatters)) { + unused << mRemoteBrowser->SendSetUpdateHitRegion(true); + } + return true; } @@ -2528,7 +2526,7 @@ nsFrameLoader::EnsureMessageManager() bool useRemoteProcess = ShouldUseRemoteProcess(); if (mMessageManager) { - if (useRemoteProcess && mRemoteBrowserShown) { + if (useRemoteProcess && mRemoteBrowser) { mMessageManager->InitWithCallback(this); } return NS_OK; @@ -2553,7 +2551,7 @@ nsFrameLoader::EnsureMessageManager() } if (useRemoteProcess) { - mMessageManager = new nsFrameMessageManager(mRemoteBrowserShown ? this : nullptr, + mMessageManager = new nsFrameMessageManager(mRemoteBrowser ? this : nullptr, static_cast(parentManager.get()), MM_CHROME); } else { diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index eda4992b210..eb7fdae5dea 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -1693,6 +1693,10 @@ bool TabChild::RecvLoadURL(const nsCString& aURI, const BrowserConfiguration& aConfiguration) { + if (!InitTabChildGlobal()) { + return false; + } + SetProcessNameToAppName(); nsresult rv = WebNavigation()->LoadURI(NS_ConvertUTF8toUTF16(aURI).get(), diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 2515602fb2b..de7bd92a297 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -266,7 +266,6 @@ TabParent::TabParent(nsIContentParent* aManager, , mOrientation(0) , mDPI(0) , mDefaultScale(0) - , mShown(false) , mUpdatedDimensions(false) , mChromeOffset(0, 0) , mManager(aManager) @@ -754,13 +753,6 @@ TabParent::LoadURL(nsIURI* aURI) return; } - if (!mShown) { - NS_WARNING(nsPrintfCString("TabParent::LoadURL(%s) called before " - "Show(). Ignoring LoadURL.\n", - spec.get()).get()); - return; - } - uint32_t appId = OwnOrContainingAppId(); if (mSendOfflineStatus && NS_IsAppOffline(appId)) { // If the app is offline in the parent process @@ -824,8 +816,6 @@ TabParent::LoadURL(nsIURI* aURI) void TabParent::Show(const ScreenIntSize& size, bool aParentIsActive) { - // sigh - mShown = true; mDimensions = size; if (mIsDestroyed) { return; diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index b1c4c061d53..2f843f3c382 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -429,7 +429,6 @@ protected: ScreenOrientation mOrientation; float mDPI; CSSToLayoutDeviceScale mDefaultScale; - bool mShown; bool mUpdatedDimensions; nsIntPoint mChromeOffset;