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 DeleteNodeTransaction_h
7 : #define DeleteNodeTransaction_h
8 :
9 : #include "mozilla/EditTransactionBase.h"
10 : #include "nsCOMPtr.h"
11 : #include "nsCycleCollectionParticipant.h"
12 : #include "nsIContent.h"
13 : #include "nsINode.h"
14 : #include "nsISupportsImpl.h"
15 : #include "nscore.h"
16 :
17 : namespace mozilla {
18 :
19 : class EditorBase;
20 : class RangeUpdater;
21 :
22 : /**
23 : * A transaction that deletes a single element
24 : */
25 : class DeleteNodeTransaction final : public EditTransactionBase
26 : {
27 : public:
28 : DeleteNodeTransaction(EditorBase& aEditorBase, nsINode& aNodeToDelete,
29 : RangeUpdater* aRangeUpdater);
30 :
31 : /**
32 : * CanDoIt() returns true if there are enough members and can modify the
33 : * parent. Otherwise, false.
34 : */
35 : bool CanDoIt() const;
36 :
37 : NS_DECL_ISUPPORTS_INHERITED
38 4 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteNodeTransaction,
39 : EditTransactionBase)
40 :
41 : NS_DECL_EDITTRANSACTIONBASE
42 :
43 : NS_IMETHOD RedoTransaction() override;
44 :
45 : protected:
46 : virtual ~DeleteNodeTransaction();
47 :
48 : // The editor for this transaction.
49 : RefPtr<EditorBase> mEditorBase;
50 :
51 : // The element to delete.
52 : nsCOMPtr<nsINode> mNodeToDelete;
53 :
54 : // Parent of node to delete.
55 : nsCOMPtr<nsINode> mParentNode;
56 :
57 : // Next sibling to remember for undo/redo purposes.
58 : nsCOMPtr<nsIContent> mRefNode;
59 :
60 : // Range updater object.
61 : RangeUpdater* mRangeUpdater;
62 : };
63 :
64 : } // namespace mozilla
65 :
66 : #endif // #ifndef DeleteNodeTransaction_h
|