nsCOMPtr<nsIDOMHTMLCollection> options;
PRUint32 numOptions;
nsHTMLSelectElement::GetOptionIndex(nsIDOMHTMLOptionElement* aOption,                                    PRUint32 * anIndex){  NS_ENSURE_ARG_POINTER(anIndex);  *anIndex = 0;  // first find index of option  nsCOMPtr<nsIDOMHTMLCollection> options;  nsresult rv = GetOptions(getter_AddRefs(options));  if (options) {    PRUint32 numOptions;    rv = options->GetLength(&numOptions);    if (NS_FAILED(rv)) {      return rv;    }    nsCOMPtr<nsIDOMNode> node;    for (PRUint32 i = 0; i < numOptions; i++) {      rv = options->Item(i, getter_AddRefs(node));      if (NS_SUCCEEDED(rv) && node) {        nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(node));        if (option && option.get() == aOption) {          *anIndex = i;          return NS_OK;        }      }    }  }  return NS_ERROR_FAILURE;}