nsCOMPtr<nsISupports> listSupports; list->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(listSupports));
nsCOMPtr<nsISupports> listSupports = do_QueryInterface(list);
nsFormControlList::AddElementToTable(nsIFormControl* aChild,                                     const nsAString& aName){  if (!ShouldBeInElements(aChild)) {    return NS_OK;  }  nsStringKey key(aName);  nsCOMPtr<nsISupports> supports;  supports = dont_AddRef(mNameLookupTable.Get(&key));  if (!supports) {    // No entry found, add the form control    nsCOMPtr<nsISupports> child(do_QueryInterface(aChild));    mNameLookupTable.Put(&key, child);  } else {    // Found something in the hash, check its type    nsCOMPtr<nsIContent> content(do_QueryInterface(supports));    nsCOMPtr<nsIContent> newChild(do_QueryInterface(aChild));    if (content) {      // Check if the new content is the same as the one we found in the      // hash, if it is then we leave it in the hash as it is, this will      // happen if a form control has both a name and an id with the same      // value      if (content == newChild) {        return NS_OK;      }      // Found an element, create a list, add the element to the list and put      // the list in the hash      nsBaseContentList *list = new nsBaseContentList();      NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);      list->AppendElement(content);      // Add the new child too      list->AppendElement(newChild);      nsCOMPtr<nsISupports> listSupports;      list->QueryInterface(NS_GET_IID(nsISupports),                           getter_AddRefs(listSupports));      // Replace the element with the list.      mNameLookupTable.Put(&key, listSupports);    } else {      // There's already a list in the hash, add the child to the list      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());      PRInt32 oldIndex = -1;      list->IndexOf(newChild, oldIndex);      // Add the new child only if it's not in our list already      if (oldIndex < 0) {        list->AppendElement(newChild);      }    }  }  return NS_OK;}