mReason = nsISelectionListener::NO_REASON;
mSelectionChangeReason = nsISelectionListener::NO_REASON;
nsSelection::nsSelection(){  PRInt32 i;  for (i = 0;i<nsISelectionController::NUM_SELECTIONTYPES;i++){    mDomSelections[i] = nsnull;  }  for (i = 0;i<nsISelectionController::NUM_SELECTIONTYPES;i++){    mDomSelections[i] = new nsTypedSelection(this);    if (!mDomSelections[i])      return;    mDomSelections[i]->AddRef();    mDomSelections[i]->SetType(GetSelectionTypeFromIndex(i));  }  mBatching = 0;  mChangesDuringBatching = PR_FALSE;  mNotifyFrames = PR_TRUE;  mLimiter = nsnull; //no default limiter.    mMouseDoubleDownState = PR_FALSE;    mHint = HINTLEFT;  mDragSelectingCells = PR_FALSE;  mSelectingTableCellMode = 0;  mSelectedCellIndex = 0;    // Check to see if the autocopy pref is enabled  //   and add the autocopy listener if it is  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));  if (prefBranch) {    static char pref[] = "clipboard.autocopy";    PRBool autoCopy = PR_FALSE;    if (NS_SUCCEEDED(prefBranch->GetBoolPref(pref, &autoCopy)) && autoCopy) {      nsCOMPtr<nsIAutoCopyService> autoCopyService =         do_GetService("@mozilla.org/autocopy;1");      if (autoCopyService) {        PRInt8 index =          GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL);        if (mDomSelections[index]) {          autoCopyService->Listen(mDomSelections[index]);        }      }    }  }  mDisplaySelection = nsISelectionController::SELECTION_OFF;  mDelayCaretOverExistingSelection = PR_TRUE;  mDelayedMouseEventValid = PR_FALSE;  mReason = nsISelectionListener::NO_REASON;}