|
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 CreateElementTxn_h__ |
|
7 #define CreateElementTxn_h__ |
|
8 |
|
9 #include "EditTxn.h" |
|
10 #include "nsCOMPtr.h" |
|
11 #include "nsCycleCollectionParticipant.h" |
|
12 #include "nsIDOMNode.h" |
|
13 #include "nsISupportsImpl.h" |
|
14 #include "nsString.h" |
|
15 #include "nscore.h" |
|
16 |
|
17 class nsEditor; |
|
18 |
|
19 /** |
|
20 * A transaction that creates a new node in the content tree. |
|
21 */ |
|
22 class CreateElementTxn : public EditTxn |
|
23 { |
|
24 public: |
|
25 enum { eAppend=-1 }; |
|
26 |
|
27 /** Initialize the transaction. |
|
28 * @param aEditor the provider of basic editing functionality |
|
29 * @param aTag the tag (P, HR, TABLE, etc.) for the new element |
|
30 * @param aParent the node into which the new element will be inserted |
|
31 * @param aOffsetInParent the location in aParent to insert the new element |
|
32 * if eAppend, the new element is appended as the last child |
|
33 */ |
|
34 NS_IMETHOD Init(nsEditor *aEditor, |
|
35 const nsAString& aTag, |
|
36 nsIDOMNode *aParent, |
|
37 uint32_t aOffsetInParent); |
|
38 |
|
39 CreateElementTxn(); |
|
40 |
|
41 NS_DECL_ISUPPORTS_INHERITED |
|
42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CreateElementTxn, EditTxn) |
|
43 |
|
44 NS_DECL_EDITTXN |
|
45 |
|
46 NS_IMETHOD RedoTransaction(); |
|
47 |
|
48 NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); |
|
49 |
|
50 protected: |
|
51 |
|
52 /** the document into which the new node will be inserted */ |
|
53 nsEditor* mEditor; |
|
54 |
|
55 /** the tag (mapping to object type) for the new element */ |
|
56 nsString mTag; |
|
57 |
|
58 /** the node into which the new node will be inserted */ |
|
59 nsCOMPtr<nsIDOMNode> mParent; |
|
60 |
|
61 /** the index in mParent for the new node */ |
|
62 uint32_t mOffsetInParent; |
|
63 |
|
64 /** the new node to insert */ |
|
65 nsCOMPtr<nsIDOMNode> mNewNode; |
|
66 |
|
67 /** the node we will insert mNewNode before. We compute this ourselves. */ |
|
68 nsCOMPtr<nsIDOMNode> mRefNode; |
|
69 }; |
|
70 |
|
71 #endif |