Bug 1334372 - Part 2. Don't use virtual method for CreateTxnForAddStyleSheet and CreateTxnForRemoveStyleSheet. r=masayuki

We don't have no overload method for both methods.  So we shouldn't use virtual.

And, other transaction methods return transaction object directly, we should change to it.

MozReview-Commit-ID: 7CXz4XeOobk

--HG--
extra : rebase_source : e208484decec42496e88bbee5ed7d19b1f6daf91
extra : amend_source : 1ebe4378f6c8133b874e573c10c368ae96a51d45
This commit is contained in:
Makoto Kato 2017-01-27 13:29:00 +09:00
parent f1e9546f92
commit 461fd31b94
3 changed files with 32 additions and 47 deletions

View File

@ -4265,29 +4265,22 @@ EditorBase::CreateTxnForComposition(const nsAString& aStringToInsert)
return transaction.forget();
}
NS_IMETHODIMP
EditorBase::CreateTxnForAddStyleSheet(StyleSheet* aSheet,
AddStyleSheetTransaction** aTransaction)
already_AddRefed<AddStyleSheetTransaction>
EditorBase::CreateTxnForAddStyleSheet(StyleSheet* aSheet)
{
RefPtr<AddStyleSheetTransaction> transaction =
new AddStyleSheetTransaction(*this, aSheet);
transaction.forget(aTransaction);
return NS_OK;
return transaction.forget();
}
NS_IMETHODIMP
EditorBase::CreateTxnForRemoveStyleSheet(
StyleSheet* aSheet,
RemoveStyleSheetTransaction** aTransaction)
already_AddRefed<RemoveStyleSheetTransaction>
EditorBase::CreateTxnForRemoveStyleSheet(StyleSheet* aSheet)
{
RefPtr<RemoveStyleSheetTransaction> transaction =
new RemoveStyleSheetTransaction(*this, aSheet);
transaction.forget(aTransaction);
return NS_OK;
return transaction.forget();
}
nsresult

View File

@ -340,16 +340,14 @@ protected:
/**
* Create a transaction for adding a style sheet.
*/
NS_IMETHOD CreateTxnForAddStyleSheet(
StyleSheet* aSheet,
AddStyleSheetTransaction** aTransaction);
already_AddRefed<mozilla::AddStyleSheetTransaction>
CreateTxnForAddStyleSheet(StyleSheet* aSheet);
/**
* Create a transaction for removing a style sheet.
*/
NS_IMETHOD CreateTxnForRemoveStyleSheet(
StyleSheet* aSheet,
RemoveStyleSheetTransaction** aTransaction);
already_AddRefed<mozilla::RemoveStyleSheetTransaction>
CreateTxnForRemoveStyleSheet(StyleSheet* aSheet);
nsresult DeleteText(nsGenericDOMDataNode& aElement,
uint32_t aOffset, uint32_t aLength);

View File

@ -2873,22 +2873,18 @@ HTMLEditor::RemoveStyleSheet(const nsAString& aURL)
RefPtr<StyleSheet> sheet = GetStyleSheetForURL(aURL);
NS_ENSURE_TRUE(sheet, NS_ERROR_UNEXPECTED);
RefPtr<RemoveStyleSheetTransaction> transaction;
nsresult rv =
CreateTxnForRemoveStyleSheet(sheet, getter_AddRefs(transaction));
RefPtr<RemoveStyleSheetTransaction> transaction =
CreateTxnForRemoveStyleSheet(sheet);
if (!transaction) {
rv = NS_ERROR_NULL_POINTER;
}
if (NS_SUCCEEDED(rv)) {
rv = DoTransaction(transaction);
if (NS_SUCCEEDED(rv)) {
mLastStyleSheetURL.Truncate(); // forget it
}
// Remove it from our internal list
rv = RemoveStyleSheetFromList(aURL);
return NS_ERROR_NULL_POINTER;
}
return rv;
nsresult rv = DoTransaction(transaction);
if (NS_SUCCEEDED(rv)) {
mLastStyleSheetURL.Truncate(); // forget it
}
// Remove it from our internal list
return RemoveStyleSheetFromList(aURL);
}
@ -3475,31 +3471,29 @@ HTMLEditor::StyleSheetLoaded(StyleSheet* aSheet,
bool aWasAlternate,
nsresult aStatus)
{
nsresult rv = NS_OK;
AutoEditBatch batchIt(this);
if (!mLastStyleSheetURL.IsEmpty())
RemoveStyleSheet(mLastStyleSheetURL);
RefPtr<AddStyleSheetTransaction> transaction;
rv = CreateTxnForAddStyleSheet(aSheet, getter_AddRefs(transaction));
RefPtr<AddStyleSheetTransaction> transaction =
CreateTxnForAddStyleSheet(aSheet);
if (!transaction) {
rv = NS_ERROR_NULL_POINTER;
return NS_OK;
}
nsresult rv = DoTransaction(transaction);
if (NS_SUCCEEDED(rv)) {
rv = DoTransaction(transaction);
// Get the URI, then url spec from the sheet
nsAutoCString spec;
rv = aSheet->GetSheetURI()->GetSpec(spec);
if (NS_SUCCEEDED(rv)) {
// Get the URI, then url spec from the sheet
nsAutoCString spec;
rv = aSheet->GetSheetURI()->GetSpec(spec);
// Save it so we can remove before applying the next one
mLastStyleSheetURL.AssignWithConversion(spec.get());
if (NS_SUCCEEDED(rv)) {
// Save it so we can remove before applying the next one
mLastStyleSheetURL.AssignWithConversion(spec.get());
// Also save in our arrays of urls and sheets
AddNewStyleSheetToList(mLastStyleSheetURL, aSheet);
}
// Also save in our arrays of urls and sheets
AddNewStyleSheetToList(mLastStyleSheetURL, aSheet);
}
}