if (!stateStr.IsEmpty()) { stateStr.Append(PRUnichar(',')); } stateStr.AppendInt(optIndex);
nsAutoString value; option->GetValue(value); state->PutOption(optIndex, value);
nsHTMLSelectElement::SaveState(){  nsAutoString stateStr;  PRUint32 len;  GetLength(&len);  for (PRUint32 optIndex = 0; optIndex < len; optIndex++) {    nsCOMPtr<nsIDOMHTMLOptionElement> option;    mOptions->ItemAsOption(optIndex, getter_AddRefs(option));    if (option) {      PRBool isSelected;      option->GetSelected(&isSelected);      if (isSelected) {        if (!stateStr.IsEmpty()) {          stateStr.Append(PRUnichar(','));        }        stateStr.AppendInt(optIndex);      }    }  }  nsCOMPtr<nsIPresState> state;  nsresult rv = GetPrimaryPresState(this, getter_AddRefs(state));  if (state) {    rv = state->SetStateProperty(NS_LITERAL_STRING("selecteditems"),                                 stateStr);    NS_ASSERTION(NS_SUCCEEDED(rv), "selecteditems set failed!");  }  return rv;}