fix for 161106: rewrite of deletion in editor. fixes various deletion probs. r=glazman; sr=kin

This commit is contained in:
jfrancis%netscape.com 2002-08-29 07:49:31 +00:00
parent 1b155ee4fd
commit 0d49c95048
6 changed files with 326 additions and 640 deletions

View File

@ -238,4 +238,26 @@ class nsTrivialFunctor : public nsBoolDomIterFunctor
};
/******************************************************************************
* general dom point utility struct
*****************************************************************************/
struct DOMPoint
{
nsCOMPtr<nsIDOMNode> node;
PRInt32 offset;
DOMPoint() : node(0),offset(0) {}
DOMPoint(nsIDOMNode *aNode, PRInt32 aOffset) :
node(aNode),offset(aOffset) {}
void SetPoint(nsIDOMNode *aNode, PRInt32 aOffset)
{
node = aNode; offset = aOffset;
}
void GetPoint(nsCOMPtr<nsIDOMNode> &aNode, PRInt32 &aOffset)
{
aNode = node; aOffset = offset;
}
};
#endif // nsEditorUtils_h__

File diff suppressed because it is too large Load Diff

View File

@ -46,6 +46,7 @@
#include "nsISupportsArray.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsEditorUtils.h"
class nsISupportsArray;
class nsVoidArray;
@ -133,9 +134,8 @@ protected:
nsresult SplitMailCites(nsISelection *aSelection, PRBool aPlaintext, PRBool *aHandled);
nsresult WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aAction,
PRBool *aCancel, PRBool *aHandled);
nsresult JoinBlocks(nsISelection *aSelection, nsCOMPtr<nsIDOMNode> *aLeftBlock,
nsCOMPtr<nsIDOMNode> *aRightBlock, PRBool *aCanceled);
nsresult MoveBlock(nsISelection *aSelection, nsIDOMNode *aNewParent, PRInt32 aOffset = -1);
nsresult JoinBlocks(nsCOMPtr<nsIDOMNode> *aLeftBlock, nsCOMPtr<nsIDOMNode> *aRightBlock, PRBool *aCanceled);
nsresult MoveBlock(nsIDOMNode *aLeft, nsIDOMNode *aRight, PRInt32 aLeftOffset, PRInt32 aRightOffset);
nsresult MoveNodeSmart(nsIDOMNode *aSource, nsIDOMNode *aDest, PRInt32 *aOffset);
nsresult MoveContents(nsIDOMNode *aSource, nsIDOMNode *aDest, PRInt32 *aOffset);
nsresult DeleteNonTableElements(nsIDOMNode *aNode);
@ -180,10 +180,6 @@ protected:
nsIDOMNode *aBodyNode,
nsISelection *aSelection,
PRBool *aHandled);
nsresult CheckForWhitespaceDeletion(nsCOMPtr<nsIDOMNode> *ioStartNode,
PRInt32 *ioStartOffset,
PRInt32 aAction,
PRBool *aHandled);
nsresult CheckForInvisibleBR(nsIDOMNode *aBlock, nsHTMLEditRules::BRLocation aWhere,
nsCOMPtr<nsIDOMNode> *outBRNode, PRInt32 aOffset=0);
PRBool ExpandSelectionForDeletion(nsISelection *aSelection);
@ -206,6 +202,10 @@ protected:
PRBool aDontTouchContent=PR_FALSE);
nsresult GetChildNodesForOperation(nsIDOMNode *inNode,
nsCOMPtr<nsISupportsArray> *outArrayOfNodes);
nsresult GetNodesFromPoint(DOMPoint point,
PRInt32 operation,
nsCOMPtr<nsISupportsArray> *arrayOfNodes,
PRBool dontTouchContent);
nsresult GetNodesFromSelection(nsISelection *selection,
PRInt32 operation,
nsCOMPtr<nsISupportsArray> *arrayOfNodes,

View File

@ -4859,7 +4859,7 @@ nsHTMLEditor::GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOu
if (!aOutLastChild || !aNode) return NS_ERROR_NULL_POINTER;
// init out parms
*aOutLastChild = nsnull;
*aOutLastChild = aNode;
// find last editable child
nsCOMPtr<nsIDOMNode> child;
@ -4879,8 +4879,6 @@ nsHTMLEditor::GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOu
return res;
}
// jfrancis or glazman may want to use this method (currently it's unused)
#ifdef XXX_DEAD_CODE
nsresult
nsHTMLEditor::GetFirstEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstLeaf)
{
@ -4888,7 +4886,7 @@ nsHTMLEditor::GetFirstEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOu
if (!aOutFirstLeaf || !aNode) return NS_ERROR_NULL_POINTER;
// init out parms
*aOutFirstLeaf = nsnull;
*aOutFirstLeaf = aNode;
// find leftmost leaf
nsCOMPtr<nsIDOMNode> child;
@ -4913,7 +4911,6 @@ nsHTMLEditor::GetFirstEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOu
*aOutFirstLeaf = child;
return res;
}
#endif
nsresult

View File

@ -728,10 +728,7 @@ protected:
nsresult GetFirstEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstChild);
nsresult GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastChild);
#ifdef XXX_DEAD_CODE
// these should be removed some day by jfrancis: GetFirstEditableLeaf & GetLastEditableLeaf
nsresult GetFirstEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstLeaf);
#endif
nsresult GetLastEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastLeaf);
nsresult GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver);

View File

@ -45,6 +45,7 @@
#include "nsISupportsArray.h"
#include "nsITextContent.h"
#include "nsIEditor.h"
#include "nsEditorUtils.h"
class nsIDOMDocument;
class nsIDOMNode;
@ -240,26 +241,6 @@ class nsWSRunObject
mTextNode(aTextNode),mOffset(aOffset),mChar(aChar) {}
};
// general dom point utility struct
struct DOMPoint
{
nsCOMPtr<nsIDOMNode> node;
PRInt32 offset;
DOMPoint() : node(0),offset(0) {}
DOMPoint(nsIDOMNode *aNode, PRInt32 aOffset) :
node(aNode),offset(aOffset) {}
void SetPoint(nsIDOMNode *aNode, PRInt32 aOffset)
{
node = aNode; offset = aOffset;
}
void GetPoint(nsCOMPtr<nsIDOMNode> &aNode, PRInt32 &aOffset)
{
aNode = node; aOffset = offset;
}
};
// protected methods ---------------------------------------------------------
// tons of utility methods.