From cf85cc663c3167c7ff82af760e501caee2789e71 Mon Sep 17 00:00:00 2001 From: "joki%netscape.com" Date: Mon, 29 Mar 1999 23:01:13 +0000 Subject: [PATCH] Adding unload event git-svn-id: svn://10.0.0.236/trunk@25479 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 22 +++++++++++++++++++++- mozilla/webshell/src/nsWebShell.cpp | 22 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index b077a9d9964..752a608e851 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -2071,7 +2071,27 @@ nsWebShell::ReleaseScriptContext(nsIScriptContext *aContext) NS_IMETHODIMP nsWebShell::OnStartDocumentLoad(nsIURL* aURL, const char* aCommand) { - return NS_OK; + nsIDocumentViewer* docViewer; + nsresult rv = NS_ERROR_FAILURE; + + if (nsnull != mScriptGlobal) { + if (nsnull != mContentViewer && + NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) { + nsIPresContext *presContext; + if (NS_OK == docViewer->GetPresContext(presContext)) { + nsEventStatus status = nsEventStatus_eIgnore; + nsMouseEvent event; + event.eventStructType = NS_EVENT; + event.message = NS_PAGE_UNLOAD; + rv = mScriptGlobal->HandleDOMEvent(*presContext, &event, nsnull, NS_EVENT_FLAG_INIT, status); + + NS_RELEASE(presContext); + } + NS_RELEASE(docViewer); + } + } + + return rv; } NS_IMETHODIMP diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index b077a9d9964..752a608e851 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -2071,7 +2071,27 @@ nsWebShell::ReleaseScriptContext(nsIScriptContext *aContext) NS_IMETHODIMP nsWebShell::OnStartDocumentLoad(nsIURL* aURL, const char* aCommand) { - return NS_OK; + nsIDocumentViewer* docViewer; + nsresult rv = NS_ERROR_FAILURE; + + if (nsnull != mScriptGlobal) { + if (nsnull != mContentViewer && + NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) { + nsIPresContext *presContext; + if (NS_OK == docViewer->GetPresContext(presContext)) { + nsEventStatus status = nsEventStatus_eIgnore; + nsMouseEvent event; + event.eventStructType = NS_EVENT; + event.message = NS_PAGE_UNLOAD; + rv = mScriptGlobal->HandleDOMEvent(*presContext, &event, nsnull, NS_EVENT_FLAG_INIT, status); + + NS_RELEASE(presContext); + } + NS_RELEASE(docViewer); + } + } + + return rv; } NS_IMETHODIMP