nsFormControlList::RemoveElementFromTable(nsIFormControl* aChild)
nsFormControlList::RemoveElementFromTable(nsIFormControl* aChild, const nsString& aName)
nsFormControlList::RemoveElementFromTable(nsIFormControl* aChild){  nsAutoString name;  nsCOMPtr<nsIContent> content = do_QueryInterface(aChild);    if (mLookupTable && content &&      (content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, name) == NS_CONTENT_ATTR_HAS_VALUE ||       content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::id, name) == NS_CONTENT_ATTR_HAS_VALUE))  {    nsStringKey key(name);    nsCOMPtr<nsISupports> supports;    supports = dont_AddRef((nsISupports *)mLookupTable->Get(&key));    if (!supports)      return NS_OK;    nsCOMPtr<nsIFormControl> fctrl(do_QueryInterface(supports));    if (fctrl) {      // Single element in the hash, just remove it...      mLookupTable->Remove(&key);    } else {      nsCOMPtr<nsIDOMNodeList> nodeList(do_QueryInterface(supports));      NS_ENSURE_TRUE(nodeList, NS_ERROR_FAILURE);      // Upcast, uggly, but it works!      nsContentList *list = NS_STATIC_CAST(nsContentList *,                                           (nsIDOMNodeList *)nodeList.get());      list->Remove(content);      PRUint32 length = 0;      list->GetLength(&length);      if (!length) {        // If the list is empty we remove if from our hash, this shouldn't happen tho        mLookupTable->Remove(&key);      } else if (length == 1) {        // Only one element left, replace the list in the hash with the        // single element.        nsCOMPtr<nsIDOMNode> node;        list->Item(0, getter_AddRefs(node));        if (node) {          nsCOMPtr<nsISupports> tmp(do_QueryInterface(node));          mLookupTable->Put(&key, tmp.get());        }      }    }  }  return NS_OK;}