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/. */
6 #ifndef JoinNodeTxn_h__
7 #define JoinNodeTxn_h__
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 "nscore.h" // for NS_IMETHOD
22 * A transaction that joins two nodes E1 (left node) and E2 (right node) into a
23 * single node E. The children of E are the children of E1 followed by the
24 * children of E2. After DoTransaction() and RedoTransaction(), E1 is removed
25 * from the content tree and E2 remains.
27 class JoinNodeTxn
: public EditTxn
30 /** @param aEditor the provider of core editing operations
31 * @param aLeftNode the first of two nodes to join
32 * @param aRightNode the second of two nodes to join
34 JoinNodeTxn(nsEditor
& aEditor
, nsINode
& aLeftNode
, nsINode
& aRightNode
);
36 /* Call this after constructing to ensure the inputs are correct */
37 nsresult
CheckValidity();
39 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinNodeTxn
, EditTxn
)
40 NS_IMETHOD
QueryInterface(REFNSIID aIID
, void** aInstancePtr
) override
;
47 /** The nodes to operate upon. After the merge, mRightNode remains and
48 * mLeftNode is removed from the content tree.
50 nsCOMPtr
<nsINode
> mLeftNode
;
51 nsCOMPtr
<nsINode
> mRightNode
;
53 /** The offset into mNode where the children of mElement are split (for
54 * undo). mOffset is the index of the first child in the right node. -1
55 * means the left node had no children.
59 /** The parent node containing mLeftNode and mRightNode */
60 nsCOMPtr
<nsINode
> mParent
;
64 } // namespace mozilla