Bug 1718815 - part 3: Move `EditorBase::AutoTransactionBatch` to `HTMLEditor` r=m_kato

I guess that this class is replaced with `AutoPlaceholderBatch`, and both of
them are followed by its instances.  However, I don't want to change the
behavior in this bug.  Therefore, this patch just moves it into `HTMLEditor`.

Depends on D119002

Differential Revision: https://phabricator.services.mozilla.com/D119003
This commit is contained in:
Masayuki Nakano 2021-07-02 08:23:45 +00:00
Родитель a68528b057
Коммит 46d18deed5
2 изменённых файлов: 27 добавлений и 26 удалений

Просмотреть файл

@ -60,7 +60,6 @@ namespace mozilla {
class AlignStateAtSelection;
class AutoRangeArray;
class AutoTopLevelEditSubActionNotifier;
class AutoTransactionBatch;
class AutoTransactionsConserveSelection;
class AutoUpdateViewBatch;
class ChangeAttributeTransaction;
@ -2147,9 +2146,10 @@ class EditorBase : public nsIEditor,
MOZ_CAN_RUN_SCRIPT void EndUpdateViewBatch();
/**
* Used by AutoTransactionBatch. After calling BeginTransactionInternal(),
* all transactions will be treated as an atomic transaction. I.e.,
* two or more transactions are undid once.
* Used by HTMLEditor::AutoTransactionBatch, nsIEditor::BeginTransaction
* and nsIEditor::EndTransation. After calling BeginTransactionInternal(),
* all transactions will be treated as an atomic transaction. I.e., two or
* more transactions are undid once.
* XXX What's the difference with PlaceholderTransaction? Should we always
* use it instead?
*/
@ -2606,28 +2606,6 @@ class EditorBase : public nsIEditor,
nsresult SetTextDirectionTo(TextDirection aTextDirection);
protected: // helper classes which may be used by friends
/**
* Stack based helper class for calling EditorBase::EndTransactionInternal().
* NOTE: This does not suppress multiple input events. In most cases,
* only one "input" event should be fired for an edit action rather
* than per edit sub-action. In such case, you should use
* AutoPlaceholderBatch instead.
*/
class MOZ_RAII AutoTransactionBatch final {
public:
MOZ_CAN_RUN_SCRIPT explicit AutoTransactionBatch(EditorBase& aEditorBase)
: mEditorBase(aEditorBase) {
MOZ_KnownLive(mEditorBase).BeginTransactionInternal();
}
MOZ_CAN_RUN_SCRIPT ~AutoTransactionBatch() {
MOZ_KnownLive(mEditorBase).EndTransactionInternal();
}
protected:
EditorBase& mEditorBase;
};
/**
* Stack based helper class for batching a collection of transactions inside
* a placeholder transaction. Different from AutoTransactionBatch, this

Просмотреть файл

@ -4407,6 +4407,29 @@ class HTMLEditor final : public EditorBase,
MOZ_KNOWN_LIVE HTMLEditor* mHTMLEditor = nullptr;
};
/**
* Stack based helper class for calling EditorBase::EndTransactionInternal().
* NOTE: This does not suppress multiple input events. In most cases,
* only one "input" event should be fired for an edit action rather
* than per edit sub-action. In such case, you should use
* EditorBase::AutoPlaceholderBatch instead.
*/
class MOZ_RAII AutoTransactionBatch final {
public:
MOZ_CAN_RUN_SCRIPT explicit AutoTransactionBatch(HTMLEditor& aHTMLEditor)
: mHTMLEditor(aHTMLEditor) {
MOZ_KnownLive(mHTMLEditor).BeginTransactionInternal();
}
MOZ_CAN_RUN_SCRIPT ~AutoTransactionBatch() {
MOZ_KnownLive(mHTMLEditor).EndTransactionInternal();
}
protected:
// The lifetime must be guaranteed by the creator of this instance.
MOZ_KNOWN_LIVE HTMLEditor& mHTMLEditor;
};
RefPtr<TypeInState> mTypeInState;
RefPtr<ComposerCommandsUpdater> mComposerCommandsUpdater;