Bug 1653011 - Simplify and make WeakPtr<Derived> usable and compact. r=froydnj,sg,geckoview-reviewers,jgilbert,kvark,snorp
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 23 Jul 2020 14:51:46 +0000
changeset 541764 be4b0f6e68c9d46ecb15aac5ad87a3a7b8731e57
parent 541763 6a3cc8878240b50d1b50d5979ad86e2078de1b4e
child 541765 918d9ebcdf466e0650b198e62835a275a0968900
push id37632
push usermalexandru@mozilla.com
push dateThu, 23 Jul 2020 21:28:42 +0000
treeherdermozilla-central@08c29f9d8779 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, sg, geckoview-reviewers, jgilbert, kvark, snorp
bugs1653011
milestone80.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1653011 - Simplify and make WeakPtr<Derived> usable and compact. r=froydnj,sg,geckoview-reviewers,jgilbert,kvark,snorp Having two classes in the inheritance chain inherit from SupportsWeakPtr now won't compile, but you can use WeakPtr<Derived> when any base class inherits from SupportsWeakPtr. Differential Revision: https://phabricator.services.mozilla.com/D83674
docshell/base/BrowsingContext.h
docshell/base/nsDocShell.h
dom/base/Document.h
dom/base/PlacesWeakCallbackWrapper.h
dom/base/Selection.h
dom/base/nsRange.cpp
dom/base/nsRange.h
dom/canvas/ClientWebGLContext.h
dom/canvas/HostWebGLContext.h
dom/canvas/IpdlQueue.h
dom/canvas/ProducerConsumerQueue.h
dom/canvas/WebGLChild.h
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextLossHandler.h
dom/canvas/WebGLFramebuffer.h
dom/canvas/WebGLParent.h
dom/canvas/WebGLProgram.h
dom/geolocation/Geolocation.cpp
dom/html/HTMLCanvasElement.h
dom/html/HTMLMediaElement.h
dom/html/TextControlState.h
dom/ipc/ProcessHangMonitor.cpp
dom/media/DOMMediaStream.h
dom/media/MediaManager.cpp
dom/media/MediaStreamTrack.h
dom/media/eme/MediaKeys.h
dom/media/webaudio/MediaStreamTrackAudioSourceNode.h
dom/media/webspeech/recognition/SpeechRecognition.h
dom/plugins/base/nsNPAPIPluginInstance.h
dom/plugins/base/nsPluginNativeWindowWin.cpp
dom/presentation/PresentationAvailability.h
dom/presentation/PresentationConnection.h
dom/promise/Promise.h
dom/webgpu/ipc/WebGPUChild.h
dom/workers/Worker.h
editor/libeditor/CompositionTransaction.h
editor/libeditor/PlaceholderTransaction.h
gfx/gl/GLContext.h
gfx/gl/MozFramebuffer.h
gfx/layers/ImageContainer.h
gfx/layers/wr/WebRenderBridgeParent.h
image/IProgressObserver.h
image/ProgressTracker.h
image/RasterImage.h
ipc/ipdl/ipdl/lower.py
js/xpconnect/src/SandboxPrivate.h
layout/base/nsPresContext.h
layout/base/nsRefreshDriver.cpp
layout/base/nsRefreshDriver.h
layout/style/CSSStyleRule.h
layout/style/SheetLoadData.h
mfbt/WeakPtr.h
mfbt/tests/TestWeakPtr.cpp
netwerk/protocol/http/Http2Stream.h
netwerk/sctp/datachannel/DataChannel.h
toolkit/components/extensions/WebExtensionPolicy.h
toolkit/components/extensions/webrequest/ChannelWrapper.h
toolkit/components/places/INativePlacesEventCallback.h
uriloader/prefetch/nsOfflineCacheUpdate.h
uriloader/preload/PreloaderBase.h
widget/android/jni/Natives.h
widget/android/nsWindow.cpp
xpcom/base/nsMessageLoop.cpp
--- a/docshell/base/BrowsingContext.h
+++ b/docshell/base/BrowsingContext.h
@@ -508,18 +508,16 @@ class BrowsingContext : public nsILoadCo
 
   // Set the window proxy object that corresponds to this browsing context.
   void SetWindowProxy(JS::Handle<JSObject*> aWindowProxy) {
     mWindowProxy = aWindowProxy;
   }
 
   Nullable<WindowProxyHolder> GetWindow();
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(BrowsingContext)
-
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BrowsingContext)
   NS_DECL_NSILOADCONTEXT
 
   // Perform a pre-order walk of this BrowsingContext subtree.
   void PreOrderWalk(const std::function<void(BrowsingContext*)>& aCallback) {
     aCallback(this);
     for (auto& child : Children()) {
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -115,17 +115,17 @@ class nsDocShell final : public nsDocLoa
                          public nsIBaseWindow,
                          public nsIRefreshURI,
                          public nsIWebProgressListener,
                          public nsIWebPageDescriptor,
                          public nsIAuthPromptProvider,
                          public nsILoadContext,
                          public nsINetworkInterceptController,
                          public nsIDeprecationWarner,
-                         public mozilla::SupportsWeakPtr<nsDocShell> {
+                         public mozilla::SupportsWeakPtr {
  public:
   enum InternalLoad : uint32_t {
     INTERNAL_LOAD_FLAGS_NONE = 0x0,
     INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL = 0x1,
     INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2,
     INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4,
 
     // This flag marks the first load in this object
@@ -174,17 +174,16 @@ class nsDocShell final : public nsDocLoa
     NS_DECL_NSIINTERFACEREQUESTOR
 
    private:
     virtual ~InterfaceRequestorProxy();
     InterfaceRequestorProxy() = default;
     nsWeakPtr mWeakPtr;
   };
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell)
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDocShell, nsDocLoader)
   NS_DECL_NSIDOCSHELL
   NS_DECL_NSIDOCSHELLTREEITEM
   NS_DECL_NSIWEBNAVIGATION
   NS_DECL_NSIBASEWINDOW
   NS_DECL_NSIINTERFACEREQUESTOR
   NS_DECL_NSIWEBPROGRESSLISTENER
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -464,17 +464,17 @@ enum class SheetPreloadStatus : uint8_t 
 class Document : public nsINode,
                  public DocumentOrShadowRoot,
                  public nsSupportsWeakReference,
                  public nsIRadioGroupContainer,
                  public nsIScriptObjectPrincipal,
                  public nsIApplicationCacheContainer,
                  public nsStubMutationObserver,
                  public DispatcherTrait,
-                 public SupportsWeakPtr<Document> {
+                 public SupportsWeakPtr {
   friend class DocumentOrShadowRoot;
 
  protected:
   explicit Document(const char* aContentType);
   virtual ~Document();
 
   Document(const Document&) = delete;
   Document& operator=(const Document&) = delete;
@@ -489,18 +489,16 @@ class Document : public nsINode,
   // to use the default one, we need to bring it back again
   void* operator new(size_t aSize) { return ::operator new(aSize); }
 
   /**
    * Called when XPCOM shutdown.
    */
   static void Shutdown();
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(Document)
-
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_IID)
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   NS_DECL_ADDSIZEOFEXCLUDINGTHIS
 
   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Document,
                                                                    nsINode)
--- a/dom/base/PlacesWeakCallbackWrapper.h
+++ b/dom/base/PlacesWeakCallbackWrapper.h
@@ -9,21 +9,19 @@
 
 #include "mozilla/dom/PlacesObserversBinding.h"
 #include "mozilla/ErrorResult.h"
 #include "nsWrapperCache.h"
 
 namespace mozilla {
 namespace dom {
 
-class PlacesWeakCallbackWrapper final
-    : public nsWrapperCache,
-      public SupportsWeakPtr<PlacesWeakCallbackWrapper> {
+class PlacesWeakCallbackWrapper final : public nsWrapperCache,
+                                        public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PlacesWeakCallbackWrapper)
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PlacesWeakCallbackWrapper)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(PlacesWeakCallbackWrapper)
 
   explicit PlacesWeakCallbackWrapper(nsISupports* aParent,
                                      PlacesEventCallback& aCallback);
 
   static already_AddRefed<PlacesWeakCallbackWrapper> Constructor(
       const GlobalObject& aGlobal, PlacesEventCallback& aCallback);
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -51,29 +51,27 @@ namespace dom {
 
 // Note, the ownership of mozilla::dom::Selection depends on which way the
 // object is created. When nsFrameSelection has created Selection,
 // addreffing/releasing the Selection object is aggregated to nsFrameSelection.
 // Otherwise normal addref/release is used.  This ensures that nsFrameSelection
 // is never deleted before its Selections.
 class Selection final : public nsSupportsWeakReference,
                         public nsWrapperCache,
-                        public SupportsWeakPtr<Selection> {
+                        public SupportsWeakPtr {
  protected:
   virtual ~Selection();
 
  public:
   /**
    * @param aFrameSelection can be nullptr.
    */
   explicit Selection(SelectionType aSelectionType,
                      nsFrameSelection* aFrameSelection);
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(Selection)
-
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Selection)
 
   // match this up with EndbatchChanges. will stop ui updates while multiple
   // selection methods are called
   void StartBatchChanges();
 
   // match this up with StartBatchChanges
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -948,16 +948,18 @@ void nsRange::RegisterSelection(Selectio
 
   mSelection = &aSelection;
 
   nsINode* commonAncestor = GetClosestCommonInclusiveAncestor();
   MOZ_ASSERT(commonAncestor, "unexpected disconnected nodes");
   RegisterClosestCommonInclusiveAncestor(commonAncestor);
 }
 
+Selection* nsRange::GetSelection() const { return mSelection; }
+
 void nsRange::UnregisterSelection() {
   mSelection = nullptr;
 
   if (mRegisteredClosestCommonInclusiveAncestor) {
     UnregisterClosestCommonInclusiveAncestor(
         mRegisteredClosestCommonInclusiveAncestor, false);
     MOZ_DIAGNOSTIC_ASSERT(
         !mRegisteredClosestCommonInclusiveAncestor,
--- a/dom/base/nsRange.h
+++ b/dom/base/nsRange.h
@@ -100,17 +100,17 @@ class nsRange final : public mozilla::do
   MOZ_CAN_RUN_SCRIPT void RegisterSelection(
       mozilla::dom::Selection& aSelection);
 
   void UnregisterSelection();
 
   /**
    * Returns pointer to a Selection if the range is associated with a Selection.
    */
-  mozilla::dom::Selection* GetSelection() const { return mSelection; }
+  mozilla::dom::Selection* GetSelection() const;
 
   /**
    * Return true if this range was generated.
    * @see SetIsGenerated
    */
   bool IsGenerated() const { return mIsGenerated; }
 
   /**
--- a/dom/canvas/ClientWebGLContext.h
+++ b/dom/canvas/ClientWebGLContext.h
@@ -387,27 +387,26 @@ class WebGLProgramJS final : public nsWr
 
   JSObject* WrapObject(JSContext*, JS::Handle<JSObject*>) override;
 };
 
 // -
 
 class WebGLQueryJS final : public nsWrapperCache,
                            public webgl::ObjectJS,
-                           public SupportsWeakPtr<WebGLQueryJS> {
+                           public SupportsWeakPtr {
   friend class ClientWebGLContext;
   friend class webgl::AvailabilityRunnable;
 
   GLenum mTarget = 0;  // !IsQuery until Bind
   bool mCanBeAvailable = false;
 
  public:
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLQueryJS)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLQueryJS)
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLQueryJS)
 
   explicit WebGLQueryJS(const ClientWebGLContext& webgl)
       : webgl::ObjectJS(webgl) {}
 
  private:
   ~WebGLQueryJS() = default;
 
  public:
@@ -487,27 +486,26 @@ class WebGLShaderJS final : public nsWra
 
   JSObject* WrapObject(JSContext*, JS::Handle<JSObject*>) override;
 };
 
 // -
 
 class WebGLSyncJS final : public nsWrapperCache,
                           public webgl::ObjectJS,
-                          public SupportsWeakPtr<WebGLSyncJS> {
+                          public SupportsWeakPtr {
   friend class ClientWebGLContext;
   friend class webgl::AvailabilityRunnable;
 
   bool mCanBeAvailable = false;
   bool mSignaled = false;
 
  public:
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLSyncJS)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLSyncJS)
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLSyncJS)
 
   explicit WebGLSyncJS(const ClientWebGLContext& webgl)
       : webgl::ObjectJS(webgl) {}
 
  private:
   ~WebGLSyncJS() = default;
 
  public:
@@ -700,25 +698,22 @@ struct TexImageSourceAdapter final : pub
   }
 };
 
 /**
  * Base class for all IDL implementations of WebGLContext
  */
 class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
                                  public nsWrapperCache,
-                                 public SupportsWeakPtr<ClientWebGLContext> {
+                                 public SupportsWeakPtr {
   friend class webgl::AvailabilityRunnable;
   friend class webgl::ObjectJS;
   friend class webgl::ProgramKeepAlive;
   friend class webgl::ShaderKeepAlive;
 
- public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(ClientWebGLContext)
-
   // ----------------------------- Lifetime and DOM ---------------------------
  public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ClientWebGLContext)
 
   JSObject* WrapObject(JSContext* cx,
                        JS::Handle<JSObject*> givenProto) override {
     if (mIsWebGL2) {
--- a/dom/canvas/HostWebGLContext.h
+++ b/dom/canvas/HostWebGLContext.h
@@ -61,29 +61,27 @@ struct LockedOutstandingContexts final {
  * causes it to drain its queue of commands.  It also maintains a map of WebGL
  * objects (e.g. ObjectIdMap<WebGLShader>) that it uses associate them with
  * their cross-process IDs.
  *
  * This class is not an implementation of the
  * nsICanvasRenderingContextInternal DOM class.  That is the
  * ClientWebGLContext.
  */
-class HostWebGLContext final : public SupportsWeakPtr<HostWebGLContext> {
+class HostWebGLContext final : public SupportsWeakPtr {
   friend class WebGLContext;
   friend class WebGLMemoryTracker;
 
   using ObjectId = webgl::ObjectId;
 
   static std::unique_ptr<LockedOutstandingContexts> OutstandingContexts() {
     return std::make_unique<LockedOutstandingContexts>();
   }
 
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(HostWebGLContext)
-
   struct RemotingData final {
     dom::WebGLParent& mParent;
     UniquePtr<HostWebGLCommandSinkP> mCommandSinkP;
     UniquePtr<HostWebGLCommandSinkI> mCommandSinkI;
   };
   struct OwnerData final {
     Maybe<ClientWebGLContext*> inProcess;
     Maybe<RemotingData> outOfProcess;
--- a/dom/canvas/IpdlQueue.h
+++ b/dom/canvas/IpdlQueue.h
@@ -300,23 +300,22 @@ class SyncConsumerActor : public AsyncCo
     MOZ_ASSERT(responseBufferIsEmpty);
 #endif
 
     return actor->RunQueue(id) ? IPC_OK() : IPC_FAIL_NO_REASON(actor);
   }
 };
 
 template <typename _Actor>
-class IpdlProducer final : public SupportsWeakPtr<IpdlProducer<_Actor>> {
+class IpdlProducer final : public SupportsWeakPtr {
   nsTArray<uint8_t> mSerializedData;
   WeakPtr<_Actor> mActor;
   uint64_t mId;
 
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(IpdlProducer<_Actor>)
   using Actor = _Actor;
   using SelfType = IpdlProducer<Actor>;
 
   // For IPDL:
   IpdlProducer() : mId(kIllegalQueueId) {}
 
   /**
    * Insert aArgs into the queue.  If the operation does not succeed then
@@ -438,19 +437,18 @@ class IpdlProducer final : public Suppor
   template <typename Arg, typename... Args>
   size_t MinSizeofArgs(mozilla::webgl::ProducerView<SelfType>& aView,
                        const Arg& aArg, const Args&... aArgs) {
     return aView.MinSizeParam(aArg) + MinSizeofArgs(aView, aArgs...);
   }
 };
 
 template <typename _Actor>
-class IpdlConsumer final : public SupportsWeakPtr<IpdlConsumer<_Actor>> {
+class IpdlConsumer final : public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(IpdlConsumer<_Actor>)
   using Actor = _Actor;
   using SelfType = IpdlConsumer<Actor>;
 
   // For IPDL
   IpdlConsumer() : mId(kIllegalQueueId) {}
 
   /**
    * Attempts to copy and remove aArgs from the queue.  If the operation does
--- a/dom/canvas/ProducerConsumerQueue.h
+++ b/dom/canvas/ProducerConsumerQueue.h
@@ -46,17 +46,17 @@ class PcqConsumer;
  * Actors used to construct a PCQ must implement this class.
  * Example:
  * class MyActorParent : public PMyActorParent, public PcqActor {
  *   MyActorParent() : PcqActor(this) {}
  *   // ...
  * }
  * Implementations of abstract methods will typically just forward to IProtocol.
  */
-class PcqActor : public SupportsWeakPtr<PcqActor> {
+class PcqActor : public SupportsWeakPtr {
   // The IProtocol part of `this`.
   IProtocol* mProtocol;
 
   using PcqActorMap = std::unordered_map<IProtocol*, PcqActor*>;
   // uses StaticAutoPtr to placate anti-static-ctor static analysis
   inline static StaticAutoPtr<PcqActorMap> sMap;
 
   static bool IsActorThread() {
@@ -77,18 +77,16 @@ class PcqActor : public SupportsWeakPtr<
     sMap->erase(mProtocol);
     if (sMap->empty()) {
       delete sMap;
       sMap = nullptr;
     }
   }
 
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PcqActor)
-
   Shmem::SharedMemory* LookupSharedMemory(int32_t aId) {
     return mProtocol->LookupSharedMemory(aId);
   }
   int32_t Id() const { return mProtocol->Id(); }
   base::ProcessId OtherPid() const { return mProtocol->OtherPid(); }
   bool AllocShmem(size_t aSize,
                   mozilla::ipc::SharedMemory::SharedMemoryType aShmType,
                   mozilla::ipc::Shmem* aShmem) {
--- a/dom/canvas/WebGLChild.h
+++ b/dom/canvas/WebGLChild.h
@@ -27,25 +27,22 @@ class ClientWebGLContext;
 
 namespace dom {
 
 struct FlushedCmdInfo final {
   size_t flushes = 0;
   size_t flushedCmdBytes = 0;
 };
 
-class WebGLChild final : public PWebGLChild,
-                         public SupportsWeakPtr<WebGLChild> {
+class WebGLChild final : public PWebGLChild, public SupportsWeakPtr {
   const WeakPtr<ClientWebGLContext> mContext;
   webgl::RaiiShmem mPendingCmdsShmem;
   size_t mPendingCmdsPos = 0;
   FlushedCmdInfo mFlushedCmdInfo;
-
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLChild)
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebGLChild, override);
   using OtherSideActor = WebGLParent;
 
   explicit WebGLChild(ClientWebGLContext&);
 
   Maybe<Range<uint8_t>> AllocPendingCmdBytes(size_t);
   void FlushPendingCmds();
 
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -198,17 +198,17 @@ struct BufferAndIndex final {
   const WebGLBuffer* buffer = nullptr;
   uint32_t id = -1;
 };
 
 }  // namespace webgl
 
 ////////////////////////////////////////////////////////////////////////////////
 
-class WebGLContext : public VRefCounted, public SupportsWeakPtr<WebGLContext> {
+class WebGLContext : public VRefCounted, public SupportsWeakPtr {
   friend class ScopedDrawCallWrapper;
   friend class ScopedDrawWithTransformFeedback;
   friend class ScopedFakeVertexAttrib0;
   friend class ScopedFBRebinder;
   friend class WebGL2Context;
   friend class WebGLContextUserData;
   friend class WebGLExtensionCompressedTextureASTC;
   friend class WebGLExtensionCompressedTextureBPTC;
@@ -314,18 +314,16 @@ class WebGLContext : public VRefCounted,
 
  public:
   class FuncScope;
 
  private:
   mutable FuncScope* mFuncScope = nullptr;
 
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLContext)
-
   static RefPtr<WebGLContext> Create(HostWebGLContext&,
                                      const webgl::InitContextDesc&,
                                      webgl::InitContextResult* out);
 
  private:
   void FinishInit();
 
  protected:
--- a/dom/canvas/WebGLContextLossHandler.h
+++ b/dom/canvas/WebGLContextLossHandler.h
@@ -9,24 +9,21 @@
 #include "mozilla/Atomics.h"
 #include "mozilla/WeakPtr.h"
 #include "mozilla/RefPtr.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 class WebGLContext;
 
-class WebGLContextLossHandler final
-    : public SupportsWeakPtr<WebGLContextLossHandler> {
+class WebGLContextLossHandler final : public SupportsWeakPtr {
   RefPtr<Runnable> mRunnable;
   Atomic<bool> mTimerIsScheduled;
 
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLContextLossHandler)
-
   explicit WebGLContextLossHandler(WebGLContext* webgl);
   ~WebGLContextLossHandler();
 
   void RunTimer();
   // Allow future queueing of context loss timer.
   void ClearTimer();
 };
 
--- a/dom/canvas/WebGLFramebuffer.h
+++ b/dom/canvas/WebGLFramebuffer.h
@@ -124,21 +124,20 @@ class WebGLFBAttachPoint final {
 
 #undef ORDER_BY
       return false;
     }
   };
 };
 
 class WebGLFramebuffer final : public WebGLContextBoundObject,
-                               public SupportsWeakPtr<WebGLFramebuffer>,
+                               public SupportsWeakPtr,
                                public CacheInvalidator {
  public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(WebGLFramebuffer, override)
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLFramebuffer)
 
   const GLuint mGLName;
   bool mHasBeenBound = false;
   const UniquePtr<gl::MozFramebuffer> mOpaque;
   gl::SwapChain mOpaqueSwapChain;
   bool mInOpaqueRAF = false;
 
  private:
--- a/dom/canvas/WebGLParent.h
+++ b/dom/canvas/WebGLParent.h
@@ -17,22 +17,21 @@ class HostWebGLContext;
 
 namespace layers {
 class SharedSurfaceTextureClient;
 class SurfaceDescriptor;
 }
 
 namespace dom {
 
-class WebGLParent : public PWebGLParent, public SupportsWeakPtr<WebGLParent> {
+class WebGLParent : public PWebGLParent, public SupportsWeakPtr {
   friend PWebGLParent;
 
  public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebGLParent, override);
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLParent)
   using OtherSideActor = WebGLChild;
 
   mozilla::ipc::IPCResult RecvInitialize(
       const webgl::InitContextDesc&, UniquePtr<HostWebGLCommandSinkP>&& aSinkP,
       UniquePtr<HostWebGLCommandSinkI>&& aSinkI, webgl::InitContextResult* out);
 
   WebGLParent();  // For IPDL
 
--- a/dom/canvas/WebGLProgram.h
+++ b/dom/canvas/WebGLProgram.h
@@ -84,22 +84,21 @@ struct LocationInfo final {
   const ActiveUniformValidationInfo info;
   const uint32_t indexIntoUniform;
   SamplerUniformInfo* const samplerInfo;
 };
 
 // -
 
 struct LinkedProgramInfo final : public RefCounted<LinkedProgramInfo>,
-                                 public SupportsWeakPtr<LinkedProgramInfo>,
+                                 public SupportsWeakPtr,
                                  public CacheInvalidator {
   friend class mozilla::WebGLProgram;
 
   MOZ_DECLARE_REFCOUNTED_TYPENAME(LinkedProgramInfo)
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(LinkedProgramInfo)
 
   //////
 
   WebGLProgram* const prog;
   const GLenum transformFeedbackBufferMode;
 
   std::unordered_map<uint8_t, const FragOutputInfo> fragOutputs;
   uint8_t zLayerCount = 1;
--- a/dom/geolocation/Geolocation.cpp
+++ b/dom/geolocation/Geolocation.cpp
@@ -59,20 +59,19 @@ class nsIPrincipal;
 // This preference allows to override the "secure context" by
 // default policy.
 #define PREF_GEO_SECURITY_ALLOWINSECURE "geo.security.allowinsecure"
 
 using mozilla::Unused;  // <snicker>
 using namespace mozilla;
 using namespace mozilla::dom;
 
-class nsGeolocationRequest final
-    : public ContentPermissionRequestBase,
-      public nsIGeolocationUpdate,
-      public SupportsWeakPtr<nsGeolocationRequest> {
+class nsGeolocationRequest final : public ContentPermissionRequestBase,
+                                   public nsIGeolocationUpdate,
+                                   public SupportsWeakPtr {
  public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIGEOLOCATIONUPDATE
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsGeolocationRequest,
                                            ContentPermissionRequestBase)
 
   nsGeolocationRequest(Geolocation* aLocator, GeoPositionCallback aCallback,
@@ -81,18 +80,16 @@ class nsGeolocationRequest final
                        uint8_t aProtocolType, nsIEventTarget* aMainThreadTarget,
                        bool aWatchPositionRequest = false,
                        int32_t aWatchId = 0);
 
   // nsIContentPermissionRequest
   MOZ_CAN_RUN_SCRIPT NS_IMETHOD Cancel(void) override;
   MOZ_CAN_RUN_SCRIPT NS_IMETHOD Allow(JS::HandleValue choices) override;
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsGeolocationRequest)
-
   void Shutdown();
 
   // MOZ_CAN_RUN_SCRIPT_BOUNDARY is OK here because we're always called from a
   // runnable.  Ideally nsIRunnable::Run and its overloads would just be
   // MOZ_CAN_RUN_SCRIPT and then we could be too...
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
   void SendLocation(nsIDOMGeoPosition* aLocation);
   bool WantsHighAccuracy() {
--- a/dom/html/HTMLCanvasElement.h
+++ b/dom/html/HTMLCanvasElement.h
@@ -83,20 +83,18 @@ class HTMLCanvasElementObserver final : 
 /*
  * FrameCaptureListener is used by captureStream() as a way of getting video
  * frames from the canvas. On a refresh driver tick after something has been
  * drawn to the canvas since the last such tick, all registered
  * FrameCaptureListeners whose `mFrameCaptureRequested` equals `true`,
  * will be given a copy of the just-painted canvas.
  * All FrameCaptureListeners get the same copy.
  */
-class FrameCaptureListener : public SupportsWeakPtr<FrameCaptureListener> {
+class FrameCaptureListener : public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(FrameCaptureListener)
-
   FrameCaptureListener() : mFrameCaptureRequested(false) {}
 
   /*
    * Called when a frame capture is desired on next paint.
    */
   void RequestFrameCapture() { mFrameCaptureRequested = true; }
 
   /*
@@ -114,17 +112,17 @@ class FrameCaptureListener : public Supp
  protected:
   virtual ~FrameCaptureListener() = default;
 
   bool mFrameCaptureRequested;
 };
 
 class HTMLCanvasElement final : public nsGenericHTMLElement,
                                 public CanvasRenderingContextHelper,
-                                public SupportsWeakPtr<HTMLCanvasElement> {
+                                public SupportsWeakPtr {
   enum { DEFAULT_CANVAS_WIDTH = 300, DEFAULT_CANVAS_HEIGHT = 150 };
 
   typedef layers::CanvasRenderer CanvasRenderer;
   typedef layers::CanvasLayer CanvasLayer;
   typedef layers::Layer Layer;
   typedef layers::LayerManager LayerManager;
   typedef layers::WebRenderCanvasData WebRenderCanvasData;
 
@@ -136,19 +134,16 @@ class HTMLCanvasElement final : public n
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // CC
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLCanvasElement,
                                            nsGenericHTMLElement)
 
-  // WeakPtr
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(HTMLCanvasElement)
-
   // WebIDL
   uint32_t Height() {
     return GetUnsignedIntAttr(nsGkAtoms::height, DEFAULT_CANVAS_HEIGHT);
   }
   void SetHeight(uint32_t aHeight, ErrorResult& aRv) {
     if (mOffscreenCanvas) {
       aRv.Throw(NS_ERROR_FAILURE);
       return;
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -98,17 +98,17 @@ enum class StreamCaptureType : uint8_t {
 enum class StreamCaptureBehavior : uint8_t {
   CONTINUE_WHEN_ENDED,
   FINISH_WHEN_ENDED
 };
 
 class HTMLMediaElement : public nsGenericHTMLElement,
                          public MediaDecoderOwner,
                          public PrincipalChangeObserver<MediaStreamTrack>,
-                         public SupportsWeakPtr<HTMLMediaElement>,
+                         public SupportsWeakPtr,
                          public nsStubMutationObserver {
  public:
   typedef mozilla::TimeStamp TimeStamp;
   typedef mozilla::layers::ImageContainer ImageContainer;
   typedef mozilla::VideoFrameContainer VideoFrameContainer;
   typedef mozilla::MediaResource MediaResource;
   typedef mozilla::MediaDecoderOwner MediaDecoderOwner;
   typedef mozilla::MetadataTags MetadataTags;
@@ -129,17 +129,16 @@ class HTMLMediaElement : public nsGeneri
     // If mFinishWhenEnded is true, this is the URI of the first resource
     // mStream got tracks for, if not a MediaStream.
     nsCOMPtr<nsIURI> mFinishWhenEndedLoadingSrc;
     // If mFinishWhenEnded is true, this is the first MediaStream mStream got
     // tracks for, if not a resource.
     RefPtr<DOMMediaStream> mFinishWhenEndedAttrStream;
   };
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(HTMLMediaElement)
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
   CORSMode GetCORSMode() { return mCORSMode; }
 
   explicit HTMLMediaElement(
       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   void Init();
 
--- a/dom/html/TextControlState.h
+++ b/dom/html/TextControlState.h
@@ -126,23 +126,21 @@ class HTMLInputElement;
  *
  *   * If the text control state object is unbound from the control's frame, the
  * value is transferred to the mValue member variable, and will be managed there
  * until a new frame is bound to the text editor state object.
  */
 
 class RestoreSelectionState;
 
-class TextControlState final : public SupportsWeakPtr<TextControlState> {
+class TextControlState final : public SupportsWeakPtr {
  public:
   typedef dom::Element Element;
   typedef dom::HTMLInputElement HTMLInputElement;
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(TextControlState)
-
   static TextControlState* Construct(TextControlElement* aOwningElement);
 
   // Note that this does not run script actually because of `sHasShutDown`
   // is set to true before calling `DeleteOrCacheForReuse()`.
   MOZ_CAN_RUN_SCRIPT_BOUNDARY static void Shutdown();
 
   /**
    * Destroy() deletes the instance immediately or later.
--- a/dom/ipc/ProcessHangMonitor.cpp
+++ b/dom/ipc/ProcessHangMonitor.cpp
@@ -228,23 +228,21 @@ class HangMonitoredProcess final : publi
   // Everything here is main thread-only.
   HangMonitorParent* mActor;
   ContentParent* mContentParent;
   HangData mHangData;
   nsAutoString mDumpId;
 };
 
 class HangMonitorParent : public PProcessHangMonitorParent,
-                          public SupportsWeakPtr<HangMonitorParent> {
+                          public SupportsWeakPtr {
  public:
   explicit HangMonitorParent(ProcessHangMonitor* aMonitor);
   ~HangMonitorParent() override;
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(HangMonitorParent)
-
   void Bind(Endpoint<PProcessHangMonitorParent>&& aEndpoint);
 
   mozilla::ipc::IPCResult RecvHangEvidence(const HangData& aHangData) override;
   mozilla::ipc::IPCResult RecvClearHang() override;
 
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
   void SetProcess(HangMonitoredProcess* aProcess) { mProcess = aProcess; }
--- a/dom/media/DOMMediaStream.h
+++ b/dom/media/DOMMediaStream.h
@@ -44,27 +44,25 @@ class OverlayImage;
 
 /**
  * DOMMediaStream is the implementation of the js-exposed MediaStream interface.
  *
  * This is a thin main-thread class grouping MediaStreamTracks together.
  */
 class DOMMediaStream : public DOMEventTargetHelper,
                        public RelativeTimeline,
-                       public SupportsWeakPtr<DOMMediaStream> {
+                       public SupportsWeakPtr {
   typedef dom::MediaStreamTrack MediaStreamTrack;
   typedef dom::AudioStreamTrack AudioStreamTrack;
   typedef dom::VideoStreamTrack VideoStreamTrack;
   typedef dom::MediaStreamTrackSource MediaStreamTrackSource;
 
  public:
   typedef dom::MediaTrackConstraints MediaTrackConstraints;
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(DOMMediaStream)
-
   class TrackListener {
    public:
     virtual ~TrackListener() = default;
 
     /**
      * Called when the DOMMediaStream has a live track added, either by
      * script (addTrack()) or the source creating one.
      */
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -287,22 +287,21 @@ void MediaManager::CallOnSuccess(GetUser
 }
 
 /**
  * SourceListener has threadsafe refcounting for use across the main, media and
  * MTG threads. But it has a non-threadsafe SupportsWeakPtr for WeakPtr usage
  * only from main thread, to ensure that garbage- and cycle-collected objects
  * don't hold a reference to it during late shutdown.
  */
-class SourceListener : public SupportsWeakPtr<SourceListener> {
+class SourceListener : public SupportsWeakPtr {
  public:
   typedef MozPromise<bool /* aIgnored */, RefPtr<MediaMgrError>, true>
       SourceListenerPromise;
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(SourceListener)
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(
       SourceListener)
 
   SourceListener();
 
   /**
    * Registers this source listener as belonging to the given window listener.
    */
--- a/dom/media/MediaStreamTrack.h
+++ b/dom/media/MediaStreamTrack.h
@@ -49,20 +49,18 @@ enum class CallerType : uint32_t;
  * Kept alive by a strong ref in all MediaStreamTracks (original and clones)
  * sharing this source.
  */
 class MediaStreamTrackSource : public nsISupports {
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(MediaStreamTrackSource)
 
  public:
-  class Sink : public SupportsWeakPtr<Sink> {
+  class Sink : public SupportsWeakPtr {
    public:
-    MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MediaStreamTrackSource::Sink)
-
     /**
      * Must be constant throughout the Sink's lifetime.
      *
      * Return true to keep the MediaStreamTrackSource where this sink is
      * registered alive.
      * Return false to allow the source to stop.
      *
      * Typically MediaStreamTrack::Sink returns true and other Sinks
@@ -340,21 +338,18 @@ class BasicTrackSource : public MediaStr
 
   const MediaSourceEnum mMediaSource;
 };
 
 /**
  * Base class that consumers of a MediaStreamTrack can use to get notifications
  * about state changes in the track.
  */
-class MediaStreamTrackConsumer
-    : public SupportsWeakPtr<MediaStreamTrackConsumer> {
+class MediaStreamTrackConsumer : public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MediaStreamTrackConsumer)
-
   /**
    * Called when the track's readyState transitions to "ended".
    * Unlike the "ended" event exposed to script this is called for any reason,
    * including MediaStreamTrack::Stop().
    */
   virtual void NotifyEnded(MediaStreamTrack* aTrack){};
 
   /**
@@ -395,18 +390,17 @@ class MediaStreamTrackConsumer
  *                -----
  * MediaStreamTrack B  \  (clone of A)
  *       mInputTrack   \ mTrack
  *            *          -> t1
  *
  *   (*) is a copy of A's mInputTrack
  */
 // clang-format on
-class MediaStreamTrack : public DOMEventTargetHelper,
-                         public SupportsWeakPtr<MediaStreamTrack> {
+class MediaStreamTrack : public DOMEventTargetHelper, public SupportsWeakPtr {
   // PeerConnection and friends need to know our owning DOMStream and track id.
   friend class mozilla::PeerConnectionImpl;
   friend class mozilla::PeerConnectionMedia;
   friend class mozilla::SourceStreamInfo;
   friend class mozilla::RemoteSourceStreamInfo;
 
   class MTGListener;
   class TrackSink;
@@ -418,18 +412,16 @@ class MediaStreamTrack : public DOMEvent
       MediaStreamTrackState aReadyState = MediaStreamTrackState::Live,
       bool aMuted = false,
       const MediaTrackConstraints& aConstraints = MediaTrackConstraints());
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamTrack,
                                            DOMEventTargetHelper)
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MediaStreamTrack)
-
   nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
 
   virtual AudioStreamTrack* AsAudioStreamTrack() { return nullptr; }
   virtual VideoStreamTrack* AsVideoStreamTrack() { return nullptr; }
 
   virtual const AudioStreamTrack* AsAudioStreamTrack() const { return nullptr; }
--- a/dom/media/eme/MediaKeys.h
+++ b/dom/media/eme/MediaKeys.h
@@ -45,24 +45,23 @@ typedef nsRefPtrHashtable<nsUint32HashKe
     PendingKeySessionsHashMap;
 typedef nsDataHashtable<nsUint32HashKey, uint32_t> PendingPromiseIdTokenHashMap;
 typedef uint32_t PromiseId;
 
 // This class is used on the main thread only.
 // Note: its addref/release is not (and can't be) thread safe!
 class MediaKeys final : public nsIDocumentActivity,
                         public nsWrapperCache,
-                        public SupportsWeakPtr<MediaKeys>,
+                        public SupportsWeakPtr,
                         public DecoderDoctorLifeLogger<MediaKeys> {
   ~MediaKeys();
 
  public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaKeys)
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MediaKeys)
   // We want to listen to the owning document so we can shutdown if it goes
   // inactive.
   NS_DECL_NSIDOCUMENTACTIVITY
 
   MediaKeys(nsPIDOMWindowInner* aParentWindow, const nsAString& aKeySystem,
             const MediaKeySystemConfiguration& aConfig);
 
   already_AddRefed<DetailedPromise> Init(ErrorResult& aRv);
--- a/dom/media/webaudio/MediaStreamTrackAudioSourceNode.h
+++ b/dom/media/webaudio/MediaStreamTrackAudioSourceNode.h
@@ -37,24 +37,23 @@ class MediaStreamTrackAudioSourceNodeEng
 
  private:
   bool mEnabled;
 };
 
 class MediaStreamTrackAudioSourceNode
     : public AudioNode,
       public PrincipalChangeObserver<MediaStreamTrack>,
-      public SupportsWeakPtr<MediaStreamTrackAudioSourceNode> {
+      public SupportsWeakPtr {
  public:
   static already_AddRefed<MediaStreamTrackAudioSourceNode> Create(
       AudioContext& aContext,
       const MediaStreamTrackAudioSourceOptions& aOptions, ErrorResult& aRv);
 
   NS_DECL_ISUPPORTS_INHERITED
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MediaStreamTrackAudioSourceNode)
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamTrackAudioSourceNode,
                                            AudioNode)
 
   static already_AddRefed<MediaStreamTrackAudioSourceNode> Constructor(
       const GlobalObject& aGlobal, AudioContext& aAudioContext,
       const MediaStreamTrackAudioSourceOptions& aOptions, ErrorResult& aRv) {
     return Create(aAudioContext, aOptions, aRv);
   }
--- a/dom/media/webspeech/recognition/SpeechRecognition.h
+++ b/dom/media/webspeech/recognition/SpeechRecognition.h
@@ -48,19 +48,18 @@ class SpeechTrackListener;
 
 LogModule* GetSpeechRecognitionLog();
 #define SR_LOG(...) \
   MOZ_LOG(GetSpeechRecognitionLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
 
 class SpeechRecognition final : public DOMEventTargetHelper,
                                 public nsIObserver,
                                 public DOMMediaStream::TrackListener,
-                                public SupportsWeakPtr<SpeechRecognition> {
+                                public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(SpeechRecognition)
   explicit SpeechRecognition(nsPIDOMWindowInner* aOwnerWindow);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SpeechRecognition,
                                            DOMEventTargetHelper)
 
   NS_DECL_NSIOBSERVER
 
--- a/dom/plugins/base/nsNPAPIPluginInstance.h
+++ b/dom/plugins/base/nsNPAPIPluginInstance.h
@@ -72,26 +72,24 @@ class nsNPAPITimer {
   NPP npp;
   uint32_t id;
   nsCOMPtr<nsITimer> timer;
   void (*callback)(NPP npp, uint32_t timerID);
   bool inCallback;
   bool needUnschedule;
 };
 
-class nsNPAPIPluginInstance final
-    : public nsIAudioChannelAgentCallback,
-      public mozilla::SupportsWeakPtr<nsNPAPIPluginInstance> {
+class nsNPAPIPluginInstance final : public nsIAudioChannelAgentCallback,
+                                    public mozilla::SupportsWeakPtr {
  private:
   typedef mozilla::PluginLibrary PluginLibrary;
 
  public:
   typedef mozilla::gfx::DrawTarget DrawTarget;
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsNPAPIPluginInstance)
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
 
   nsresult Initialize(nsNPAPIPlugin* aPlugin, nsPluginInstanceOwner* aOwner,
                       const nsACString& aMIMEType);
   nsresult Start();
   nsresult Stop();
   nsresult SetWindow(NPWindow* window);
--- a/dom/plugins/base/nsPluginNativeWindowWin.cpp
+++ b/dom/plugins/base/nsPluginNativeWindowWin.cpp
@@ -88,21 +88,19 @@ void PluginWindowEvent::Init(WeakPtr<nsP
   mWParam = aWParam;
   mLParam = aLParam;
 }
 
 /**
  *  nsPluginNativeWindow Windows specific class declaration
  */
 
-class nsPluginNativeWindowWin
-    : public nsPluginNativeWindow,
-      public SupportsWeakPtr<nsPluginNativeWindowWin> {
+class nsPluginNativeWindowWin : public nsPluginNativeWindow,
+                                public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsPluginNativeWindowWin)
   nsPluginNativeWindowWin();
 
   virtual nsresult CallSetWindow(
       RefPtr<nsNPAPIPluginInstance>& aPluginInstance);
 
  private:
   nsresult SubclassAndAssociateWindow();
   nsresult UndoSubclassAndAssociateWindow();
--- a/dom/presentation/PresentationAvailability.h
+++ b/dom/presentation/PresentationAvailability.h
@@ -14,23 +14,22 @@
 namespace mozilla {
 namespace dom {
 
 class Promise;
 
 class PresentationAvailability final
     : public DOMEventTargetHelper,
       public nsIPresentationAvailabilityListener,
-      public SupportsWeakPtr<PresentationAvailability> {
+      public SupportsWeakPtr {
  public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationAvailability,
                                            DOMEventTargetHelper)
   NS_DECL_NSIPRESENTATIONAVAILABILITYLISTENER
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PresentationAvailability)
 
   static already_AddRefed<PresentationAvailability> Create(
       nsPIDOMWindowInner* aWindow, const nsTArray<nsString>& aUrls,
       RefPtr<Promise>& aPromise);
 
   virtual void DisconnectFromOwner() override;
 
   virtual JSObject* WrapObject(JSContext* aCx,
--- a/dom/presentation/PresentationConnection.h
+++ b/dom/presentation/PresentationConnection.h
@@ -17,28 +17,26 @@
 #include "nsIWeakReferenceUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 class Blob;
 class PresentationConnectionList;
 
-class PresentationConnection final
-    : public DOMEventTargetHelper,
-      public nsIPresentationSessionListener,
-      public nsIRequest,
-      public SupportsWeakPtr<PresentationConnection> {
+class PresentationConnection final : public DOMEventTargetHelper,
+                                     public nsIPresentationSessionListener,
+                                     public nsIRequest,
+                                     public SupportsWeakPtr {
  public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationConnection,
                                            DOMEventTargetHelper)
   NS_DECL_NSIPRESENTATIONSESSIONLISTENER
   NS_DECL_NSIREQUEST
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PresentationConnection)
 
   static already_AddRefed<PresentationConnection> Create(
       nsPIDOMWindowInner* aWindow, const nsAString& aId, const nsAString& aUrl,
       const uint8_t aRole, PresentationConnectionList* aList = nullptr);
 
   virtual void DisconnectFromOwner() override;
 
   virtual JSObject* WrapObject(JSContext* aCx,
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -30,25 +30,24 @@ namespace mozilla {
 namespace dom {
 
 class AnyCallback;
 class MediaStreamError;
 class PromiseInit;
 class PromiseNativeHandler;
 class PromiseDebugging;
 
-class Promise : public SupportsWeakPtr<Promise> {
+class Promise : public SupportsWeakPtr {
   friend class PromiseTask;
   friend class PromiseWorkerProxy;
   friend class PromiseWorkerProxyRunnable;
 
  public:
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(Promise)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(Promise)
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(Promise)
 
   enum PropagateUserInteraction {
     eDontPropagateUserInteraction,
     ePropagateUserInteraction
   };
 
   // Promise creation tries to create a JS reflector for the Promise, so is
   // fallible.  Furthermore, we don't want to do JS-wrapping on a 0-refcount
--- a/dom/webgpu/ipc/WebGPUChild.h
+++ b/dom/webgpu/ipc/WebGPUChild.h
@@ -20,18 +20,17 @@ namespace webgpu {
 namespace ffi {
 struct WGPUClient;
 struct WGPUTextureViewDescriptor;
 }  // namespace ffi
 
 struct TextureInfo;
 typedef MozPromise<RawId, Maybe<ipc::ResponseRejectReason>, true> RawIdPromise;
 
-class WebGPUChild final : public PWebGPUChild,
-                          public SupportsWeakPtr<WebGPUChild> {
+class WebGPUChild final : public PWebGPUChild {
  public:
   friend class layers::CompositorBridgeChild;
 
   NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(WebGPUChild)
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGPUChild)
 
  public:
   explicit WebGPUChild();
--- a/dom/workers/Worker.h
+++ b/dom/workers/Worker.h
@@ -19,23 +19,21 @@
 
 namespace mozilla {
 namespace dom {
 
 struct PostMessageOptions;
 struct WorkerOptions;
 class WorkerPrivate;
 
-class Worker : public DOMEventTargetHelper, public SupportsWeakPtr<Worker> {
+class Worker : public DOMEventTargetHelper, public SupportsWeakPtr {
  public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Worker,
                                                          DOMEventTargetHelper)
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(Worker)
-
   static already_AddRefed<Worker> Constructor(const GlobalObject& aGlobal,
                                               const nsAString& aScriptURL,
                                               const WorkerOptions& aOptions,
                                               ErrorResult& aRv);
 
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
 
--- a/editor/libeditor/CompositionTransaction.h
+++ b/editor/libeditor/CompositionTransaction.h
@@ -24,19 +24,18 @@ class Text;
 }  // namespace dom
 
 /**
  * CompositionTransaction stores all edit for a composition, i.e.,
  * from compositionstart event to compositionend event.  E.g., inserting a
  * composition string, modifying the composition string or its IME selection
  * ranges and commit or cancel the composition.
  */
-class CompositionTransaction final
-    : public EditTransactionBase,
-      public SupportsWeakPtr<CompositionTransaction> {
+class CompositionTransaction final : public EditTransactionBase,
+                                     public SupportsWeakPtr {
  protected:
   CompositionTransaction(EditorBase& aEditorBase,
                          const nsAString& aStringToInsert,
                          const EditorDOMPointInText& aPointToInsert);
 
  public:
   /**
    * Creates a composition transaction.  aEditorBase must not return from
@@ -49,18 +48,16 @@ class CompositionTransaction final
    *                            E.g., password editor can hide the character
    *                            with a different character.
    * @param aPointToInsert      The insertion point.
    */
   static already_AddRefed<CompositionTransaction> Create(
       EditorBase& aEditorBase, const nsAString& aStringToInsert,
       const EditorDOMPointInText& aPointToInsert);
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(CompositionTransaction)
-
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CompositionTransaction,
                                            EditTransactionBase)
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_EDITTRANSACTIONBASE
   NS_DECL_EDITTRANSACTIONBASE_GETASMETHODS_OVERRIDE(CompositionTransaction)
 
--- a/editor/libeditor/PlaceholderTransaction.h
+++ b/editor/libeditor/PlaceholderTransaction.h
@@ -17,19 +17,18 @@ class EditorBase;
 
 /**
  * An aggregate transaction that knows how to absorb all subsequent
  * transactions with the same name.  This transaction does not "Do" anything.
  * But it absorbs other transactions via merge, and can undo/redo the
  * transactions it has absorbed.
  */
 
-class PlaceholderTransaction final
-    : public EditAggregateTransaction,
-      public SupportsWeakPtr<PlaceholderTransaction> {
+class PlaceholderTransaction final : public EditAggregateTransaction,
+                                     public SupportsWeakPtr {
  protected:
   PlaceholderTransaction(EditorBase& aEditorBase, nsStaticAtom& aName,
                          Maybe<SelectionState>&& aSelState);
 
  public:
   /**
    * Creates a placeholder transaction.  This never returns nullptr.
    *
@@ -43,18 +42,16 @@ class PlaceholderTransaction final
     // Make sure to move aSelState into a local variable to null out the
     // original Maybe<SelectionState> variable.
     Maybe<SelectionState> selState(std::move(aSelState));
     RefPtr<PlaceholderTransaction> transaction =
         new PlaceholderTransaction(aEditorBase, aName, std::move(selState));
     return transaction.forget();
   }
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PlaceholderTransaction)
-
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PlaceholderTransaction,
                                            EditAggregateTransaction)
   // ------------ EditAggregateTransaction -----------------------
 
   NS_DECL_EDITTRANSACTIONBASE
   NS_DECL_EDITTRANSACTIONBASE_GETASMETHODS_OVERRIDE(PlaceholderTransaction)
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -184,20 +184,18 @@ enum class GLRenderer {
   Tegra,
   AndroidEmulator,
   GalliumLlvmpipe,
   IntelHD3000,
   MicrosoftBasicRenderDriver,
   Other
 };
 
-class GLContext : public GenericAtomicRefCounted,
-                  public SupportsWeakPtr<GLContext> {
+class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(GLContext)
   static MOZ_THREAD_LOCAL(uintptr_t) sCurrentContext;
 
   const GLContextDesc mDesc;
 
   bool mImplicitMakeCurrent = false;
   bool mUseTLSIsCurrent;
 
   class TlsScope final {
--- a/gfx/gl/MozFramebuffer.h
+++ b/gfx/gl/MozFramebuffer.h
@@ -10,24 +10,22 @@
 #include "GLConsts.h"
 #include "GLContextTypes.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/WeakPtr.h"
 
 namespace mozilla {
 namespace gl {
 
-class DepthAndStencilBuffer final
-    : public SupportsWeakPtr<DepthAndStencilBuffer> {
+class DepthAndStencilBuffer final : public SupportsWeakPtr {
   const WeakPtr<GLContext> mWeakGL;
   const gfx::IntSize mSize;
 
  public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DepthAndStencilBuffer)
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(DepthAndStencilBuffer)
 
   const GLuint mDepthRB;
   const GLuint mStencilRB;
 
   static RefPtr<DepthAndStencilBuffer> Create(GLContext* const gl,
                                               const gfx::IntSize& size,
                                               const uint32_t samples);
 
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -358,24 +358,22 @@ class ImageContainerListener final {
  * SetCurrentImages sends a message through the ImageBridge to the compositor
  * thread to update the image, without going through the main thread or
  * a layer transaction.
  * The ImageContainer uses a shared memory block containing a cross-process
  * mutex to communicate with the compositor thread. SetCurrentImage
  * synchronously updates the shared state to point to the new image and the old
  * image is immediately released (not true in Normal or Asynchronous modes).
  */
-class ImageContainer final : public SupportsWeakPtr<ImageContainer> {
+class ImageContainer final : public SupportsWeakPtr {
   friend class ImageContainerChild;
 
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageContainer)
 
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(ImageContainer)
-
   enum Mode { SYNCHRONOUS = 0x0, ASYNCHRONOUS = 0x01 };
 
   static const uint64_t sInvalidAsyncContainerId = 0;
 
   explicit ImageContainer(ImageContainer::Mode flag = SYNCHRONOUS);
 
   /**
    * Create ImageContainer just to hold another ASYNCHRONOUS ImageContainer's
--- a/gfx/layers/wr/WebRenderBridgeParent.h
+++ b/gfx/layers/wr/WebRenderBridgeParent.h
@@ -93,24 +93,22 @@ struct CompositorAnimationIdsForEpoch {
   CompositorAnimationIdsForEpoch(const wr::Epoch& aEpoch,
                                  nsTArray<uint64_t>&& aIds)
       : mEpoch(aEpoch), mIds(std::move(aIds)) {}
 
   wr::Epoch mEpoch;
   nsTArray<uint64_t> mIds;
 };
 
-class WebRenderBridgeParent final
-    : public PWebRenderBridgeParent,
-      public CompositorVsyncSchedulerOwner,
-      public CompositableParentManager,
-      public layers::FrameRecorder,
-      public SupportsWeakPtr<WebRenderBridgeParent> {
+class WebRenderBridgeParent final : public PWebRenderBridgeParent,
+                                    public CompositorVsyncSchedulerOwner,
+                                    public CompositableParentManager,
+                                    public layers::FrameRecorder,
+                                    public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebRenderBridgeParent)
   WebRenderBridgeParent(CompositorBridgeParentBase* aCompositorBridge,
                         const wr::PipelineId& aPipelineId,
                         widget::CompositorWidget* aWidget,
                         CompositorVsyncScheduler* aScheduler,
                         RefPtr<wr::WebRenderAPI>&& aApi,
                         RefPtr<AsyncImagePipelineManager>&& aImageMgr,
                         TimeDuration aVsyncRate);
 
--- a/image/IProgressObserver.h
+++ b/image/IProgressObserver.h
@@ -22,20 +22,18 @@ namespace image {
  * This is the ImageLib-internal version of imgINotificationObserver,
  * essentially, with implementation details that code outside of ImageLib
  * shouldn't see.
  *
  * XXX(seth): It's preferable to avoid adding anything to this interface if
  * possible.  In the long term, it would be ideal to get to a place where we can
  * just use the imgINotificationObserver interface internally as well.
  */
-class IProgressObserver : public SupportsWeakPtr<IProgressObserver> {
+class IProgressObserver : public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(IProgressObserver)
-
   // Subclasses may or may not be XPCOM classes, so we just require that they
   // implement AddRef and Release.
   NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   // imgINotificationObserver methods:
   virtual void Notify(int32_t aType, const nsIntRect* aRect = nullptr) = 0;
   virtual void OnLoadComplete(bool aLastPart) = 0;
 
--- a/image/ProgressTracker.h
+++ b/image/ProgressTracker.h
@@ -94,21 +94,20 @@ class ObserverTable : public nsDataHasht
  * loading and decoding process, and makes it possible to send notifications to
  * IProgressObservers, both synchronously and asynchronously.
  *
  * When a new observer needs to be notified of the current progress of an image,
  * call the Notify() method on this class with the relevant observer as its
  * argument, and the notifications will be replayed to the observer
  * asynchronously.
  */
-class ProgressTracker : public mozilla::SupportsWeakPtr<ProgressTracker> {
+class ProgressTracker : public mozilla::SupportsWeakPtr {
   virtual ~ProgressTracker() {}
 
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(ProgressTracker)
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ProgressTracker)
 
   ProgressTracker();
 
   bool HasImage() const {
     MutexAutoLock lock(mMutex);
     return mImage;
   }
--- a/image/RasterImage.h
+++ b/image/RasterImage.h
@@ -153,27 +153,26 @@ namespace image {
 
 class Decoder;
 struct DecoderFinalStatus;
 struct DecoderTelemetry;
 class ImageMetadata;
 class SourceBuffer;
 
 class RasterImage final : public ImageResource,
-                          public SupportsWeakPtr<RasterImage>
+                          public SupportsWeakPtr
 #ifdef DEBUG
     ,
                           public imgIContainerDebug
 #endif
 {
   // (no public constructor - use ImageFactory)
   virtual ~RasterImage();
 
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(RasterImage)
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_IMGICONTAINER
 #ifdef DEBUG
   NS_DECL_IMGICONTAINERDEBUG
 #endif
 
   nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) const override;
   size_t GetNativeSizesLength() const override;
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -3295,40 +3295,30 @@ class _GenerateProtocolActorCode(ipdl.as
         inherits = []
         if ptype.isToplevel():
             inherits.append(Inherit(p.openedProtocolInterfaceType(),
                                     viz='public'))
         else:
             inherits.append(Inherit(p.managerInterfaceType(), viz='public'))
 
         if hasAsyncReturns:
-            inherits.append(Inherit(Type('SupportsWeakPtr', T=ExprVar(self.clsname)),
-                                    viz='public'))
+            inherits.append(Inherit(Type('SupportsWeakPtr'), viz='public'))
             self.hdrfile.addthing(CppDirective('include', '"mozilla/WeakPtr.h"'))
 
         if ptype.isToplevel() and self.side == 'parent':
             self.hdrfile.addthings([
                 _makeForwardDeclForQClass('nsIFile', []),
                 Whitespace.NL
             ])
 
         self.cls = Class(
             self.clsname,
             inherits=inherits,
             abstract=True)
 
-        if hasAsyncReturns:
-            self.cls.addstmts([
-                Label.PUBLIC,
-                Whitespace('', indent=True),
-                ExprCall(ExprVar('MOZ_DECLARE_WEAKREFERENCE_TYPENAME'),
-                         [ExprVar(self.clsname)]),
-                Whitespace.NL
-            ])
-
         self.cls.addstmt(Label.PRIVATE)
         friends = _FindFriends().findFriends(ptype)
         if ptype.isManaged():
             friends.update(ptype.managers)
 
         # |friend| managed actors so that they can call our Dealloc*()
         friends.update(ptype.manages)
 
--- a/js/xpconnect/src/SandboxPrivate.h
+++ b/js/xpconnect/src/SandboxPrivate.h
@@ -14,20 +14,19 @@
 #include "nsWeakReference.h"
 #include "nsWrapperCache.h"
 
 #include "js/RootingAPI.h"
 
 class SandboxPrivate : public nsIGlobalObject,
                        public nsIScriptObjectPrincipal,
                        public nsSupportsWeakReference,
-                       public mozilla::SupportsWeakPtr<SandboxPrivate>,
+                       public mozilla::SupportsWeakPtr,
                        public nsWrapperCache {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(SandboxPrivate);
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(SandboxPrivate,
                                                          nsIGlobalObject)
 
   static void Create(nsIPrincipal* principal, JS::Handle<JSObject*> global) {
     RefPtr<SandboxPrivate> sbp = new SandboxPrivate(principal);
     sbp->SetWrapper(global);
     sbp->PreserveWrapper(ToSupports(sbp.get()));
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -121,31 +121,29 @@ enum class nsLayoutPhase : uint8_t {
 #define NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND (1 << 0)
 #define NS_AUTHOR_SPECIFIED_PADDING (1 << 1)
 
 class nsRootPresContext;
 
 // An interface for presentation contexts. Presentation contexts are
 // objects that provide an outer context for a presentation shell.
 
-class nsPresContext : public nsISupports,
-                      public mozilla::SupportsWeakPtr<nsPresContext> {
+class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
  public:
   using Encoding = mozilla::Encoding;
   template <typename T>
   using NotNull = mozilla::NotNull<T>;
   using MediaEmulationData = mozilla::MediaEmulationData;
   using StylePrefersColorScheme = mozilla::StylePrefersColorScheme;
 
   typedef mozilla::ScrollStyles ScrollStyles;
   using TransactionId = mozilla::layers::TransactionId;
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS_FINAL
   NS_DECL_CYCLE_COLLECTION_CLASS(nsPresContext)
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsPresContext)
 
   enum nsPresContextType {
     eContext_Galley,        // unpaginated screen presentation
     eContext_PrintPreview,  // paginated screen presentation
     eContext_Print,         // paginated printer presentation
     eContext_PageLayout     // paginated & editable.
   };
 
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -2455,16 +2455,18 @@ void nsRefreshDriver::SetThrottled(bool 
     if (mActiveTimer) {
       // We want to switch our timer type here, so just stop and
       // restart the timer.
       EnsureTimerStarted(eForceAdjustTimer);
     }
   }
 }
 
+nsPresContext* nsRefreshDriver::GetPresContext() const { return mPresContext; }
+
 /*static*/
 void nsRefreshDriver::PVsyncActorCreated(VsyncChild* aVsyncChild) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!XRE_IsParentProcess());
   RefPtr<RefreshDriverTimer> vsyncRefreshDriverTimer =
       new VsyncRefreshDriverTimer(aVsyncChild);
 
   // If we are using software timer, swap current timer to
--- a/layout/base/nsRefreshDriver.h
+++ b/layout/base/nsRefreshDriver.h
@@ -328,17 +328,17 @@ class nsRefreshDriver final : public moz
    * Throttle or unthrottle the refresh driver.  This is done if the
    * corresponding presshell is hidden or shown.
    */
   void SetThrottled(bool aThrottled);
 
   /**
    * Return the prescontext we were initialized with
    */
-  nsPresContext* GetPresContext() const { return mPresContext; }
+  nsPresContext* GetPresContext() const;
 
   /**
    * PBackgroundChild actor is created asynchronously in content process.
    * We can't create vsync-based timers during PBackground startup. This
    * function will be called when PBackgroundChild actor is created. Then we can
    * do the pending vsync-based timer creation.
    */
   static void PVsyncActorCreated(mozilla::layout::VsyncChild* aVsyncChild);
--- a/layout/style/CSSStyleRule.h
+++ b/layout/style/CSSStyleRule.h
@@ -46,29 +46,26 @@ class CSSStyleRuleDeclaration final : pu
   ~CSSStyleRuleDeclaration();
 
   inline CSSStyleRule* Rule();
   inline const CSSStyleRule* Rule() const;
 
   RefPtr<DeclarationBlock> mDecls;
 };
 
-class CSSStyleRule final : public BindingStyleRule,
-                           public SupportsWeakPtr<CSSStyleRule> {
+class CSSStyleRule final : public BindingStyleRule, public SupportsWeakPtr {
  public:
   CSSStyleRule(already_AddRefed<RawServoStyleRule> aRawRule, StyleSheet* aSheet,
                css::Rule* aParentRule, uint32_t aLine, uint32_t aColumn);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CSSStyleRule,
                                                          css::Rule)
   bool IsCCLeaf() const final MOZ_MUST_OVERRIDE;
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(CSSStyleRule)
-
   uint32_t GetSelectorCount() override;
   nsresult GetSelectorText(uint32_t aSelectorIndex, nsAString& aText) override;
   nsresult GetSpecificity(uint32_t aSelectorIndex,
                           uint64_t* aSpecificity) override;
   nsresult SelectorMatchesElement(dom::Element* aElement,
                                   uint32_t aSelectorIndex,
                                   const nsAString& aPseudo,
                                   bool aRelevantLinkVisited,
--- a/layout/style/SheetLoadData.h
+++ b/layout/style/SheetLoadData.h
@@ -34,18 +34,16 @@ namespace css {
  *********************************************/
 
 static_assert(eAuthorSheetFeatures == 0 && eUserSheetFeatures == 1 &&
                   eAgentSheetFeatures == 2,
               "sheet parsing mode constants won't fit "
               "in SheetLoadData::mParsingMode");
 
 class SheetLoadData final : public PreloaderBase,
-                            // FIXME(bug 1653011): This is a bit unfortunate.
-                            public SupportsWeakPtr<SheetLoadData>,
                             public nsIRunnable,
                             public nsIThreadObserver {
   using MediaMatched = dom::LinkStyle::MediaMatched;
   using IsAlternate = dom::LinkStyle::IsAlternate;
   using IsPreload = Loader::IsPreload;
   using UseSystemPrincipal = Loader::UseSystemPrincipal;
 
  protected:
--- a/mfbt/WeakPtr.h
+++ b/mfbt/WeakPtr.h
@@ -11,32 +11,27 @@
  * its lifetime. It works by creating a single shared reference counted object
  * (WeakReference) that each WeakPtr will access 'Foo' through. This lets 'Foo'
  * clear the pointer in the WeakReference without having to know about all of
  * the WeakPtrs to it and allows the WeakReference to live beyond the lifetime
  * of 'Foo'.
  *
  * PLEASE NOTE: This weak pointer implementation is not thread-safe.
  *
- * Note that when deriving from SupportsWeakPtr you should add
- * MOZ_DECLARE_WEAKREFERENCE_TYPENAME(ClassName) to the public section of your
- * class, where ClassName is the name of your class.
- *
  * The overhead of WeakPtr is that accesses to 'Foo' becomes an additional
  * dereference, and an additional heap allocated pointer sized object shared
  * between all of the WeakPtrs.
  *
  * Example of usage:
  *
  *   // To have a class C support weak pointers, inherit from
- *   // SupportsWeakPtr<C>.
- *   class C : public SupportsWeakPtr<C>
+ *   // SupportsWeakPtr
+ *   class C : public SupportsWeakPtr
  *   {
  *   public:
- *     MOZ_DECLARE_WEAKREFERENCE_TYPENAME(C)
  *     int mNum;
  *     void act();
  *   };
  *
  *   C* ptr = new C();
  *
  *   // Get weak pointers to ptr. The first time a weak pointer
  *   // is obtained, a reference counted WeakReference object is created that
@@ -57,16 +52,19 @@
  *   MOZ_ASSERT(!weak, "Deleting |ptr| clears weak pointers to it.");
  *   MOZ_ASSERT(!other, "Deleting |ptr| clears all weak pointers to it.");
  *
  * WeakPtr is typesafe and may be used with any class. It is not required that
  * the class be reference-counted or allocated in any particular way.
  *
  * The API was loosely inspired by Chromium's weak_ptr.h:
  * http://src.chromium.org/svn/trunk/src/base/memory/weak_ptr.h
+ *
+ * Note that multiple base classes inheriting from SupportsWeakPtr is not
+ * currently supported. We could support it if needed though.
  */
 
 #ifndef mozilla_WeakPtr_h
 #define mozilla_WeakPtr_h
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
@@ -80,17 +78,17 @@
 #if defined(MOZILLA_INTERNAL_API)
 // For thread safety checking.
 #  include "nsISupportsImpl.h"
 #endif
 
 #if defined(MOZILLA_INTERNAL_API) && \
     defined(MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED)
 
-// Weak referencing is not implemeted as thread safe.  When a WeakPtr
+// Weak referencing is not implemented as thread safe.  When a WeakPtr
 // is created or dereferenced on thread A but the real object is just
 // being Released() on thread B, there is a possibility of a race
 // when the proxy object (detail::WeakReference) is notified about
 // the real object destruction just between when thread A is storing
 // the object pointer locally and is about to add a reference to it.
 //
 // Hence, a non-null weak proxy object is considered to have a single
 // "owning thread".  It means that each query for a weak reference,
@@ -105,21 +103,21 @@
     /* Will be none if mPtr = nullptr. */         \
     Maybe<nsAutoOwningEventTarget> _owningThread;
 #  define MOZ_WEAKPTR_INIT_THREAD_SAFETY_CHECK() \
     do {                                         \
       if (p) {                                   \
         _owningThread.emplace();                 \
       }                                          \
     } while (false)
-#  define MOZ_WEAKPTR_ASSERT_THREAD_SAFETY()                                  \
-    do {                                                                      \
-      if (_owningThread.isSome() && !_owningThread.ref().IsCurrentThread()) { \
-        WeakPtrTraits<T>::AssertSafeToAccessFromNonOwningThread();            \
-      }                                                                       \
+#  define MOZ_WEAKPTR_ASSERT_THREAD_SAFETY()                  \
+    do {                                                      \
+      MOZ_DIAGNOSTIC_ASSERT(                                  \
+          !_owningThread || _owningThread->IsCurrentThread(), \
+          "WeakPtr accessed from multiple threads");          \
     } while (false)
 #  define MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED(that) \
     (that)->AssertThreadSafety();
 #  define MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED_IF(that) \
     do {                                                      \
       if (that) {                                             \
         (that)->AssertThreadSafety();                         \
       }                                                       \
@@ -144,121 +142,91 @@
     } while (false)
 
 #endif
 
 namespace mozilla {
 
 template <typename T>
 class WeakPtr;
-template <typename T>
 class SupportsWeakPtr;
 
-#ifdef MOZ_REFCOUNTED_LEAK_CHECKING
-#  define MOZ_DECLARE_WEAKREFERENCE_TYPENAME(T)  \
-    static const char* weakReferenceTypeName() { \
-      return "WeakReference<" #T ">";            \
-    }
-#else
-#  define MOZ_DECLARE_WEAKREFERENCE_TYPENAME(T)
-#endif
-
-template <class T>
-struct WeakPtrTraits {
-  static void AssertSafeToAccessFromNonOwningThread() {
-    MOZ_DIAGNOSTIC_ASSERT(false, "WeakPtr accessed from multiple threads");
-  }
-};
-
 namespace detail {
 
 // This can live beyond the lifetime of the class derived from
 // SupportsWeakPtr.
-template <class T>
-class WeakReference : public ::mozilla::RefCounted<WeakReference<T>> {
+class WeakReference : public ::mozilla::RefCounted<WeakReference> {
  public:
-  explicit WeakReference(T* p) : mPtr(p) {
+  explicit WeakReference(const SupportsWeakPtr* p)
+      : mPtr(const_cast<SupportsWeakPtr*>(p)) {
     MOZ_WEAKPTR_INIT_THREAD_SAFETY_CHECK();
   }
 
-  T* get() const {
+  SupportsWeakPtr* get() const {
     MOZ_WEAKPTR_ASSERT_THREAD_SAFETY();
     return mPtr;
   }
 
 #ifdef MOZ_REFCOUNTED_LEAK_CHECKING
-  const char* typeName() const {
-    // The first time this is called mPtr is null, so don't
-    // invoke any methods on mPtr.
-    return T::weakReferenceTypeName();
-  }
+  const char* typeName() const { return "WeakReference"; }
   size_t typeSize() const { return sizeof(*this); }
 #endif
 
 #ifdef MOZ_WEAKPTR_THREAD_SAFETY_CHECKING
   void AssertThreadSafety() { MOZ_WEAKPTR_ASSERT_THREAD_SAFETY(); }
 #endif
 
  private:
-  friend class mozilla::SupportsWeakPtr<T>;
+  friend class mozilla::SupportsWeakPtr;
 
   void detach() {
     MOZ_WEAKPTR_ASSERT_THREAD_SAFETY();
     mPtr = nullptr;
   }
 
-  T* MOZ_NON_OWNING_REF mPtr;
+  SupportsWeakPtr* MOZ_NON_OWNING_REF mPtr;
   MOZ_WEAKPTR_DECLARE_THREAD_SAFETY_CHECK
 };
 
 }  // namespace detail
 
-template <typename T>
 class SupportsWeakPtr {
+  using WeakReference = detail::WeakReference;
+
  protected:
   ~SupportsWeakPtr() {
-    static_assert(std::is_base_of<SupportsWeakPtr<T>, T>::value,
-                  "T must derive from SupportsWeakPtr<T>");
     DetachWeakPtr();
   }
 
  protected:
   void DetachWeakPtr() {
-    if (mSelfReferencingWeakPtr) {
-      mSelfReferencingWeakPtr.mRef->detach();
+    if (mSelfReferencingWeakReference) {
+      mSelfReferencingWeakReference->detach();
     }
   }
 
  private:
-  const WeakPtr<T>& SelfReferencingWeakPtr() {
-    if (!mSelfReferencingWeakPtr) {
-      mSelfReferencingWeakPtr.mRef =
-          new detail::WeakReference<T>(static_cast<T*>(this));
+  WeakReference* SelfReferencingWeakReference() const {
+    if (!mSelfReferencingWeakReference) {
+      mSelfReferencingWeakReference = new WeakReference(this);
     } else {
-      MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED(mSelfReferencingWeakPtr.mRef);
+      MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED(mSelfReferencingWeakReference);
     }
-    return mSelfReferencingWeakPtr;
+    return mSelfReferencingWeakReference.get();
   }
 
-  const WeakPtr<const T>& SelfReferencingWeakPtr() const {
-    const WeakPtr<T>& p =
-        const_cast<SupportsWeakPtr*>(this)->SelfReferencingWeakPtr();
-    return reinterpret_cast<const WeakPtr<const T>&>(p);
-  }
+  template <typename U>
+  friend class WeakPtr;
 
-  friend class WeakPtr<T>;
-  friend class WeakPtr<const T>;
-
-  WeakPtr<T> mSelfReferencingWeakPtr;
+  mutable RefPtr<WeakReference> mSelfReferencingWeakReference;
 };
 
 template <typename T>
 class WeakPtr {
-  typedef detail::WeakReference<T> WeakReference;
-  using NonConstT = std::remove_const_t<T>;
+  using WeakReference = detail::WeakReference;
 
  public:
   WeakPtr& operator=(const WeakPtr& aOther) {
     // We must make sure the reference we have now is safe to be dereferenced
     // before we throw it away... (this can be called from a ctor)
     MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED_IF(mRef);
     // ...and make sure the new reference is used on a single thread as well.
     MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED(aOther.mRef);
@@ -278,62 +246,46 @@ class WeakPtr {
     MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED_IF(mRef);
     if (!mRef || mRef->get()) {
       // Ensure that mRef is dereferenceable in the uninitialized state.
       mRef = new WeakReference(nullptr);
     }
     return *this;
   }
 
-  WeakPtr& operator=(SupportsWeakPtr<NonConstT> const* aOther) {
+  WeakPtr& operator=(const T* aOther) {
     // We must make sure the reference we have now is safe to be dereferenced
     // before we throw it away.
     MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED_IF(mRef);
     if (aOther) {
-      *this = aOther->SelfReferencingWeakPtr();
-    } else if (!mRef || mRef->get()) {
-      // Ensure that mRef is dereferenceable in the uninitialized state.
-      mRef = new WeakReference(nullptr);
-    }
-    // The thread safety check happens inside SelfReferencingWeakPtr
-    // or is initialized in the WeakReference constructor.
-    return *this;
-  }
-
-  WeakPtr& operator=(SupportsWeakPtr<NonConstT>* aOther) {
-    // We must make sure the reference we have now is safe to be dereferenced
-    // before we throw it away.
-    MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED_IF(mRef);
-    if (aOther) {
-      *this = aOther->SelfReferencingWeakPtr();
+      mRef = aOther->SelfReferencingWeakReference();
     } else if (!mRef || mRef->get()) {
       // Ensure that mRef is dereferenceable in the uninitialized state.
       mRef = new WeakReference(nullptr);
     }
     // The thread safety check happens inside SelfReferencingWeakPtr
     // or is initialized in the WeakReference constructor.
     return *this;
   }
 
   MOZ_IMPLICIT WeakPtr(T* aOther) { *this = aOther; }
 
   // Ensure that mRef is dereferenceable in the uninitialized state.
   WeakPtr() : mRef(new WeakReference(nullptr)) {}
 
-  operator T*() const { return mRef->get(); }
-  T& operator*() const { return *mRef->get(); }
-
-  T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return mRef->get(); }
-
-  T* get() const { return mRef->get(); }
+  explicit operator bool() const { return mRef->get(); }
+  T* get() const { return static_cast<T*>(mRef->get()); }
+  operator T*() const { return get(); }
+  T& operator*() const { return *get(); }
+  T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return get(); }
 
   ~WeakPtr() { MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED(mRef); }
 
  private:
-  friend class SupportsWeakPtr<T>;
+  friend class SupportsWeakPtr;
 
   explicit WeakPtr(const RefPtr<WeakReference>& aOther) : mRef(aOther) {}
 
   RefPtr<WeakReference> mRef;
 };
 
 #define NS_IMPL_CYCLE_COLLECTION_UNLINK_WEAK_PTR tmp->DetachWeakPtr();
 
--- a/mfbt/tests/TestWeakPtr.cpp
+++ b/mfbt/tests/TestWeakPtr.cpp
@@ -7,28 +7,25 @@
 #include "mozilla/WeakPtr.h"
 
 using mozilla::SupportsWeakPtr;
 using mozilla::WeakPtr;
 
 static char IamB[] = "B";
 static char IamC[] = "C";
 static char IamD[] = "D";
-static char IamE[] = "E";
 
-class B : public SupportsWeakPtr<B> {
+class B : public SupportsWeakPtr {
  public:
   char const* whoAmI() const { return IamB; }
 };
 
-// To have a class C support weak pointers, inherit from SupportsWeakPtr<C>.
-class C : public SupportsWeakPtr<C> {
+// To have a class C support weak pointers, inherit from SupportsWeakPtr.
+class C : public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(C)
-
   int mNum;
 
   C() : mNum(0) {}
 
   ~C() {
     // Setting mNum in the destructor allows us to test against use-after-free
     // below
     mNum = 0xDEAD;
@@ -38,29 +35,23 @@ class C : public SupportsWeakPtr<C> {
 
   void act() {}
 
   bool isConst() { return false; }
 
   bool isConst() const { return true; }
 };
 
-// Supports weakptr for two base classes (B and C) and itself (D)
-class D : public B, public C, public SupportsWeakPtr<D> {
+// Derived from a class that supports weakptr, but doesn't implement itself
+// To check upcast works as expected
+class D : public B {
  public:
   char const* whoAmI() const { return IamD; }
 };
 
-// Derived from a class that supports weakptr, but doesn't implement itself
-// To check upcast works as expected
-class E : public D {
- public:
-  char const* whoAmI() const { return IamE; }
-};
-
 bool isConst(C*) { return false; }
 
 bool isConst(const C*) { return true; }
 
 int main() {
   C* c1 = new C;
   MOZ_RELEASE_ASSERT(c1->mNum == 0);
 
@@ -131,43 +122,24 @@ int main() {
                      "Deleting an object should clear WeakPtr's to it.");
   MOZ_RELEASE_ASSERT(w2,
                      "Deleting an object should not clear WeakPtr that are not "
                      "pointing to it.");
 
   delete c2;
   MOZ_RELEASE_ASSERT(!w2, "Deleting an object should clear WeakPtr's to it.");
 
-  // Testing multiple base classes weak pointer support
+  // Check that we correctly upcast to the base class supporting weakptr
   D* d = new D;
-  WeakPtr<D> dd = d;
-  WeakPtr<const D> ddconst = d;
-  WeakPtr<C> dc = d;
-  WeakPtr<const C> dcconst = d;
   WeakPtr<B> db = d;
-  WeakPtr<const B> dbconst = d;
 
-  MOZ_RELEASE_ASSERT(dd->whoAmI() == IamD);
-  MOZ_RELEASE_ASSERT(ddconst->whoAmI() == IamD);
-  MOZ_RELEASE_ASSERT(dc->whoAmI() == IamC);
-  MOZ_RELEASE_ASSERT(dcconst->whoAmI() == IamC);
+  // You should be able to use WeakPtr<D> even if it's a base class which
+  // implements SupportsWeakPtr.
+  WeakPtr<D> weakd = d;
+
   MOZ_RELEASE_ASSERT(db->whoAmI() == IamB);
-  MOZ_RELEASE_ASSERT(dbconst->whoAmI() == IamB);
+  MOZ_RELEASE_ASSERT(weakd.get() == db.get());
 
   delete d;
 
-  MOZ_RELEASE_ASSERT(!dd);
-  MOZ_RELEASE_ASSERT(!ddconst);
-  MOZ_RELEASE_ASSERT(!dc);
-  MOZ_RELEASE_ASSERT(!dcconst);
   MOZ_RELEASE_ASSERT(!db);
-  MOZ_RELEASE_ASSERT(!dbconst);
-
-  // Check that we correctly upcast to the base class supporting weakptr
-  E* e = new E;
-  WeakPtr<D> ed = e;
-
-  MOZ_RELEASE_ASSERT(ed->whoAmI() == IamD);
-
-  delete e;
-
-  MOZ_RELEASE_ASSERT(!ed);
+  MOZ_RELEASE_ASSERT(!weakd);
 }
--- a/netwerk/protocol/http/Http2Stream.h
+++ b/netwerk/protocol/http/Http2Stream.h
@@ -26,19 +26,18 @@ namespace mozilla {
 namespace net {
 
 class nsStandardURL;
 class Http2Session;
 class Http2Decompressor;
 
 class Http2Stream : public nsAHttpSegmentReader,
                     public nsAHttpSegmentWriter,
-                    public SupportsWeakPtr<Http2Stream> {
+                    public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(Http2Stream)
   NS_DECL_NSAHTTPSEGMENTREADER
   NS_DECL_NSAHTTPSEGMENTWRITER
 
   enum stateType {
     IDLE,
     RESERVED_BY_REMOTE,
     OPEN,
     CLOSED_BY_LOCAL,
--- a/netwerk/sctp/datachannel/DataChannel.h
+++ b/netwerk/sctp/datachannel/DataChannel.h
@@ -125,21 +125,18 @@ class DataChannelConnection final : publ
   enum {
     PENDING_NONE = 0U,  // No outgoing messages are pending
     PENDING_DCEP = 1U,  // Outgoing DCEP messages are pending
     PENDING_DATA = 2U,  // Outgoing data channel messages are pending
   };
 
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DataChannelConnection)
 
-  class DataConnectionListener
-      : public SupportsWeakPtr<DataConnectionListener> {
+  class DataConnectionListener : public SupportsWeakPtr {
    public:
-    MOZ_DECLARE_WEAKREFERENCE_TYPENAME(
-        DataChannelConnection::DataConnectionListener)
     virtual ~DataConnectionListener() = default;
 
     // Called when a new DataChannel has been opened by the other side.
     virtual void NotifyDataChannel(already_AddRefed<DataChannel> channel) = 0;
   };
 
   // Create a new DataChannel Connection
   // Must be called on Main thread
--- a/toolkit/components/extensions/WebExtensionPolicy.h
+++ b/toolkit/components/extensions/WebExtensionPolicy.h
@@ -31,21 +31,20 @@ namespace extensions {
 using dom::WebExtensionInit;
 using dom::WebExtensionLocalizeCallback;
 
 class DocInfo;
 class WebExtensionContentScript;
 
 class WebExtensionPolicy final : public nsISupports,
                                  public nsWrapperCache,
-                                 public SupportsWeakPtr<WebExtensionPolicy> {
+                                 public SupportsWeakPtr {
  public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebExtensionPolicy)
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebExtensionPolicy)
 
   using ScriptArray = nsTArray<RefPtr<WebExtensionContentScript>>;
 
   static already_AddRefed<WebExtensionPolicy> Constructor(
       dom::GlobalObject& aGlobal, const WebExtensionInit& aInit,
       ErrorResult& aRv);
 
   nsAtom* Id() const { return mId; }
--- a/toolkit/components/extensions/webrequest/ChannelWrapper.h
+++ b/toolkit/components/extensions/webrequest/ChannelWrapper.h
@@ -105,21 +105,20 @@ struct ChannelHolder {
   mutable nsIChannel* MOZ_NON_OWNING_REF mWeakChannel;
   mutable Maybe<nsIHttpChannel*> MOZ_NON_OWNING_REF mWeakHttpChannel;
 };
 }  // namespace detail
 
 class WebRequestChannelEntry;
 
 class ChannelWrapper final : public DOMEventTargetHelper,
-                             public SupportsWeakPtr<ChannelWrapper>,
+                             public SupportsWeakPtr,
                              public LinkedListElement<ChannelWrapper>,
                              private detail::ChannelHolder {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(ChannelWrapper)
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(ChannelWrapper,
                                                          DOMEventTargetHelper)
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_CHANNELWRAPPER_IID)
 
   void Die();
 
--- a/toolkit/components/places/INativePlacesEventCallback.h
+++ b/toolkit/components/places/INativePlacesEventCallback.h
@@ -9,22 +9,20 @@
 #include "mozilla/dom/PlacesObserversBinding.h"
 #include "mozilla/WeakPtr.h"
 #include "nsISupports.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 namespace places {
 
-class INativePlacesEventCallback
-    : public SupportsWeakPtr<INativePlacesEventCallback> {
+class INativePlacesEventCallback : public SupportsWeakPtr {
  public:
   typedef dom::Sequence<OwningNonNull<dom::PlacesEvent>> PlacesEventSequence;
 
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(INativePlacesEventCallback)
   NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual void HandlePlacesEvent(const PlacesEventSequence& aEvents) = 0;
 
  protected:
   virtual ~INativePlacesEventCallback() = default;
 };
 
--- a/uriloader/prefetch/nsOfflineCacheUpdate.h
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.h
@@ -178,20 +178,18 @@ class nsOfflineManifestItem : public nsO
 
   // manifest hash data
   nsCOMPtr<nsICryptoHash> mManifestHash;
   bool mManifestHashInitialized;
   nsCString mManifestHashValue;
   nsCString mOldManifestHashValue;
 };
 
-class nsOfflineCacheUpdateOwner
-    : public mozilla::SupportsWeakPtr<nsOfflineCacheUpdateOwner> {
+class nsOfflineCacheUpdateOwner : public mozilla::SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsOfflineCacheUpdateOwner)
   virtual ~nsOfflineCacheUpdateOwner() {}
   virtual nsresult UpdateFinished(nsOfflineCacheUpdate* aUpdate) = 0;
 };
 
 class nsOfflineCacheUpdate final : public nsIOfflineCacheUpdate,
                                    public nsIOfflineCacheUpdateObserver,
                                    public nsIRunnable,
                                    public nsOfflineCacheUpdateOwner {
--- a/uriloader/preload/PreloaderBase.h
+++ b/uriloader/preload/PreloaderBase.h
@@ -34,20 +34,18 @@ class Document;
  * A half-abstract base class that resource loaders' respective
  * channel-listening classes should derive from.  Provides a unified API to
  * register the load or preload in a document scoped service, links <link
  * rel="preload"> DOM nodes with the load progress and provides API to possibly
  * consume the data by later, dynamically discovered consumers.
  *
  * This class is designed to be used only on the main thread.
  */
-class PreloaderBase : public SupportsWeakPtr<PreloaderBase>,
-                      public nsISupports {
+class PreloaderBase : public SupportsWeakPtr, public nsISupports {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PreloaderBase)
   PreloaderBase() = default;
 
   // Called by resource loaders to register this preload in the document's
   // preload service to provide coalescing, and access to the preload when it
   // should be used for an actual load.
   void NotifyOpen(const PreloadHashKey& aKey, dom::Document* aDocument,
                   bool aIsPreload);
   void NotifyOpen(const PreloadHashKey& aKey, nsIChannel* aChannel,
--- a/widget/android/jni/Natives.h
+++ b/widget/android/jni/Natives.h
@@ -48,29 +48,28 @@ namespace jni {
  *
  * * If the C++ class inherits from mozilla::SupportsWeakPtr, weak pointers
  *   will be used. The Java instance will store and own the pointer to a
  *   WeakPtr object. The C++ class itself is otherwise not owned or directly
  *   referenced. Note that mozilla::SupportsWeakPtr only supports being used on
  *   a single thread. To attach a Java instance to a C++ instance, pass in a
  *   mozilla::SupportsWeakPtr pointer to the C++ class (i.e. MyClass*).
  *
- *   class MyClass : public SupportsWeakPtr<MyClass>
+ *   class MyClass : public SupportsWeakPtr
  *                 , public MyJavaClass::Natives<MyClass>
  *   {
  *       // ...
  *
  *   public:
- *       MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MyClass)
  *       using MyJavaClass::Natives<MyClass>::DisposeNative;
  *
  *       void AttachTo(const MyJavaClass::LocalRef& instance)
  *       {
  *           MyJavaClass::Natives<MyClass>::AttachNative(
- *                   instance, static_cast<SupportsWeakPtr<MyClass>*>(this));
+ *                   instance, static_cast<SupportsWeakPtr*>(this));
  *
  *           // "instance" does NOT own "this", so the C++ object
  *           // lifetime is separate from the Java object lifetime.
  *       }
  *   };
  *
  * * If the C++ class contains public members AddRef() and Release(), the Java
  *   instance will store and own the pointer to a RefPtr object, which holds a
@@ -123,17 +122,17 @@ namespace jni {
 
 namespace detail {
 
 enum NativePtrType { OWNING, WEAK, REFPTR };
 
 template <class Impl>
 class NativePtrPicker {
   template <class I>
-  static std::enable_if_t<std::is_base_of<SupportsWeakPtr<I>, I>::value,
+  static std::enable_if_t<std::is_base_of<SupportsWeakPtr, I>::value,
                           char (&)[NativePtrType::WEAK]>
   Test(char);
 
   template <class I, typename = decltype(&I::AddRef, &I::Release)>
   static char (&Test(int))[NativePtrType::REFPTR];
 
   template <class>
   static char (&Test(...))[NativePtrType::OWNING];
@@ -763,17 +762,17 @@ class NativeImpl {
         sizeof(Natives::methods) / sizeof(Natives::methods[0]));
     MOZ_CATCH_JNI_EXCEPTION(ctx.Env());
     sInited = true;
   }
 
  protected:
   // Associate a C++ instance with a Java instance.
   static void AttachNative(const typename Cls::LocalRef& instance,
-                           SupportsWeakPtr<Impl>* ptr) {
+                           SupportsWeakPtr* ptr) {
     static_assert(NativePtrPicker<Impl>::value == NativePtrType::WEAK,
                   "Use another AttachNative for non-WeakPtr usage");
     return NativePtr<Impl>::Set(instance, static_cast<Impl*>(ptr));
   }
 
   static void AttachNative(const typename Cls::LocalRef& instance,
                            UniquePtr<Impl>&& ptr) {
     static_assert(NativePtrPicker<Impl>::value == NativePtrType::OWNING,
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -291,30 +291,27 @@ class nsWindow::NativePtr<Impl>::Locked 
       : MutexAutoLock(aPtr.mImplLock), mImpl(aPtr.mImpl) {}
 
   operator Impl*() const { return mImpl; }
   Impl* operator->() const { return mImpl; }
 };
 
 class nsWindow::GeckoViewSupport final
     : public GeckoSession::Window::Natives<GeckoViewSupport>,
-      public SupportsWeakPtr<GeckoViewSupport> {
+      public SupportsWeakPtr {
   nsWindow& window;
 
   // We hold a WeakRef because we want to allow the
   // GeckoSession.Window to be garbage collected.
   // Callers need to create a LocalRef from this
   // before calling methods.
   GeckoSession::Window::WeakRef mGeckoViewWindow;
 
  public:
   typedef GeckoSession::Window::Natives<GeckoViewSupport> Base;
-  typedef SupportsWeakPtr<GeckoViewSupport> SupportsWeakPtr;
-
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(GeckoViewSupport);
 
   template <typename Functor>
   static void OnNativeCall(Functor&& aCall) {
     NS_DispatchToMainThread(new WindowEvent<Functor>(std::move(aCall)));
   }
 
   GeckoViewSupport(nsWindow* aWindow,
                    const GeckoSession::Window::LocalRef& aInstance)
--- a/xpcom/base/nsMessageLoop.cpp
+++ b/xpcom/base/nsMessageLoop.cpp
@@ -22,20 +22,18 @@ namespace {
 /**
  * This Task runs its nsIRunnable when Run() is called, or after
  * aEnsureRunsAfterMS milliseconds have elapsed since the object was
  * constructed.
  *
  * Note that the MessageLoop owns this object and will delete it after it calls
  * Run().  Tread lightly.
  */
-class MessageLoopIdleTask : public Runnable,
-                            public SupportsWeakPtr<MessageLoopIdleTask> {
+class MessageLoopIdleTask : public Runnable, public SupportsWeakPtr {
  public:
-  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MessageLoopIdleTask)
   MessageLoopIdleTask(nsIRunnable* aTask, uint32_t aEnsureRunsAfterMS);
   NS_IMETHOD Run() override;
 
  private:
   nsresult Init(uint32_t aEnsureRunsAfterMS);
 
   nsCOMPtr<nsIRunnable> mTask;
   nsCOMPtr<nsITimer> mTimer;