if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }  nsCOMPtr<nsIDOMSelection> selection; PRBool cancel, handled; PRInt32 theAction = nsTextEditRules::kInsertText; PRInt32 opID = kOpInsertText; if (mInIMEMode) { theAction = nsTextEditRules::kInsertTextIME; opID = kOpInsertIMEText; } nsAutoPlaceHolderBatch batch(this, nsnull); nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);   nsresult result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; nsAutoString resultString; nsTextRulesInfo ruleInfo(theAction); ruleInfo.inString = &aStringToInsert; ruleInfo.outString = &resultString; ruleInfo.typeInState = *mTypeInState; ruleInfo.maxLength = mMaxTextLength;  result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); if (NS_FAILED(result)) return result; if (!cancel && !handled) { result = InsertTextImpl(resultString); } if (!cancel) {  result = mRules->DidDoAction(selection, &ruleInfo, result); } return result;
return nsTextEditor::InsertText(aStringToInsert);
NS_IMETHODIMP nsHTMLEditor::InsertText(const nsString& aStringToInsert){  if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }  nsCOMPtr<nsIDOMSelection> selection;  PRBool cancel, handled;  PRInt32 theAction = nsTextEditRules::kInsertText;  PRInt32 opID = kOpInsertText;  if (mInIMEMode)   {    theAction = nsTextEditRules::kInsertTextIME;    opID = kOpInsertIMEText;  }  nsAutoPlaceHolderBatch batch(this, nsnull);   nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);  // pre-process  nsresult result = GetSelection(getter_AddRefs(selection));  if (NS_FAILED(result)) return result;  if (!selection) return NS_ERROR_NULL_POINTER;  nsAutoString resultString;  nsTextRulesInfo ruleInfo(theAction);  ruleInfo.inString = &aStringToInsert;  ruleInfo.outString = &resultString;  ruleInfo.typeInState = *mTypeInState;  ruleInfo.maxLength = mMaxTextLength;  result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);  if (NS_FAILED(result)) return result;  if (!cancel && !handled)  {    result = InsertTextImpl(resultString);  }  if (!cancel)  {    // post-process     result = mRules->DidDoAction(selection, &ruleInfo, result);  }  return result;}