nsIContent *originator = ((nsFormEvent *)aEvent)->originator; if (originator) { shell->GetPrimaryFrameFor(originator, &originatingFrame); }
originatingElement = ((nsFormEvent *)aEvent)->originator;
nsHTMLFormElement::DoSubmitOrReset(nsIPresContext* aPresContext,                                   nsEvent* aEvent,                                   PRInt32 aMessage) {  NS_ENSURE_ARG_POINTER(aPresContext);  // 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;}