nsCOMPtr<nsIWebProgress> webProgress = do_GetInterface(docShell); NS_ASSERTION(webProgress, "nsIDocShell not converted to nsIWebProgress!"); rv = webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_ALL);
mWebProgress = do_GetInterface(docShell); NS_ASSERTION(mWebProgress, "nsIDocShell not converted to nsIWebProgress!"); rv = mWebProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_ALL);
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;  mSubmittingRequest = nsnull;  nsIContent *originatingElement = nsnull;  // Get the originating frame (failure is non-fatal)  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) {      nsCOMPtr<nsIWebProgress> 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    mIsSubmitting = PR_FALSE;  }  return rv;}