2016-07-07 11:20:22 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef StylesheetTransactions_h
|
|
|
|
#define StylesheetTransactions_h
|
|
|
|
|
2017-01-27 07:15:20 +03:00
|
|
|
#include "mozilla/EditorBase.h" // mEditor
|
2016-07-08 08:15:21 +03:00
|
|
|
#include "mozilla/EditTransactionBase.h" // for EditTransactionBase, etc.
|
2016-09-26 15:03:25 +03:00
|
|
|
#include "mozilla/StyleSheet.h" // for mozilla::StyleSheet
|
2016-07-07 11:20:22 +03:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsID.h" // for REFNSIID
|
|
|
|
#include "nscore.h" // for NS_IMETHOD
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
class AddStyleSheetTransaction final : public EditTransactionBase
|
2016-07-07 11:20:22 +03:00
|
|
|
{
|
2017-12-18 11:29:32 +03:00
|
|
|
protected:
|
|
|
|
AddStyleSheetTransaction(EditorBase& aEditor, StyleSheet& aStyleSheet);
|
|
|
|
|
2016-07-07 11:20:22 +03:00
|
|
|
public:
|
|
|
|
/**
|
2017-12-18 11:29:32 +03:00
|
|
|
* Creates an add style sheet transaction. This never returns nullptr.
|
|
|
|
*
|
|
|
|
* @param aEditorBase The editor.
|
|
|
|
* @param aSheet The style sheet to add.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<AddStyleSheetTransaction>
|
|
|
|
Create(EditorBase& aEditorBase, StyleSheet& aStyleSheet)
|
|
|
|
{
|
|
|
|
RefPtr<AddStyleSheetTransaction> transaction =
|
|
|
|
new AddStyleSheetTransaction(aEditorBase, aStyleSheet);
|
|
|
|
return transaction.forget();
|
|
|
|
}
|
2016-07-07 11:20:22 +03:00
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AddStyleSheetTransaction,
|
|
|
|
EditTransactionBase)
|
2016-07-07 11:20:22 +03:00
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_EDITTRANSACTIONBASE
|
2016-07-07 11:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// The editor that created this transaction.
|
2017-03-21 13:00:36 +03:00
|
|
|
RefPtr<EditorBase> mEditorBase;
|
2016-07-07 11:20:22 +03:00
|
|
|
// The style sheet to add.
|
2016-09-26 15:03:25 +03:00
|
|
|
RefPtr<mozilla::StyleSheet> mSheet;
|
2016-07-07 11:20:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
class RemoveStyleSheetTransaction final : public EditTransactionBase
|
2016-07-07 11:20:22 +03:00
|
|
|
{
|
2017-12-18 11:29:32 +03:00
|
|
|
protected:
|
|
|
|
RemoveStyleSheetTransaction(EditorBase& aEditor, StyleSheet& aStyleSheet);
|
|
|
|
|
2016-07-07 11:20:22 +03:00
|
|
|
public:
|
|
|
|
/**
|
2017-12-18 11:29:32 +03:00
|
|
|
* Creates a remove style sheet transaction. This never returns nullptr.
|
|
|
|
*
|
2016-07-07 11:20:22 +03:00
|
|
|
* @param aEditor The object providing core editing operations.
|
|
|
|
* @param aSheet The stylesheet to remove.
|
|
|
|
*/
|
2017-12-18 11:29:32 +03:00
|
|
|
static already_AddRefed<RemoveStyleSheetTransaction>
|
|
|
|
Create(EditorBase& aEditorBase, StyleSheet& aStyleSheet)
|
|
|
|
{
|
|
|
|
RefPtr<RemoveStyleSheetTransaction> transaction =
|
|
|
|
new RemoveStyleSheetTransaction(aEditorBase, aStyleSheet);
|
|
|
|
return transaction.forget();
|
|
|
|
}
|
2016-07-07 11:20:22 +03:00
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RemoveStyleSheetTransaction,
|
|
|
|
EditTransactionBase)
|
2016-07-07 11:20:22 +03:00
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_EDITTRANSACTIONBASE
|
2016-07-07 11:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// The editor that created this transaction.
|
2017-03-21 13:00:36 +03:00
|
|
|
RefPtr<EditorBase> mEditorBase;
|
2016-07-07 11:20:22 +03:00
|
|
|
// The style sheet to remove.
|
2016-09-26 15:03:25 +03:00
|
|
|
RefPtr<StyleSheet> mSheet;
|
2016-07-07 11:20:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // #ifndef StylesheetTransactions_h
|