2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef JoinElementTxn_h__
|
|
|
|
#define JoinElementTxn_h__
|
|
|
|
|
2012-07-12 23:33:42 -07:00
|
|
|
#include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN
|
|
|
|
#include "nsCOMPtr.h" // for nsCOMPtr
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsID.h" // for REFNSIID
|
|
|
|
#include "nscore.h" // for NS_IMETHOD
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsEditor;
|
2013-01-09 15:05:08 -08:00
|
|
|
class nsINode;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A transaction that joins two elements E1 (left node) and E2 (right node)
|
2013-01-09 15:05:08 -08:00
|
|
|
* into a single node E.
|
2007-03-22 10:30:00 -07:00
|
|
|
* The children of E are the children of E1 followed by the children of E2.
|
|
|
|
* After DoTransaction() and RedoTransaction(), E1 is removed from the content
|
|
|
|
* tree and E2 remains.
|
|
|
|
*/
|
|
|
|
class JoinElementTxn : public EditTxn
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initialize the transaction
|
|
|
|
* @param aEditor the provider of core editing operations
|
|
|
|
* @param aLeftNode the first of two nodes to join
|
|
|
|
* @param aRightNode the second of two nodes to join
|
|
|
|
*/
|
|
|
|
NS_IMETHOD Init(nsEditor *aEditor,
|
2013-01-09 15:05:08 -08:00
|
|
|
nsINode *aLeftNode,
|
|
|
|
nsINode *aRightNode);
|
2009-04-24 15:45:34 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
JoinElementTxn();
|
|
|
|
|
2009-05-08 21:59:25 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinElementTxn, EditTxn)
|
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_EDITTXN
|
|
|
|
|
|
|
|
protected:
|
2013-01-09 15:05:08 -08:00
|
|
|
|
|
|
|
/** the elements to operate upon.
|
2007-03-22 10:30:00 -07:00
|
|
|
* After the merge, mRightNode remains and mLeftNode is removed from the content tree.
|
|
|
|
*/
|
2013-01-09 15:05:08 -08:00
|
|
|
nsCOMPtr<nsINode> mLeftNode;
|
|
|
|
nsCOMPtr<nsINode> mRightNode;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** the offset into mNode where the children of mElement are split (for undo).<BR>
|
2013-01-09 15:05:08 -08:00
|
|
|
* mOffset is the index of the first child in the right node.
|
2007-03-22 10:30:00 -07:00
|
|
|
* -1 means the left node had no children.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** the parent node containing mLeftNode and mRightNode */
|
2013-01-09 15:05:08 -08:00
|
|
|
nsCOMPtr<nsINode> mParent;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsEditor* mEditor;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|