} else {       PRBool isMultiple; nsresult res = GetMultiple(&isMultiple); if (NS_FAILED(res)) { isMultiple = PR_FALSE; }     nsCOMPtr<nsIPresState> presState; nsCOMPtr<nsISupportsArray> value; res = GetPresState(getter_AddRefs(presState), getter_AddRefs(value)); if (NS_SUCCEEDED(res) && !presState) { return NS_OK; }    PRBool doesExist = PR_FALSE; if (!value) { res = NS_NewISupportsArray(getter_AddRefs(value)); } else { doesExist = PR_TRUE; }  if (NS_SUCCEEDED(res) && value) {    PRUint32 count = 0; value->Count(&count);    if (!isMultiple) { value->Clear(); count = 0; }   nsCOMPtr<nsISupportsPRInt32> thisVal; nsresult res = nsComponentManager::CreateInstance(NS_SUPPORTS_PRINT32_PROGID, nsnull, NS_GET_IID(nsISupportsPRInt32), (void**)getter_AddRefs(thisVal)); if (NS_SUCCEEDED(res) && thisVal) { res = thisVal->SetData(aIndex); if (NS_SUCCEEDED(res)) { PRBool okay = value->InsertElementAt((nsISupports *)thisVal, count); if (!okay) res = NS_ERROR_OUT_OF_MEMORY; } }    if (!doesExist) { presState->SetStatePropertyAsSupports("selecteditems", value); } }
nsHTMLSelectElement::SetSelectedIndex(PRInt32 aValue){  nsIFormControlFrame* formControlFrame = nsnull;  if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) {    nsString value;    value.Append(aValue, 10);    nsIPresContext* presContext;    nsGenericHTMLElement::GetPresContext(this, &presContext);    formControlFrame->SetProperty(presContext, nsHTMLAtoms::selectedindex, value);    NS_IF_RELEASE(presContext);  }  return NS_OK;}