if (!mSelectionListeners) return NS_ERROR_FAILURE;
nsTypedSelection::NotifySelectionListeners(){  if (!mSelectionListeners)    return NS_ERROR_FAILURE;  if (!mFrameSelection)    return NS_OK;//nothing to do   if (mFrameSelection->GetBatching()){    mFrameSelection->SetDirty();    return NS_OK;  }  PRUint32 cnt;  nsresult rv = mSelectionListeners->Count(&cnt);  if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIDOMDocument> domdoc;  nsCOMPtr<nsIDocument> doc;  nsCOMPtr<nsIPresShell> shell;  rv = GetPresShell(getter_AddRefs(shell));  if (NS_SUCCEEDED(rv) && shell)  {    rv = shell->GetDocument(getter_AddRefs(doc));    if (NS_FAILED(rv))      doc = 0;    domdoc = do_QueryInterface(doc);  }  short reason = mFrameSelection->PopReason();  for (PRUint32 i = 0; i < cnt;i++)  {    nsCOMPtr<nsISupports> isupports(dont_AddRef(mSelectionListeners->ElementAt(i)));    nsCOMPtr<nsISelectionListener> thisListener = do_QueryInterface(isupports);    if (thisListener)    	thisListener->NotifySelectionChanged(domdoc,this, reason);  }	return NS_OK;}