From 5be4b0641dbdccd3577daa64cbd756e0d4541c05 Mon Sep 17 00:00:00 2001 From: "jkeiser%netscape.com" Date: Thu, 1 Aug 2002 18:17:48 +0000 Subject: [PATCH] Make compose window not invoke double form submit protection (bug 136906), r=darin, sr=rpotts, a=rjesup git-svn-id: svn://10.0.0.236/trunk@126170 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsHTMLFormElement.cpp | 16 +++++++--- .../mailnews/compose/src/nsSmtpService.cpp | 29 ++++++++++++++----- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp index f993303ad8a..6ea031a8e7a 100644 --- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -827,10 +827,18 @@ nsHTMLFormElement::DoSubmit(nsIPresContext* aPresContext, nsEvent* aEvent) // or request; for example, if it's to a named anchor within the same page // the submit will not really do anything. if (docShell) { - nsCOMPtr webProgress = do_GetInterface(docShell); - NS_ASSERTION(webProgress, "nsIDocShell not converted to nsIWebProgress!"); - rv = webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_ALL); - NS_ENSURE_SUBMIT_SUCCESS(rv); + // If the channel is pending, we have to listen for web progress. + PRBool pending = PR_FALSE; + mSubmittingRequest->IsPending(&pending); + if (pending) { + nsCOMPtr webProgress = do_GetInterface(docShell); + NS_ASSERTION(webProgress, "nsIDocShell not converted to nsIWebProgress!"); + rv = webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_ALL); + NS_ENSURE_SUBMIT_SUCCESS(rv); + } else { + mSubmittingRequest = nsnull; + mIsSubmitting = PR_FALSE; + } } else { // in case we didn't do anything, reset mIsSubmitting diff --git a/mozilla/mailnews/compose/src/nsSmtpService.cpp b/mozilla/mailnews/compose/src/nsSmtpService.cpp index bd25b831618..d76cef95a80 100644 --- a/mozilla/mailnews/compose/src/nsSmtpService.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpService.cpp @@ -377,6 +377,7 @@ public: protected: nsCOMPtr m_url; nsresult mStatus; + nsCOMPtr mLoadGroup; }; nsMailtoChannel::nsMailtoChannel(nsIURI * aURI) @@ -392,19 +393,21 @@ NS_IMPL_ISUPPORTS2(nsMailtoChannel, nsIChannel, nsIRequest); NS_IMETHODIMP nsMailtoChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup) { - *aLoadGroup = nsnull; - return NS_OK; + *aLoadGroup = mLoadGroup; + NS_IF_ADDREF(*aLoadGroup); + return NS_OK; } NS_IMETHODIMP nsMailtoChannel::SetLoadGroup(nsILoadGroup * aLoadGroup) { - return NS_OK; + mLoadGroup = aLoadGroup; + return NS_OK; } NS_IMETHODIMP nsMailtoChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks) { - NS_NOTREACHED("GetNotificationCallbacks"); - return NS_ERROR_NOT_IMPLEMENTED; + NS_NOTREACHED("GetNotificationCallbacks"); + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP nsMailtoChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks) @@ -414,8 +417,8 @@ NS_IMETHODIMP nsMailtoChannel::SetNotificationCallbacks(nsIInterfaceRequestor* a NS_IMETHODIMP nsMailtoChannel::GetOriginalURI(nsIURI* *aURI) { - *aURI = nsnull; - return NS_OK; + *aURI = nsnull; + return NS_OK; } NS_IMETHODIMP nsMailtoChannel::SetOriginalURI(nsIURI* aURI) @@ -438,6 +441,11 @@ NS_IMETHODIMP nsMailtoChannel::Open(nsIInputStream **_retval) NS_IMETHODIMP nsMailtoChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { + // Add to the load group to fire start event + if (mLoadGroup) { + mLoadGroup->AddRequest(this, ctxt); + } + mStatus = listener->OnStartRequest(this, ctxt); // If OnStartRequest(...) failed, then propagate the error code... @@ -449,6 +457,11 @@ NS_IMETHODIMP nsMailtoChannel::AsyncOpen(nsIStreamListener *listener, nsISupport // Call OnStopRequest(...) for correct-ness. (void) listener->OnStopRequest(this, ctxt, mStatus); + // Remove from the load group to fire stop event + if (mLoadGroup) { + mLoadGroup->RemoveRequest(this, ctxt, mStatus); + } + // Always return NS_ERROR_NO_CONTENT since this channel never provides // data... return NS_ERROR_NO_CONTENT; @@ -532,7 +545,7 @@ NS_IMETHODIMP nsMailtoChannel::GetName(nsACString &aName) NS_IMETHODIMP nsMailtoChannel::IsPending(PRBool *result) { - *result = PR_TRUE; + *result = PR_FALSE; return NS_OK; }