2001-09-25 22:53:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-01-08 22:16:22 +00:00
|
|
|
|
|
|
|
#ifndef SplitElementTxn_h__
|
|
|
|
#define SplitElementTxn_h__
|
|
|
|
|
2012-07-13 06:33:42 +00:00
|
|
|
#include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN
|
|
|
|
#include "nsCOMPtr.h" // for nsCOMPtr
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
#include "nscore.h" // for NS_IMETHOD
|
1999-01-08 22:16:22 +00:00
|
|
|
|
2000-01-04 03:09:41 +00:00
|
|
|
class nsEditor;
|
2014-05-31 15:06:29 +00:00
|
|
|
class nsINode;
|
2000-01-04 03:09:41 +00:00
|
|
|
|
1999-01-08 22:16:22 +00:00
|
|
|
/**
|
|
|
|
* A transaction that splits an element E into two identical nodes, E1 and E2
|
|
|
|
* with the children of E divided between E1 and E2.
|
|
|
|
*/
|
|
|
|
class SplitElementTxn : public EditTxn
|
|
|
|
{
|
|
|
|
public:
|
1999-02-15 18:25:30 +00:00
|
|
|
/** initialize the transaction.
|
|
|
|
* @param aEditor the provider of core editing operations
|
|
|
|
* @param aNode the node to split
|
|
|
|
* @param aOffset the location within aNode to do the split.
|
|
|
|
* aOffset may refer to children of aNode, or content of aNode.
|
|
|
|
* The left node will have child|content 0..aOffset-1.
|
|
|
|
*/
|
2000-01-04 03:09:41 +00:00
|
|
|
NS_IMETHOD Init (nsEditor *aEditor,
|
2014-05-31 15:06:29 +00:00
|
|
|
nsINode *aNode,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aOffset);
|
2009-04-24 22:45:34 +00:00
|
|
|
|
1999-01-21 01:51:09 +00:00
|
|
|
SplitElementTxn();
|
1999-01-08 22:16:22 +00:00
|
|
|
|
2011-02-19 22:18:37 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2009-05-09 04:59:25 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitElementTxn, EditTxn)
|
|
|
|
|
2007-01-11 14:38:02 +00:00
|
|
|
NS_DECL_EDITTXN
|
1999-01-08 22:16:22 +00:00
|
|
|
|
2001-03-09 14:23:59 +00:00
|
|
|
NS_IMETHOD RedoTransaction(void);
|
1999-01-08 22:16:22 +00:00
|
|
|
|
2014-05-31 15:06:29 +00:00
|
|
|
NS_IMETHOD GetNewNode(nsINode **aNewNode);
|
1999-02-24 17:24:37 +00:00
|
|
|
|
1999-01-08 22:16:22 +00:00
|
|
|
protected:
|
2014-05-31 15:06:29 +00:00
|
|
|
|
1999-01-08 22:16:22 +00:00
|
|
|
/** the element to operate upon */
|
2014-05-31 15:06:29 +00:00
|
|
|
nsCOMPtr<nsINode> mExistingRightNode;
|
1999-01-08 22:16:22 +00:00
|
|
|
|
|
|
|
/** the offset into mElement where the children of mElement are split.<BR>
|
1999-02-15 18:25:30 +00:00
|
|
|
* mOffset is the index of the first child in the right node.
|
1999-01-08 22:16:22 +00:00
|
|
|
* -1 means the new node gets no children.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mOffset;
|
1999-01-08 22:16:22 +00:00
|
|
|
|
|
|
|
/** the element we create when splitting mElement */
|
2014-05-31 15:06:29 +00:00
|
|
|
nsCOMPtr<nsINode> mNewLeftNode;
|
1999-01-21 01:51:09 +00:00
|
|
|
|
|
|
|
/** the parent shared by mExistingRightNode and mNewLeftNode */
|
2014-05-31 15:06:29 +00:00
|
|
|
nsCOMPtr<nsINode> mParent;
|
2000-01-04 03:09:41 +00:00
|
|
|
nsEditor* mEditor;
|
1999-01-08 22:16:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|