Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef DeleteRangeTxn_h__ |
michael@0 | 7 | #define DeleteRangeTxn_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "EditAggregateTxn.h" |
michael@0 | 10 | #include "EditTxn.h" |
michael@0 | 11 | #include "nsAutoPtr.h" |
michael@0 | 12 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 13 | #include "nsID.h" |
michael@0 | 14 | #include "nsIEditor.h" |
michael@0 | 15 | #include "nsISupportsImpl.h" |
michael@0 | 16 | #include "nsRange.h" |
michael@0 | 17 | #include "nscore.h" |
michael@0 | 18 | |
michael@0 | 19 | class nsEditor; |
michael@0 | 20 | class nsINode; |
michael@0 | 21 | class nsRangeUpdater; |
michael@0 | 22 | |
michael@0 | 23 | /** |
michael@0 | 24 | * A transaction that deletes an entire range in the content tree |
michael@0 | 25 | */ |
michael@0 | 26 | class DeleteRangeTxn : public EditAggregateTxn |
michael@0 | 27 | { |
michael@0 | 28 | public: |
michael@0 | 29 | /** initialize the transaction. |
michael@0 | 30 | * @param aEditor the object providing basic editing operations |
michael@0 | 31 | * @param aRange the range to delete |
michael@0 | 32 | */ |
michael@0 | 33 | nsresult Init(nsEditor* aEditor, |
michael@0 | 34 | nsRange* aRange, |
michael@0 | 35 | nsRangeUpdater* aRangeUpdater); |
michael@0 | 36 | |
michael@0 | 37 | DeleteRangeTxn(); |
michael@0 | 38 | |
michael@0 | 39 | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteRangeTxn, EditAggregateTxn) |
michael@0 | 40 | NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); |
michael@0 | 41 | |
michael@0 | 42 | NS_DECL_EDITTXN |
michael@0 | 43 | |
michael@0 | 44 | NS_IMETHOD RedoTransaction(); |
michael@0 | 45 | |
michael@0 | 46 | virtual void LastRelease() |
michael@0 | 47 | { |
michael@0 | 48 | mRange = nullptr; |
michael@0 | 49 | EditAggregateTxn::LastRelease(); |
michael@0 | 50 | } |
michael@0 | 51 | protected: |
michael@0 | 52 | |
michael@0 | 53 | nsresult CreateTxnsToDeleteBetween(nsINode* aNode, |
michael@0 | 54 | int32_t aStartOffset, |
michael@0 | 55 | int32_t aEndOffset); |
michael@0 | 56 | |
michael@0 | 57 | nsresult CreateTxnsToDeleteNodesBetween(); |
michael@0 | 58 | |
michael@0 | 59 | nsresult CreateTxnsToDeleteContent(nsINode* aParent, |
michael@0 | 60 | int32_t aOffset, |
michael@0 | 61 | nsIEditor::EDirection aAction); |
michael@0 | 62 | |
michael@0 | 63 | protected: |
michael@0 | 64 | |
michael@0 | 65 | /** p1 in the range */ |
michael@0 | 66 | nsRefPtr<nsRange> mRange; |
michael@0 | 67 | |
michael@0 | 68 | /** the editor for this transaction */ |
michael@0 | 69 | nsEditor* mEditor; |
michael@0 | 70 | |
michael@0 | 71 | /** range updater object */ |
michael@0 | 72 | nsRangeUpdater* mRangeUpdater; |
michael@0 | 73 | }; |
michael@0 | 74 | |
michael@0 | 75 | #endif |