result = GetSelectedIndex(&selectedIndex); if (NS_SUCCEEDED(result)) { nsCOMPtr<nsIDOMNSHTMLOptionCollection> options;
nsresult rv = GetSelectedIndex(&selectedIndex);
nsHTMLSelectElement::GetValue(nsAWritableString& aValue){  nsresult result = NS_OK;  PRInt32 selectedIndex;  result = GetSelectedIndex(&selectedIndex);  if (NS_SUCCEEDED(result)) {    nsCOMPtr<nsIDOMNSHTMLOptionCollection> options;    result = GetOptions(getter_AddRefs(options));    if (NS_SUCCEEDED(result)) {      nsCOMPtr<nsIDOMNode> node;      if (selectedIndex == -1) {        selectedIndex = 0;      }      result = options->Item(selectedIndex, getter_AddRefs(node));      if (NS_SUCCEEDED(result) && node) {        nsCOMPtr<nsIHTMLContent> option = do_QueryInterface(node);        if (option) {          nsHTMLValue value;          // first check to see if value is there and has a value          nsresult rv = option->GetHTMLAttribute(nsHTMLAtoms::value, value);          if (NS_CONTENT_ATTR_HAS_VALUE == rv) {            if (eHTMLUnit_String == value.GetUnit()) {              value.GetStringValue(aValue);            } else {              aValue.SetLength(0);            }            return NS_OK;          }#if 0 // temporary for bug 4050          // first check to see if label is there and has a value          rv = option->GetHTMLAttribute(nsHTMLAtoms::label, value);          if (NS_CONTENT_ATTR_HAS_VALUE == rv) {            if (eHTMLUnit_String == value.GetUnit()) {              value.GetStringValue(aValue);            } else {              aValue.SetLength(0);            }            return NS_OK;          } #endif          nsCOMPtr<nsIDOMHTMLOptionElement> optElement(do_QueryInterface(node));          if (optElement) {            optElement->GetText(aValue);          }          return NS_OK;        }      }    }  }  return result;}