nsCOMPtr<nsIFormSubmission> submission; nsresult rv = GetSubmissionFromForm(this, aPresContext, getter_AddRefs(submission)); NS_ENSURE_SUBMIT_SUCCESS(rv);     rv = WalkFormElements(submission, originatingElement); NS_ENSURE_SUBMIT_SUCCESS(rv);     nsCOMPtr<nsIURI> actionURI; rv = GetActionURL(getter_AddRefs(actionURI)); NS_ENSURE_SUBMIT_SUCCESS(rv);  if (!actionURI) { mIsSubmitting = PR_FALSE; return NS_OK; }       PRBool schemeIsJavaScript = PR_FALSE; if (NS_SUCCEEDED(actionURI->SchemeIs("javascript", &schemeIsJavaScript)) && schemeIsJavaScript) { mIsSubmitting = PR_FALSE; }  nsAutoString target; rv = GetTarget(target); NS_ENSURE_SUBMIT_SUCCESS(rv);     PRBool aCancelSubmit = PR_FALSE; rv = NotifySubmitObservers(actionURI, &aCancelSubmit); NS_ENSURE_SUBMIT_SUCCESS(rv);  if (aCancelSubmit) { mIsSubmitting = PR_FALSE; return NS_OK; }     nsCOMPtr<nsIDocShell> docShell; rv = submission->SubmitTo(actionURI, target, this, aPresContext, getter_AddRefs(docShell), getter_AddRefs(mSubmittingRequest)); NS_ENSURE_SUBMIT_SUCCESS(rv);     if (docShell) {  PRBool pending = PR_FALSE; mSubmittingRequest->IsPending(&pending); if (pending) { mWebProgress = do_GetInterface(docShell); NS_ASSERTION(mWebProgress, "nsIDocShell not converted to nsIWebProgress!"); rv = mWebProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_ALL); NS_ENSURE_SUBMIT_SUCCESS(rv); } else { ForgetCurrentSubmission(); } } else { ForgetCurrentSubmission(); }  return rv;
return NS_OK;
nsHTMLFormElement::DoSubmit(nsIPresContext* aPresContext, nsEvent* aEvent){  NS_ASSERTION(!mIsSubmitting, "Either two people are trying to submit or the "               "previous submit was not properly cancelled by the DocShell");  if (mIsSubmitting) {    // XXX Should this return an error?    return NS_OK;  }  // Mark us as submitting so that we don't try to submit again  mIsSubmitting = PR_TRUE;  NS_ASSERTION(!mWebProgress && !mSubmittingRequest, "Web progress / submitting request should not exist here!");  // Get the originating frame (failure is non-fatal)  nsIContent *originatingElement = nsnull;  if (aEvent) {    if (NS_FORM_EVENT == aEvent->eventStructType) {      originatingElement = ((nsFormEvent *)aEvent)->originator;    }  }  //  // Get the submission object  //  nsCOMPtr<nsIFormSubmission> submission;  nsresult rv = GetSubmissionFromForm(this, aPresContext,                                      getter_AddRefs(submission));  NS_ENSURE_SUBMIT_SUCCESS(rv);  //  // Dump the data into the submission object  //  rv = WalkFormElements(submission, originatingElement);  NS_ENSURE_SUBMIT_SUCCESS(rv);  //  // Get the action and target  //  nsCOMPtr<nsIURI> actionURI;  rv = GetActionURL(getter_AddRefs(actionURI));  NS_ENSURE_SUBMIT_SUCCESS(rv);  if (!actionURI) {    mIsSubmitting = PR_FALSE;    return NS_OK;  }  // javascript URIs are not really submissions; they just call a function.  // Also, they may synchronously call submit(), and we want them to be able to  // do so while still disallowing other double submissions. (Bug 139798)  // Note that any other URI types that are of equivalent type should also be  // added here.  PRBool schemeIsJavaScript = PR_FALSE;  if (NS_SUCCEEDED(actionURI->SchemeIs("javascript", &schemeIsJavaScript)) &&      schemeIsJavaScript) {    mIsSubmitting = PR_FALSE;  }  nsAutoString target;  rv = GetTarget(target);  NS_ENSURE_SUBMIT_SUCCESS(rv);  //  // Notify observers of submit  //  PRBool aCancelSubmit = PR_FALSE;  rv = NotifySubmitObservers(actionURI, &aCancelSubmit);  NS_ENSURE_SUBMIT_SUCCESS(rv);  if (aCancelSubmit) {    mIsSubmitting = PR_FALSE;    return NS_OK;  }  //  // Submit  //  nsCOMPtr<nsIDocShell> docShell;  rv = submission->SubmitTo(actionURI, target, this, aPresContext,                            getter_AddRefs(docShell),                            getter_AddRefs(mSubmittingRequest));  NS_ENSURE_SUBMIT_SUCCESS(rv);  // Even if the submit succeeds, it's possible for there to be no docshell  // or request; for example, if it's to a named anchor within the same page  // the submit will not really do anything.  if (docShell) {    // If the channel is pending, we have to listen for web progress.    PRBool pending = PR_FALSE;    mSubmittingRequest->IsPending(&pending);    if (pending) {      mWebProgress = do_GetInterface(docShell);      NS_ASSERTION(mWebProgress, "nsIDocShell not converted to nsIWebProgress!");      rv = mWebProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_ALL);      NS_ENSURE_SUBMIT_SUCCESS(rv);    } else {      ForgetCurrentSubmission();    }  } else {    ForgetCurrentSubmission();  }  return rv;}