forked from mirrors/gecko-dev
Bug 1769619 - Introduce nsIDocShellTreeOwner::primaryContentBrowsingContext, r=smaug
This is currently effectively just a helper around the existing properties. Theoretically we could streamline things here in the future by managing primary content entirely based on BrowsingContext rather than docshell, but there's enough complexity there right now with other properties like updating properties on content shells as they're attached, that it's probably not worth trying to unify right now, especially considering the low number of consumers. Differential Revision: https://phabricator.services.mozilla.com/D146495
This commit is contained in:
parent
caef665f7f
commit
e1e439a7b1
9 changed files with 88 additions and 0 deletions
|
|
@ -398,6 +398,25 @@ nsDocShellTreeOwner::GetPrimaryRemoteTab(nsIRemoteTab** aTab) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellTreeOwner::GetPrimaryContentBrowsingContext(
|
||||
mozilla::dom::BrowsingContext** aBc) {
|
||||
if (mTreeOwner) {
|
||||
return mTreeOwner->GetPrimaryContentBrowsingContext(aBc);
|
||||
}
|
||||
if (mPrimaryRemoteTab) {
|
||||
return mPrimaryRemoteTab->GetBrowsingContext(aBc);
|
||||
}
|
||||
if (mPrimaryContentShell) {
|
||||
return mPrimaryContentShell->GetBrowsingContextXPCOM(aBc);
|
||||
}
|
||||
if (mWebBrowser->mDocShell) {
|
||||
return mWebBrowser->mDocShell->GetBrowsingContextXPCOM(aBc);
|
||||
}
|
||||
*aBc = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellTreeOwner::GetPrimaryContentSize(int32_t* aWidth, int32_t* aHeight) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
interface nsIDocShellTreeItem;
|
||||
interface nsIRemoteTab;
|
||||
webidl BrowsingContext;
|
||||
|
||||
[scriptable, uuid(0e3dc4b1-4cea-4a37-af71-79f0afd07574)]
|
||||
interface nsIDocShellTreeOwner : nsISupports
|
||||
|
|
@ -51,6 +52,12 @@ interface nsIDocShellTreeOwner : nsISupports
|
|||
*/
|
||||
readonly attribute nsIRemoteTab primaryRemoteTab;
|
||||
|
||||
/*
|
||||
Get the BrowsingContext associated with either the primary content shell or
|
||||
primary remote tab, depending on which is available.
|
||||
*/
|
||||
readonly attribute BrowsingContext primaryContentBrowsingContext;
|
||||
|
||||
/*
|
||||
Tells the tree owner to size its window or parent window in such a way
|
||||
that the shell passed along will be the size specified.
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1209621
|
|||
"There shouldn't be primaryContentShell because no browser has primary=true.");
|
||||
is(treeOwner.primaryRemoteTab, null,
|
||||
"There shouldn't be primaryRemoteTab because no remote browser has primary=true.");
|
||||
is(treeOwner.primaryContentBrowsingContext, null,
|
||||
"There shouldn't be primaryContentBrowsingContext because no browser has primary=true.");
|
||||
|
||||
var ip = document.getElementById("inprocess");
|
||||
var remote = document.getElementById("remote");
|
||||
|
|
@ -40,6 +42,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1209621
|
|||
"primary browser should be the primaryContentShell.");
|
||||
is(treeOwner.primaryRemoteTab, null,
|
||||
"There shouldn't be primaryRemoteTab because no remote browser has primary=true.");
|
||||
is(treeOwner.primaryContentBrowsingContext, ip.browsingContext,
|
||||
"primary browsing context should be the primaryContentBrowsingContext.");
|
||||
|
||||
ip.removeAttribute("primary");
|
||||
remote.setAttribute("primary", "true");
|
||||
|
|
@ -49,12 +53,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1209621
|
|||
ok(tp, "Remote browsers should have a remoteTab.");
|
||||
is(treeOwner.primaryRemoteTab, tp,
|
||||
"primary remote browser should be the primaryRemoteTab.");
|
||||
is(treeOwner.primaryContentBrowsingContext, remote.browsingContext,
|
||||
"primary remote browser should be the primaryContentBrowsingContext.");
|
||||
|
||||
remote.removeAttribute("primary");
|
||||
is(treeOwner.primaryContentShell, null,
|
||||
"There shouldn't be primaryContentShell because no browser has primary=true.");
|
||||
is(treeOwner.primaryRemoteTab, null,
|
||||
"There shouldn't be primaryRemoteTab because no remote browser has primary=true.");
|
||||
is(treeOwner.primaryContentBrowsingContext, null,
|
||||
"There shouldn't be primaryContentBrowsingContext because no browser has primary=true.");
|
||||
|
||||
remote2.setAttribute("primary", "true");
|
||||
var tp2 = remote2.frameLoader.remoteTab;
|
||||
|
|
@ -63,6 +71,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1209621
|
|||
"primary remote browser should be the primaryRemoteTab.");
|
||||
is(treeOwner.primaryContentShell, null,
|
||||
"There shouldn't be primaryContentShell because no browser has primary=true.");
|
||||
is(treeOwner.primaryContentBrowsingContext, remote2.browsingContext,
|
||||
"primary remote browser should be the primaryContentBrowsingContext.");
|
||||
|
||||
window.arguments[0].setTimeout(function() { this.done(); }, 0);
|
||||
window.close();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
interface nsIPrincipal;
|
||||
webidl Element;
|
||||
webidl WindowGlobalParent;
|
||||
webidl BrowsingContext;
|
||||
|
||||
[builtinclass, scriptable, uuid(8e49f7b0-1f98-4939-bf91-e9c39cd56434)]
|
||||
interface nsIRemoteTab : nsISupports
|
||||
|
|
@ -55,6 +56,11 @@ interface nsIRemoteTab : nsISupports
|
|||
*/
|
||||
readonly attribute int32_t osPid;
|
||||
|
||||
/**
|
||||
* The toplevel BrowsingContext loaded in this remote tab.
|
||||
*/
|
||||
readonly attribute BrowsingContext browsingContext;
|
||||
|
||||
/**
|
||||
* True if we've previously received layers for this tab when switching to
|
||||
* it.
|
||||
|
|
|
|||
|
|
@ -228,6 +228,18 @@ BrowserHost::GetOsPid(int32_t* aOsPid) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute BrowsingContext browsingContext; */
|
||||
NS_IMETHODIMP
|
||||
BrowserHost::GetBrowsingContext(BrowsingContext** aBc) {
|
||||
if (!mRoot) {
|
||||
*aBc = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
RefPtr<BrowsingContext> bc = mRoot->GetBrowsingContext();
|
||||
bc.forget(aBc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute boolean hasPresented; */
|
||||
NS_IMETHODIMP
|
||||
BrowserHost::GetHasPresented(bool* aHasPresented) {
|
||||
|
|
|
|||
|
|
@ -450,6 +450,19 @@ AppWindow::GetPrimaryRemoteTab(nsIRemoteTab** aTab) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AppWindow::GetPrimaryContentBrowsingContext(
|
||||
mozilla::dom::BrowsingContext** aBc) {
|
||||
if (mPrimaryBrowserParent) {
|
||||
return mPrimaryBrowserParent->GetBrowsingContext(aBc);
|
||||
}
|
||||
if (mPrimaryContentShell) {
|
||||
return mPrimaryContentShell->GetBrowsingContextXPCOM(aBc);
|
||||
}
|
||||
*aBc = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static LayoutDeviceIntSize GetOuterToInnerSizeDifference(nsIWidget* aWindow) {
|
||||
if (!aWindow) {
|
||||
return LayoutDeviceIntSize();
|
||||
|
|
|
|||
|
|
@ -130,6 +130,13 @@ nsChromeTreeOwner::GetPrimaryRemoteTab(nsIRemoteTab** aTab) {
|
|||
return mAppWindow->GetPrimaryRemoteTab(aTab);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeTreeOwner::GetPrimaryContentBrowsingContext(
|
||||
mozilla::dom::BrowsingContext** aBc) {
|
||||
NS_ENSURE_STATE(mAppWindow);
|
||||
return mAppWindow->GetPrimaryContentBrowsingContext(aBc);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeTreeOwner::GetPrimaryContentSize(int32_t* aWidth, int32_t* aHeight) {
|
||||
NS_ENSURE_STATE(mAppWindow);
|
||||
|
|
|
|||
|
|
@ -191,6 +191,13 @@ nsContentTreeOwner::GetPrimaryRemoteTab(nsIRemoteTab** aTab) {
|
|||
return mAppWindow->GetPrimaryRemoteTab(aTab);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentTreeOwner::GetPrimaryContentBrowsingContext(
|
||||
mozilla::dom::BrowsingContext** aBc) {
|
||||
NS_ENSURE_STATE(mAppWindow);
|
||||
return mAppWindow->GetPrimaryContentBrowsingContext(aBc);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentTreeOwner::GetPrimaryContentSize(int32_t* aWidth, int32_t* aHeight) {
|
||||
NS_ENSURE_STATE(mAppWindow);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ interface nsIXULBrowserWindow;
|
|||
interface nsIRemoteTab;
|
||||
interface mozIDOMWindowProxy;
|
||||
interface nsIOpenWindowInfo;
|
||||
webidl BrowsingContext;
|
||||
|
||||
native LiveResizeListenerArray(nsTArray<RefPtr<mozilla::LiveResizeListener>>);
|
||||
|
||||
|
|
@ -56,6 +57,12 @@ interface nsIAppWindow : nsISupports
|
|||
*/
|
||||
readonly attribute nsIRemoteTab primaryRemoteTab;
|
||||
|
||||
/**
|
||||
* Helper for getting the BrowsingContext from either `primaryContentShell` or
|
||||
* `primaryRemoteTab` depending on which is available.
|
||||
*/
|
||||
readonly attribute BrowsingContext primaryContentBrowsingContext;
|
||||
|
||||
void remoteTabAdded(in nsIRemoteTab aTab, in boolean aPrimary);
|
||||
void remoteTabRemoved(in nsIRemoteTab aTab);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue