nsListControlFrame::Reset(nsIPresContext* aPresContext) {   if (!mIsAllFramesHere) { return; }  nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent)); if (!options) { return; }     PRBool hasBeenRestored = mPresState != nsnull;  PRUint32 numOptions; options->GetLength(&numOptions);  mSelectedIndex      = kNothingSelected; mStartExtendedIndex = kNothingSelected; mEndExtendedIndex   = kNothingSelected; PRBool multiple; GetMultiple(&multiple);  Deselect();    mSelectionCache->Clear(); mSelectionCacheLength = 0; PRUint32 i; for (i = 0; i < numOptions; i++) { nsCOMPtr<nsIDOMHTMLOptionElement> option = getter_AddRefs(GetOption(*options, i)); if (option) { PRBool selected = PR_FALSE; if (!hasBeenRestored) { option->GetDefaultSelected(&selected); }  mSelectionCache->AppendElement((void*)selected); mSelectionCacheLength++;  if (selected) { mSelectedIndex = i; SetContentSelected(i, PR_TRUE); if (multiple) { mStartExtendedIndex = i; if (mEndExtendedIndex == kNothingSelected) { mEndExtendedIndex = i; } } } } }   if (hasBeenRestored) { nsCOMPtr<nsISupports> supp; mPresState->GetStatePropertyAsSupports("selecteditems", getter_AddRefs(supp));  nsresult res = NS_ERROR_NULL_POINTER; if (!supp) return;  nsCOMPtr<nsISupportsArray> value = do_QueryInterface(supp); if (!value) return;  PRUint32 count = 0; value->Count(&count);  nsCOMPtr<nsISupportsPRInt32> thisVal; PRInt32 j=0; for (PRUint32 i=0; i<count; i++) { nsCOMPtr<nsISupports> suppval = getter_AddRefs(value->ElementAt(i)); thisVal = do_QueryInterface(suppval); if (thisVal) { res = thisVal->GetData(&j); if (NS_SUCCEEDED(res)) { mSelectedIndex = j; SetContentSelected(j, PR_TRUE); mSelectionCache->ReplaceElementAt((void*)PR_TRUE, j); if (multiple) { mStartExtendedIndex = j; if (mEndExtendedIndex == kNothingSelected) { mEndExtendedIndex = j; } } } } else { res = NS_ERROR_UNEXPECTED; } if (!NS_SUCCEEDED(res)) break; } }  if (mComboboxFrame != nsnull) { if (mSelectedIndex == kNothingSelected) { mComboboxFrame->MakeSureSomethingIsSelected(mPresContext); } else { mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); } } }
virtual void Reset(nsIPresContext* aPresContext) { ResetList(aPresContext); }
nsListControlFrame::Reset(nsIPresContext* aPresContext){  // if all the frames aren't here   // don't bother reseting  if (!mIsAllFramesHere) {    return;  }  nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));  if (!options) {    return;  }  // Check here to see if this listbox has has its state restored  // Either by being a list or by being a dropdown.  // if we have been restored then we don't set any of the default selections  PRBool hasBeenRestored = mPresState != nsnull;  PRUint32 numOptions;  options->GetLength(&numOptions);  mSelectedIndex      = kNothingSelected;  mStartExtendedIndex = kNothingSelected;  mEndExtendedIndex   = kNothingSelected;  PRBool multiple;  GetMultiple(&multiple);  Deselect();  // Clear the cache and set the default selections  // if we havn't been restored  mSelectionCache->Clear();  mSelectionCacheLength = 0;  PRUint32 i;  for (i = 0; i < numOptions; i++) {    nsCOMPtr<nsIDOMHTMLOptionElement> option = getter_AddRefs(GetOption(*options, i));    if (option) {      PRBool selected = PR_FALSE;      if (!hasBeenRestored) {        option->GetDefaultSelected(&selected);      }      mSelectionCache->AppendElement((void*)selected);      mSelectionCacheLength++;      if (selected) {        mSelectedIndex = i;        SetContentSelected(i, PR_TRUE);        if (multiple) {          mStartExtendedIndex = i;          if (mEndExtendedIndex == kNothingSelected) {            mEndExtendedIndex = i;          }        }      }    }  }  // Ok, so we were restored, now set the last known selections from the restore state.  if (hasBeenRestored) {    nsCOMPtr<nsISupports> supp;    mPresState->GetStatePropertyAsSupports("selecteditems", getter_AddRefs(supp));    nsresult res = NS_ERROR_NULL_POINTER;    if (!supp)      return;    nsCOMPtr<nsISupportsArray> value = do_QueryInterface(supp);    if (!value)      return;    PRUint32 count = 0;    value->Count(&count);    nsCOMPtr<nsISupportsPRInt32> thisVal;    PRInt32 j=0;    for (PRUint32 i=0; i<count; i++) {      nsCOMPtr<nsISupports> suppval = getter_AddRefs(value->ElementAt(i));      thisVal = do_QueryInterface(suppval);      if (thisVal) {        res = thisVal->GetData(&j);        if (NS_SUCCEEDED(res)) {          mSelectedIndex = j;          SetContentSelected(j, PR_TRUE);// might want to use ToggleSelection          mSelectionCache->ReplaceElementAt((void*)PR_TRUE, j);          if (multiple) {            mStartExtendedIndex = j;            if (mEndExtendedIndex == kNothingSelected) {              mEndExtendedIndex = j;            }          }        }      } else {        res = NS_ERROR_UNEXPECTED;      }      if (!NS_SUCCEEDED(res)) break;    }  }      if (mComboboxFrame != nsnull) {    if (mSelectedIndex == kNothingSelected) {      mComboboxFrame->MakeSureSomethingIsSelected(mPresContext);    } else {      mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event    }  }} 