editor/libeditor/base/JoinElementTxn.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/base/JoinElementTxn.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef JoinElementTxn_h__
    1.10 +#define JoinElementTxn_h__
    1.11 +
    1.12 +#include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
    1.13 +#include "nsCOMPtr.h"                   // for nsCOMPtr
    1.14 +#include "nsCycleCollectionParticipant.h"
    1.15 +#include "nsID.h"                       // for REFNSIID
    1.16 +#include "nsIDOMNode.h"                 // for nsIDOMNode
    1.17 +#include "nscore.h"                     // for NS_IMETHOD
    1.18 +
    1.19 +class nsEditor;
    1.20 +
    1.21 +/**
    1.22 + * A transaction that joins two elements E1 (left node) and E2 (right node)
    1.23 + * into a single node E.  
    1.24 + * The children of E are the children of E1 followed by the children of E2.
    1.25 + * After DoTransaction() and RedoTransaction(), E1 is removed from the content
    1.26 + * tree and E2 remains.
    1.27 + */
    1.28 +class JoinElementTxn : public EditTxn
    1.29 +{
    1.30 +public:
    1.31 +  /** initialize the transaction
    1.32 +    * @param aEditor    the provider of core editing operations
    1.33 +    * @param aLeftNode  the first of two nodes to join
    1.34 +    * @param aRightNode the second of two nodes to join
    1.35 +    */
    1.36 +  NS_IMETHOD Init(nsEditor   *aEditor,
    1.37 +                  nsIDOMNode *aLeftNode,
    1.38 +                  nsIDOMNode *aRightNode);
    1.39 +
    1.40 +  JoinElementTxn();
    1.41 +
    1.42 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinElementTxn, EditTxn)
    1.43 +  NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
    1.44 +
    1.45 +  NS_DECL_EDITTXN
    1.46 +
    1.47 +protected:
    1.48 +  
    1.49 +  /** the elements to operate upon.  
    1.50 +    * After the merge, mRightNode remains and mLeftNode is removed from the content tree.
    1.51 +    */
    1.52 +  nsCOMPtr<nsIDOMNode> mLeftNode;
    1.53 +  nsCOMPtr<nsIDOMNode> mRightNode;
    1.54 +
    1.55 +  /** the offset into mNode where the children of mElement are split (for undo).<BR>
    1.56 +    * mOffset is the index of the first child in the right node. 
    1.57 +    * -1 means the left node had no children.
    1.58 +    */
    1.59 +  uint32_t  mOffset;
    1.60 +
    1.61 +  /** the parent node containing mLeftNode and mRightNode */
    1.62 +  nsCOMPtr<nsIDOMNode> mParent;
    1.63 +  nsEditor*  mEditor;
    1.64 +};
    1.65 +
    1.66 +#endif

mercurial