From d589dab4ad6ffec79e6075d044089ac83d6df415 Mon Sep 17 00:00:00 2001 From: "jst%netscape.com" Date: Wed, 11 Oct 2000 11:22:01 +0000 Subject: [PATCH] Putting back a change that was accidentally backed out. git-svn-id: svn://10.0.0.236/branches/Netscape_20000922_BRANCH@80932 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsHTMLEditor.cpp | 21 +++++++++++++++++-- .../editor/libeditor/html/nsHTMLEditor.cpp | 21 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index bdb00348d63..0b2ce1d0c0f 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -5484,6 +5484,15 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) rv = nsuiEvent->GetRangeOffset(&newSelectionOffset); if (NS_FAILED(rv)) return rv; + /* Creating a range to store insert position because when + we delete the selection, range gravity will make sure the insertion + point is in the correct place */ + nsCOMPtr destinationRange; + rv = CreateRange(newSelectionParent, newSelectionOffset,newSelectionParent, newSelectionOffset, getter_AddRefs(destinationRange)); + if (NS_FAILED(rv)) + return rv; + if(!destinationRange) + return NS_ERROR_FAILURE; // We never have to delete if selection is already collapsed PRBool deleteSelection = PR_FALSE; @@ -5552,9 +5561,17 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) if (!(deleteSelection && srcdomdoc != destdomdoc)) { // Move the selection to the point under the mouse cursor + rv = destinationRange->GetStartContainer(getter_AddRefs(newSelectionParent)); + if (NS_FAILED(rv)) + return rv; + if(!newSelectionParent) + return NS_ERROR_FAILURE; + + rv = destinationRange->GetStartOffset(&newSelectionOffset); + if (NS_FAILED(rv)) + return rv; selection->Collapse(newSelectionParent, newSelectionOffset); - } - + } // We have to figure out whether to delete and relocate caret only once doPlaceCaret = PR_FALSE; } diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index bdb00348d63..0b2ce1d0c0f 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -5484,6 +5484,15 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) rv = nsuiEvent->GetRangeOffset(&newSelectionOffset); if (NS_FAILED(rv)) return rv; + /* Creating a range to store insert position because when + we delete the selection, range gravity will make sure the insertion + point is in the correct place */ + nsCOMPtr destinationRange; + rv = CreateRange(newSelectionParent, newSelectionOffset,newSelectionParent, newSelectionOffset, getter_AddRefs(destinationRange)); + if (NS_FAILED(rv)) + return rv; + if(!destinationRange) + return NS_ERROR_FAILURE; // We never have to delete if selection is already collapsed PRBool deleteSelection = PR_FALSE; @@ -5552,9 +5561,17 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) if (!(deleteSelection && srcdomdoc != destdomdoc)) { // Move the selection to the point under the mouse cursor + rv = destinationRange->GetStartContainer(getter_AddRefs(newSelectionParent)); + if (NS_FAILED(rv)) + return rv; + if(!newSelectionParent) + return NS_ERROR_FAILURE; + + rv = destinationRange->GetStartOffset(&newSelectionOffset); + if (NS_FAILED(rv)) + return rv; selection->Collapse(newSelectionParent, newSelectionOffset); - } - + } // We have to figure out whether to delete and relocate caret only once doPlaceCaret = PR_FALSE; }