if (!ShouldBeInElements(aChild)) { return NS_OK; }
NS_ENSURE_TRUE(mControls, NS_ERROR_UNEXPECTED);
nsFormControlList::RemoveElementFromTable(nsIFormControl* aChild,                                          const nsAString& aName){  if (!ShouldBeInElements(aChild)) {    return NS_OK;  }  nsCOMPtr<nsIContent> content = do_QueryInterface(aChild);    if (!content) {    return NS_OK;  }  nsCOMPtr<nsISupports> supports;  if (!mNameLookupTable.Get(aName,getter_AddRefs(supports)))    return NS_OK;  nsCOMPtr<nsIFormControl> fctrl(do_QueryInterface(supports));  if (fctrl) {    // Single element in the hash, just remove it...    mNameLookupTable.Remove(aName);    return NS_OK;  }  nsCOMPtr<nsIDOMNodeList> nodeList(do_QueryInterface(supports));  NS_ENSURE_TRUE(nodeList, NS_ERROR_FAILURE);  // Upcast, uggly, but it works!  nsBaseContentList *list = NS_STATIC_CAST(nsBaseContentList *,                                           (nsIDOMNodeList *)nodeList.get());  list->RemoveElement(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    mNameLookupTable.Remove(aName);  } 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));      NS_ENSURE_TRUE(mNameLookupTable.Put(aName, tmp),NS_ERROR_FAILURE);    }  }  return NS_OK;}