зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1368046 - Part 1: Propagate window.name across processes for RecvCreateWindowInDifferentProcess, r=smaug
MozReview-Commit-ID: 6xmLN9pbCKd
This commit is contained in:
Родитель
eaba7e1d97
Коммит
ac7ba92fd5
|
@ -5058,10 +5058,10 @@ nsBrowserAccess.prototype = {
|
|||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIBrowserDOMWindow, Ci.nsISupports]),
|
||||
|
||||
_openURIInNewTab(aURI, aReferrer, aReferrerPolicy, aIsPrivate,
|
||||
aIsExternal, aForceNotRemote = false,
|
||||
aUserContextId = Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID,
|
||||
aOpener = null, aTriggeringPrincipal = null,
|
||||
aNextTabParentId = 0) {
|
||||
aIsExternal, aForceNotRemote = false,
|
||||
aUserContextId = Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID,
|
||||
aOpener = null, aTriggeringPrincipal = null,
|
||||
aNextTabParentId = 0, aName = "") {
|
||||
let win, needToFocusWin;
|
||||
|
||||
// try the current window. if we're in a popup, fall back on the most recent browser window
|
||||
|
@ -5095,6 +5095,7 @@ nsBrowserAccess.prototype = {
|
|||
forceNotRemote: aForceNotRemote,
|
||||
opener: aOpener,
|
||||
nextTabParentId: aNextTabParentId,
|
||||
name: aName,
|
||||
});
|
||||
let browser = win.gBrowser.getBrowserForTab(tab);
|
||||
|
||||
|
@ -5198,7 +5199,7 @@ nsBrowserAccess.prototype = {
|
|||
},
|
||||
|
||||
openURIInFrame: function browser_openURIInFrame(aURI, aParams, aWhere, aFlags,
|
||||
aNextTabParentId) {
|
||||
aNextTabParentId, aName) {
|
||||
if (aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWTAB) {
|
||||
dump("Error: openURIInFrame can only open in new tabs");
|
||||
return null;
|
||||
|
@ -5218,7 +5219,7 @@ nsBrowserAccess.prototype = {
|
|||
isExternal, false,
|
||||
userContextId, null,
|
||||
aParams.triggeringPrincipal,
|
||||
aNextTabParentId);
|
||||
aNextTabParentId, aName);
|
||||
if (browser)
|
||||
return browser.QueryInterface(Ci.nsIFrameLoaderOwner);
|
||||
|
||||
|
|
|
@ -1558,6 +1558,7 @@
|
|||
var aCreateLazyBrowser;
|
||||
var aNextTabParentId;
|
||||
var aFocusUrlBar;
|
||||
var aName;
|
||||
if (arguments.length == 2 &&
|
||||
typeof arguments[1] == "object" &&
|
||||
!(arguments[1] instanceof Ci.nsIURI)) {
|
||||
|
@ -1584,6 +1585,7 @@
|
|||
aCreateLazyBrowser = params.createLazyBrowser;
|
||||
aNextTabParentId = params.nextTabParentId;
|
||||
aFocusUrlBar = params.focusUrlBar;
|
||||
aName = params.name;
|
||||
}
|
||||
|
||||
var bgLoad = (aLoadInBackground != null) ? aLoadInBackground :
|
||||
|
@ -1612,7 +1614,8 @@
|
|||
opener: aOpener,
|
||||
isPrerendered: aIsPrerendered,
|
||||
nextTabParentId: aNextTabParentId,
|
||||
focusUrlBar: aFocusUrlBar });
|
||||
focusUrlBar: aFocusUrlBar,
|
||||
name: aName });
|
||||
if (!bgLoad)
|
||||
this.selectedTab = tab;
|
||||
|
||||
|
@ -2058,6 +2061,14 @@
|
|||
b.sameProcessAsFrameLoader = aParams.sameProcessAsFrameLoader;
|
||||
}
|
||||
|
||||
// This will be used by gecko to control the name of the opened
|
||||
// window.
|
||||
if (aParams.name) {
|
||||
// XXX: The `name` property is special in HTML and XUL. Should
|
||||
// we use a different attribute name for this?
|
||||
b.setAttribute("name", aParams.name);
|
||||
}
|
||||
|
||||
// Create the browserStack container
|
||||
var stack = document.createElementNS(NS_XUL, "stack");
|
||||
stack.className = "browserStack";
|
||||
|
@ -2318,6 +2329,7 @@
|
|||
var aNextTabParentId;
|
||||
var aNoInitialLabel;
|
||||
var aFocusUrlBar;
|
||||
var aName;
|
||||
if (arguments.length == 2 &&
|
||||
typeof arguments[1] == "object" &&
|
||||
!(arguments[1] instanceof Ci.nsIURI)) {
|
||||
|
@ -2348,6 +2360,7 @@
|
|||
aNextTabParentId = params.nextTabParentId;
|
||||
aNoInitialLabel = params.noInitialLabel;
|
||||
aFocusUrlBar = params.focusUrlBar;
|
||||
aName = params.name;
|
||||
}
|
||||
|
||||
// if we're adding tabs, we're past interrupt mode, ditch the owner
|
||||
|
@ -2474,7 +2487,8 @@
|
|||
sameProcessAsFrameLoader: aSameProcessAsFrameLoader,
|
||||
opener: aOpener,
|
||||
isPrerendered: aIsPrerendered,
|
||||
nextTabParentId: aNextTabParentId });
|
||||
nextTabParentId: aNextTabParentId,
|
||||
name: aName });
|
||||
}
|
||||
|
||||
t.linkedBrowser = b;
|
||||
|
|
|
@ -10569,3 +10569,13 @@ nsContentUtils::UserInteractionObserver::Observe(nsISupports* aSubject,
|
|||
|
||||
Atomic<bool> nsContentUtils::UserInteractionObserver::sUserActive(false);
|
||||
NS_IMPL_ISUPPORTS(nsContentUtils::UserInteractionObserver, nsIObserver)
|
||||
|
||||
/* static */ bool
|
||||
nsContentUtils::IsOverridingWindowName(const nsAString& aName)
|
||||
{
|
||||
return !aName.IsEmpty() &&
|
||||
!aName.LowerCaseEqualsLiteral("_blank") &&
|
||||
!aName.LowerCaseEqualsLiteral("_top") &&
|
||||
!aName.LowerCaseEqualsLiteral("_parent") &&
|
||||
!aName.LowerCaseEqualsLiteral("_self");
|
||||
}
|
||||
|
|
|
@ -2993,6 +2993,13 @@ public:
|
|||
// heuristic strategy should be used to trigger the caching of the bytecode.
|
||||
static int32_t BytecodeCacheStrategy() { return sBytecodeCacheStrategy; }
|
||||
|
||||
/**
|
||||
* Checks if the passed-in name should override an existing name on the
|
||||
* window. Values which should not override include: "", "_blank", "_top",
|
||||
* "_parent" and "_self".
|
||||
*/
|
||||
static bool IsOverridingWindowName(const nsAString& aName);
|
||||
|
||||
private:
|
||||
static bool InitializeEventTable();
|
||||
|
||||
|
|
|
@ -3023,6 +3023,16 @@ nsFrameLoader::TryRemoteBrowser()
|
|||
mRemoteBrowser->SetBrowserDOMWindow(browserDOMWin);
|
||||
}
|
||||
|
||||
// Send down the name of the browser through mRemoteBrowser if it is set.
|
||||
// Only do this on xul:browsers for now.
|
||||
if (mOwnerContent->IsXULElement()) {
|
||||
nsAutoString frameName;
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, frameName);
|
||||
if (nsContentUtils::IsOverridingWindowName(frameName)) {
|
||||
Unused << mRemoteBrowser->SendSetWindowName(frameName);
|
||||
}
|
||||
}
|
||||
|
||||
ReallyLoadFrameScripts();
|
||||
InitializeBrowserAPI();
|
||||
|
||||
|
|
|
@ -105,12 +105,18 @@ interface nsIBrowserDOMWindow : nsISupports
|
|||
|
||||
/**
|
||||
* As above, but return the nsIFrameLoaderOwner for the new window.
|
||||
*
|
||||
* Additional Parameters:
|
||||
* @param aNextTabParentId The TabParent to associate the window with
|
||||
* @param aName The name to give the window opened in the new tab.
|
||||
* @return The nsIFrameLoaderOwner for the newly opened window.
|
||||
// XXXbz is this the right API?
|
||||
// See bug 537428
|
||||
*/
|
||||
nsIFrameLoaderOwner openURIInFrame(in nsIURI aURI, in nsIOpenURIInFrameParams params,
|
||||
in short aWhere, in long aFlags,
|
||||
in unsigned long long aNextTabParentId);
|
||||
in unsigned long long aNextTabParentId,
|
||||
in AString aName);
|
||||
|
||||
/**
|
||||
* @param aWindow the window to test.
|
||||
|
|
|
@ -4412,6 +4412,7 @@ ContentParent::CommonCreateWindow(PBrowserParent* aThisTab,
|
|||
const OriginAttributes& aOpenerOriginAttributes,
|
||||
const float& aFullZoom,
|
||||
uint64_t aNextTabParentId,
|
||||
const nsString& aName,
|
||||
nsresult& aResult,
|
||||
nsCOMPtr<nsITabParent>& aNewTabParent,
|
||||
bool* aWindowIsNew)
|
||||
|
@ -4494,7 +4495,7 @@ ContentParent::CommonCreateWindow(PBrowserParent* aThisTab,
|
|||
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner;
|
||||
aResult = browserDOMWin->OpenURIInFrame(aURIToLoad, params, openLocation,
|
||||
nsIBrowserDOMWindow::OPEN_NEW,
|
||||
aNextTabParentId,
|
||||
aNextTabParentId, aName,
|
||||
getter_AddRefs(frameLoaderOwner));
|
||||
if (NS_SUCCEEDED(aResult) && frameLoaderOwner) {
|
||||
RefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
|
||||
|
@ -4522,6 +4523,13 @@ ContentParent::CommonCreateWindow(PBrowserParent* aThisTab,
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aNewTabParent);
|
||||
// If we were passed a name for the window which would override the default,
|
||||
// we should send it down to the new tab.
|
||||
if (nsContentUtils::IsOverridingWindowName(aName)) {
|
||||
Unused << TabParent::GetFrom(aNewTabParent)->SendSetWindowName(aName);
|
||||
}
|
||||
|
||||
if (aURIToLoad) {
|
||||
nsCOMPtr<mozIDOMWindowProxy> openerWindow;
|
||||
if (aSetOpener && thisTabParent) {
|
||||
|
@ -4592,7 +4600,7 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
|
|||
CommonCreateWindow(aThisTab, /* aSetOpener = */ true, aChromeFlags,
|
||||
aCalledFromJS, aPositionSpecified, aSizeSpecified,
|
||||
nullptr, aFeatures, aBaseURI, aOpenerOriginAttributes,
|
||||
aFullZoom, nextTabParentId, *aResult,
|
||||
aFullZoom, nextTabParentId, NullString(), *aResult,
|
||||
newRemoteTab, aWindowIsNew);
|
||||
if (!ipcResult) {
|
||||
return ipcResult;
|
||||
|
@ -4633,7 +4641,8 @@ ContentParent::RecvCreateWindowInDifferentProcess(
|
|||
const nsCString& aFeatures,
|
||||
const nsCString& aBaseURI,
|
||||
const OriginAttributes& aOpenerOriginAttributes,
|
||||
const float& aFullZoom)
|
||||
const float& aFullZoom,
|
||||
const nsString& aName)
|
||||
{
|
||||
nsCOMPtr<nsITabParent> newRemoteTab;
|
||||
bool windowIsNew;
|
||||
|
@ -4643,7 +4652,7 @@ ContentParent::RecvCreateWindowInDifferentProcess(
|
|||
CommonCreateWindow(aThisTab, /* aSetOpener = */ false, aChromeFlags,
|
||||
aCalledFromJS, aPositionSpecified, aSizeSpecified,
|
||||
uriToLoad, aFeatures, aBaseURI, aOpenerOriginAttributes,
|
||||
aFullZoom, /* aNextTabParentId = */ 0, rv,
|
||||
aFullZoom, /* aNextTabParentId = */ 0, aName, rv,
|
||||
newRemoteTab, &windowIsNew);
|
||||
if (!ipcResult) {
|
||||
return ipcResult;
|
||||
|
|
|
@ -556,7 +556,8 @@ public:
|
|||
const nsCString& aFeatures,
|
||||
const nsCString& aBaseURI,
|
||||
const OriginAttributes& aOpenerOriginAttributes,
|
||||
const float& aFullZoom) override;
|
||||
const float& aFullZoom,
|
||||
const nsString& aName) override;
|
||||
|
||||
static bool AllocateLayerTreeId(TabParent* aTabParent, uint64_t* aId);
|
||||
|
||||
|
@ -715,6 +716,7 @@ private:
|
|||
const OriginAttributes& aOpenerOriginAttributes,
|
||||
const float& aFullZoom,
|
||||
uint64_t aNextTabParentId,
|
||||
const nsString& aName,
|
||||
nsresult& aResult,
|
||||
nsCOMPtr<nsITabParent>& aNewTabParent,
|
||||
bool* aWindowIsNew);
|
||||
|
|
|
@ -890,6 +890,11 @@ child:
|
|||
*/
|
||||
async AwaitLargeAlloc();
|
||||
|
||||
/**
|
||||
* Tell the TabChild to set the name of its toplevel docshell to the given name.
|
||||
*/
|
||||
async SetWindowName(nsString aName);
|
||||
|
||||
/*
|
||||
* FIXME: write protocol!
|
||||
|
||||
|
|
|
@ -1009,7 +1009,8 @@ parent:
|
|||
nsCString aFeatures,
|
||||
nsCString aBaseURI,
|
||||
OriginAttributes aOpenerOriginAttributes,
|
||||
float aFullZoom);
|
||||
float aFullZoom,
|
||||
nsString aName);
|
||||
|
||||
sync GetAndroidSystemInfo()
|
||||
returns (AndroidSystemInfo info);
|
||||
|
|
|
@ -3158,6 +3158,16 @@ TabChild::StopAwaitingLargeAlloc()
|
|||
return awaiting;
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
TabChild::RecvSetWindowName(const nsString& aName)
|
||||
{
|
||||
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(WebNavigation());
|
||||
if (item) {
|
||||
item->SetName(aName);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::plugins::PPluginWidgetChild*
|
||||
TabChild::AllocPPluginWidgetChild()
|
||||
{
|
||||
|
|
|
@ -735,6 +735,8 @@ protected:
|
|||
|
||||
virtual mozilla::ipc::IPCResult RecvAwaitLargeAlloc() override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvSetWindowName(const nsString& aName) override;
|
||||
|
||||
private:
|
||||
void HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
|
||||
const ScrollableLayerGuid& aGuid);
|
||||
|
|
|
@ -3439,10 +3439,13 @@ nsBrowserAccess.prototype = {
|
|||
},
|
||||
|
||||
openURIInFrame: function browser_openURIInFrame(aURI, aParams, aWhere, aFlags,
|
||||
aNextTabParentId) {
|
||||
aNextTabParentId, aName) {
|
||||
// We currently ignore aNextTabParentId on mobile. This needs to change
|
||||
// when Fennec starts to support e10s. Assertions will fire if this code
|
||||
// isn't fixed by then.
|
||||
//
|
||||
// We also ignore aName if it is set, as it is currently only used on the
|
||||
// e10s codepath.
|
||||
let browser = this._getBrowser(aURI, null, aWhere, aFlags);
|
||||
if (browser)
|
||||
return browser.QueryInterface(Ci.nsIFrameLoaderOwner);
|
||||
|
|
Загрузка…
Ссылка в новой задаче