nsCOMPtr<nsIContent> content = do_QueryInterface(aChild); if (!content) { return NS_OK; }  nsStringKey key(aName);  nsCOMPtr<nsISupports> supports(dont_AddRef(mNameLookupTable.Get(&key)));  if (!supports) return NS_OK;  nsCOMPtr<nsIFormControl> fctrl(do_QueryInterface(supports));  if (fctrl) {  mNameLookupTable.Remove(&key);  return NS_OK; }  nsCOMPtr<nsIDOMNodeList> nodeList(do_QueryInterface(supports)); NS_ENSURE_TRUE(nodeList, NS_ERROR_FAILURE);   nsBaseContentList *list = NS_STATIC_CAST(nsBaseContentList *, (nsIDOMNodeList *)nodeList.get());  list->RemoveElement(content);  PRUint32 length = 0; list->GetLength(&length);  if (!length) {   mNameLookupTable.Remove(&key); } else if (length == 1) {   nsCOMPtr<nsIDOMNode> node; list->Item(0, getter_AddRefs(node));  if (node) { nsCOMPtr<nsISupports> tmp(do_QueryInterface(node)); mNameLookupTable.Put(&key, tmp.get()); } }  return NS_OK;
return mControls->RemoveElementFromTable(aElement, aName);
nsFormControlList::RemoveElementFromTable(nsIFormControl* aChild,                                          const nsAString& aName){  if (!ShouldBeInElements(aChild)) {    return NS_OK;  }  nsCOMPtr<nsIContent> content = do_QueryInterface(aChild);    if (!content) {    return NS_OK;  }  nsStringKey key(aName);  nsCOMPtr<nsISupports> supports(dont_AddRef(mNameLookupTable.Get(&key)));  if (!supports)    return NS_OK;  nsCOMPtr<nsIFormControl> fctrl(do_QueryInterface(supports));  if (fctrl) {    // Single element in the hash, just remove it...    mNameLookupTable.Remove(&key);    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(&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));      mNameLookupTable.Put(&key, tmp.get());    }  }  return NS_OK;}