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
Родитель 7e42f9c457
Коммит 63e6e518f3
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__

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

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

@ -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,

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

@ -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

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

@ -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);

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

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