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 CreateElementTransaction_h
7 : #define CreateElementTransaction_h
8 :
9 : #include "mozilla/EditTransactionBase.h"
10 : #include "nsCOMPtr.h"
11 : #include "nsCycleCollectionParticipant.h"
12 : #include "nsISupportsImpl.h"
13 :
14 : class nsIAtom;
15 : class nsIContent;
16 : class nsINode;
17 :
18 : /**
19 : * A transaction that creates a new node in the content tree.
20 : */
21 : namespace mozilla {
22 :
23 : class EditorBase;
24 : namespace dom {
25 : class Element;
26 : } // namespace dom
27 :
28 : class CreateElementTransaction final : public EditTransactionBase
29 : {
30 : public:
31 : /**
32 : * Initialize the transaction.
33 : * @param aEditorBase The provider of basic editing functionality.
34 : * @param aTag The tag (P, HR, TABLE, etc.) for the new element.
35 : * @param aParent The node into which the new element will be
36 : * inserted.
37 : * @param aOffsetInParent The location in aParent to insert the new element.
38 : * If eAppend, the new element is appended as the last
39 : * child.
40 : */
41 : CreateElementTransaction(EditorBase& aEditorBase,
42 : nsIAtom& aTag,
43 : nsINode& aParent,
44 : int32_t aOffsetInParent);
45 :
46 : NS_DECL_ISUPPORTS_INHERITED
47 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CreateElementTransaction,
48 : EditTransactionBase)
49 :
50 : NS_DECL_EDITTRANSACTIONBASE
51 :
52 : NS_IMETHOD RedoTransaction() override;
53 :
54 : already_AddRefed<dom::Element> GetNewNode();
55 :
56 : protected:
57 : virtual ~CreateElementTransaction();
58 :
59 : // The document into which the new node will be inserted.
60 : RefPtr<EditorBase> mEditorBase;
61 :
62 : // The tag (mapping to object type) for the new element.
63 : nsCOMPtr<nsIAtom> mTag;
64 :
65 : // The node into which the new node will be inserted.
66 : nsCOMPtr<nsINode> mParent;
67 :
68 : // The index in mParent for the new node.
69 : int32_t mOffsetInParent;
70 :
71 : // The new node to insert.
72 : nsCOMPtr<dom::Element> mNewNode;
73 :
74 : // The node we will insert mNewNode before. We compute this ourselves.
75 : nsCOMPtr<nsIContent> mRefNode;
76 : };
77 :
78 : } // namespace mozilla
79 :
80 : #endif // #ifndef CreateElementTransaction_h
|