From e674affbbee86a182af197d96c6d7dd41a6a4342 Mon Sep 17 00:00:00 2001 From: "joki%netscape.com" Date: Thu, 13 May 1999 23:51:25 +0000 Subject: [PATCH] Adding unload event during window closing. git-svn-id: svn://10.0.0.236/trunk@31519 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 19 +++++++++++++++++++ mozilla/webshell/src/nsWebShell.cpp | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 34872b5dc6f..c6f233f2ce7 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -897,6 +897,25 @@ nsWebShell::Destroy() { nsresult rv = NS_OK; + //Fire unload event before we blow anything away. + if (nsnull != mScriptGlobal) { + nsIDocumentViewer* docViewer; + 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); + } + } + // Stop any URLs that are currently being loaded... Stop(); diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 34872b5dc6f..c6f233f2ce7 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -897,6 +897,25 @@ nsWebShell::Destroy() { nsresult rv = NS_OK; + //Fire unload event before we blow anything away. + if (nsnull != mScriptGlobal) { + nsIDocumentViewer* docViewer; + 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); + } + } + // Stop any URLs that are currently being loaded... Stop();