if (mWebProgress) { return NS_OK; } else {  nsCOMPtr<nsISupports> supps; aPresContext->GetContainer(getter_AddRefs(supps)); if (supps) { nsresult rv; mWebProgress = do_GetInterface(supps, &rv); if (NS_SUCCEEDED(rv)) { mWebProgress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener *, this)); } } }
nsHTMLFormElement::DoSubmitOrReset(nsIPresContext* aPresContext,                                   nsEvent* aEvent,                                   PRInt32 aMessage) {  NS_ENSURE_ARG_POINTER(aPresContext);  // If mWebProgress is not null then we are in the middle of a submit  // if it is null, then we need to add the form content as a listener  // to check for double submits (Bug 72906) or whether someone is doing a submit  // from the "onsubmit" handler (Bug 85286).  if (mWebProgress) {    return NS_OK;  } else {    // Get out container and add ourself as a listener for progress    nsCOMPtr<nsISupports> supps;    aPresContext->GetContainer(getter_AddRefs(supps));    if (supps) {      nsresult rv;      mWebProgress = do_GetInterface(supps, &rv);      if (NS_SUCCEEDED(rv)) {        mWebProgress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener *, this));      }    }  }  // Make sure the presentation is up-to-date  nsCOMPtr<nsIDocument> doc;  GetDocument(*getter_AddRefs(doc));  if (doc) {    doc->FlushPendingNotifications();  }  // Get the form manager  nsCOMPtr<nsIPresShell> shell;  aPresContext->GetShell(getter_AddRefs(shell));  NS_ENSURE_TRUE(shell, NS_OK);  nsIFrame* frame = nsnull;  shell->GetPrimaryFrameFor(this, &frame);  NS_ENSURE_TRUE(frame, NS_OK);  nsIFormManager* formMan = nsnull;  frame->QueryInterface(NS_GET_IID(nsIFormManager), (void**)&formMan);  NS_ENSURE_TRUE(formMan, NS_OK);  // Submit or Reset the form  nsresult rv = NS_OK;  if (NS_FORM_RESET == aMessage) {    rv = formMan->OnReset(aPresContext);  }  else if (NS_FORM_SUBMIT == aMessage) {    nsIFrame *originatingFrame = nsnull;    // Get the originating frame (failure is non-fatal)    if (aEvent) {      if (NS_FORM_EVENT == aEvent->eventStructType) {        nsIContent *originator = ((nsFormEvent *)aEvent)->originator;        if (originator) {          shell->GetPrimaryFrameFor(originator, &originatingFrame);        }      }    }    rv = formMan->OnSubmit(aPresContext, originatingFrame);  }  return rv;}