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 JoinElementTxn_h__ michael@0: #define JoinElementTxn_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 "nsID.h" // for REFNSIID michael@0: #include "nsIDOMNode.h" // for nsIDOMNode michael@0: #include "nscore.h" // for NS_IMETHOD michael@0: michael@0: class nsEditor; michael@0: michael@0: /** michael@0: * A transaction that joins two elements E1 (left node) and E2 (right node) michael@0: * into a single node E. michael@0: * The children of E are the children of E1 followed by the children of E2. michael@0: * After DoTransaction() and RedoTransaction(), E1 is removed from the content michael@0: * tree and E2 remains. michael@0: */ michael@0: class JoinElementTxn : 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 aLeftNode the first of two nodes to join michael@0: * @param aRightNode the second of two nodes to join michael@0: */ michael@0: NS_IMETHOD Init(nsEditor *aEditor, michael@0: nsIDOMNode *aLeftNode, michael@0: nsIDOMNode *aRightNode); michael@0: michael@0: JoinElementTxn(); michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinElementTxn, EditTxn) michael@0: NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); michael@0: michael@0: NS_DECL_EDITTXN michael@0: michael@0: protected: michael@0: michael@0: /** the elements to operate upon. michael@0: * After the merge, mRightNode remains and mLeftNode is removed from the content tree. michael@0: */ michael@0: nsCOMPtr mLeftNode; michael@0: nsCOMPtr mRightNode; michael@0: michael@0: /** the offset into mNode where the children of mElement are split (for undo).
michael@0: * mOffset is the index of the first child in the right node. michael@0: * -1 means the left node had no children. michael@0: */ michael@0: uint32_t mOffset; michael@0: michael@0: /** the parent node containing mLeftNode and mRightNode */ michael@0: nsCOMPtr mParent; michael@0: nsEditor* mEditor; michael@0: }; michael@0: michael@0: #endif