editor/libeditor/base/InsertElementTxn.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/base/InsertElementTxn.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     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 InsertElementTxn_h__
    1.10 +#define InsertElementTxn_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 "nsIDOMNode.h"                 // for nsIDOMNode
    1.16 +#include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED
    1.17 +#include "nscore.h"                     // for NS_IMETHOD
    1.18 +
    1.19 +class nsIEditor;
    1.20 +
    1.21 +/**
    1.22 + * A transaction that inserts a single element
    1.23 + */
    1.24 +class InsertElementTxn : public EditTxn
    1.25 +{
    1.26 +public:
    1.27 +  /** initialize the transaction.
    1.28 +    * @param aNode   the node to insert
    1.29 +    * @param aParent the node to insert into
    1.30 +    * @param aOffset the offset in aParent to insert aNode
    1.31 +    */
    1.32 +  NS_IMETHOD Init(nsIDOMNode *aNode,
    1.33 +                  nsIDOMNode *aParent,
    1.34 +                  int32_t     aOffset,
    1.35 +                  nsIEditor  *aEditor);
    1.36 +
    1.37 +  InsertElementTxn();
    1.38 +
    1.39 +  NS_DECL_ISUPPORTS_INHERITED
    1.40 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertElementTxn, EditTxn)
    1.41 +
    1.42 +  NS_DECL_EDITTXN
    1.43 +
    1.44 +protected:
    1.45 +  
    1.46 +  /** the element to insert */
    1.47 +  nsCOMPtr<nsIDOMNode> mNode;
    1.48 +
    1.49 +  /** the node into which the new node will be inserted */
    1.50 +  nsCOMPtr<nsIDOMNode> mParent;
    1.51 +
    1.52 +  /** the editor for this transaction */
    1.53 +  nsIEditor*           mEditor;
    1.54 +
    1.55 +  /** the index in mParent for the new node */
    1.56 +  int32_t mOffset;
    1.57 +};
    1.58 +
    1.59 +#endif

mercurial