editor/libeditor/base/JoinElementTxn.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 JoinElementTxn_h__
     7 #define JoinElementTxn_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 "nsIDOMNode.h"                 // for nsIDOMNode
    14 #include "nscore.h"                     // for NS_IMETHOD
    16 class nsEditor;
    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);
    37   JoinElementTxn();
    39   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinElementTxn, EditTxn)
    40   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
    42   NS_DECL_EDITTXN
    44 protected:
    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;
    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;
    58   /** the parent node containing mLeftNode and mRightNode */
    59   nsCOMPtr<nsIDOMNode> mParent;
    60   nsEditor*  mEditor;
    61 };
    63 #endif

mercurial