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 InsertNodeTransaction_h
7 : #define InsertNodeTransaction_h
8 :
9 : #include "mozilla/EditTransactionBase.h" // for EditTransactionBase, etc.
10 : #include "nsCOMPtr.h" // for nsCOMPtr
11 : #include "nsCycleCollectionParticipant.h"
12 : #include "nsIContent.h" // for nsIContent
13 : #include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
14 :
15 : namespace mozilla {
16 :
17 : class EditorBase;
18 :
19 : /**
20 : * A transaction that inserts a single element
21 : */
22 : class InsertNodeTransaction final : public EditTransactionBase
23 : {
24 : public:
25 : /**
26 : * Initialize the transaction.
27 : * @param aNode The node to insert.
28 : * @param aParent The node to insert into.
29 : * @param aOffset The offset in aParent to insert aNode.
30 : */
31 : InsertNodeTransaction(nsIContent& aNode, nsINode& aParent, int32_t aOffset,
32 : EditorBase& aEditorBase);
33 :
34 : NS_DECL_ISUPPORTS_INHERITED
35 12 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertNodeTransaction,
36 : EditTransactionBase)
37 :
38 : NS_DECL_EDITTRANSACTIONBASE
39 :
40 : protected:
41 : virtual ~InsertNodeTransaction();
42 :
43 : // The element to insert.
44 : nsCOMPtr<nsIContent> mNode;
45 :
46 : // The node into which the new node will be inserted.
47 : nsCOMPtr<nsINode> mParent;
48 :
49 : // The index in mParent for the new node.
50 : int32_t mOffset;
51 :
52 : // The editor for this transaction.
53 : RefPtr<EditorBase> mEditorBase;
54 : };
55 :
56 : } // namespace mozilla
57 :
58 : #endif // #ifndef InsertNodeTransaction_h
|