From eb2ab3d2eec56dad2bc2e8a4a92774bb86089d76 Mon Sep 17 00:00:00 2001 From: "jfrancis%netscape.com" Date: Fri, 5 May 2000 21:57:58 +0000 Subject: [PATCH] rest of fix for bug 30763 --- editor/base/nsTextEditRules.cpp | 9 ++++++--- editor/libeditor/text/nsTextEditRules.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/editor/base/nsTextEditRules.cpp b/editor/base/nsTextEditRules.cpp index dec7c59d8cff..4a4a4262a9c4 100644 --- a/editor/base/nsTextEditRules.cpp +++ b/editor/base/nsTextEditRules.cpp @@ -469,6 +469,11 @@ nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P res = mEditor->SplitNodeDeep(preNode, selNode, selOffset, &newOffset, &outLeftNode, &outRightNode); if (NS_FAILED(res)) return res; PRBool bIsEmptyNode; + + // rememeber parent of selNode now, since we might delete selNode below + res = preNode->GetParentNode(getter_AddRefs(selNode)); + if (NS_FAILED(res)) return res; + if (outLeftNode) { res = IsEmptyNode(outLeftNode, &bIsEmptyNode, PR_TRUE, PR_FALSE); @@ -477,7 +482,7 @@ nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P } if (outRightNode) { - // HACK alert: consume a br if there s one at front of node + // HACK alert: consume a br if there is one at front of node nsCOMPtr firstNode; res = mEditor->GetFirstEditableNode(outRightNode, &firstNode); if (firstNode && nsHTMLEditUtils::IsBreak(firstNode)) @@ -489,8 +494,6 @@ nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P if (NS_FAILED(res)) return res; if (bIsEmptyNode) mEditor->DeleteNode(outRightNode); } - res = preNode->GetParentNode(getter_AddRefs(selNode)); - if (NS_FAILED(res)) return res; nsCOMPtr brNode; // last ePrevious param causes selection to be set before the break res = mEditor->CreateBR(selNode, newOffset, &brNode, nsIEditor::ePrevious); diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index dec7c59d8cff..4a4a4262a9c4 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -469,6 +469,11 @@ nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P res = mEditor->SplitNodeDeep(preNode, selNode, selOffset, &newOffset, &outLeftNode, &outRightNode); if (NS_FAILED(res)) return res; PRBool bIsEmptyNode; + + // rememeber parent of selNode now, since we might delete selNode below + res = preNode->GetParentNode(getter_AddRefs(selNode)); + if (NS_FAILED(res)) return res; + if (outLeftNode) { res = IsEmptyNode(outLeftNode, &bIsEmptyNode, PR_TRUE, PR_FALSE); @@ -477,7 +482,7 @@ nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P } if (outRightNode) { - // HACK alert: consume a br if there s one at front of node + // HACK alert: consume a br if there is one at front of node nsCOMPtr firstNode; res = mEditor->GetFirstEditableNode(outRightNode, &firstNode); if (firstNode && nsHTMLEditUtils::IsBreak(firstNode)) @@ -489,8 +494,6 @@ nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P if (NS_FAILED(res)) return res; if (bIsEmptyNode) mEditor->DeleteNode(outRightNode); } - res = preNode->GetParentNode(getter_AddRefs(selNode)); - if (NS_FAILED(res)) return res; nsCOMPtr brNode; // last ePrevious param causes selection to be set before the break res = mEditor->CreateBR(selNode, newOffset, &brNode, nsIEditor::ePrevious);