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
Родитель 1b155ee4fd
Коммит 0d49c95048
6 изменённых файлов: 326 добавлений и 640 удалений

Просмотреть файл

@ -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__ #endif // nsEditorUtils_h__

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -728,10 +728,7 @@ protected:
nsresult GetFirstEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstChild); nsresult GetFirstEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstChild);
nsresult GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastChild); 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); nsresult GetFirstEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstLeaf);
#endif
nsresult GetLastEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastLeaf); nsresult GetLastEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastLeaf);
nsresult GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver); nsresult GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver);

Просмотреть файл

@ -45,6 +45,7 @@
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsITextContent.h" #include "nsITextContent.h"
#include "nsIEditor.h" #include "nsIEditor.h"
#include "nsEditorUtils.h"
class nsIDOMDocument; class nsIDOMDocument;
class nsIDOMNode; class nsIDOMNode;
@ -238,27 +239,7 @@ class nsWSRunObject
mTextNode(do_QueryInterface(aNode)),mOffset(aOffset),mChar(aChar) {} mTextNode(do_QueryInterface(aNode)),mOffset(aOffset),mChar(aChar) {}
WSPoint(nsITextContent *aTextNode, PRInt32 aOffset, PRUnichar aChar) : WSPoint(nsITextContent *aTextNode, PRInt32 aOffset, PRUnichar aChar) :
mTextNode(aTextNode),mOffset(aOffset),mChar(aChar) {} 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 --------------------------------------------------------- // protected methods ---------------------------------------------------------