Bug 918634 - swapFrameLoader not implemented for e10s. Frameloader impl. r=smaug

--HG--
extra : rebase_source : 01867c6208df8213b04469404dc6c1f768f8c025
This commit is contained in:
Bill McCloskey 2014-10-07 15:30:42 +13:00
parent 71324ef0ab
commit a60891a738
4 changed files with 108 additions and 3 deletions

View File

@ -183,7 +183,7 @@ skip-if = e10s # Bug ????? - This bug attached an event listener directly to the
[browser_bug484315.js]
skip-if = e10s
[browser_bug491431.js]
skip-if = buildapp == 'mulet' || e10s # Bug 918634 - swapFrameLoaders (and thus replaceTabWithWindow) not implemented for e10s
skip-if = buildapp == 'mulet'
[browser_bug495058.js]
skip-if = e10s # Bug 918634 - swapFrameLoaders (and thus replaceTabWithWindow) not implemented for e10s
[browser_bug517902.js]

View File

@ -69,6 +69,7 @@
#include "nsInProcessTabChildGlobal.h"
#include "Layers.h"
#include "ClientLayerManager.h"
#include "AppProcessChecker.h"
#include "ContentParent.h"
@ -940,6 +941,93 @@ nsFrameLoader::Hide()
baseWin->SetParentWidget(nullptr);
}
nsresult
nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther,
nsRefPtr<nsFrameLoader>& aFirstToSwap,
nsRefPtr<nsFrameLoader>& aSecondToSwap)
{
Element* ourContent = mOwnerContent;
Element* otherContent = aOther->mOwnerContent;
if (!ourContent || !otherContent) {
// Can't handle this
return NS_ERROR_NOT_IMPLEMENTED;
}
// Make sure there are no same-origin issues
bool equal;
nsresult rv =
ourContent->NodePrincipal()->Equals(otherContent->NodePrincipal(), &equal);
if (NS_FAILED(rv) || !equal) {
// Security problems loom. Just bail on it all
return NS_ERROR_DOM_SECURITY_ERR;
}
nsIDocument* ourDoc = ourContent->GetCurrentDoc();
nsIDocument* otherDoc = otherContent->GetCurrentDoc();
if (!ourDoc || !otherDoc) {
// Again, how odd, given that we had docshells
return NS_ERROR_NOT_IMPLEMENTED;
}
nsIPresShell* ourShell = ourDoc->GetShell();
nsIPresShell* otherShell = otherDoc->GetShell();
if (!ourShell || !otherShell) {
return NS_ERROR_NOT_IMPLEMENTED;
}
if (mInSwap || aOther->mInSwap) {
return NS_ERROR_NOT_IMPLEMENTED;
}
mInSwap = aOther->mInSwap = true;
nsIFrame* ourFrame = ourContent->GetPrimaryFrame();
nsIFrame* otherFrame = otherContent->GetPrimaryFrame();
if (!ourFrame || !otherFrame) {
mInSwap = aOther->mInSwap = false;
return NS_ERROR_NOT_IMPLEMENTED;
}
nsSubDocumentFrame* ourFrameFrame = do_QueryFrame(ourFrame);
if (!ourFrameFrame) {
mInSwap = aOther->mInSwap = false;
return NS_ERROR_NOT_IMPLEMENTED;
}
rv = ourFrameFrame->BeginSwapDocShells(otherFrame);
if (NS_FAILED(rv)) {
mInSwap = aOther->mInSwap = false;
return rv;
}
SetOwnerContent(otherContent);
aOther->SetOwnerContent(ourContent);
mRemoteBrowser->SetOwnerElement(otherContent);
aOther->mRemoteBrowser->SetOwnerElement(ourContent);
nsRefPtr<nsFrameMessageManager> ourMessageManager = mMessageManager;
nsRefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager;
// Swap and setup things in parent message managers.
if (mMessageManager) {
mMessageManager->SetCallback(aOther);
}
if (aOther->mMessageManager) {
aOther->mMessageManager->SetCallback(this);
}
mMessageManager.swap(aOther->mMessageManager);
aFirstToSwap.swap(aSecondToSwap);
ourFrameFrame->EndSwapDocShells(otherFrame);
ourDoc->FlushPendingNotifications(Flush_Layout);
otherDoc->FlushPendingNotifications(Flush_Layout);
mInSwap = aOther->mInSwap = false;
return NS_OK;
}
nsresult
nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
nsRefPtr<nsFrameLoader>& aFirstToSwap,
@ -950,6 +1038,15 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
"Swapping some sort of random loaders?");
NS_ENSURE_STATE(!mInShow && !aOther->mInShow);
if (mRemoteFrame && aOther->mRemoteFrame) {
return SwapWithOtherRemoteLoader(aOther, aFirstToSwap, aSecondToSwap);
}
if (mRemoteFrame || aOther->mRemoteFrame) {
NS_WARNING("Swapping remote and non-remote frames is not currently supported");
return NS_ERROR_NOT_IMPLEMENTED;
}
Element* ourContent = mOwnerContent;
Element* otherContent = aOther->mOwnerContent;

View File

@ -131,6 +131,10 @@ public:
nsRefPtr<nsFrameLoader>& aFirstToSwap,
nsRefPtr<nsFrameLoader>& aSecondToSwap);
nsresult SwapWithOtherRemoteLoader(nsFrameLoader* aOther,
nsRefPtr<nsFrameLoader>& aFirstToSwap,
nsRefPtr<nsFrameLoader>& aSecondToSwap);
// When IPC is enabled, destroy any associated child process.
void DestroyChild();

View File

@ -1123,8 +1123,12 @@
}
// Re-attach the docShells to the form fill controller.
this.attachFormFill();
aOtherBrowser.attachFormFill();
if (!this.isRemoteBrowser) {
this.attachFormFill();
}
if (!aOtherBrowser.isRemoteBrowser) {
aOtherBrowser.attachFormFill();
}
// Null the current nsITypeAheadFind instances so that they're
// lazily re-created on access. We need to do this because they