зеркало из https://github.com/mozilla/pjs.git
Don't let background tabs set the status b=104532 r=danm sr=jst
This commit is contained in:
Родитель
8b6abc1d30
Коммит
c3d65e8c11
|
@ -51,7 +51,7 @@ interface nsIDocShellTreeItem;
|
|||
interface nsIAppShell;
|
||||
interface nsIXULBrowserWindow;
|
||||
|
||||
[scriptable, uuid(5d72a699-a252-4161-a45f-e7d35e78b7f3)]
|
||||
[scriptable, uuid(b6c2f9e1-53a0-45f2-a2b8-fe37861fe8a8)]
|
||||
interface nsIXULWindow : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -128,6 +128,7 @@ interface nsIXULWindow : nsISupports
|
|||
*/
|
||||
attribute PRUint32 contextFlags;
|
||||
|
||||
attribute PRUint32 chromeFlags;
|
||||
/**
|
||||
* Create a new window.
|
||||
* @param aChromeFlags see nsIWebBrowserChrome
|
||||
|
|
|
@ -88,8 +88,7 @@ private:
|
|||
//*****************************************************************************
|
||||
|
||||
nsContentTreeOwner::nsContentTreeOwner(PRBool fPrimary) : mXULWindow(nsnull),
|
||||
mPrimary(fPrimary), mContentTitleSetting(PR_FALSE),
|
||||
mChromeFlags(nsIWebBrowserChrome::CHROME_ALL)
|
||||
mPrimary(fPrimary), mContentTitleSetting(PR_FALSE)
|
||||
{
|
||||
// note if this fails, QI on nsIEmbeddingSiteWindow(2) will simply fail
|
||||
mSiteWindow2 = new nsSiteWindow2(this);
|
||||
|
@ -126,9 +125,6 @@ NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
|
|||
NS_ENSURE_ARG_POINTER(aSink);
|
||||
*aSink = 0;
|
||||
|
||||
if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome)))
|
||||
return mXULWindow->GetInterface(aIID, aSink);
|
||||
|
||||
if(aIID.Equals(NS_GET_IID(nsIPrompt)))
|
||||
return mXULWindow->GetInterface(aIID, aSink);
|
||||
if(aIID.Equals(NS_GET_IID(nsIAuthPrompt)))
|
||||
|
@ -136,12 +132,8 @@ NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
|
|||
if (aIID.Equals(NS_GET_IID(nsIDocShellTreeItem))) {
|
||||
nsCOMPtr<nsIDocShell> shell;
|
||||
mXULWindow->GetDocShell(getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
nsIDocShellTreeItem *result;
|
||||
CallQueryInterface(shell, &result);
|
||||
*aSink = result;
|
||||
return NS_OK;
|
||||
}
|
||||
if (shell)
|
||||
return shell->QueryInterface(aIID, aSink);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -406,34 +398,12 @@ NS_IMETHODIMP nsContentTreeOwner::GetWebBrowser(nsIWebBrowser** aWebBrowser)
|
|||
|
||||
NS_IMETHODIMP nsContentTreeOwner::SetChromeFlags(PRUint32 aChromeFlags)
|
||||
{
|
||||
mChromeFlags = aChromeFlags;
|
||||
NS_ENSURE_SUCCESS(ApplyChromeFlags(), NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
return mXULWindow->SetChromeFlags(aChromeFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::GetChromeFlags(PRUint32* aChromeFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChromeFlags);
|
||||
|
||||
*aChromeFlags = mChromeFlags;
|
||||
|
||||
/* mChromeFlags is kept up to date, except for scrollbar visibility.
|
||||
That can be changed directly by the content DOM window, which
|
||||
doesn't know to update the chrome window. So that we must check
|
||||
separately. */
|
||||
|
||||
// however, it's pointless to ask if the window isn't set up yet
|
||||
if (!mXULWindow->mChromeLoaded)
|
||||
return NS_OK;
|
||||
|
||||
PRBool scrollbarVisibility = mXULWindow->GetContentScrollbarVisibility();
|
||||
if (scrollbarVisibility)
|
||||
*aChromeFlags |= nsIWebBrowserChrome::CHROME_SCROLLBARS;
|
||||
else
|
||||
*aChromeFlags &= ~nsIWebBrowserChrome::CHROME_SCROLLBARS;
|
||||
|
||||
return NS_OK;
|
||||
return mXULWindow->GetChromeFlags(aChromeFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::DestroyBrowserWindow()
|
||||
|
@ -630,68 +600,6 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const PRUnichar* aTitle)
|
|||
return mXULWindow->SetTitle(title.get());
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsContentTreeOwner: Helpers
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::ApplyChromeFlags()
|
||||
{
|
||||
if(!mXULWindow->mChromeLoaded)
|
||||
return NS_OK; // We'll do this later when chrome is loaded
|
||||
|
||||
nsCOMPtr<nsIDOMElement> window;
|
||||
mXULWindow->GetWindowDOMElement(getter_AddRefs(window));
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||
|
||||
// menubar has its own special treatment
|
||||
mXULWindow->mWindow->ShowMenuBar(mChromeFlags &
|
||||
nsIWebBrowserChrome::CHROME_MENUBAR ?
|
||||
PR_TRUE : PR_FALSE);
|
||||
|
||||
/* Scrollbars have their own special treatment. (note here we *do* use
|
||||
mChromeFlags directly, without going through the accessor. This method
|
||||
is intended to be used right after setting mChromeFlags, so this is
|
||||
where the content window's scrollbar state is set to match mChromeFlags
|
||||
in the first place. */
|
||||
mXULWindow->SetContentScrollbarVisibility(mChromeFlags &
|
||||
nsIWebBrowserChrome::CHROME_SCROLLBARS ?
|
||||
PR_TRUE : PR_FALSE);
|
||||
|
||||
/* the other flags are handled together. we have style rules
|
||||
in navigator.css that trigger visibility based on
|
||||
the 'chromehidden' attribute of the <window> tag. */
|
||||
nsAutoString newvalue;
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR))
|
||||
newvalue.AppendLiteral("menubar ");
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR))
|
||||
newvalue.AppendLiteral("toolbar ");
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_LOCATIONBAR))
|
||||
newvalue.AppendLiteral("location ");
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR))
|
||||
newvalue.AppendLiteral("directories ");
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_STATUSBAR))
|
||||
newvalue.AppendLiteral("status ");
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_EXTRA))
|
||||
newvalue.AppendLiteral("extrachrome");
|
||||
|
||||
|
||||
// Get the old value, to avoid useless style reflows if we're just
|
||||
// setting stuff to the exact same thing.
|
||||
nsAutoString oldvalue;
|
||||
window->GetAttribute(NS_LITERAL_STRING("chromehidden"), oldvalue);
|
||||
|
||||
if (oldvalue != newvalue)
|
||||
window->SetAttribute(NS_LITERAL_STRING("chromehidden"), newvalue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsContentTreeOwner: Accessors
|
||||
//*****************************************************************************
|
||||
|
|
|
@ -77,8 +77,6 @@ protected:
|
|||
void XULWindow(nsXULWindow* aXULWindow);
|
||||
nsXULWindow* XULWindow();
|
||||
|
||||
NS_IMETHOD ApplyChromeFlags();
|
||||
|
||||
protected:
|
||||
nsXULWindow *mXULWindow;
|
||||
nsSiteWindow2 *mSiteWindow2;
|
||||
|
@ -88,9 +86,6 @@ protected:
|
|||
nsString mTitleSeparator;
|
||||
nsString mTitlePreface;
|
||||
nsString mTitleDefault;
|
||||
|
||||
private:
|
||||
PRUint32 mChromeFlags; // don't use directly! use GetChromeFlags()
|
||||
};
|
||||
|
||||
#endif /* nsContentTreeOwner_h__ */
|
||||
|
|
|
@ -125,7 +125,8 @@ nsXULWindow::nsXULWindow() : mChromeTreeOwner(nsnull),
|
|||
mShowAfterLoad(PR_FALSE), mIntrinsicallySized(PR_FALSE),
|
||||
mCenterAfterLoad(PR_FALSE), mIsHiddenWindow(PR_FALSE),
|
||||
mContextFlags(0), mBlurSuppressionLevel(0),
|
||||
mPersistentAttributesDirty(0), mPersistentAttributesMask(0)
|
||||
mPersistentAttributesDirty(0), mPersistentAttributesMask(0),
|
||||
mChromeFlags(nsIWebBrowserChrome::CHROME_ALL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -279,9 +280,35 @@ NS_IMETHODIMP nsXULWindow::GetContextFlags(PRUint32 *aContextFlags)
|
|||
NS_IMETHODIMP nsXULWindow::SetContextFlags(PRUint32 aContextFlags)
|
||||
{
|
||||
mContextFlags = aContextFlags;
|
||||
if(mContentTreeOwner)
|
||||
mContentTreeOwner->ApplyChromeFlags();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetChromeFlags(PRUint32 *aChromeFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChromeFlags);
|
||||
*aChromeFlags = mChromeFlags;
|
||||
/* mChromeFlags is kept up to date, except for scrollbar visibility.
|
||||
That can be changed directly by the content DOM window, which
|
||||
doesn't know to update the chrome window. So that we must check
|
||||
separately. */
|
||||
|
||||
// however, it's pointless to ask if the window isn't set up yet
|
||||
if (!mChromeLoaded)
|
||||
return NS_OK;
|
||||
|
||||
if (GetContentScrollbarVisibility())
|
||||
*aChromeFlags |= nsIWebBrowserChrome::CHROME_SCROLLBARS;
|
||||
else
|
||||
*aChromeFlags &= ~nsIWebBrowserChrome::CHROME_SCROLLBARS;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::SetChromeFlags(PRUint32 aChromeFlags)
|
||||
{
|
||||
mChromeFlags = aChromeFlags;
|
||||
if (mChromeLoaded)
|
||||
NS_ENSURE_SUCCESS(ApplyChromeFlags(), NS_ERROR_FAILURE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -926,9 +953,7 @@ void nsXULWindow::OnChromeLoaded()
|
|||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mChromeLoaded = PR_TRUE;
|
||||
|
||||
if(mContentTreeOwner)
|
||||
mContentTreeOwner->ApplyChromeFlags();
|
||||
ApplyChromeFlags();
|
||||
|
||||
LoadWindowClassFromXUL();
|
||||
LoadIconFromXUL();
|
||||
|
@ -1160,13 +1185,7 @@ PRBool nsXULWindow::LoadMiscPersistentAttributesFromXUL()
|
|||
/* Honor request to maximize only if the window is sizable.
|
||||
An unsizable, unmaximizable, yet maximized window confuses
|
||||
Windows OS and is something of a travesty, anyway. */
|
||||
PRUint32 chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_RESIZE;
|
||||
nsCOMPtr<nsIWebBrowserChrome> chrome(do_GetInterface(
|
||||
NS_ISUPPORTS_CAST(nsIXULWindow *, this)));
|
||||
if (chrome)
|
||||
chrome->GetChromeFlags(&chromeFlags);
|
||||
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
|
||||
if (mChromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
|
||||
mIntrinsicallySized = PR_FALSE;
|
||||
sizeMode = nsSizeMode_Maximized;
|
||||
}
|
||||
|
@ -1589,28 +1608,14 @@ NS_IMETHODIMP nsXULWindow::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
|||
nsContentShellInfo* shellInfo = nsnull;
|
||||
nsDependentString newID(aID);
|
||||
|
||||
PRBool resetTreeOwner = PR_FALSE;
|
||||
|
||||
PRInt32 count = mContentShells.Count();
|
||||
|
||||
// First null any extant references to us in any of the content shell
|
||||
// fields.
|
||||
PRInt32 i;
|
||||
for (i = 0; i < count; i++) {
|
||||
nsContentShellInfo* info = (nsContentShellInfo*)mContentShells.ElementAt(i);
|
||||
if (info->child == aContentShell) {
|
||||
info->child = nsnull;
|
||||
resetTreeOwner = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Now find the appropriate entry and put ourselves in as the content shell.
|
||||
for (i = 0; i < count; i++) {
|
||||
nsContentShellInfo* info = (nsContentShellInfo*)mContentShells.ElementAt(i);
|
||||
|
||||
if (info->primary == aPrimary && info->id.Equals(newID)) {
|
||||
// We already exist. Do a replace.
|
||||
info->child = aContentShell;
|
||||
info->id = newID;
|
||||
info->primary = aPrimary;
|
||||
shellInfo = info;
|
||||
break;
|
||||
}
|
||||
|
@ -1621,18 +1626,14 @@ NS_IMETHODIMP nsXULWindow::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
|||
mContentShells.AppendElement((void*)shellInfo);
|
||||
}
|
||||
|
||||
// Set the default content tree owner if one does not exist.
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
||||
aContentShell->GetTreeOwner(getter_AddRefs(treeOwner));
|
||||
if (!treeOwner || resetTreeOwner) {
|
||||
if (aPrimary) {
|
||||
NS_ENSURE_SUCCESS(EnsurePrimaryContentTreeOwner(), NS_ERROR_FAILURE);
|
||||
aContentShell->SetTreeOwner(mPrimaryContentTreeOwner);
|
||||
}
|
||||
else {
|
||||
NS_ENSURE_SUCCESS(EnsureContentTreeOwner(), NS_ERROR_FAILURE);
|
||||
aContentShell->SetTreeOwner(mContentTreeOwner);
|
||||
}
|
||||
// Set the default content tree owner
|
||||
if (aPrimary) {
|
||||
NS_ENSURE_SUCCESS(EnsurePrimaryContentTreeOwner(), NS_ERROR_FAILURE);
|
||||
aContentShell->SetTreeOwner(mPrimaryContentTreeOwner);
|
||||
}
|
||||
else {
|
||||
NS_ENSURE_SUCCESS(EnsureContentTreeOwner(), NS_ERROR_FAILURE);
|
||||
aContentShell->SetTreeOwner(mContentTreeOwner);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1708,10 +1709,7 @@ NS_IMETHODIMP nsXULWindow::CreateNewChromeWindow(PRInt32 aChromeFlags,
|
|||
|
||||
NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);
|
||||
|
||||
// XXX Ick, this should be able to go away.....
|
||||
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(newWindow));
|
||||
if(browserChrome)
|
||||
browserChrome->SetChromeFlags(aChromeFlags);
|
||||
newWindow->SetChromeFlags(aChromeFlags);
|
||||
|
||||
*_retval = newWindow;
|
||||
NS_ADDREF(*_retval);
|
||||
|
@ -1775,9 +1773,7 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(PRInt32 aChromeFlags,
|
|||
|
||||
nsCOMPtr<nsIWebShellWindow> webShellWindow(do_QueryInterface(newWindow));
|
||||
|
||||
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(newWindow));
|
||||
if(browserChrome)
|
||||
browserChrome->SetChromeFlags(aChromeFlags);
|
||||
newWindow->SetChromeFlags(aChromeFlags);
|
||||
|
||||
nsCOMPtr<nsIAppShell> subShell(do_CreateInstance(kAppShellCID));
|
||||
NS_ENSURE_TRUE(subShell, NS_ERROR_FAILURE);
|
||||
|
@ -2019,6 +2015,56 @@ void nsXULWindow::PersistentAttributesDirty(PRUint32 aDirtyFlags) {
|
|||
mPersistentAttributesDirty |= aDirtyFlags & mPersistentAttributesMask;
|
||||
}
|
||||
|
||||
nsresult nsXULWindow::ApplyChromeFlags()
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> window;
|
||||
GetWindowDOMElement(getter_AddRefs(window));
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||
|
||||
// menubar has its own special treatment
|
||||
mWindow->ShowMenuBar(mChromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR ?
|
||||
PR_TRUE : PR_FALSE);
|
||||
|
||||
// Scrollbars have their own special treatment.
|
||||
SetContentScrollbarVisibility(mChromeFlags &
|
||||
nsIWebBrowserChrome::CHROME_SCROLLBARS ?
|
||||
PR_TRUE : PR_FALSE);
|
||||
|
||||
/* the other flags are handled together. we have style rules
|
||||
in navigator.css that trigger visibility based on
|
||||
the 'chromehidden' attribute of the <window> tag. */
|
||||
nsAutoString newvalue;
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR))
|
||||
newvalue.AppendLiteral("menubar ");
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR))
|
||||
newvalue.AppendLiteral("toolbar ");
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_LOCATIONBAR))
|
||||
newvalue.AppendLiteral("location ");
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR))
|
||||
newvalue.AppendLiteral("directories ");
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_STATUSBAR))
|
||||
newvalue.AppendLiteral("status ");
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_EXTRA))
|
||||
newvalue.AppendLiteral("extrachrome ");
|
||||
|
||||
|
||||
// Get the old value, to avoid useless style reflows if we're just
|
||||
// setting stuff to the exact same thing.
|
||||
nsAutoString oldvalue;
|
||||
window->GetAttribute(NS_LITERAL_STRING("chromehidden"), oldvalue);
|
||||
|
||||
if (oldvalue != newvalue)
|
||||
window->SetAttribute(NS_LITERAL_STRING("chromehidden"), newvalue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetXULBrowserWindow(nsIXULBrowserWindow * *aXULBrowserWindow)
|
||||
{
|
||||
NS_IF_ADDREF(*aXULBrowserWindow = mXULBrowserWindow);
|
||||
|
|
|
@ -130,6 +130,7 @@ protected:
|
|||
void SetContentScrollbarVisibility(PRBool aVisible);
|
||||
PRBool GetContentScrollbarVisibility();
|
||||
void PersistentAttributesDirty(PRUint32 aDirtyFlags);
|
||||
nsresult ApplyChromeFlags();
|
||||
|
||||
nsChromeTreeOwner* mChromeTreeOwner;
|
||||
nsContentTreeOwner* mContentTreeOwner;
|
||||
|
@ -154,6 +155,7 @@ protected:
|
|||
PRUint32 mBlurSuppressionLevel;
|
||||
PRUint32 mPersistentAttributesDirty; // persistentAttributes
|
||||
PRUint32 mPersistentAttributesMask;
|
||||
PRUint32 mChromeFlags;
|
||||
nsString mTitle;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче