From d1d086c279c82202bc9e7603144d861c5fd707db Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Tue, 18 Sep 2018 04:34:21 +0000 Subject: [PATCH] Bug 1491199 - Get rid of nsIEditorBlobListener. r=masayuki Since bug 1489812 is landed, we can get rid of nsIEditorBlobListener. Differential Revision: https://phabricator.services.mozilla.com/D5844 --- editor/libeditor/HTMLEditor.h | 11 ++++++--- editor/libeditor/HTMLEditorDataTransfer.cpp | 27 +++++++++++++++++---- editor/moz.build | 1 - editor/nsIEditorBlobListener.idl | 14 ----------- 4 files changed, 29 insertions(+), 24 deletions(-) delete mode 100644 editor/nsIEditorBlobListener.idl diff --git a/editor/libeditor/HTMLEditor.h b/editor/libeditor/HTMLEditor.h index a7f4531444385..a6478b5aa238a 100644 --- a/editor/libeditor/HTMLEditor.h +++ b/editor/libeditor/HTMLEditor.h @@ -21,7 +21,6 @@ #include "nsICSSLoaderObserver.h" #include "nsIDocumentObserver.h" #include "nsIDOMEventListener.h" -#include "nsIEditorBlobListener.h" #include "nsIEditorMailSupport.h" #include "nsIEditorStyleSheets.h" #include "nsIHTMLAbsPosEditor.h" @@ -1490,7 +1489,7 @@ class HTMLEditor final : public TextEditor MaybeCollapseSelectionAtFirstEditableNode( bool aIgnoreIfSelectionInEditingHost); - class BlobReader final : public nsIEditorBlobListener + class BlobReader final { public: BlobReader(dom::BlobImpl* aBlob, HTMLEditor* aHTMLEditor, @@ -1498,8 +1497,11 @@ class HTMLEditor final : public TextEditor nsINode* aDestinationNode, int32_t aDestOffset, bool aDoDeleteSelection); - NS_DECL_ISUPPORTS - NS_DECL_NSIEDITORBLOBLISTENER + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(BlobReader) + NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(BlobReader) + + nsresult OnResult(const nsACString& aResult); + nsresult OnError(const nsAString& aErrorName); private: ~BlobReader() @@ -2265,6 +2267,7 @@ class HTMLEditor final : public TextEditor friend class EditorBase; friend class EmptyEditableFunctor; friend class HTMLEditRules; + friend class SlurpBlobEventListener; friend class TextEditor; friend class WSRunObject; }; diff --git a/editor/libeditor/HTMLEditorDataTransfer.cpp b/editor/libeditor/HTMLEditorDataTransfer.cpp index 1a9bde04e903b..e1d35d6c9426d 100644 --- a/editor/libeditor/HTMLEditorDataTransfer.cpp +++ b/editor/libeditor/HTMLEditorDataTransfer.cpp @@ -956,7 +956,24 @@ ImgFromData(const nsACString& aType, const nsACString& aData, nsString& aOutput) return NS_OK; } -NS_IMPL_ISUPPORTS(HTMLEditor::BlobReader, nsIEditorBlobListener) +NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLEditor::BlobReader) + +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(HTMLEditor::BlobReader) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mBlob) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mHTMLEditor) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceDoc) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mDestinationNode) +NS_IMPL_CYCLE_COLLECTION_UNLINK_END + +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(HTMLEditor::BlobReader) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBlob) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mHTMLEditor) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceDoc) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDestinationNode) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END + +NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(HTMLEditor::BlobReader, AddRef) +NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(HTMLEditor::BlobReader, Release) HTMLEditor::BlobReader::BlobReader(BlobImpl* aBlob, HTMLEditor* aHTMLEditor, @@ -978,7 +995,7 @@ HTMLEditor::BlobReader::BlobReader(BlobImpl* aBlob, MOZ_ASSERT(mDestinationNode); } -NS_IMETHODIMP +nsresult HTMLEditor::BlobReader::OnResult(const nsACString& aResult) { nsString blobType; @@ -1000,7 +1017,7 @@ HTMLEditor::BlobReader::OnResult(const nsACString& aResult) return rv; } -NS_IMETHODIMP +nsresult HTMLEditor::BlobReader::OnError(const nsAString& aError) { const nsPromiseFlatString& flat = PromiseFlatString(aError); @@ -1020,7 +1037,7 @@ class SlurpBlobEventListener final : public nsIDOMEventListener NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_CLASS(SlurpBlobEventListener) - explicit SlurpBlobEventListener(nsIEditorBlobListener* aListener) + explicit SlurpBlobEventListener(HTMLEditor::BlobReader* aListener) : mListener(aListener) { } @@ -1029,7 +1046,7 @@ class SlurpBlobEventListener final : public nsIDOMEventListener private: ~SlurpBlobEventListener() = default; - RefPtr mListener; + RefPtr mListener; }; NS_IMPL_CYCLE_COLLECTION(SlurpBlobEventListener, mListener) diff --git a/editor/moz.build b/editor/moz.build index 4386232db2280..9744cf64a1f53 100644 --- a/editor/moz.build +++ b/editor/moz.build @@ -15,7 +15,6 @@ XPIDL_SOURCES += [ 'nsIDocumentStateListener.idl', 'nsIEditActionListener.idl', 'nsIEditor.idl', - 'nsIEditorBlobListener.idl', 'nsIEditorMailSupport.idl', 'nsIEditorObserver.idl', 'nsIEditorSpellCheck.idl', diff --git a/editor/nsIEditorBlobListener.idl b/editor/nsIEditorBlobListener.idl deleted file mode 100644 index af731e85909de..0000000000000 --- a/editor/nsIEditorBlobListener.idl +++ /dev/null @@ -1,14 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; 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/. */ - -#include "nsISupports.idl" - -[builtinclass, uuid(eb8b8ad9-5d8f-43bd-8ce5-5b943c180d56)] -interface nsIEditorBlobListener : nsISupports -{ - void onResult(in ACString aResult); - void onError(in AString aErrorName); -};