if (!mDocument || !mParent) { return NS_OK; }   nsCOMPtr<nsIPresShell> presShell; mDocument->GetShellAt(0, getter_AddRefs(presShell)); if (!presShell) { return NS_OK; }  nsIFrame *frame = nsnull; presShell->GetPrimaryFrameFor(this, &frame);
nsIFrame* frame = GetPrimaryFrame(PR_FALSE);
nsHTMLInputElement::SetCheckedInternal(PRBool aChecked){  //  // Set the value  //  SET_BOOLBIT(mBitField, BF_CHECKED, aChecked);  //  // Notify the frame  //  // If the document or parent is not there, don't even bother looking  // for the frame.  It won't (shouldn't) be there.  if (!mDocument || !mParent) {    return NS_OK;  }  // Get presentation shell 0  nsCOMPtr<nsIPresShell> presShell;  mDocument->GetShellAt(0, getter_AddRefs(presShell));  if (!presShell) {    return NS_OK;  }  nsIFrame *frame = nsnull;  presShell->GetPrimaryFrameFor(this, &frame);  if (!frame) {    return NS_OK;  }  PRInt32 type;  GetType(&type);  nsCOMPtr<nsIPresContext> presContext;  GetPresContext(this, getter_AddRefs(presContext));  if (type == NS_FORM_INPUT_CHECKBOX) {    nsICheckboxControlFrame* checkboxFrame = nsnull;    CallQueryInterface(frame, &checkboxFrame);    if (checkboxFrame) {      checkboxFrame->OnChecked(presContext, aChecked);    }  } else if (type == NS_FORM_INPUT_RADIO) {    nsIRadioControlFrame* radioFrame = nsnull;    CallQueryInterface(frame, &radioFrame);    if (radioFrame) {      radioFrame->OnChecked(presContext, aChecked);    }  }  // Notify the document that the CSS :checked pseudoclass for this element  // has changed state.  // XXX HACK Only do this if there is a frame.  Otherwise for some reason  // ContentStatesChanged() is creating an extra bogus frame at this point.  // Probably ContentStatesChanged() needs to be told not to worry if there is  // no frame in some cases.  Bug 134560.  if (mDocument && frame) {    mDocument->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_CHECKED);  }  return NS_OK;}