michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef SplitElementTxn_h__ michael@0: #define SplitElementTxn_h__ michael@0: michael@0: #include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN michael@0: #include "nsCOMPtr.h" // for nsCOMPtr michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsIDOMNode.h" // for nsIDOMNode michael@0: #include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED michael@0: #include "nscore.h" // for NS_IMETHOD michael@0: michael@0: class nsEditor; michael@0: michael@0: /** michael@0: * A transaction that splits an element E into two identical nodes, E1 and E2 michael@0: * with the children of E divided between E1 and E2. michael@0: */ michael@0: class SplitElementTxn : public EditTxn michael@0: { michael@0: public: michael@0: /** initialize the transaction. michael@0: * @param aEditor the provider of core editing operations michael@0: * @param aNode the node to split michael@0: * @param aOffset the location within aNode to do the split. michael@0: * aOffset may refer to children of aNode, or content of aNode. michael@0: * The left node will have child|content 0..aOffset-1. michael@0: */ michael@0: NS_IMETHOD Init (nsEditor *aEditor, michael@0: nsIDOMNode *aNode, michael@0: int32_t aOffset); michael@0: michael@0: SplitElementTxn(); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitElementTxn, EditTxn) michael@0: michael@0: NS_DECL_EDITTXN michael@0: michael@0: NS_IMETHOD RedoTransaction(void); michael@0: michael@0: NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); michael@0: michael@0: protected: michael@0: michael@0: /** the element to operate upon */ michael@0: nsCOMPtr mExistingRightNode; michael@0: michael@0: /** the offset into mElement where the children of mElement are split.
michael@0: * mOffset is the index of the first child in the right node. michael@0: * -1 means the new node gets no children. michael@0: */ michael@0: int32_t mOffset; michael@0: michael@0: /** the element we create when splitting mElement */ michael@0: nsCOMPtr mNewLeftNode; michael@0: michael@0: /** the parent shared by mExistingRightNode and mNewLeftNode */ michael@0: nsCOMPtr mParent; michael@0: nsEditor* mEditor; michael@0: }; michael@0: michael@0: #endif