Line data Source code
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 DeleteRangeTransaction_h
7 : #define DeleteRangeTransaction_h
8 :
9 : #include "EditAggregateTransaction.h"
10 : #include "nsCycleCollectionParticipant.h"
11 : #include "nsID.h"
12 : #include "nsIEditor.h"
13 : #include "nsISupportsImpl.h"
14 : #include "nsRange.h"
15 : #include "nscore.h"
16 :
17 : class nsINode;
18 :
19 : namespace mozilla {
20 :
21 : class EditorBase;
22 : class RangeUpdater;
23 :
24 : /**
25 : * A transaction that deletes an entire range in the content tree
26 : */
27 0 : class DeleteRangeTransaction final : public EditAggregateTransaction
28 : {
29 : public:
30 : /**
31 : * @param aEditorBase The object providing basic editing operations.
32 : * @param aRangeToDelete The range to delete.
33 : */
34 : DeleteRangeTransaction(EditorBase& aEditorBase,
35 : nsRange& aRangeToDelete,
36 : RangeUpdater* aRangeUpdater);
37 :
38 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteRangeTransaction,
39 : EditAggregateTransaction)
40 : NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
41 :
42 : NS_DECL_EDITTRANSACTIONBASE
43 :
44 : NS_IMETHOD RedoTransaction() override;
45 :
46 0 : virtual void LastRelease() override
47 : {
48 0 : mRangeToDelete = nullptr;
49 0 : EditAggregateTransaction::LastRelease();
50 0 : }
51 :
52 : protected:
53 : nsresult CreateTxnsToDeleteBetween(nsINode* aNode,
54 : int32_t aStartOffset,
55 : int32_t aEndOffset);
56 :
57 : nsresult CreateTxnsToDeleteNodesBetween(nsRange* aRangeToDelete);
58 :
59 : nsresult CreateTxnsToDeleteContent(nsINode* aParent,
60 : int32_t aOffset,
61 : nsIEditor::EDirection aAction);
62 :
63 : // The editor for this transaction.
64 : RefPtr<EditorBase> mEditorBase;
65 :
66 : // P1 in the range. This is only non-null until DoTransaction is called and
67 : // we convert it into child transactions.
68 : RefPtr<nsRange> mRangeToDelete;
69 :
70 : // Range updater object.
71 : RangeUpdater* mRangeUpdater;
72 : };
73 :
74 : } // namespace mozilla
75 :
76 : #endif // #ifndef DeleteRangeTransaction_h
|