editor/libeditor/base/CreateElementTxn.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/base/CreateElementTxn.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     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 CreateElementTxn_h__
    1.10 +#define CreateElementTxn_h__
    1.11 +
    1.12 +#include "EditTxn.h"
    1.13 +#include "nsCOMPtr.h"
    1.14 +#include "nsCycleCollectionParticipant.h"
    1.15 +#include "nsIDOMNode.h"
    1.16 +#include "nsISupportsImpl.h"
    1.17 +#include "nsString.h"
    1.18 +#include "nscore.h"
    1.19 +
    1.20 +class nsEditor;
    1.21 +
    1.22 +/**
    1.23 + * A transaction that creates a new node in the content tree.
    1.24 + */
    1.25 +class CreateElementTxn : public EditTxn
    1.26 +{
    1.27 +public:
    1.28 +  enum { eAppend=-1 };
    1.29 +
    1.30 +  /** Initialize the transaction.
    1.31 +    * @param aEditor the provider of basic editing functionality
    1.32 +    * @param aTag    the tag (P, HR, TABLE, etc.) for the new element
    1.33 +    * @param aParent the node into which the new element will be inserted
    1.34 +    * @param aOffsetInParent the location in aParent to insert the new element
    1.35 +    *                        if eAppend, the new element is appended as the last child
    1.36 +    */
    1.37 +  NS_IMETHOD Init(nsEditor *aEditor,
    1.38 +                  const nsAString& aTag,
    1.39 +                  nsIDOMNode *aParent,
    1.40 +                  uint32_t aOffsetInParent);
    1.41 +
    1.42 +  CreateElementTxn();
    1.43 +
    1.44 +  NS_DECL_ISUPPORTS_INHERITED
    1.45 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CreateElementTxn, EditTxn)
    1.46 +
    1.47 +  NS_DECL_EDITTXN
    1.48 +
    1.49 +  NS_IMETHOD RedoTransaction();
    1.50 +
    1.51 +  NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
    1.52 +
    1.53 +protected:
    1.54 +  
    1.55 +  /** the document into which the new node will be inserted */
    1.56 +  nsEditor* mEditor;
    1.57 +  
    1.58 +  /** the tag (mapping to object type) for the new element */
    1.59 +  nsString mTag;
    1.60 +
    1.61 +  /** the node into which the new node will be inserted */
    1.62 +  nsCOMPtr<nsIDOMNode> mParent;
    1.63 +
    1.64 +  /** the index in mParent for the new node */
    1.65 +  uint32_t mOffsetInParent;
    1.66 +
    1.67 +  /** the new node to insert */
    1.68 +  nsCOMPtr<nsIDOMNode> mNewNode;  
    1.69 +
    1.70 +  /** the node we will insert mNewNode before.  We compute this ourselves. */
    1.71 +  nsCOMPtr<nsIDOMNode> mRefNode;
    1.72 +};
    1.73 +
    1.74 +#endif

mercurial