Fixing bug 243213. Don't waste time looking up the nsIURIFixup service for every docshell, and move some members around to make things align up and pack better on some 64-bit platforms. r=bzbarsky@mit.edu, sr=darin@meer.net

This commit is contained in:
jst%mozilla.jstenback.com 2004-05-11 00:12:09 +00:00
Родитель b89e5c16d2
Коммит 94fc777387
3 изменённых файлов: 100 добавлений и 89 удалений

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

@ -173,6 +173,12 @@ static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
// Number of documents currently loading
static PRInt32 gNumberOfDocumentsLoading = 0;
// Global count of existing docshells.
static PRInt32 gDocShellCount = 0;
// Global reference to the URI fixup service.
nsIURIFixup *nsDocShell::sURIFixup = 0;
// Hint for native dispatch of plevents on how long to delay after
// all documents have loaded in milliseconds before favoring normal
// native event dispatch priorites over performance
@ -233,12 +239,6 @@ nsDocShellFocusController nsDocShellFocusController::mDocShellFocusControllerSin
//*****************************************************************************
nsDocShell::nsDocShell():
mContentListener(nsnull),
mMarginWidth(0),
mMarginHeight(0),
mItemType(typeContent),
mCurrentScrollbarPref(-1, -1),
mDefaultScrollbarPref(-1, -1),
mAllowSubframes(PR_TRUE),
mAllowPlugins(PR_TRUE),
mAllowJavascript(PR_TRUE),
@ -249,8 +249,6 @@ nsDocShell::nsDocShell():
mCreatingDocument(PR_FALSE),
mUseErrorPages(PR_FALSE),
mAllowAuth(PR_TRUE),
mAppType(nsIDocShell::APP_TYPE_UNKNOWN),
mBusyFlags(BUSY_FLAGS_NONE),
mFiredUnloadEvent(PR_FALSE),
mEODForCurrentDocument(PR_FALSE),
mURIResultedInDocument(PR_FALSE),
@ -260,11 +258,27 @@ nsDocShell::nsDocShell():
mValidateOrigin(PR_FALSE),
mIsExecutingOnLoadHandler(PR_FALSE),
mIsPrintingOrPP(PR_FALSE),
mAppType(nsIDocShell::APP_TYPE_UNKNOWN),
mChildOffset(0),
mBusyFlags(BUSY_FLAGS_NONE),
mMarginWidth(0),
mMarginHeight(0),
mItemType(typeContent),
mContentListener(nsnull),
mCurrentScrollbarPref(-1, -1),
mDefaultScrollbarPref(-1, -1),
mEditorData(nsnull),
mParent(nsnull),
mTreeOwner(nsnull),
mChromeEventHandler(nsnull)
{
if (gDocShellCount++ == 0) {
NS_ASSERTION(sURIFixup == nsnull,
"Huh, sURIFixup not null in first nsDocShell ctor!");
CallGetService(NS_URIFIXUP_CONTRACTID, &sURIFixup);
}
#ifdef PR_LOGGING
if (! gDocShellLog)
gDocShellLog = PR_NewLogModule("nsDocShell");
@ -278,6 +292,10 @@ nsDocShell::~nsDocShell()
dsfc->ClosingDown(this);
}
Destroy();
if (--gDocShellCount == 0) {
NS_IF_RELEASE(sURIFixup);
}
}
NS_IMETHODIMP
@ -2469,23 +2487,19 @@ nsDocShell::LoadURI(const PRUnichar * aURI,
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_OK;
// Create the fixup object if necessary
if (!mURIFixup) {
mURIFixup = do_GetService(NS_URIFIXUP_CONTRACTID);
if (!mURIFixup) {
// No fixup service so try and create a URI and see what happens
nsAutoString uriString(aURI);
// Cleanup the empty spaces that might be on each end.
uriString.Trim(" ");
// Eliminate embedded newlines, which single-line text fields now allow:
uriString.StripChars("\r\n");
NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE);
if (!sURIFixup) {
// No fixup service so try and create a URI and see what happens
nsAutoString uriString(aURI);
// Cleanup the empty spaces that might be on each end.
uriString.Trim(" ");
// Eliminate embedded newlines, which single-line text fields now allow:
uriString.StripChars("\r\n");
NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE);
rv = NS_NewURI(getter_AddRefs(uri), uriString);
}
}
if (mURIFixup) {
rv = NS_NewURI(getter_AddRefs(uri), uriString);
} else {
// Call the fixup object
rv = mURIFixup->CreateFixupURI(NS_ConvertUCS2toUTF8(aURI),
rv = sURIFixup->CreateFixupURI(NS_ConvertUCS2toUTF8(aURI),
nsIURIFixup::FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP,
getter_AddRefs(uri));
}
@ -7048,19 +7062,16 @@ nsDocShell::InterfaceRequestorProxy::GetInterface(const nsIID & aIID, void **aSi
nsresult
nsDocShell::SetBaseUrlForWyciwyg(nsIContentViewer * aContentViewer)
{
nsCOMPtr<nsIURI> baseURI;
nsCOMPtr<nsIDocument> document;
nsresult rv = NS_OK;
if (!aContentViewer)
return NS_ERROR_FAILURE;
// Create the fixup object if necessary
if (!mURIFixup)
mURIFixup = do_GetService(NS_URIFIXUP_CONTRACTID, &rv);
nsCOMPtr<nsIURI> baseURI;
nsCOMPtr<nsIDocument> document;
nsresult rv = NS_ERROR_NOT_AVAILABLE;
if (mURIFixup)
rv = mURIFixup->CreateExposableURI(mCurrentURI, getter_AddRefs(baseURI));
if (sURIFixup)
rv = sURIFixup->CreateExposableURI(mCurrentURI,
getter_AddRefs(baseURI));
// Get the current document and set the base uri
if (baseURI) {

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

@ -326,6 +326,59 @@ protected:
nsIChannel * aChannel,
nsresult aResult);
protected:
PRPackedBool mAllowSubframes;
PRPackedBool mAllowPlugins;
PRPackedBool mAllowJavascript;
PRPackedBool mAllowMetaRedirects;
PRPackedBool mAllowImages;
PRPackedBool mFocusDocFirst;
PRPackedBool mHasFocus;
PRPackedBool mCreatingDocument; // (should be) debugging only
PRPackedBool mUseErrorPages;
PRPackedBool mAllowAuth;
PRPackedBool mFiredUnloadEvent;
// this flag is for bug #21358. a docshell may load many urls
// which don't result in new documents being created (i.e. a new
// content viewer) we want to make sure we don't call a on load
// event more than once for a given content viewer.
PRPackedBool mEODForCurrentDocument;
PRPackedBool mURIResultedInDocument;
PRPackedBool mIsBeingDestroyed;
// used to keep track of whether user click links should be handle
// by us or immediately kicked out to an external
// application. mscott: eventually i'm going to try to fold this
// up into the uriloader where it belongs but i haven't figured
// out how to do that yet.
PRPackedBool mUseExternalProtocolHandler;
// Disallow popping up new windows with target=
PRPackedBool mDisallowPopupWindows;
// Validate window targets to prevent frameset spoofing
PRPackedBool mValidateOrigin;
PRPackedBool mIsExecutingOnLoadHandler;
// Indicates that a DocShell in this "docshell tree" is printing
PRPackedBool mIsPrintingOrPP;
PRUint32 mAppType;
// Offset in the parent's child list.
PRInt32 mChildOffset;
PRUint32 mBusyFlags;
PRInt32 mMarginWidth;
PRInt32 mMarginHeight;
PRInt32 mItemType;
PRUint32 mLoadType;
nsString mName;
nsString mTitle;
nsVoidArray mChildren;
@ -345,30 +398,9 @@ protected:
nsCOMPtr<nsISHistory> mSessionHistory;
nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
nsCOMPtr<nsISupports> mLoadCookie; // the load cookie associated with the window context.
nsCOMPtr<nsIURIFixup> mURIFixup;
nsCOMPtr<nsIWebBrowserFind> mFind;
PRInt32 mMarginWidth;
PRInt32 mMarginHeight;
PRInt32 mItemType;
nsPoint mCurrentScrollbarPref; // this document only
nsPoint mDefaultScrollbarPref; // persistent across doc loads
PRUint32 mLoadType;
PRBool mAllowSubframes;
PRPackedBool mAllowPlugins;
PRPackedBool mAllowJavascript;
PRPackedBool mAllowMetaRedirects;
PRPackedBool mAllowImages;
PRPackedBool mFocusDocFirst;
PRPackedBool mHasFocus;
PRPackedBool mCreatingDocument; // (should be) debugging only
PRPackedBool mUseErrorPages;
PRPackedBool mAllowAuth;
PRUint32 mAppType;
PRInt32 mChildOffset; // Offset in the parent's child list.
PRUint32 mBusyFlags;
// Reference to the SHEntry for this docshell until the page is destroyed.
// Somebody give me better name
nsCOMPtr<nsISHEntry> mOSHE;
@ -376,34 +408,6 @@ protected:
// Somebody give me better name
nsCOMPtr<nsISHEntry> mLSHE;
PRPackedBool mFiredUnloadEvent;
// this flag is for bug #21358. a docshell may load many urls
// which don't result in new documents being created (i.e. a new content viewer)
// we want to make sure we don't call a on load event more than once for a given
// content viewer.
PRPackedBool mEODForCurrentDocument;
PRPackedBool mURIResultedInDocument;
PRPackedBool mIsBeingDestroyed;
// used to keep track of whether user click links should be handle by us
// or immediately kicked out to an external application. mscott: eventually
// i'm going to try to fold this up into the uriloader where it belongs but i haven't
// figured out how to do that yet.
PRPackedBool mUseExternalProtocolHandler;
// Disallow popping up new windows with target=
PRPackedBool mDisallowPopupWindows;
// Validate window targets to prevent frameset spoofing
PRPackedBool mValidateOrigin;
PRPackedBool mIsExecutingOnLoadHandler;
// Indicates that a DocShell in this "docshell tree" is printing
PRPackedBool mIsPrintingOrPP;
// Editor stuff
nsDocShellEditorData* mEditorData; // editor data, if any
@ -418,6 +422,8 @@ protected:
nsIDocShellTreeOwner * mTreeOwner; // Weak Reference
nsIChromeEventHandler * mChromeEventHandler; //Weak Reference
static nsIURIFixup *sURIFixup;
public:
class InterfaceRequestorProxy : public nsIInterfaceRequestor {

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

@ -773,13 +773,7 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
return NS_OK;
}
// Create the fixup object if necessary
if (!mURIFixup)
{
mURIFixup = do_GetService(NS_URIFIXUP_CONTRACTID);
}
if (mURIFixup)
if (sURIFixup)
{
//
// Try and make an alternative URI from the old one
@ -870,7 +864,7 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
if (doCreateAlternate)
{
newURI = nsnull;
mURIFixup->CreateFixupURI(oldSpec,
sURIFixup->CreateFixupURI(oldSpec,
nsIURIFixup::FIXUP_FLAGS_MAKE_ALTERNATE_URI, getter_AddRefs(newURI));
}
}