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 CreateElementTxn_h__ michael@0: #define CreateElementTxn_h__ michael@0: michael@0: #include "EditTxn.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsIDOMNode.h" michael@0: #include "nsISupportsImpl.h" michael@0: #include "nsString.h" michael@0: #include "nscore.h" michael@0: michael@0: class nsEditor; michael@0: michael@0: /** michael@0: * A transaction that creates a new node in the content tree. michael@0: */ michael@0: class CreateElementTxn : public EditTxn michael@0: { michael@0: public: michael@0: enum { eAppend=-1 }; michael@0: michael@0: /** Initialize the transaction. michael@0: * @param aEditor the provider of basic editing functionality michael@0: * @param aTag the tag (P, HR, TABLE, etc.) for the new element michael@0: * @param aParent the node into which the new element will be inserted michael@0: * @param aOffsetInParent the location in aParent to insert the new element michael@0: * if eAppend, the new element is appended as the last child michael@0: */ michael@0: NS_IMETHOD Init(nsEditor *aEditor, michael@0: const nsAString& aTag, michael@0: nsIDOMNode *aParent, michael@0: uint32_t aOffsetInParent); michael@0: michael@0: CreateElementTxn(); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CreateElementTxn, EditTxn) michael@0: michael@0: NS_DECL_EDITTXN michael@0: michael@0: NS_IMETHOD RedoTransaction(); michael@0: michael@0: NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); michael@0: michael@0: protected: michael@0: michael@0: /** the document into which the new node will be inserted */ michael@0: nsEditor* mEditor; michael@0: michael@0: /** the tag (mapping to object type) for the new element */ michael@0: nsString mTag; michael@0: michael@0: /** the node into which the new node will be inserted */ michael@0: nsCOMPtr mParent; michael@0: michael@0: /** the index in mParent for the new node */ michael@0: uint32_t mOffsetInParent; michael@0: michael@0: /** the new node to insert */ michael@0: nsCOMPtr mNewNode; michael@0: michael@0: /** the node we will insert mNewNode before. We compute this ourselves. */ michael@0: nsCOMPtr mRefNode; michael@0: }; michael@0: michael@0: #endif