if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }  nsCOMPtr<nsIDOMSelection> selection; PRBool cancel, handled;      if (aAction == eNextWord || aAction == ePreviousWord || aAction == eToBeginningOfLine || aAction == eToEndOfLine) { if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED; nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak); nsCOMPtr<nsISelectionController> selCont (do_QueryInterface(ps)); if (!selCont) return NS_ERROR_NO_INTERFACE;  nsresult result; switch (aAction) { case eNextWord: result = selCont->WordMove(PR_TRUE, PR_TRUE);   aAction = eNone; break; case ePreviousWord: result = selCont->WordMove(PR_FALSE, PR_TRUE); aAction = eNone; break; case eToBeginningOfLine: result = selCont->IntraLineMove(PR_FALSE, PR_TRUE); aAction = eNone; break; case eToEndOfLine: result = selCont->IntraLineMove(PR_TRUE, PR_TRUE); aAction = eNone; break; default: result = NS_OK; break; } if (NS_FAILED(result)) { #ifdef DEBUG printf("Selection controller interface didn't work!\n"); #endif return result; } }   nsAutoPlaceHolderBatch batch(this, gDeleteTxnName); nsAutoRules beginRulesSniffing(this, kOpDeleteSelection, aAction);   nsresult result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER;  nsTextRulesInfo ruleInfo(nsTextEditRules::kDeleteSelection); ruleInfo.collapsedAction = aAction; result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); if (NS_FAILED(result)) return result; if (!cancel && !handled) { result = DeleteSelectionImpl(aAction); } if (!cancel) {  result = mRules->DidDoAction(selection, &ruleInfo, result); }  return result;
return nsTextEditor::DeleteSelection(aAction);
NS_IMETHODIMP nsHTMLEditor::DeleteSelection(nsIEditor::EDirection aAction){  if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }  nsCOMPtr<nsIDOMSelection> selection;  PRBool cancel, handled;  // If it's one of these modes,  // we have to extend the selection first.  // This can't happen inside selection batching --  // selection refuses to move if batching is on.  if (aAction == eNextWord || aAction == ePreviousWord      || aAction == eToBeginningOfLine || aAction == eToEndOfLine)  {    if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;    nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);    nsCOMPtr<nsISelectionController> selCont (do_QueryInterface(ps));    if (!selCont)      return NS_ERROR_NO_INTERFACE;    nsresult result;    switch (aAction)    {        case eNextWord:          result = selCont->WordMove(PR_TRUE, PR_TRUE);          // DeleteSelectionImpl doesn't handle these actions          // because it's inside batching, so don't confuse it:          aAction = eNone;          break;        case ePreviousWord:          result = selCont->WordMove(PR_FALSE, PR_TRUE);          aAction = eNone;          break;        case eToBeginningOfLine:          result = selCont->IntraLineMove(PR_FALSE, PR_TRUE);          aAction = eNone;          break;        case eToEndOfLine:          result = selCont->IntraLineMove(PR_TRUE, PR_TRUE);          aAction = eNone;          break;        default:       // avoid several compiler warnings          result = NS_OK;          break;    }    if (NS_FAILED(result))    {#ifdef DEBUG      printf("Selection controller interface didn't work!\n");#endif      return result;    }  }  // delete placeholder txns merge.  nsAutoPlaceHolderBatch batch(this, gDeleteTxnName);  nsAutoRules beginRulesSniffing(this, kOpDeleteSelection, aAction);  // pre-process  nsresult result = GetSelection(getter_AddRefs(selection));  if (NS_FAILED(result)) return result;  if (!selection) return NS_ERROR_NULL_POINTER;  nsTextRulesInfo ruleInfo(nsTextEditRules::kDeleteSelection);  ruleInfo.collapsedAction = aAction;  result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);  if (NS_FAILED(result)) return result;  if (!cancel && !handled)  {    result = DeleteSelectionImpl(aAction);  }  if (!cancel)  {    // post-process     result = mRules->DidDoAction(selection, &ruleInfo, result);  }  return result;}