PRInt32 numNodes; rv = ChildCount(numNodes); if (NS_SUCCEEDED(rv)) { for (PRInt32 i = 0; i < numNodes; i++) { nsIContent *result; ChildAt(i, result); if (result) { if (result->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) return result; NS_RELEASE(result); } } }
return GetFirstFormControl(this);
nsHTMLLabelElement::GetForContent(){  nsresult rv;  // Get the element that this label is for  nsAutoString elementId;  rv = GetHtmlFor(elementId);  if (NS_SUCCEEDED(rv) && !elementId.IsEmpty()) {    // We have a FOR attribute.    nsCOMPtr<nsIDOMDocument> domDoc;    GetOwnerDocument(getter_AddRefs(domDoc));    if (domDoc) {      nsCOMPtr<nsIDOMElement> domElement;      domDoc->GetElementById(elementId, getter_AddRefs(domElement));      nsIContent *result = nsnull;      if (domElement) {        CallQueryInterface(domElement, &result);        if (result && !result->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) {          NS_RELEASE(result); // assigns null        }      }      return result;    }  } else {    // No FOR attribute, we are a label for our first child element.    PRInt32 numNodes;    rv = ChildCount(numNodes);    if (NS_SUCCEEDED(rv)) {      for (PRInt32 i = 0; i < numNodes; i++) {        nsIContent *result;        ChildAt(i, result);        if (result) {          if (result->IsContentOfType(nsIContent::eHTML_FORM_CONTROL))            return result;          NS_RELEASE(result);        }      }    }  }  return nsnull;}