From 6fd2ac030174bfb202c5f2f30c93a02e356a5538 Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Tue, 7 Mar 2000 06:02:04 +0000 Subject: [PATCH] Bug #21358 --> Make sure we only call the on load handler ONCE per document. This prevents a nasty loop if the onload handler tries to load an ftp url. r=travis a=jar git-svn-id: svn://10.0.0.236/trunk@62295 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 5 +++-- mozilla/docshell/base/nsDocShell.h | 5 +++++ mozilla/docshell/base/nsWebShell.cpp | 4 +++- mozilla/webshell/src/nsWebShell.cpp | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 2ac0ad96bea..81ca3173224 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -73,7 +73,8 @@ nsDocShell::nsDocShell() : mTreeOwner(nsnull), mChromeEventHandler(nsnull), mCurrentScrollbarPref(-1,-1), - mDefaultScrollbarPref(-1,-1) + mDefaultScrollbarPref(-1,-1), + mEODForCurrentDocument (PR_FALSE) { NS_INIT_REFCNT(); } @@ -1893,7 +1894,7 @@ NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType, } NS_ENSURE_SUCCESS(SetupNewViewer(viewer), NS_ERROR_FAILURE); - + mEODForCurrentDocument = PR_FALSE; // clear the current flag return NS_OK; } diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index 9cdb2f371b4..bb1b278881f 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -199,6 +199,11 @@ protected: nsPoint mDefaultScrollbarPref; // persistent across doc loads PRBool mUpdateHistoryOnLoad; PRBool mInitialPageLoad; + // 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. + PRBool mEODForCurrentDocument; /* WEAK REFERENCES BELOW HERE. Note these are intentionally not addrefd. Doing so will create a cycle. diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index f3e5a5e23d4..dc6cf696f67 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -2667,7 +2667,7 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, if (loader == mDocLoader) { mProcessedEndDocumentLoad = PR_TRUE; - if (mScriptGlobal) { + if (mScriptGlobal && !mEODForCurrentDocument) { nsIDocumentViewer* docViewer; if (nsnull != mContentViewer && NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) { @@ -2685,6 +2685,8 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, } } + mEODForCurrentDocument = PR_TRUE; + // Fire the EndLoadURL of the web shell container if (nsnull != aURL) { nsAutoString urlString; diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index f3e5a5e23d4..dc6cf696f67 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -2667,7 +2667,7 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, if (loader == mDocLoader) { mProcessedEndDocumentLoad = PR_TRUE; - if (mScriptGlobal) { + if (mScriptGlobal && !mEODForCurrentDocument) { nsIDocumentViewer* docViewer; if (nsnull != mContentViewer && NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) { @@ -2685,6 +2685,8 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, } } + mEODForCurrentDocument = PR_TRUE; + // Fire the EndLoadURL of the web shell container if (nsnull != aURL) { nsAutoString urlString;