editor/libeditor/InsertNodeTxn.h
author Markus Stange <mstange@themasta.com>
Mon, 15 Jun 2015 19:20:59 -0400
changeset 249905 3f025568ad349d7b4a4da45feef6812c4e4d4101
parent 200619 e59ab9d1ae98309b1a303da5c3425d9d2db876d2
child 252629 91d6e262b662a0b4e47358665e222d3927337af9
permissions -rw-r--r--
Bug 1165185 - Try to avoid invalidations when scrolling transformed elements. r=roc

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */

#ifndef InsertNodeTxn_h__
#define InsertNodeTxn_h__

#include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
#include "nsCOMPtr.h"                   // for nsCOMPtr
#include "nsCycleCollectionParticipant.h"
#include "nsIContent.h"                 // for nsIContent
#include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED

class nsEditor;

namespace mozilla {
namespace dom {

/**
 * A transaction that inserts a single element
 */
class InsertNodeTxn : public EditTxn
{
public:
  /** initialize the transaction.
    * @param aNode   the node to insert
    * @param aParent the node to insert into
    * @param aOffset the offset in aParent to insert aNode
    */
  InsertNodeTxn(nsIContent& aNode, nsINode& aParent, int32_t aOffset,
                nsEditor& aEditor);

  NS_DECL_ISUPPORTS_INHERITED
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertNodeTxn, EditTxn)

  NS_DECL_EDITTXN

protected:
  virtual ~InsertNodeTxn();

  /** the element to insert */
  nsCOMPtr<nsIContent> mNode;

  /** the node into which the new node will be inserted */
  nsCOMPtr<nsINode> mParent;

  /** the index in mParent for the new node */
  int32_t mOffset;

  /** the editor for this transaction */
  nsEditor& mEditor;
};

}
}

#endif