InsertNodeTransaction.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/. */
  5. #ifndef InsertNodeTransaction_h
  6. #define InsertNodeTransaction_h
  7. #include "mozilla/EditTransactionBase.h" // for EditTransactionBase, etc.
  8. #include "nsCOMPtr.h" // for nsCOMPtr
  9. #include "nsCycleCollectionParticipant.h"
  10. #include "nsIContent.h" // for nsIContent
  11. #include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
  12. namespace mozilla {
  13. class EditorBase;
  14. /**
  15. * A transaction that inserts a single element
  16. */
  17. class InsertNodeTransaction final : public EditTransactionBase
  18. {
  19. public:
  20. /**
  21. * Initialize the transaction.
  22. * @param aNode The node to insert.
  23. * @param aParent The node to insert into.
  24. * @param aOffset The offset in aParent to insert aNode.
  25. */
  26. InsertNodeTransaction(nsIContent& aNode, nsINode& aParent, int32_t aOffset,
  27. EditorBase& aEditorBase);
  28. NS_DECL_ISUPPORTS_INHERITED
  29. NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertNodeTransaction,
  30. EditTransactionBase)
  31. NS_DECL_EDITTRANSACTIONBASE
  32. protected:
  33. virtual ~InsertNodeTransaction();
  34. // The element to insert.
  35. nsCOMPtr<nsIContent> mNode;
  36. // The node into which the new node will be inserted.
  37. nsCOMPtr<nsINode> mParent;
  38. // The index in mParent for the new node.
  39. int32_t mOffset;
  40. // The editor for this transaction.
  41. RefPtr<EditorBase> mEditorBase;
  42. };
  43. } // namespace mozilla
  44. #endif // #ifndef InsertNodeTransaction_h