Skip to content

Commit

Permalink
Bug 1047603 - Make TabParent::AnswerCreateWindow force the initial br…
Browse files Browse the repository at this point in the history
…owser to be remote in a new window. r=smaug.

--HG--
extra : rebase_source : 87551351dc763be7f5a8a47d02de21eb3f10c745
  • Loading branch information
mikeconley committed Jan 13, 2015
1 parent c8bb8cc commit 1cf83f9
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 41 deletions.
9 changes: 7 additions & 2 deletions browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,8 +940,6 @@ var gBrowserInit = {
Cc["@mozilla.org/eventlistenerservice;1"]
.getService(Ci.nsIEventListenerService)
.addSystemEventListener(gBrowser, "click", contentAreaClick, true);
} else {
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true);
}

// hook up UI through progress listener
Expand Down Expand Up @@ -4098,6 +4096,13 @@ var XULBrowserWindow = {
// unsupported
},

forceInitialBrowserRemote: function() {
let initBrowser =
document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
gBrowser.updateBrowserRemoteness(initBrowser, true);
return initBrowser.frameLoader.tabParent;
},

setDefaultStatus: function (status) {
this.defaultStatus = status;
this.updateStatusField();
Expand Down
13 changes: 0 additions & 13 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13754,19 +13754,6 @@ nsDocShell::GetOpener()
return opener;
}

void
nsDocShell::SetOpenedRemote(nsITabParent* aOpenedRemote)
{
mOpenedRemote = do_GetWeakReference(aOpenedRemote);
}

nsITabParent*
nsDocShell::GetOpenedRemote()
{
nsCOMPtr<nsITabParent> openedRemote(do_QueryReferent(mOpenedRemote));
return openedRemote;
}

URLSearchParams*
nsDocShell::GetURLSearchParams()
{
Expand Down
1 change: 0 additions & 1 deletion docshell/base/nsDocShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,6 @@ class nsDocShell MOZ_FINAL : public nsDocLoader,
nsTObserverArray<nsWeakPtr> mScrollObservers;
nsCString mOriginalUriString;
nsWeakPtr mOpener;
nsWeakPtr mOpenedRemote;

// A depth count of how many times NotifyRunToCompletionStart
// has been called without a matching NotifyRunToCompletionStop.
Expand Down
9 changes: 1 addition & 8 deletions docshell/base/nsIDocShell.idl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface nsITabParent;

typedef unsigned long nsLoadFlags;

[scriptable, builtinclass, uuid(888fcf04-a69b-11e4-8d33-6fbb72d2eb03)]
[scriptable, builtinclass, uuid(f84b1ae4-2f78-4bad-b36a-6a8516ee6e40)]
interface nsIDocShell : nsIDocShellTreeItem
{
/**
Expand Down Expand Up @@ -1025,13 +1025,6 @@ interface nsIDocShell : nsIDocShellTreeItem
[noscript,notxpcom,nostdcall] void setOpener(in nsITabParent aOpener);
[noscript,notxpcom,nostdcall] nsITabParent getOpener();

/**
* See the documentation for setOpener and getOpener about why we
* don't use attribute here instead.
*/
[noscript,notxpcom,nostdcall] void setOpenedRemote(in nsITabParent aOpenedRemote);
[noscript,notxpcom,nostdcall] nsITabParent getOpenedRemote();

// URLSearchParams for the window.location is owned by the docShell.
[noscript,notxpcom] URLSearchParams getURLSearchParams();

Expand Down
1 change: 0 additions & 1 deletion dom/base/nsFrameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,6 @@ nsFrameLoader::TryRemoteBrowser()
eCaseMatters)) {
unused << mRemoteBrowser->SendSetUpdateHitRegion(true);
}
parentDocShell->SetOpenedRemote(mRemoteBrowser);
}
return true;
}
Expand Down
19 changes: 15 additions & 4 deletions dom/ipc/TabParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,22 @@ TabParent::RecvCreateWindow(PBrowserParent* aNewTab,
nsCOMPtr<nsPIDOMWindow> pwindow = do_QueryInterface(window);
NS_ENSURE_TRUE(pwindow, false);

nsRefPtr<nsIDocShell> newDocShell = pwindow->GetDocShell();
NS_ENSURE_TRUE(newDocShell, false);
nsCOMPtr<nsIDocShell> windowDocShell = pwindow->GetDocShell();
NS_ENSURE_TRUE(windowDocShell, false);

nsCOMPtr<nsITabParent> newRemoteTab = newDocShell->GetOpenedRemote();
NS_ENSURE_TRUE(newRemoteTab, false);
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
windowDocShell->GetTreeOwner(getter_AddRefs(treeOwner));

nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(treeOwner);
NS_ENSURE_TRUE(xulWin, false);

nsCOMPtr<nsIXULBrowserWindow> xulBrowserWin;
xulWin->GetXULBrowserWindow(getter_AddRefs(xulBrowserWin));
NS_ENSURE_TRUE(xulBrowserWin, false);

nsCOMPtr<nsITabParent> newRemoteTab;
rv = xulBrowserWin->ForceInitialBrowserRemote(getter_AddRefs(newRemoteTab));
NS_ENSURE_SUCCESS(rv, false);

MOZ_ASSERT(TabParent::GetFrom(newRemoteTab) == newTab);

Expand Down
11 changes: 10 additions & 1 deletion xpfe/appshell/nsIXULBrowserWindow.idl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ interface nsIRequest;
interface nsIDOMElement;
interface nsIInputStream;
interface nsIDocShell;
interface nsITabParent;

/**
* The nsIXULBrowserWindow supplies the methods that may be called from the
* internals of the browser area to tell the containing xul window to update
* its ui.
*/
[scriptable, uuid(162d3378-a7d5-410c-8635-fe80e32020fc)]
[scriptable, uuid(db89f748-9736-40b2-a172-3928aa1194b2)]
interface nsIXULBrowserWindow : nsISupports
{
/**
Expand All @@ -40,6 +41,14 @@ interface nsIXULBrowserWindow : nsISupports
in nsIDOMNode linkNode,
in boolean isAppTab);

/**
* Find the initial browser of the window and set its remote attribute.
* This can be used to ensure that there is a remote browser in a new
* window when it first spawns.
*
*/
nsITabParent forceInitialBrowserRemote();

/**
* Determines whether a load should continue.
*
Expand Down
14 changes: 3 additions & 11 deletions xpfe/appshell/nsXULWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIIOService.h"
#include "nsILoadContext.h"
#include "nsIObserverService.h"
#include "nsIWindowMediator.h"
#include "nsIScreenManager.h"
Expand Down Expand Up @@ -1798,19 +1799,10 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(int32_t aChromeFlags,
if (!NS_ProcessNextEvent(thread))
break;
}
}

// If aOpeningTab is not null, it means that we're creating a new window
// with a remote browser, which doesn't have a primary docshell. In that
// case, we check for the chrome window docshell and make sure that a new
// remote tab was opened and stashed in that docshell.
if (aOpeningTab) {
NS_ENSURE_STATE(xulWin->mDocShell);
NS_ENSURE_STATE(xulWin->mDocShell->GetOpenedRemote());
} else {
NS_ENSURE_STATE(xulWin->mPrimaryContentShell);
}

NS_ENSURE_STATE(xulWin->mPrimaryContentShell);

*_retval = newWindow;
NS_ADDREF(*_retval);

Expand Down

0 comments on commit 1cf83f9

Please sign in to comment.