Bug 1452235 part 5. Stop inheriting nsISupports for nsDOMSerializer. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 09 Apr 2018 16:30:33 -0400
changeset 779617 7c4d25c790931ba6e977d167371b98d9dfbe5c01
parent 779616 224c47afe070ac65aa4f66957b1d986b137f76ea
child 779618 e38e1bbb7b7c0058dca3845216dc0fe34c9bb9b6
push id105824
push usernnethercote@mozilla.com
push dateTue, 10 Apr 2018 09:55:33 +0000
reviewersqdot
bugs1452235
milestone61.0a1
Bug 1452235 part 5. Stop inheriting nsISupports for nsDOMSerializer. r=qdot MozReview-Commit-ID: 89iyRqKcAl0
dom/base/nsDOMSerializer.cpp
dom/base/nsDOMSerializer.h
dom/bindings/Bindings.conf
dom/fetch/BodyExtractor.cpp
--- a/dom/base/nsDOMSerializer.cpp
+++ b/dom/base/nsDOMSerializer.cpp
@@ -17,32 +17,16 @@
 #include "nsINode.h"
 
 using namespace mozilla;
 
 nsDOMSerializer::nsDOMSerializer()
 {
 }
 
-nsDOMSerializer::~nsDOMSerializer()
-{
-}
-
-// QueryInterface implementation for nsDOMSerializer
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMSerializer)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMSerializer, mOwner)
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMSerializer)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMSerializer)
-
-
 static already_AddRefed<nsIDocumentEncoder>
 SetUpEncoder(nsINode& aRoot, const nsAString& aCharset, ErrorResult& aRv)
 {
   nsresult rv;
   nsCOMPtr<nsIDocumentEncoder> encoder =
     do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "application/xhtml+xml", &rv);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
--- a/dom/base/nsDOMSerializer.h
+++ b/dom/base/nsDOMSerializer.h
@@ -2,67 +2,48 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 nsDOMSerializer_h_
 #define nsDOMSerializer_h_
 
-#include "nsISupports.h"
-#include "nsWrapperCache.h"
+#include "mozilla/dom/NonRefcountedDOMObject.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/XMLSerializerBinding.h"
 
 class nsINode;
 class nsIOutputStream;
 
-class nsDOMSerializer final : public nsISupports,
-                              public nsWrapperCache
+class nsDOMSerializer final : public mozilla::dom::NonRefcountedDOMObject
 {
 public:
   nsDOMSerializer();
 
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMSerializer)
-
   // WebIDL API
-  static already_AddRefed<nsDOMSerializer>
+  static nsDOMSerializer*
   Constructor(const mozilla::dom::GlobalObject& aOwner,
               mozilla::ErrorResult& rv)
   {
-    RefPtr<nsDOMSerializer> domSerializer = new nsDOMSerializer(aOwner.GetAsSupports());
-    return domSerializer.forget();
+    return new nsDOMSerializer();
   }
 
   void
   SerializeToString(nsINode& aRoot, nsAString& aStr,
                     mozilla::ErrorResult& rv);
 
   void
   SerializeToStream(nsINode& aRoot, nsIOutputStream* aStream,
                     const nsAString& aCharset,
                     mozilla::ErrorResult& aRv);
 
-  nsISupports* GetParentObject() const
+  bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
+                  JS::MutableHandle<JSObject*> aReflector)
   {
-    return mOwner;
-  }
-
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
-  {
-    return mozilla::dom::XMLSerializerBinding::Wrap(aCx, this, aGivenProto);
+    return mozilla::dom::XMLSerializerBinding::Wrap(aCx, this, aGivenProto,
+                                                    aReflector);
   }
-
-private:
-  virtual ~nsDOMSerializer();
-
-  explicit nsDOMSerializer(nsISupports* aOwner) : mOwner(aOwner)
-  {
-    MOZ_ASSERT(aOwner);
-  }
-
-  nsCOMPtr<nsISupports> mOwner;
 };
 
 
 #endif
 
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1381,16 +1381,17 @@ DOMInterfaces = {
 },
 
 'XMLHttpRequestEventTarget': {
     'concrete': False
 },
 
 'XMLSerializer': {
     'nativeType': 'nsDOMSerializer',
+    'wrapperCache': False
 },
 
 'XPathEvaluator': {
     'wrapperCache': False
 },
 
 'XPathExpression': {
     'wrapperCache': False,
--- a/dom/fetch/BodyExtractor.cpp
+++ b/dom/fetch/BodyExtractor.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "BodyExtractor.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/FormData.h"
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/dom/URLSearchParams.h"
 #include "mozilla/dom/XMLHttpRequest.h"
+#include "mozilla/UniquePtr.h"
 #include "nsContentUtils.h"
 #include "nsDOMSerializer.h"
 #include "nsIGlobalObject.h"
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsIStorageStream.h"
 #include "nsStringStream.h"
 
@@ -100,17 +101,17 @@ BodyExtractor<nsIDocument>::GetAsStream(
     uint32_t written;
     rv = output->Write(utf8Serialized.get(), utf8Serialized.Length(), &written);
     NS_ENSURE_SUCCESS(rv, rv);
 
     MOZ_ASSERT(written == utf8Serialized.Length());
   } else {
     aContentTypeWithCharset.AssignLiteral("application/xml;charset=UTF-8");
 
-    RefPtr<nsDOMSerializer> serializer = new nsDOMSerializer();
+    auto serializer = MakeUnique<nsDOMSerializer>();
 
     // Make sure to use the encoding we'll send
     ErrorResult res;
     serializer->SerializeToStream(*mBody, output, NS_LITERAL_STRING("UTF-8"),
                                   res);
     if (NS_WARN_IF(res.Failed())) {
       return res.StealNSResult();
     }