From cb89b3b4db8eef3becf8d631f4e16106ee2fe892 Mon Sep 17 00:00:00 2001 From: "jfrancis%netscape.com" Date: Wed, 26 May 1999 22:28:04 +0000 Subject: [PATCH] fixed dom range gravity error --- content/base/src/nsRange.cpp | 11 ++++++++--- layout/base/src/nsRange.cpp | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/content/base/src/nsRange.cpp b/content/base/src/nsRange.cpp index 5ae27d0cb8c..fd27a2f2fe2 100644 --- a/content/base/src/nsRange.cpp +++ b/content/base/src/nsRange.cpp @@ -1427,7 +1427,12 @@ nsresult nsRange::Clone(nsIDOMRange** aReturn) if (NS_FAILED(res)) return res; - return DoSetRange(mStartParent, mStartOffset, mEndParent, mEndOffset); + res = (*aReturn)->SetStart(mStartParent, mStartOffset); + if (NS_FAILED(res)) + return res; + + res = (*aReturn)->SetEnd(mEndParent, mEndOffset); + return res; } nsresult nsRange::InsertNode(nsIDOMNode* aN) @@ -1598,12 +1603,12 @@ nsresult nsRange::OwnerChildRemoved(nsIContent* aParentNode, PRInt32 aOffset, ns if (theRange->mStartParent == domNode) { // if child deleted before start, move start offset left one - if (aOffset <= theRange->mStartOffset) theRange->mStartOffset--; + if (aOffset < theRange->mStartOffset) theRange->mStartOffset--; } if (theRange->mEndParent == domNode) { // if child deleted before end, move end offset left one - if (aOffset <= theRange->mEndOffset) + if (aOffset < theRange->mEndOffset) { if (theRange->mEndOffset>0) theRange->mEndOffset--; } diff --git a/layout/base/src/nsRange.cpp b/layout/base/src/nsRange.cpp index 5ae27d0cb8c..fd27a2f2fe2 100644 --- a/layout/base/src/nsRange.cpp +++ b/layout/base/src/nsRange.cpp @@ -1427,7 +1427,12 @@ nsresult nsRange::Clone(nsIDOMRange** aReturn) if (NS_FAILED(res)) return res; - return DoSetRange(mStartParent, mStartOffset, mEndParent, mEndOffset); + res = (*aReturn)->SetStart(mStartParent, mStartOffset); + if (NS_FAILED(res)) + return res; + + res = (*aReturn)->SetEnd(mEndParent, mEndOffset); + return res; } nsresult nsRange::InsertNode(nsIDOMNode* aN) @@ -1598,12 +1603,12 @@ nsresult nsRange::OwnerChildRemoved(nsIContent* aParentNode, PRInt32 aOffset, ns if (theRange->mStartParent == domNode) { // if child deleted before start, move start offset left one - if (aOffset <= theRange->mStartOffset) theRange->mStartOffset--; + if (aOffset < theRange->mStartOffset) theRange->mStartOffset--; } if (theRange->mEndParent == domNode) { // if child deleted before end, move end offset left one - if (aOffset <= theRange->mEndOffset) + if (aOffset < theRange->mEndOffset) { if (theRange->mEndOffset>0) theRange->mEndOffset--; }