2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
1999-02-24 20:24:37 +03:00
|
|
|
|
2016-07-07 09:56:16 +03:00
|
|
|
#ifndef InsertNodeTransaction_h
|
|
|
|
#define InsertNodeTransaction_h
|
1999-02-24 20:24:37 +03:00
|
|
|
|
2016-07-08 08:15:21 +03:00
|
|
|
#include "mozilla/EditTransactionBase.h" // for EditTransactionBase, etc.
|
2017-11-22 11:29:22 +03:00
|
|
|
#include "mozilla/EditorDOMPoint.h" // for EditorDOMPoint
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsCOMPtr.h" // for nsCOMPtr
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2014-08-20 16:25:17 +04:00
|
|
|
#include "nsIContent.h" // for nsIContent
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2014-08-20 16:25:17 +04:00
|
|
|
namespace mozilla {
|
1999-02-24 20:24:37 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
class EditorBase;
|
|
|
|
|
1999-02-24 20:24:37 +03:00
|
|
|
/**
|
1999-05-07 23:23:17 +04:00
|
|
|
* A transaction that inserts a single element
|
1999-02-24 20:24:37 +03:00
|
|
|
*/
|
2016-07-08 03:48:34 +03:00
|
|
|
class InsertNodeTransaction final : public EditTransactionBase
|
1999-02-24 20:24:37 +03:00
|
|
|
{
|
2017-12-15 11:34:52 +03:00
|
|
|
protected:
|
|
|
|
InsertNodeTransaction(EditorBase& aEditorBase,
|
|
|
|
nsIContent& aContentToInsert,
|
|
|
|
const EditorRawDOMPoint& aPointToInsert);
|
|
|
|
|
1999-02-24 20:24:37 +03:00
|
|
|
public:
|
2016-07-07 09:56:16 +03:00
|
|
|
/**
|
2017-12-15 11:34:52 +03:00
|
|
|
* Create a transaction for inserting aContentToInsert before the child
|
|
|
|
* at aPointToInsert.
|
2017-11-22 11:29:22 +03:00
|
|
|
*
|
2017-12-15 11:34:52 +03:00
|
|
|
* @param aEditorBase The editor which manages the transaction.
|
|
|
|
* @param aContentToInsert The node to be inserted.
|
|
|
|
* @param aPointToInsert The insertion point of aContentToInsert.
|
|
|
|
* If this refers end of the container, the
|
|
|
|
* transaction will append the node to the
|
|
|
|
* container. Otherwise, will insert the node
|
|
|
|
* before child node referred by this.
|
|
|
|
* @return A InsertNodeTranaction which was initialized
|
|
|
|
* with the arguments.
|
2016-07-07 09:56:16 +03:00
|
|
|
*/
|
2017-12-15 11:34:52 +03:00
|
|
|
static already_AddRefed<InsertNodeTransaction>
|
|
|
|
Create(EditorBase& aEditorBase,
|
|
|
|
nsIContent& aContentToInsert,
|
|
|
|
const EditorRawDOMPoint& aPointToInsert);
|
|
|
|
|
1999-02-24 20:24:37 +03:00
|
|
|
|
2011-02-20 01:18:37 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertNodeTransaction,
|
|
|
|
EditTransactionBase)
|
2009-05-09 08:59:25 +04:00
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_EDITTRANSACTIONBASE
|
1999-09-22 02:31:27 +04:00
|
|
|
|
1999-02-24 20:24:37 +03:00
|
|
|
protected:
|
2016-07-07 09:56:16 +03:00
|
|
|
virtual ~InsertNodeTransaction();
|
2014-07-09 01:23:18 +04:00
|
|
|
|
2016-07-07 09:56:16 +03:00
|
|
|
// The element to insert.
|
2017-11-22 11:29:22 +03:00
|
|
|
nsCOMPtr<nsIContent> mContentToInsert;
|
1999-02-24 20:24:37 +03:00
|
|
|
|
2017-11-22 11:29:22 +03:00
|
|
|
// The DOM point we will insert mContentToInsert.
|
|
|
|
EditorDOMPoint mPointToInsert;
|
2014-08-20 16:25:17 +04:00
|
|
|
|
2016-07-07 09:56:16 +03:00
|
|
|
// The editor for this transaction.
|
2017-03-21 13:00:36 +03:00
|
|
|
RefPtr<EditorBase> mEditorBase;
|
1999-02-24 20:24:37 +03:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2014-08-20 16:25:17 +04:00
|
|
|
|
2016-07-07 09:56:16 +03:00
|
|
|
#endif // #ifndef InsertNodeTransaction_h
|