Set the chromehidden attribute earlier, so we don't have to reresolve style and

redo layout on the whole window.  Bug 345560, r=sicking, sr=neil.
This commit is contained in:
bzbarsky%mit.edu 2006-07-25 00:20:33 +00:00
Родитель 39ebc1b4f3
Коммит ada7c7aa95
5 изменённых файлов: 48 добавлений и 16 удалений

Просмотреть файл

@ -70,6 +70,7 @@ REQUIRES = xpcom \
xultmpl \
webshell \
unicharutil \
appshell \
$(NULL)
CPPSRCS = nsXULControllers.cpp

Просмотреть файл

@ -122,6 +122,9 @@
#include "nsContentErrors.h"
#include "nsIObserverService.h"
#include "nsNodeUtils.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIXULWindow.h"
//----------------------------------------------------------------------
//
@ -2940,6 +2943,25 @@ nsXULDocument::ResumeWalk()
}
SetTitle(title);
// Before starting layout, check whether we're a toplevel chrome
// window. If we are, set our chrome flags now, so that we don't have
// to restyle the whole frame tree after StartLayout.
nsCOMPtr<nsISupports> container = GetContainer();
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(container);
if (item) {
nsCOMPtr<nsIDocShellTreeOwner> owner;
item->GetTreeOwner(getter_AddRefs(owner));
nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(owner);
if (xulWin) {
nsCOMPtr<nsIDocShell> xulWinShell;
xulWin->GetDocShell(getter_AddRefs(xulWinShell));
if (SameCOMIdentity(xulWinShell, container)) {
// We're the chrome document! Apply our chrome flags now.
xulWin->ApplyChromeFlags();
}
}
}
StartLayout();
if (mIsWritingFastLoad && IsChromeURI(mDocumentURI))

Просмотреть файл

@ -138,4 +138,12 @@ interface nsIXULWindow : nsISupports
in nsIAppShell aAppShell);
attribute nsIXULBrowserWindow XULBrowserWindow;
/**
* Back-door method to force application of chrome flags at a particular
* time. Do NOT call this unless you know what you're doing! In particular,
* calling this when this XUL window doesn't yet have a document in its
* docshell could cause problems.
*/
[noscript] void applyChromeFlags();
};

Просмотреть файл

@ -2012,20 +2012,27 @@ void nsXULWindow::PersistentAttributesDirty(PRUint32 aDirtyFlags)
mPersistentAttributesDirty |= aDirtyFlags & mPersistentAttributesMask;
}
nsresult nsXULWindow::ApplyChromeFlags()
NS_IMETHODIMP 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);
if (mChromeLoaded) {
// The two calls in this block don't need to happen early because they
// don't cause a global restyle on the document. Not only that, but the
// scrollbar stuff needs a content area to toggle the scrollbars on anyway.
// So just don't do these until mChromeLoaded is true.
// menubar has its own special treatment
mWindow->ShowMenuBar(mChromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR ?
PR_TRUE : PR_FALSE);
// Scrollbars have their own special treatment.
SetContentScrollbarVisibility(mChromeFlags &
// Scrollbars have their own special treatment.
SetContentScrollbarVisibility(mChromeFlags &
nsIWebBrowserChrome::CHROME_SCROLLBARS ?
PR_TRUE : PR_FALSE);
PR_TRUE : PR_FALSE);
}
/* the other flags are handled together. we have style rules
in navigator.css that trigger visibility based on
@ -2050,14 +2057,9 @@ nsresult nsXULWindow::ApplyChromeFlags()
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);
// Note that if we're not actually changing the value this will be a no-op,
// so no need to compare to the old value.
window->SetAttribute(NS_LITERAL_STRING("chromehidden"), newvalue);
return NS_OK;
}

Просмотреть файл

@ -148,7 +148,6 @@ protected:
void SetContentScrollbarVisibility(PRBool aVisible);
PRBool GetContentScrollbarVisibility();
void PersistentAttributesDirty(PRUint32 aDirtyFlags);
nsresult ApplyChromeFlags();
nsChromeTreeOwner* mChromeTreeOwner;
nsContentTreeOwner* mContentTreeOwner;