editor/libeditor/base/DeleteRangeTxn.h

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

mercurial