From e1f400aecdf3e935693ca17de4ae5cd4756b05d7 Mon Sep 17 00:00:00 2001 From: "jfrancis%netscape.com" Date: Sat, 1 May 1999 19:37:50 +0000 Subject: [PATCH] fix for bug 5782 - check for null return when getting prev/next node is deletion rules; rvd floppy moose, appr chofmann git-svn-id: svn://10.0.0.236/trunk@29950 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsHTMLEditRules.cpp | 18 +++++++++++++++--- .../editor/libeditor/html/nsHTMLEditRules.cpp | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/mozilla/editor/base/nsHTMLEditRules.cpp b/mozilla/editor/base/nsHTMLEditRules.cpp index 46e6768c88b..e1fc11c4a6c 100644 --- a/mozilla/editor/base/nsHTMLEditRules.cpp +++ b/mozilla/editor/base/nsHTMLEditRules.cpp @@ -367,6 +367,13 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::Dir res = GetPriorNode(node, getter_AddRefs(priorNode)); if (NS_FAILED(res)) return res; + // if there is no prior node then cancel the deletion + if (!priorNode) + { + *aCancel = PR_TRUE; + return res; + } + // XXX hackery - using this to skip empty text nodes, // since these are almost always non displayed preservation // of returns in the original html. but they could @@ -423,9 +430,14 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::Dir nsCOMPtr nextNode; res = GetNextNode(node, getter_AddRefs(nextNode)); if (NS_FAILED(res)) return res; - if (HasSameBlockNodeParent(node, nextNode)) return NS_OK; - - // deleting across blocks + + // if there is no next node then cancel the deletion + if (!nextNode) + { + *aCancel = PR_TRUE; + return res; + } + // XXX hackery - using this to skip empty text nodes, // since these are almost always non displayed preservation // of returns in the original html. but they could diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp index 46e6768c88b..e1fc11c4a6c 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp @@ -367,6 +367,13 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::Dir res = GetPriorNode(node, getter_AddRefs(priorNode)); if (NS_FAILED(res)) return res; + // if there is no prior node then cancel the deletion + if (!priorNode) + { + *aCancel = PR_TRUE; + return res; + } + // XXX hackery - using this to skip empty text nodes, // since these are almost always non displayed preservation // of returns in the original html. but they could @@ -423,9 +430,14 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::Dir nsCOMPtr nextNode; res = GetNextNode(node, getter_AddRefs(nextNode)); if (NS_FAILED(res)) return res; - if (HasSameBlockNodeParent(node, nextNode)) return NS_OK; - - // deleting across blocks + + // if there is no next node then cancel the deletion + if (!nextNode) + { + *aCancel = PR_TRUE; + return res; + } + // XXX hackery - using this to skip empty text nodes, // since these are almost always non displayed preservation // of returns in the original html. but they could