Bug 18553, better fix which should cause fewer problems. Clear event listeners

before every document load, including the first, except when setNewDocument
is called from document.open. r=heikki, sr=jst
This commit is contained in:
mstoltz%netscape.com 2001-10-02 00:54:44 +00:00
parent d4b47f80bb
commit 9dcfafdfd4
10 changed files with 26 additions and 15 deletions

View File

@ -950,7 +950,7 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget,
mDocument->SetScriptGlobalObject(global);
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(mDocument));
if (nsnull != domdoc) {
global->SetNewDocument(domdoc);
global->SetNewDocument(domdoc, PR_TRUE);
}
}
}
@ -1168,7 +1168,7 @@ DocumentViewerImpl::Close()
nsCOMPtr<nsIScriptGlobalObject> globalObject;
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
if (globalObject) {
globalObject->SetNewDocument(nsnull);
globalObject->SetNewDocument(nsnull, PR_TRUE);
}
// out of band cleanup of webshell
mDocument->SetScriptGlobalObject(nsnull);
@ -1286,7 +1286,7 @@ DocumentViewerImpl::SetDOMDocument(nsIDOMDocument *aDocument)
rv = owner->GetScriptGlobalObject(getter_AddRefs(global));
if (NS_SUCCEEDED(rv) && (nsnull != global)) {
mDocument->SetScriptGlobalObject(global);
global->SetNewDocument(aDocument);
global->SetNewDocument(aDocument, PR_TRUE);
}
}
}

View File

@ -2105,7 +2105,7 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURL)
nsCOMPtr<nsIDOMDocument> kungFuDeathGrip =
do_QueryInterface((nsIHTMLDocument*)this);
result = mScriptGlobalObject->SetNewDocument(kungFuDeathGrip);
result = mScriptGlobalObject->SetNewDocument(kungFuDeathGrip, PR_FALSE);
if (NS_FAILED(result))
return result;

View File

@ -116,7 +116,8 @@ public:
// nsIScriptGlobalObject methods
NS_IMETHOD SetContext(nsIScriptContext *aContext);
NS_IMETHOD GetContext(nsIScriptContext **aContext);
NS_IMETHOD SetNewDocument(nsIDOMDocument *aDocument);
NS_IMETHOD SetNewDocument(nsIDOMDocument *aDocument,
PRBool removeEventListeners);
NS_IMETHOD SetDocShell(nsIDocShell *aDocShell);
NS_IMETHOD GetDocShell(nsIDocShell **aDocShell);
NS_IMETHOD SetOpenerWindow(nsIDOMWindowInternal *aOpener);
@ -238,7 +239,8 @@ nsXBLDocGlobalObject::GetContext(nsIScriptContext **aContext)
NS_IMETHODIMP
nsXBLDocGlobalObject::SetNewDocument(nsIDOMDocument *aDocument)
nsXBLDocGlobalObject::SetNewDocument(nsIDOMDocument *aDocument,
PRBool removeEventListeners)
{
NS_NOTREACHED("waaah!");
return NS_ERROR_UNEXPECTED;

View File

@ -84,7 +84,8 @@ public:
// nsIScriptGlobalObject methods
NS_IMETHOD SetContext(nsIScriptContext *aContext);
NS_IMETHOD GetContext(nsIScriptContext **aContext);
NS_IMETHOD SetNewDocument(nsIDOMDocument *aDocument);
NS_IMETHOD SetNewDocument(nsIDOMDocument *aDocument,
PRBool removeEventListeners);
NS_IMETHOD SetDocShell(nsIDocShell *aDocShell);
NS_IMETHOD GetDocShell(nsIDocShell **aDocShell);
NS_IMETHOD SetOpenerWindow(nsIDOMWindowInternal *aOpener);
@ -636,7 +637,8 @@ nsXULPDGlobalObject::GetContext(nsIScriptContext **aContext)
NS_IMETHODIMP
nsXULPDGlobalObject::SetNewDocument(nsIDOMDocument *aDocument)
nsXULPDGlobalObject::SetNewDocument(nsIDOMDocument *aDocument,
PRBool removeEventListeners)
{
NS_NOTREACHED("waaah!");
return NS_ERROR_UNEXPECTED;

3
dom/jar.mn Normal file
View File

@ -0,0 +1,3 @@
en-US.jar:
locale/en-US/communicator/dom/dom.properties (resources/locale/dom.properties)

View File

@ -66,7 +66,8 @@ public:
NS_IMETHOD SetContext(nsIScriptContext *aContext)=0;
NS_IMETHOD GetContext(nsIScriptContext **aContext)=0;
NS_IMETHOD SetNewDocument(nsIDOMDocument *aDocument)=0;
NS_IMETHOD SetNewDocument(nsIDOMDocument *aDocument,
PRBool removeEventListeners)=0;
NS_IMETHOD SetDocShell(nsIDocShell *aDocShell)=0;
NS_IMETHOD GetDocShell(nsIDocShell **aDocShell)=0;
NS_IMETHOD SetOpenerWindow(nsIDOMWindowInternal *aOpener)=0;

View File

@ -0,0 +1 @@
JSURLLoadBlockedWarning=Attempt to load a javascript: URL from one host\nin a window displaying content from another host\nwas blocked by the security manager.

View File

@ -288,7 +288,8 @@ NS_IMETHODIMP GlobalWindowImpl::GetContext(nsIScriptContext ** aContext)
return NS_OK;
}
NS_IMETHODIMP GlobalWindowImpl::SetNewDocument(nsIDOMDocument* aDocument)
NS_IMETHODIMP GlobalWindowImpl::SetNewDocument(nsIDOMDocument* aDocument,
PRBool removeEventListeners)
{
if (!aDocument) {
if (mDocument) {
@ -376,7 +377,7 @@ NS_IMETHODIMP GlobalWindowImpl::SetNewDocument(nsIDOMDocument* aDocument)
doc = nsnull; // Forces release now
}
if (mListenerManager) {
if (removeEventListeners && mListenerManager) {
mListenerManager->RemoveAllListeners(PR_FALSE);
mListenerManager = nsnull;
}

View File

@ -125,7 +125,8 @@ public:
// nsIScriptGlobalObject
NS_IMETHOD SetContext(nsIScriptContext *aContext);
NS_IMETHOD GetContext(nsIScriptContext **aContext);
NS_IMETHOD SetNewDocument(nsIDOMDocument *aDocument);
NS_IMETHOD SetNewDocument(nsIDOMDocument *aDocument,
PRBool removeEventListeners);
NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
NS_IMETHOD GetDocShell(nsIDocShell** aDocShell);
NS_IMETHOD SetOpenerWindow(nsIDOMWindowInternal *aOpener);

View File

@ -950,7 +950,7 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget,
mDocument->SetScriptGlobalObject(global);
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(mDocument));
if (nsnull != domdoc) {
global->SetNewDocument(domdoc);
global->SetNewDocument(domdoc, PR_TRUE);
}
}
}
@ -1168,7 +1168,7 @@ DocumentViewerImpl::Close()
nsCOMPtr<nsIScriptGlobalObject> globalObject;
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
if (globalObject) {
globalObject->SetNewDocument(nsnull);
globalObject->SetNewDocument(nsnull, PR_TRUE);
}
// out of band cleanup of webshell
mDocument->SetScriptGlobalObject(nsnull);
@ -1286,7 +1286,7 @@ DocumentViewerImpl::SetDOMDocument(nsIDOMDocument *aDocument)
rv = owner->GetScriptGlobalObject(getter_AddRefs(global));
if (NS_SUCCEEDED(rv) && (nsnull != global)) {
mDocument->SetScriptGlobalObject(global);
global->SetNewDocument(aDocument);
global->SetNewDocument(aDocument, PR_TRUE);
}
}
}