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-01-06 23:30:13 +03:00
|
|
|
|
2016-07-08 08:03:31 +03:00
|
|
|
#ifndef mozilla_EditTransactionBase_h
|
|
|
|
#define mozilla_EditTransactionBase_h
|
1999-01-06 23:30:13 +03:00
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
1999-01-06 23:30:13 +03:00
|
|
|
#include "nsITransaction.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nscore.h"
|
1999-01-09 03:24:48 +03:00
|
|
|
|
2020-04-23 10:02:16 +03:00
|
|
|
already_AddRefed<mozilla::EditTransactionBase>
|
|
|
|
nsITransaction::GetAsEditTransactionBase() {
|
|
|
|
RefPtr<mozilla::EditTransactionBase> editTransactionBase;
|
|
|
|
return NS_SUCCEEDED(
|
|
|
|
GetAsEditTransactionBase(getter_AddRefs(editTransactionBase)))
|
|
|
|
? editTransactionBase.forget()
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
2020-04-23 08:46:43 +03:00
|
|
|
class ChangeAttributeTransaction;
|
|
|
|
class ChangeStyleTransaction;
|
|
|
|
class CompositionTransaction;
|
|
|
|
class CreateElementTransaction;
|
|
|
|
class DeleteNodeTransaction;
|
|
|
|
class DeleteRangeTransaction;
|
|
|
|
class DeleteTextTransaction;
|
|
|
|
class EditAggregateTransaction;
|
|
|
|
class InsertNodeTransaction;
|
|
|
|
class InsertTextTransaction;
|
|
|
|
class JoinNodeTransaction;
|
|
|
|
class PlaceholderTransaction;
|
2020-05-21 05:30:09 +03:00
|
|
|
class ReplaceTextTransaction;
|
2020-04-23 08:46:43 +03:00
|
|
|
class SplitNodeTransaction;
|
|
|
|
|
|
|
|
#define NS_DECL_GETASTRANSACTION_BASE(aClass) \
|
|
|
|
virtual aClass* GetAs##aClass(); \
|
|
|
|
virtual const aClass* GetAs##aClass() const;
|
|
|
|
|
1999-01-06 23:30:13 +03:00
|
|
|
/**
|
2007-01-11 17:38:02 +03:00
|
|
|
* Base class for all document editing transactions.
|
1999-01-06 23:30:13 +03:00
|
|
|
*/
|
2016-07-08 03:48:34 +03:00
|
|
|
class EditTransactionBase : public nsITransaction {
|
1999-01-06 23:30:13 +03:00
|
|
|
public:
|
2009-05-09 08:59:25 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(EditTransactionBase, nsITransaction)
|
1999-01-06 23:30:13 +03:00
|
|
|
|
2020-04-03 11:32:01 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT NS_IMETHOD RedoTransaction(void) override;
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_IMETHOD GetIsTransient(bool* aIsTransient) override;
|
|
|
|
NS_IMETHOD Merge(nsITransaction* aTransaction, bool* aDidMerge) override;
|
2020-04-23 10:02:16 +03:00
|
|
|
NS_IMETHOD GetAsEditTransactionBase(
|
|
|
|
EditTransactionBase** aEditTransactionBase) final {
|
|
|
|
MOZ_ASSERT(aEditTransactionBase);
|
|
|
|
MOZ_ASSERT(!*aEditTransactionBase);
|
|
|
|
*aEditTransactionBase = do_AddRef(this).take();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-06-24 02:40:02 +04:00
|
|
|
|
2020-04-23 08:46:43 +03:00
|
|
|
NS_DECL_GETASTRANSACTION_BASE(ChangeAttributeTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(ChangeStyleTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(CompositionTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(CreateElementTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(DeleteNodeTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(DeleteRangeTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(DeleteTextTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(EditAggregateTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(InsertNodeTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(InsertTextTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(JoinNodeTransaction)
|
|
|
|
NS_DECL_GETASTRANSACTION_BASE(PlaceholderTransaction)
|
2020-05-21 05:30:09 +03:00
|
|
|
NS_DECL_GETASTRANSACTION_BASE(ReplaceTextTransaction)
|
2020-04-23 08:46:43 +03:00
|
|
|
NS_DECL_GETASTRANSACTION_BASE(SplitNodeTransaction)
|
|
|
|
|
2014-06-24 02:40:02 +04:00
|
|
|
protected:
|
2020-03-06 07:38:25 +03:00
|
|
|
virtual ~EditTransactionBase() = default;
|
2007-01-11 17:38:02 +03:00
|
|
|
};
|
1999-01-06 23:30:13 +03:00
|
|
|
|
2020-04-23 08:46:43 +03:00
|
|
|
#undef NS_DECL_GETASTRANSACTION_BASE
|
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-04-03 11:32:01 +03:00
|
|
|
#define NS_DECL_EDITTRANSACTIONBASE \
|
|
|
|
MOZ_CAN_RUN_SCRIPT NS_IMETHOD DoTransaction() override; \
|
|
|
|
MOZ_CAN_RUN_SCRIPT NS_IMETHOD UndoTransaction() override;
|
1999-01-06 23:30:13 +03:00
|
|
|
|
2020-04-23 08:46:43 +03:00
|
|
|
#define NS_DECL_EDITTRANSACTIONBASE_GETASMETHODS_OVERRIDE(aClass) \
|
|
|
|
aClass* GetAs##aClass() final { return this; } \
|
|
|
|
const aClass* GetAs##aClass() const final { return this; }
|
|
|
|
|
2016-07-08 08:03:31 +03:00
|
|
|
#endif // #ifndef mozilla_EditTransactionBase_h
|