if (option) { mElements.RemoveElement(option);
PRInt32 oldIndex = mOptions->IndexOf(aContent);   mOptions->RemoveOption(aContent);   nsIFormControlFrame* fcFrame = nsnull; nsresult result = GetPrimaryFrame(this, fcFrame, PR_FALSE);  if (NS_SUCCEEDED(result) && fcFrame) { nsISelectControlFrame* selectFrame = nsnull;  result = fcFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame), (void **)&selectFrame);  if (NS_SUCCEEDED(result) && selectFrame) {      nsCOMPtr<nsIPresContext> presContext;  GetPresContext(this, getter_AddRefs(presContext));  result = selectFrame->RemoveOption(presContext, oldIndex); } } else {        nsCOMPtr<nsIPresState> presState; nsCOMPtr<nsISupportsArray> value; nsresult res = GetPresState(getter_AddRefs(presState), getter_AddRefs(value));  if (NS_SUCCEEDED(res) && value) {   PRUint32 count = 0;  value->Count(&count);    PRInt32 j=0; PRUint32 i;  for (i = 0; i < count; i++) { nsCOMPtr<nsISupports> suppval = getter_AddRefs(value->ElementAt(i));  if (suppval) { nsCOMPtr<nsISupportsPRInt32> thisVal = do_QueryInterface(suppval);  if (thisVal) { res = thisVal->GetData(&j);   if (NS_SUCCEEDED(res) && j == oldIndex) { res = value->RemoveElementAt(i);  break; } } else { res = NS_ERROR_UNEXPECTED; }  break; } } }
nsHTMLOptionCollection::RemoveOption(nsIContent* aOption){  nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(aOption));  if (option) {    mElements.RemoveElement(option);  }}