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 DeleteRangeTxn_h__ michael@0: #define DeleteRangeTxn_h__ michael@0: michael@0: #include "EditAggregateTxn.h" michael@0: #include "EditTxn.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsID.h" michael@0: #include "nsIEditor.h" michael@0: #include "nsISupportsImpl.h" michael@0: #include "nsRange.h" michael@0: #include "nscore.h" michael@0: michael@0: class nsEditor; michael@0: class nsINode; michael@0: class nsRangeUpdater; michael@0: michael@0: /** michael@0: * A transaction that deletes an entire range in the content tree michael@0: */ michael@0: class DeleteRangeTxn : public EditAggregateTxn michael@0: { michael@0: public: michael@0: /** initialize the transaction. michael@0: * @param aEditor the object providing basic editing operations michael@0: * @param aRange the range to delete michael@0: */ michael@0: nsresult Init(nsEditor* aEditor, michael@0: nsRange* aRange, michael@0: nsRangeUpdater* aRangeUpdater); michael@0: michael@0: DeleteRangeTxn(); michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteRangeTxn, EditAggregateTxn) michael@0: NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); michael@0: michael@0: NS_DECL_EDITTXN michael@0: michael@0: NS_IMETHOD RedoTransaction(); michael@0: michael@0: virtual void LastRelease() michael@0: { michael@0: mRange = nullptr; michael@0: EditAggregateTxn::LastRelease(); michael@0: } michael@0: protected: michael@0: michael@0: nsresult CreateTxnsToDeleteBetween(nsINode* aNode, michael@0: int32_t aStartOffset, michael@0: int32_t aEndOffset); michael@0: michael@0: nsresult CreateTxnsToDeleteNodesBetween(); michael@0: michael@0: nsresult CreateTxnsToDeleteContent(nsINode* aParent, michael@0: int32_t aOffset, michael@0: nsIEditor::EDirection aAction); michael@0: michael@0: protected: michael@0: michael@0: /** p1 in the range */ michael@0: nsRefPtr mRange; michael@0: michael@0: /** the editor for this transaction */ michael@0: nsEditor* mEditor; michael@0: michael@0: /** range updater object */ michael@0: nsRangeUpdater* mRangeUpdater; michael@0: }; michael@0: michael@0: #endif