|
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 JoinElementTxn_h__ |
|
7 #define JoinElementTxn_h__ |
|
8 |
|
9 #include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN |
|
10 #include "nsCOMPtr.h" // for nsCOMPtr |
|
11 #include "nsCycleCollectionParticipant.h" |
|
12 #include "nsID.h" // for REFNSIID |
|
13 #include "nsIDOMNode.h" // for nsIDOMNode |
|
14 #include "nscore.h" // for NS_IMETHOD |
|
15 |
|
16 class nsEditor; |
|
17 |
|
18 /** |
|
19 * A transaction that joins two elements E1 (left node) and E2 (right node) |
|
20 * into a single node E. |
|
21 * The children of E are the children of E1 followed by the children of E2. |
|
22 * After DoTransaction() and RedoTransaction(), E1 is removed from the content |
|
23 * tree and E2 remains. |
|
24 */ |
|
25 class JoinElementTxn : public EditTxn |
|
26 { |
|
27 public: |
|
28 /** initialize the transaction |
|
29 * @param aEditor the provider of core editing operations |
|
30 * @param aLeftNode the first of two nodes to join |
|
31 * @param aRightNode the second of two nodes to join |
|
32 */ |
|
33 NS_IMETHOD Init(nsEditor *aEditor, |
|
34 nsIDOMNode *aLeftNode, |
|
35 nsIDOMNode *aRightNode); |
|
36 |
|
37 JoinElementTxn(); |
|
38 |
|
39 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinElementTxn, EditTxn) |
|
40 NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); |
|
41 |
|
42 NS_DECL_EDITTXN |
|
43 |
|
44 protected: |
|
45 |
|
46 /** the elements to operate upon. |
|
47 * After the merge, mRightNode remains and mLeftNode is removed from the content tree. |
|
48 */ |
|
49 nsCOMPtr<nsIDOMNode> mLeftNode; |
|
50 nsCOMPtr<nsIDOMNode> mRightNode; |
|
51 |
|
52 /** the offset into mNode where the children of mElement are split (for undo).<BR> |
|
53 * mOffset is the index of the first child in the right node. |
|
54 * -1 means the left node had no children. |
|
55 */ |
|
56 uint32_t mOffset; |
|
57 |
|
58 /** the parent node containing mLeftNode and mRightNode */ |
|
59 nsCOMPtr<nsIDOMNode> mParent; |
|
60 nsEditor* mEditor; |
|
61 }; |
|
62 |
|
63 #endif |