Bug 1776056 - Switch to the tab an animation is running and make sure the animation...
[gecko.git] / editor / libeditor / EditTransactionBase.h
bloba09acb01078c339cbeb3fa70396732fddae77d77
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/. */
6 #ifndef mozilla_EditTransactionBase_h
7 #define mozilla_EditTransactionBase_h
9 #include "mozilla/EditorForwards.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsISupportsImpl.h"
13 #include "nsITransaction.h"
14 #include "nscore.h"
16 already_AddRefed<mozilla::EditTransactionBase>
17 nsITransaction::GetAsEditTransactionBase() {
18 RefPtr<mozilla::EditTransactionBase> editTransactionBase;
19 return NS_SUCCEEDED(
20 GetAsEditTransactionBase(getter_AddRefs(editTransactionBase)))
21 ? editTransactionBase.forget()
22 : nullptr;
25 namespace mozilla {
26 class LogModule;
28 #define NS_DECL_GETASTRANSACTION_BASE(aClass) \
29 virtual aClass* GetAs##aClass(); \
30 virtual const aClass* GetAs##aClass() const;
32 /**
33 * Base class for all document editing transactions.
35 class EditTransactionBase : public nsITransaction {
36 public:
37 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
38 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(EditTransactionBase, nsITransaction)
40 MOZ_CAN_RUN_SCRIPT NS_IMETHOD RedoTransaction(void) override;
41 NS_IMETHOD GetIsTransient(bool* aIsTransient) override;
42 NS_IMETHOD Merge(nsITransaction* aTransaction, bool* aDidMerge) override;
43 NS_IMETHOD GetAsEditTransactionBase(
44 EditTransactionBase** aEditTransactionBase) final {
45 MOZ_ASSERT(aEditTransactionBase);
46 MOZ_ASSERT(!*aEditTransactionBase);
47 *aEditTransactionBase = do_AddRef(this).take();
48 return NS_OK;
51 NS_DECL_GETASTRANSACTION_BASE(ChangeAttributeTransaction)
52 NS_DECL_GETASTRANSACTION_BASE(ChangeStyleTransaction)
53 NS_DECL_GETASTRANSACTION_BASE(CompositionTransaction)
54 NS_DECL_GETASTRANSACTION_BASE(DeleteNodeTransaction)
55 NS_DECL_GETASTRANSACTION_BASE(DeleteRangeTransaction)
56 NS_DECL_GETASTRANSACTION_BASE(DeleteTextTransaction)
57 NS_DECL_GETASTRANSACTION_BASE(EditAggregateTransaction)
58 NS_DECL_GETASTRANSACTION_BASE(InsertNodeTransaction)
59 NS_DECL_GETASTRANSACTION_BASE(InsertTextTransaction)
60 NS_DECL_GETASTRANSACTION_BASE(JoinNodesTransaction)
61 NS_DECL_GETASTRANSACTION_BASE(MoveNodeTransaction)
62 NS_DECL_GETASTRANSACTION_BASE(PlaceholderTransaction)
63 NS_DECL_GETASTRANSACTION_BASE(ReplaceTextTransaction)
64 NS_DECL_GETASTRANSACTION_BASE(SplitNodeTransaction)
66 protected:
67 virtual ~EditTransactionBase() = default;
69 static LogModule* GetLogModule();
72 #undef NS_DECL_GETASTRANSACTION_BASE
74 } // namespace mozilla
76 #define NS_DECL_EDITTRANSACTIONBASE \
77 MOZ_CAN_RUN_SCRIPT NS_IMETHOD DoTransaction() override; \
78 MOZ_CAN_RUN_SCRIPT NS_IMETHOD UndoTransaction() override;
80 #define NS_DECL_EDITTRANSACTIONBASE_GETASMETHODS_OVERRIDE(aClass) \
81 aClass* GetAs##aClass() final { return this; } \
82 const aClass* GetAs##aClass() const final { return this; }
84 #endif // #ifndef mozilla_EditTransactionBase_h