Fix for bug 191762 (dragged image doesn't land where it's dropped)
editor/libeditor/base/nsSelectionState.cpp - Reworked the logic in SelAdjJoinNodes() to avoid adding aOldLeftNodeLength twice to the calculated offset when the start/end node is the parent. editor/libeditor/html/nsHTMLDataTransfer.cpp editor/libeditor/text/nsPlaintextDataTransfer.cpp - Modified the InsertFromDrop() to use an nsAutoTrackDOMPoint, instead of relying on range gravity, to calculate the correct insert position after deleting the current selection. r=jfrancis@netscape.com sr=sfraser@netscape.com git-svn-id: svn://10.0.0.236/trunk@138611 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1146,15 +1146,6 @@ 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<nsIDOMRange> 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;
|
||||
@@ -1214,6 +1205,9 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||
|
||||
if (deleteSelection)
|
||||
{
|
||||
// Use an auto tracker so that our drop point is correctly
|
||||
// positioned after the delete.
|
||||
nsAutoTrackDOMPoint tracker(mRangeUpdater, &newSelectionParent, &newSelectionOffset);
|
||||
rv = DeleteSelection(eNone);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
@@ -1223,15 +1217,6 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user