Bug 1451672 - part 12: Create HTMLEditor::RemoveStyleSheetWithTransaction() as implementation of nsIEditorStyleSheets::RemoveStyleSheet() r=m_kato

MozReview-Commit-ID: BIXU3jzD1rU

--HG--
extra : rebase_source : ba0eb79cfbfc6c3f8a30dbed457993e436510409
This commit is contained in:
Masayuki Nakano 2018-04-12 17:20:21 +09:00
parent bd0aa50472
commit 4131c9f033
2 changed files with 18 additions and 3 deletions

View File

@ -2915,9 +2915,17 @@ HTMLEditor::ReplaceStyleSheet(const nsAString& aURL)
NS_IMETHODIMP
HTMLEditor::RemoveStyleSheet(const nsAString& aURL)
{
return RemoveStyleSheetWithTransaction(aURL);
}
nsresult
HTMLEditor::RemoveStyleSheetWithTransaction(const nsAString& aURL)
{
RefPtr<StyleSheet> sheet = GetStyleSheetForURL(aURL);
NS_ENSURE_TRUE(sheet, NS_ERROR_UNEXPECTED);
if (NS_WARN_IF(!sheet)) {
return NS_ERROR_UNEXPECTED;
}
RefPtr<RemoveStyleSheetTransaction> transaction =
RemoveStyleSheetTransaction::Create(*this, *sheet);
@ -3419,8 +3427,9 @@ HTMLEditor::StyleSheetLoaded(StyleSheet* aSheet,
{
AutoPlaceholderBatch batchIt(this);
if (!mLastStyleSheetURL.IsEmpty())
RemoveStyleSheet(mLastStyleSheetURL);
if (!mLastStyleSheetURL.IsEmpty()) {
RemoveStyleSheetWithTransaction(mLastStyleSheetURL);
}
RefPtr<AddStyleSheetTransaction> transaction =
AddStyleSheetTransaction::Create(*this, *aSheet);

View File

@ -1193,6 +1193,12 @@ protected:
*/
already_AddRefed<dom::Element> GetSelectedElement(const nsAString& aTagName);
/**
* RemoveStyleSheetWithTransaction() removes the given URL stylesheet
* from mStyleSheets and mStyleSheetURLs.
*/
nsresult RemoveStyleSheetWithTransaction(const nsAString& aURL);
protected:
RefPtr<TypeInState> mTypeInState;
RefPtr<ComposerCommandsUpdater> mComposerCommandsUpdater;