mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1425412 - part 10: Create factory methods for AddStyleSheetTransaction and RemoveStyleSheetTransaction, and remove EditorBase::CreateTxnForAddStyleSheet() and EditorBase::CreateTxnForRemoveStyleSheet() r=m_kato
This patch creates factory methods for AddStyleSheetTransaction and RemoveStyleSheetTransaction, and removes EditorBase::CreateTxnForAddStyleSheet() and EditorBase::CreateTxnForRemoveStyleSheet() instead. MozReview-Commit-ID: 6dnZctDtNik --HG-- extra : rebase_source : 43eaadbde06e4a0b061ea8136e12ffeccfaf5592
This commit is contained in:
parent
07e48c2f29
commit
bbbb83c937
@ -4583,24 +4583,6 @@ EditorBase::DoAfterRedoTransaction()
|
||||
MOZ_ALWAYS_SUCCEEDS(IncrementModificationCount(1));
|
||||
}
|
||||
|
||||
already_AddRefed<AddStyleSheetTransaction>
|
||||
EditorBase::CreateTxnForAddStyleSheet(StyleSheet* aSheet)
|
||||
{
|
||||
RefPtr<AddStyleSheetTransaction> transaction =
|
||||
new AddStyleSheetTransaction(*this, aSheet);
|
||||
|
||||
return transaction.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<RemoveStyleSheetTransaction>
|
||||
EditorBase::CreateTxnForRemoveStyleSheet(StyleSheet* aSheet)
|
||||
{
|
||||
RefPtr<RemoveStyleSheetTransaction> transaction =
|
||||
new RemoveStyleSheetTransaction(*this, aSheet);
|
||||
|
||||
return transaction.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<EditAggregateTransaction>
|
||||
EditorBase::CreateTxnForDeleteSelection(EDirection aAction,
|
||||
nsINode** aRemovingNode,
|
||||
|
@ -560,18 +560,6 @@ protected:
|
||||
int32_t* aOffset,
|
||||
int32_t* aLength);
|
||||
|
||||
/**
|
||||
* Create a transaction for adding a style sheet.
|
||||
*/
|
||||
already_AddRefed<mozilla::AddStyleSheetTransaction>
|
||||
CreateTxnForAddStyleSheet(StyleSheet* aSheet);
|
||||
|
||||
/**
|
||||
* Create a transaction for removing a style sheet.
|
||||
*/
|
||||
already_AddRefed<mozilla::RemoveStyleSheetTransaction>
|
||||
CreateTxnForRemoveStyleSheet(StyleSheet* aSheet);
|
||||
|
||||
nsresult DeleteText(nsGenericDOMDataNode& aElement,
|
||||
uint32_t aOffset, uint32_t aLength);
|
||||
|
||||
|
@ -2802,11 +2802,7 @@ HTMLEditor::RemoveStyleSheet(const nsAString& aURL)
|
||||
NS_ENSURE_TRUE(sheet, NS_ERROR_UNEXPECTED);
|
||||
|
||||
RefPtr<RemoveStyleSheetTransaction> transaction =
|
||||
CreateTxnForRemoveStyleSheet(sheet);
|
||||
if (!transaction) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
RemoveStyleSheetTransaction::Create(*this, *sheet);
|
||||
nsresult rv = DoTransaction(transaction);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mLastStyleSheetURL.Truncate(); // forget it
|
||||
@ -3382,11 +3378,7 @@ HTMLEditor::StyleSheetLoaded(StyleSheet* aSheet,
|
||||
RemoveStyleSheet(mLastStyleSheetURL);
|
||||
|
||||
RefPtr<AddStyleSheetTransaction> transaction =
|
||||
CreateTxnForAddStyleSheet(aSheet);
|
||||
if (!transaction) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
AddStyleSheetTransaction::Create(*this, *aSheet);
|
||||
nsresult rv = DoTransaction(transaction);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Get the URI, then url spec from the sheet
|
||||
|
@ -45,11 +45,10 @@ RemoveStyleSheet(EditorBase& aEditor, StyleSheet* aSheet)
|
||||
******************************************************************************/
|
||||
|
||||
AddStyleSheetTransaction::AddStyleSheetTransaction(EditorBase& aEditorBase,
|
||||
StyleSheet* aSheet)
|
||||
StyleSheet& aStyleSheet)
|
||||
: mEditorBase(&aEditorBase)
|
||||
, mSheet(aSheet)
|
||||
, mSheet(&aStyleSheet)
|
||||
{
|
||||
MOZ_ASSERT(aSheet);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(AddStyleSheetTransaction,
|
||||
@ -93,11 +92,10 @@ AddStyleSheetTransaction::GetTxnDescription(nsAString& aString)
|
||||
|
||||
RemoveStyleSheetTransaction::RemoveStyleSheetTransaction(
|
||||
EditorBase& aEditorBase,
|
||||
StyleSheet* aSheet)
|
||||
StyleSheet& aStyleSheet)
|
||||
: mEditorBase(&aEditorBase)
|
||||
, mSheet(aSheet)
|
||||
, mSheet(&aStyleSheet)
|
||||
{
|
||||
MOZ_ASSERT(aSheet);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(RemoveStyleSheetTransaction,
|
||||
|
@ -17,12 +17,23 @@ namespace mozilla {
|
||||
|
||||
class AddStyleSheetTransaction final : public EditTransactionBase
|
||||
{
|
||||
protected:
|
||||
AddStyleSheetTransaction(EditorBase& aEditor, StyleSheet& aStyleSheet);
|
||||
|
||||
public:
|
||||
/**
|
||||
* @param aEditor The object providing core editing operations
|
||||
* @param aSheet The stylesheet to add
|
||||
*/
|
||||
AddStyleSheetTransaction(EditorBase& aEditor, StyleSheet* aSheet);
|
||||
* 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();
|
||||
}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AddStyleSheetTransaction,
|
||||
EditTransactionBase)
|
||||
@ -40,12 +51,23 @@ protected:
|
||||
|
||||
class RemoveStyleSheetTransaction final : public EditTransactionBase
|
||||
{
|
||||
protected:
|
||||
RemoveStyleSheetTransaction(EditorBase& aEditor, StyleSheet& aStyleSheet);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a remove style sheet transaction. This never returns nullptr.
|
||||
*
|
||||
* @param aEditor The object providing core editing operations.
|
||||
* @param aSheet The stylesheet to remove.
|
||||
*/
|
||||
RemoveStyleSheetTransaction(EditorBase& aEditor, StyleSheet* aSheet);
|
||||
static already_AddRefed<RemoveStyleSheetTransaction>
|
||||
Create(EditorBase& aEditorBase, StyleSheet& aStyleSheet)
|
||||
{
|
||||
RefPtr<RemoveStyleSheetTransaction> transaction =
|
||||
new RemoveStyleSheetTransaction(aEditorBase, aStyleSheet);
|
||||
return transaction.forget();
|
||||
}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RemoveStyleSheetTransaction,
|
||||
EditTransactionBase)
|
||||
@ -58,7 +80,6 @@ protected:
|
||||
RefPtr<EditorBase> mEditorBase;
|
||||
// The style sheet to remove.
|
||||
RefPtr<StyleSheet> mSheet;
|
||||
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user