nsCOMPtr<nsIDOMHTMLInputElement> elem(do_QueryInterface(control)); if (elem) {
nsCOMPtr<nsIContent> controlContent(do_QueryInterface(control)); if (controlContent) {
nsHTMLFormElement::WalkRadioGroup(const nsAString& aName,                                  nsIRadioVisitor* aVisitor){  nsresult rv = NS_OK;  PRBool stopIterating = PR_FALSE;  if (aName.IsEmpty()) {    //    // XXX If the name is empty, it's not stored in the control list.  There    // *must* be a more efficient way to do this.    //    nsCOMPtr<nsIFormControl> control;    PRUint32 len = 0;    GetElementCount(&len);    for (PRUint32 i=0; i<len; i++) {      GetElementAt(i, getter_AddRefs(control));      PRInt32 type;      control->GetType(&type);      if (type == NS_FORM_INPUT_RADIO) {        nsCOMPtr<nsIDOMHTMLInputElement> elem(do_QueryInterface(control));        if (elem) {          //          // XXX This is a particularly frivolous string copy just to determine          // if the string is empty or not          //          nsAutoString name;          elem->GetName(name);          if (name.IsEmpty()) {            aVisitor->Visit(control, &stopIterating);            if (stopIterating) {              break;            }          }        }      }    }  } else {    //    // Get the control / list of controls from the form using form["name"]    //    nsCOMPtr<nsISupports> item;    rv = ResolveName(aName, getter_AddRefs(item));    if (item) {      //      // If it's just a lone radio button, then select it.      //      nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(item));      if (formControl) {        PRInt32 type;        formControl->GetType(&type);        if (type == NS_FORM_INPUT_RADIO) {          aVisitor->Visit(formControl, &stopIterating);        }      } else {        nsCOMPtr<nsIDOMNodeList> nodeList(do_QueryInterface(item));        if (nodeList) {          PRUint32 length = 0;          nodeList->GetLength(&length);          for (PRUint32 i=0; i<length; i++) {            nsCOMPtr<nsIDOMNode> node;            nodeList->Item(i, getter_AddRefs(node));            nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(node));            if (formControl) {              PRInt32 type;              formControl->GetType(&type);              if (type == NS_FORM_INPUT_RADIO) {                aVisitor->Visit(formControl, &stopIterating);                if (stopIterating) {                  break;                }              }            }          }        }      }    }  }  return rv;}