16706: Call the rules code to delete the bogus node before inserting html, to fix the new mail reply code. r=jfrancis

This commit is contained in:
akkana%netscape.com 1999-10-21 21:51:47 +00:00
parent 864bb2e148
commit 2d47aab79e
2 changed files with 34 additions and 2 deletions

View File

@ -1272,11 +1272,27 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
nsAutoEditBatch beginBatching(this);
nsresult res;
nsCOMPtr<nsIDOMSelection>selection;
// Call the rules code in case there's anything we need to do first
// (e.g. delete the bogus node):
// Call the rules code in case there's anything we need to do first
// (e.g. delete the bogus node):
if (!mRules) return NS_ERROR_NOT_INITIALIZED;
res = GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
nsTextRulesInfo ruleInfo(nsHTMLEditRules::kInsertElement);
PRBool cancel, handled;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNode> parentNode;
PRInt32 offsetOfNewNode;
res = DeleteSelectionAndPrepareToCreateNode(parentNode, offsetOfNewNode);
nsCOMPtr<nsIDOMSelection>selection;
res = GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
if (!selection) return NS_ERROR_NULL_POINTER;

View File

@ -1272,11 +1272,27 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
nsAutoEditBatch beginBatching(this);
nsresult res;
nsCOMPtr<nsIDOMSelection>selection;
// Call the rules code in case there's anything we need to do first
// (e.g. delete the bogus node):
// Call the rules code in case there's anything we need to do first
// (e.g. delete the bogus node):
if (!mRules) return NS_ERROR_NOT_INITIALIZED;
res = GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
nsTextRulesInfo ruleInfo(nsHTMLEditRules::kInsertElement);
PRBool cancel, handled;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNode> parentNode;
PRInt32 offsetOfNewNode;
res = DeleteSelectionAndPrepareToCreateNode(parentNode, offsetOfNewNode);
nsCOMPtr<nsIDOMSelection>selection;
res = GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
if (!selection) return NS_ERROR_NULL_POINTER;