Bug 1224105 - Allow windowless chrome docshells containing content docshells (r=smaug)

This commit is contained in:
Bill McCloskey 2015-11-11 21:08:28 -08:00
parent a4a149fd8d
commit ecabf2935c
2 changed files with 37 additions and 0 deletions

View File

@ -326,6 +326,24 @@ nsDocShellTreeOwner::RemoveFromWatcher()
}
}
void
nsDocShellTreeOwner::EnsureContentTreeOwner()
{
if (mContentTreeOwner) {
return;
}
mContentTreeOwner = new nsDocShellTreeOwner();
nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetWebBrowserChrome();
if (browserChrome) {
mContentTreeOwner->SetWebBrowserChrome(browserChrome);
}
if (mWebBrowser) {
mContentTreeOwner->WebBrowser(mWebBrowser);
}
}
NS_IMETHODIMP
nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
bool aPrimary, bool aTargetable,
@ -335,6 +353,9 @@ nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
return mTreeOwner->ContentShellAdded(aContentShell, aPrimary, aTargetable,
aID);
EnsureContentTreeOwner();
aContentShell->SetTreeOwner(mContentTreeOwner);
if (aPrimary) {
mPrimaryContentShell = aContentShell;
mPrimaryTabParent = nullptr;
@ -791,6 +812,13 @@ nsDocShellTreeOwner::WebBrowser(nsWebBrowser* aWebBrowser)
}
mWebBrowser = aWebBrowser;
if (mContentTreeOwner) {
mContentTreeOwner->WebBrowser(aWebBrowser);
if (!aWebBrowser) {
mContentTreeOwner = nullptr;
}
}
}
nsWebBrowser*
@ -844,6 +872,11 @@ nsDocShellTreeOwner::SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome)
mOwnerRequestor = requestor;
}
}
if (mContentTreeOwner) {
mContentTreeOwner->SetWebBrowserChrome(aWebBrowserChrome);
}
return NS_OK;
}

View File

@ -101,6 +101,8 @@ protected:
void AddToWatcher();
void RemoveFromWatcher();
void EnsureContentTreeOwner();
// These helper functions return the correct instances of the requested
// interfaces. If the object passed to SetWebBrowserChrome() implements
// nsISupportsWeakReference, then these functions call QueryReferent on
@ -128,6 +130,8 @@ protected:
RefPtr<ChromeTooltipListener> mChromeTooltipListener;
RefPtr<ChromeContextMenuListener> mChromeContextMenuListener;
RefPtr<nsDocShellTreeOwner> mContentTreeOwner;
nsCOMPtr<nsIPrompt> mPrompter;
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
nsCOMPtr<nsITabParent> mPrimaryTabParent;