nsresult rv = NS_ERROR_FAILURE;   if (mDirty) { GetOptions(); }  PRInt32 length = mElements.Count();
PRUint32 length; nsresult rv = mElements->Count(&length);
nsHTMLOptionCollection::SetOption(PRInt32 aIndex,                                  nsIDOMHTMLOptionElement *aOption){  if (!mSelect) {    return NS_OK;  }  nsresult rv = NS_ERROR_FAILURE;  // Update the options list  if (mDirty) {    GetOptions();  }  PRInt32 length = mElements.Count();  // If the indx is within range  if ((aIndex >= 0) && (aIndex <= length)) {    // if the new option is null, remove this option    if (!aOption) {      mSelect->Remove(aIndex);      // We're done.      return NS_OK;    }    nsCOMPtr<nsIDOMNode> ret;    if (aIndex == length) {      rv = mSelect->AppendChild(aOption, getter_AddRefs(ret));    } else {      nsIDOMNode *refChild = (nsIDOMNode*)mElements.ElementAt(aIndex);      NS_ENSURE_TRUE(refChild, NS_ERROR_UNEXPECTED);      nsCOMPtr<nsIDOMNode> parent;      refChild->GetParentNode(getter_AddRefs(parent));      if (parent) {        rv = parent->ReplaceChild(aOption, refChild, getter_AddRefs(ret));      }    }  }  return rv;}