Backed out changeset 4bcb784492bb (bug 1268313)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Fri, 29 Apr 2016 14:21:18 +0200
changeset 295443 c6884584fa07940f3b84fd4a7f33622def0b9431
parent 295442 9979c96310a07ada1d91c166027c0829bea264d2
child 295444 4bd91d8dd4f5e38bb9d4ced0ee9203c6251525a8
push idunknown
push userunknown
push dateunknown
bugs1268313
milestone49.0a1
backs out4bcb784492bb8d26a13a234cdf581b0badbf21e6
Backed out changeset 4bcb784492bb (bug 1268313)
dom/ipc/ContentBridgeChild.cpp
dom/ipc/ContentBridgeParent.cpp
dom/ipc/ContentBridgeParent.h
dom/ipc/ContentParent.cpp
dom/ipc/PreallocatedProcessManager.cpp
dom/media/gmp/GMPDecryptorChild.cpp
dom/media/gmp/GMPPlatform.cpp
dom/media/gmp/GMPStorageChild.cpp
dom/media/gmp/GMPVideoDecoderChild.cpp
dom/media/gmp/GMPVideoEncoderChild.cpp
dom/media/systemservices/MediaSystemResourceManager.cpp
gfx/layers/apz/src/APZCTreeManager.cpp
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/InputQueue.cpp
gfx/layers/apz/util/APZCCallbackHelper.cpp
gfx/layers/apz/util/APZCCallbackHelper.h
gfx/layers/apz/util/ChromeProcessController.cpp
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/RemoteContentController.cpp
gfx/thebes/SoftwareVsyncSource.cpp
gfx/vr/ipc/VRManagerParent.cpp
ipc/chromium/src/base/task.h
widget/nsBaseWidget.cpp
xpcom/base/nsDumpUtils.cpp
xpcom/base/nsDumpUtils.h
--- a/dom/ipc/ContentBridgeChild.cpp
+++ b/dom/ipc/ContentBridgeChild.cpp
@@ -29,18 +29,18 @@ ContentBridgeChild::~ContentBridgeChild(
 {
   RefPtr<DeleteTask<Transport>> task = new DeleteTask<Transport>(mTransport);
   XRE_GetIOMessageLoop()->PostTask(task.forget());
 }
 
 void
 ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
 {
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy);
-  MessageLoop::current()->PostTask(runnable.forget());
+  MessageLoop::current()->PostTask(
+    NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy));
 }
 
 /*static*/ ContentBridgeChild*
 ContentBridgeChild::Create(Transport* aTransport, ProcessId aOtherPid)
 {
   RefPtr<ContentBridgeChild> bridge =
     new ContentBridgeChild(aTransport);
   bridge->mSelfRef = bridge;
--- a/dom/ipc/ContentBridgeParent.cpp
+++ b/dom/ipc/ContentBridgeParent.cpp
@@ -32,18 +32,18 @@ ContentBridgeParent::~ContentBridgeParen
 
 void
 ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os) {
     os->RemoveObserver(this, "content-child-shutdown");
   }
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy);
-  MessageLoop::current()->PostTask(runnable.forget());
+  MessageLoop::current()->PostTask(
+    NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy));
 }
 
 /*static*/ ContentBridgeParent*
 ContentBridgeParent::Create(Transport* aTransport, ProcessId aOtherPid)
 {
   RefPtr<ContentBridgeParent> bridge =
     new ContentBridgeParent(aTransport);
   bridge->mSelfRef = bridge;
@@ -163,18 +163,18 @@ ContentBridgeParent::DeallocPBrowserPare
   return nsIContentParent::DeallocPBrowserParent(aParent);
 }
 
 void
 ContentBridgeParent::NotifyTabDestroyed()
 {
   int32_t numLiveTabs = ManagedPBrowserParent().Count();
   if (numLiveTabs == 1) {
-    RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ContentBridgeParent::Close);
-    MessageLoop::current()->PostTask(runnable.forget());
+    MessageLoop::current()->PostTask(
+      NewRunnableMethod(this, &ContentBridgeParent::Close));
   }
 }
 
 // This implementation is identical to ContentParent::GetCPOWManager but we can't
 // move it to nsIContentParent because it calls ManagedPJavaScriptParent() which
 // only exists in PContentParent and PContentBridgeParent.
 jsipc::CPOWManager*
 ContentBridgeParent::GetCPOWManager()
--- a/dom/ipc/ContentBridgeParent.h
+++ b/dom/ipc/ContentBridgeParent.h
@@ -74,22 +74,16 @@ protected:
     mIsForApp = aIsForApp;
   }
 
   void SetIsForBrowser(bool aIsForBrowser)
   {
     mIsForBrowser = aIsForBrowser;
   }
 
-  void Close()
-  {
-    // Trick NS_NewRunnableMethod
-    PContentBridgeParent::Close();
-  }
-
 protected:
   virtual bool
   RecvSyncMessage(const nsString& aMsg,
                   const ClonedMessageData& aData,
                   InfallibleTArray<jsipc::CpowEntry>&& aCpows,
                   const IPC::Principal& aPrincipal,
                   nsTArray<StructuredCloneData>* aRetvals) override;
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2172,20 +2172,19 @@ ContentParent::ActorDestroy(ActorDestroy
       }
     }
     }
   }
 
   // Destroy any processes created by this ContentParent
   for(uint32_t i = 0; i < childIDArray.Length(); i++) {
     ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]);
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<ShutDownMethod>(cp, &ContentParent::ShutDownProcess,
-                                                   SEND_SHUTDOWN_MESSAGE);
-    MessageLoop::current()->PostTask(runnable.forget());
+    MessageLoop::current()->PostTask(
+      NewRunnableMethod(cp, &ContentParent::ShutDownProcess,
+                        SEND_SHUTDOWN_MESSAGE));
   }
   cpm->RemoveContentProcess(this->ChildID());
 
   if (mDriverCrashGuard) {
     mDriverCrashGuard->NotifyCrashed();
   }
 }
 
@@ -2256,20 +2255,19 @@ ContentParent::NotifyTabDestroyed(const 
   // There can be more than one PBrowser for a given app process
   // because of popup windows.  When the last one closes, shut
   // us down.
   ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
   nsTArray<TabId> tabIds = cpm->GetTabParentsByProcessId(this->ChildID());
   if (tabIds.Length() == 1) {
     // In the case of normal shutdown, send a shutdown message to child to
     // allow it to perform shutdown tasks.
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<ShutDownMethod>(this, &ContentParent::ShutDownProcess,
-                                                   SEND_SHUTDOWN_MESSAGE);
-    MessageLoop::current()->PostTask(runnable.forget());
+    MessageLoop::current()->PostTask(
+      NewRunnableMethod(this, &ContentParent::ShutDownProcess,
+                        SEND_SHUTDOWN_MESSAGE));
   }
 }
 
 jsipc::CPOWManager*
 ContentParent::GetCPOWManager()
 {
   if (PJavaScriptParent* p = LoneManagedOrNullAsserts(ManagedPJavaScriptParent())) {
     return CPOWManagerFor(p);
--- a/dom/ipc/PreallocatedProcessManager.cpp
+++ b/dom/ipc/PreallocatedProcessManager.cpp
@@ -199,32 +199,31 @@ PreallocatedProcessManagerImpl::Enable()
 
 void
 PreallocatedProcessManagerImpl::AllocateAfterDelay()
 {
   if (!mEnabled || mPreallocatedAppProcess) {
     return;
   }
 
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle);
   MessageLoop::current()->PostDelayedTask(
-    runnable.forget(),
+    NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle),
     Preferences::GetUint("dom.ipc.processPrelaunch.delayMs",
                          DEFAULT_ALLOCATE_DELAY));
 }
 
 void
 PreallocatedProcessManagerImpl::AllocateOnIdle()
 {
   if (!mEnabled || mPreallocatedAppProcess) {
     return;
   }
 
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow);
-  MessageLoop::current()->PostIdleTask(runnable.forget());
+  MessageLoop::current()->PostIdleTask(
+    NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow));
 }
 
 void
 PreallocatedProcessManagerImpl::AllocateNow()
 {
   if (!mEnabled || mPreallocatedAppProcess) {
     return;
   }
@@ -239,17 +238,17 @@ PreallocatedProcessManagerImpl::Schedule
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mPreallocateAppProcessTask) {
     // Make sure there is only one request running.
     return;
   }
 
-  RefPtr<CancelableTask> task = NS_NewCancelableRunnableMethod(
+  RefPtr<CancelableTask> task = NewRunnableMethod(
     this, &PreallocatedProcessManagerImpl::DelayedNuwaFork);
   mPreallocateAppProcessTask = task;
   MessageLoop::current()->PostDelayedTask(task.forget(),
     Preferences::GetUint("dom.ipc.processPrelaunch.delayMs",
                          DEFAULT_ALLOCATE_DELAY));
 }
 
 void
--- a/dom/media/gmp/GMPDecryptorChild.cpp
+++ b/dom/media/gmp/GMPDecryptorChild.cpp
@@ -56,18 +56,17 @@ GMPDecryptorChild::CallOnGMPThread(Metho
 {
   if (ON_GMP_THREAD()) {
     // Use forwarding reference when we can.
     CallMethod(aMethod, Forward<ParamType>(aParams)...);
   } else {
     // Use const reference when we have to.
     auto m = &GMPDecryptorChild::CallMethod<
         decltype(aMethod), typename AddConstReference<ParamType>::Type...>;
-    RefPtr<mozilla::Runnable> t =
-      dont_add_new_uses_of_this::NewRunnableMethod(this, m, aMethod, Forward<ParamType>(aParams)...);
+    RefPtr<mozilla::Runnable> t = NewRunnableMethod(this, m, aMethod, Forward<ParamType>(aParams)...);
     mPlugin->GMPMessageLoop()->PostTask(t.forget());
   }
 }
 
 void
 GMPDecryptorChild::Init(GMPDecryptor* aSession)
 {
   MOZ_ASSERT(aSession);
@@ -166,21 +165,17 @@ GMPDecryptorChild::KeyStatusChanged(cons
 }
 
 void
 GMPDecryptorChild::Decrypted(GMPBuffer* aBuffer, GMPErr aResult)
 {
   if (!ON_GMP_THREAD()) {
     // We should run this whole method on the GMP thread since the buffer needs
     // to be deleted after the SendDecrypted call.
-    RefPtr<Runnable> t =
-      NS_NewRunnableMethodWithArgs<GMPBuffer*,
-                                   GMPErr>(this,
-                                           &GMPDecryptorChild::Decrypted,
-                                           aBuffer, aResult);
+    RefPtr<Runnable> t = NewRunnableMethod(this, &GMPDecryptorChild::Decrypted, aBuffer, aResult);
     mPlugin->GMPMessageLoop()->PostTask(t.forget());
     return;
   }
 
   if (!aBuffer) {
     NS_WARNING("GMPDecryptorCallback passed bull GMPBuffer");
     return;
   }
--- a/dom/media/gmp/GMPPlatform.cpp
+++ b/dom/media/gmp/GMPPlatform.cpp
@@ -68,18 +68,17 @@ public:
   void Post()
   {
     // We assert here for two reasons.
     // 1) Nobody should be blocking the main thread.
     // 2) This prevents deadlocks when doing sync calls to main which if the
     //    main thread tries to do a sync call back to the calling thread.
     MOZ_ASSERT(!IsOnChildMainThread());
 
-    RefPtr<mozilla::Runnable> runnable = NS_NewRunnableMethod(this, &SyncRunnable::Run);
-    mMessageLoop->PostTask(runnable.forget());
+    mMessageLoop->PostTask(NewRunnableMethod(this, &SyncRunnable::Run));
     MonitorAutoLock lock(mMonitor);
     while (!mDone) {
       lock.Wait();
     }
   }
 
   void Run()
   {
@@ -117,18 +116,17 @@ CreateThread(GMPThread** aThread)
 GMPErr
 RunOnMainThread(GMPTask* aTask)
 {
   if (!aTask || !sMainLoop) {
     return GMPGenericErr;
   }
 
   RefPtr<Runnable> r = new Runnable(aTask);
-  RefPtr<mozilla::Runnable> runnable = NS_NewRunnableMethod(r, &Runnable::Run);
-  sMainLoop->PostTask(runnable.forget());
+  sMainLoop->PostTask(NewRunnableMethod(r.get(), &Runnable::Run));
 
   return GMPNoErr;
 }
 
 GMPErr
 SyncRunOnMainThread(GMPTask* aTask)
 {
   if (!aTask || !sMainLoop || IsOnChildMainThread()) {
@@ -250,18 +248,18 @@ GMPThreadImpl::Post(GMPTask* aTask)
     bool started = mThread.Start();
     if (!started) {
       NS_WARNING("Unable to start GMPThread!");
       return;
     }
   }
 
   RefPtr<Runnable> r = new Runnable(aTask);
-  RefPtr<mozilla::Runnable> runnable = NS_NewRunnableMethod(r, &Runnable::Run);
-  mThread.message_loop()->PostTask(runnable.forget());
+
+  mThread.message_loop()->PostTask(NewRunnableMethod(r.get(), &Runnable::Run));
 }
 
 void
 GMPThreadImpl::Join()
 {
   {
     MutexAutoLock lock(mMutex);
     if (mThread.IsRunning()) {
--- a/dom/media/gmp/GMPStorageChild.cpp
+++ b/dom/media/gmp/GMPStorageChild.cpp
@@ -10,17 +10,17 @@
 #define ON_GMP_THREAD() (mPlugin->GMPMessageLoop() == MessageLoop::current())
 
 #define CALL_ON_GMP_THREAD(_func, ...) \
   do { \
     if (ON_GMP_THREAD()) { \
       _func(__VA_ARGS__); \
     } else { \
       mPlugin->GMPMessageLoop()->PostTask( \
-        dont_add_new_uses_of_this::NewRunnableMethod(this, &GMPStorageChild::_func, ##__VA_ARGS__) \
+        NewRunnableMethod(this, &GMPStorageChild::_func, ##__VA_ARGS__) \
       ); \
     } \
   } while(false)
 
 static nsTArray<uint8_t>
 ToArray(const uint8_t* aData, uint32_t aDataSize)
 {
   nsTArray<uint8_t> data;
--- a/dom/media/gmp/GMPVideoDecoderChild.cpp
+++ b/dom/media/gmp/GMPVideoDecoderChild.cpp
@@ -221,18 +221,17 @@ GMPVideoDecoderChild::Alloc(size_t aSize
   MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current());
 
   bool rv;
 #ifndef SHMEM_ALLOC_IN_CHILD
   ++mNeedShmemIntrCount;
   rv = CallNeedShmem(aSize, aMem);
   --mNeedShmemIntrCount;
   if (mPendingDecodeComplete) {
-    RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete);
-    mPlugin->GMPMessageLoop()->PostTask(runnable.forget());
+    mPlugin->GMPMessageLoop()->PostTask(NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete));
   }
 #else
 #ifdef GMP_SAFE_SHMEM
   rv = AllocShmem(aSize, aType, aMem);
 #else
   rv = AllocUnsafeShmem(aSize, aType, aMem);
 #endif
 #endif
--- a/dom/media/gmp/GMPVideoEncoderChild.cpp
+++ b/dom/media/gmp/GMPVideoEncoderChild.cpp
@@ -202,18 +202,17 @@ GMPVideoEncoderChild::Alloc(size_t aSize
   MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current());
 
   bool rv;
 #ifndef SHMEM_ALLOC_IN_CHILD
   ++mNeedShmemIntrCount;
   rv = CallNeedShmem(aSize, aMem);
   --mNeedShmemIntrCount;
   if (mPendingEncodeComplete) {
-    RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete);
-    mPlugin->GMPMessageLoop()->PostTask(runnable.forget());
+    mPlugin->GMPMessageLoop()->PostTask(NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete));
   }
 #else
 #ifdef GMP_SAFE_SHMEM
   rv = AllocShmem(aSize, aType, aMem);
 #else
   rv = AllocUnsafeShmem(aSize, aType, aMem);
 #endif
 #endif
--- a/dom/media/systemservices/MediaSystemResourceManager.cpp
+++ b/dom/media/systemservices/MediaSystemResourceManager.cpp
@@ -193,22 +193,21 @@ MediaSystemResourceManager::Acquire(Medi
     return;
   }
   // State Check
   if (aClient->mResourceState != MediaSystemResourceClient::RESOURCE_STATE_START) {
     HandleAcquireResult(aClient->mId, false);
     return;
   }
   aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING;
-  RefPtr<Runnable> runnable =
-    NS_NewRunnableMethodWithArgs<uint32_t>(
+  ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
+    NewRunnableMethod(
       this,
       &MediaSystemResourceManager::DoAcquire,
-      aClient->mId);
-  ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget());
+      aClient->mId));
 }
 
 bool
 MediaSystemResourceManager::AcquireSyncNoWait(MediaSystemResourceClient* aClient)
 {
   MOZ_ASSERT(aClient);
   MOZ_ASSERT(!InImageBridgeChildThread());
 
@@ -237,22 +236,21 @@ MediaSystemResourceManager::AcquireSyncN
       return false;
     }
     // Hold barrier Monitor until acquire task end.
     aClient->mAcquireSyncWaitMonitor = &barrier;
     aClient->mAcquireSyncWaitDone = &done;
     aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING;
   }
 
-  RefPtr<Runnable> runnable =
-    NS_NewRunnableMethodWithArgs<uint32_t>(
+  ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
+    NewRunnableMethod(
       this,
       &MediaSystemResourceManager::DoAcquire,
-      aClient->mId);
-  ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget());
+      aClient->mId));
 
   // should stop the thread until done.
   while (!done) {
     barrier.Wait();
   }
 
   {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
@@ -305,22 +303,21 @@ MediaSystemResourceManager::ReleaseResou
         aClient->mResourceState == MediaSystemResourceClient::RESOURCE_STATE_END) {
 
       aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END;
       return;
     }
 
     aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END;
 
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<uint32_t>(
+    ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
+      NewRunnableMethod(
         this,
         &MediaSystemResourceManager::DoRelease,
-        aClient->mId);
-    ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget());
+        aClient->mId));
   }
 }
 
 void
 MediaSystemResourceManager::DoRelease(uint32_t aId)
 {
   MOZ_ASSERT(InImageBridgeChildThread());
   if (mShutDown || !mChild) {
@@ -334,23 +331,22 @@ MediaSystemResourceManager::RecvResponse
 {
   HandleAcquireResult(aId, aSuccess);
 }
 
 void
 MediaSystemResourceManager::HandleAcquireResult(uint32_t aId, bool aSuccess)
 {
   if (!InImageBridgeChildThread()) {
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<uint32_t, bool>(
+    ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
+      NewRunnableMethod(
         this,
         &MediaSystemResourceManager::HandleAcquireResult,
         aId,
-        aSuccess);
-    ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget());
+        aSuccess));
     return;
   }
 
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   MediaSystemResourceClient* client = mResourceClients.Get(aId);
   if (!client) {
     // Client was already unregistered.
     return;
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -1330,18 +1330,18 @@ APZCTreeManager::AdjustScrollForSurfaceS
 }
 
 void
 APZCTreeManager::ClearTree()
 {
   // Ensure that no references to APZCs are alive in any lingering input
   // blocks. This breaks cycles from InputBlockState::mTargetApzc back to
   // the InputQueue.
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(mInputQueue.get(), &InputQueue::Clear);
-  APZThreadUtils::RunOnControllerThread(runnable.forget());
+  APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
+    mInputQueue.get(), &InputQueue::Clear));
 
   MutexAutoLock lock(mTreeLock);
 
   // Collect the nodes into a list, and then destroy each one.
   // We can't destroy them as we collect them, because ForEachNode()
   // does a pre-order traversal of the tree, and Destroy() nulls out
   // the fields needed to reach the children of the node.
   nsTArray<RefPtr<HitTestingTreeNode>> nodesToDestroy;
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -511,19 +511,19 @@ public:
       // This APZC or an APZC further down the handoff chain may be be overscrolled.
       // Start a snap-back animation on the overscrolled APZC.
       // Note:
       //   This needs to be a deferred task even though it can safely run
       //   while holding mMonitor, because otherwise, if the overscrolled APZC
       //   is this one, then the SetState(NOTHING) in UpdateAnimation will
       //   stomp on the SetState(SNAP_BACK) it does.
       mDeferredTasks.AppendElement(
-            NS_NewRunnableMethodWithArg<AsyncPanZoomController*>(mOverscrollHandoffChain.get(),
-                                                                 &OverscrollHandoffChain::SnapBackOverscrolledApzc,
-                                                                 &mApzc));
+            NewRunnableMethod(mOverscrollHandoffChain.get(),
+                              &OverscrollHandoffChain::SnapBackOverscrolledApzc,
+                              &mApzc));
       return false;
     }
 
     // AdjustDisplacement() zeroes out the Axis velocity if we're in overscroll.
     // Since we need to hand off the velocity to the tree manager in such a case,
     // we save it here. Would be ParentLayerVector instead of ParentLayerPoint
     // if we had vector classes.
     ParentLayerPoint velocity = mApzc.GetVelocityVector();
@@ -563,23 +563,21 @@ public:
       // there isn't, we take the new fling ourselves, entering an overscrolled
       // state.
       // Note: APZC is holding mMonitor, so directly calling
       // HandleFlingOverscroll() (which acquires the tree lock) would violate
       // the lock ordering. Instead we schedule HandleFlingOverscroll() to be
       // called after mMonitor is released.
       APZC_LOG("%p fling went into overscroll, handing off with velocity %s\n", &mApzc, Stringify(velocity).c_str());
       mDeferredTasks.AppendElement(
-          NS_NewRunnableMethodWithArgs<ParentLayerPoint,
-                                       RefPtr<const OverscrollHandoffChain>,
-                                       RefPtr<const AsyncPanZoomController>>(&mApzc,
-                                                                             &AsyncPanZoomController::HandleFlingOverscroll,
-                                                                             velocity,
-                                                                             mOverscrollHandoffChain,
-                                                                             mScrolledApzc));
+            NewRunnableMethod(&mApzc,
+                              &AsyncPanZoomController::HandleFlingOverscroll,
+                              velocity,
+                              mOverscrollHandoffChain,
+                              mScrolledApzc));
 
       // If there is a remaining velocity on this APZC, continue this fling
       // as well. (This fling and the handed-off fling will run concurrently.)
       // Note that AdjustDisplacement() will have zeroed out the velocity
       // along the axes where we're overscrolled.
       return !IsZero(mApzc.GetVelocityVector());
     }
 
@@ -697,17 +695,19 @@ public:
       // animation too early. We do still want to request a fling snap, though,
       // in case the end of the axis at which we're overscrolled is not a valid
       // snap point, so we request one now. If there are no snap points, this will
       // do nothing. If there are snap points, we'll get a scrollTo that snaps us
       // back to the nearest valid snap point.
       // The scroll snapping is done in a deferred task, otherwise the state
       // change to NOTHING caused by the overscroll animation ending would
       // clobber a possible state change to SMOOTH_SCROLL in ScrollSnap().
-      mDeferredTasks.AppendElement(NS_NewRunnableMethod(&mApzc, &AsyncPanZoomController::ScrollSnap));
+      mDeferredTasks.AppendElement(
+            NewRunnableMethod(&mApzc,
+            &AsyncPanZoomController::ScrollSnap));
       return false;
     }
     return true;
   }
 
   virtual bool WantsRepaints() override
   {
     return false;
@@ -814,19 +814,19 @@ public:
       // there is an APZC further in the handoff chain which is pannable; if
       // there isn't, we take the new fling ourselves, entering an overscrolled
       // state.
       // Note: APZC is holding mMonitor, so directly calling
       // HandleSmoothScrollOverscroll() (which acquires the tree lock) would violate
       // the lock ordering. Instead we schedule HandleSmoothScrollOverscroll() to be
       // called after mMonitor is released.
       mDeferredTasks.AppendElement(
-          NS_NewRunnableMethodWithArgs<ParentLayerPoint>(&mApzc,
-                                                         &AsyncPanZoomController::HandleSmoothScrollOverscroll,
-                                                         velocity));
+            NewRunnableMethod(&mApzc,
+                              &AsyncPanZoomController::HandleSmoothScrollOverscroll,
+                              velocity));
       return false;
     }
 
     return true;
   }
 
   void SetDestination(const nsPoint& aNewDestination) {
     mXAxisModel.SetDestination(static_cast<int32_t>(aNewDestination.x));
@@ -2167,24 +2167,21 @@ nsEventStatus AsyncPanZoomController::Ge
         }
         touch->SetSingleTapOccurred();
       }
       // Because this may be being running as part of APZCTreeManager::ReceiveInputEvent,
       // calling controller->HandleSingleTap directly might mean that content receives
       // the single tap message before the corresponding touch-up. To avoid that we
       // schedule the singletap message to run on the next spin of the event loop.
       // See bug 965381 for the issue this was causing.
-      RefPtr<Runnable> runnable =
-        NS_NewRunnableMethodWithArgs<CSSPoint,
-                                     mozilla::Modifiers,
-                                     ScrollableLayerGuid>(controller, &GeckoContentController::HandleSingleTap,
-                                                          geckoScreenPoint, aModifiers,
-                                                          GetGuid());
-
-      controller->PostDelayedTask(runnable.forget(), 0);
+      controller->PostDelayedTask(
+        NewRunnableMethod(controller.get(), &GeckoContentController::HandleSingleTap,
+                          geckoScreenPoint, aModifiers,
+                          GetGuid()),
+        0);
       return nsEventStatus_eConsumeNoDefault;
     }
   }
   return nsEventStatus_eIgnore;
 }
 
 void AsyncPanZoomController::OnTouchEndOrCancel() {
   if (RefPtr<GeckoContentController> controller = GetGeckoContentController()) {
--- a/gfx/layers/apz/src/InputQueue.cpp
+++ b/gfx/layers/apz/src/InputQueue.cpp
@@ -565,19 +565,18 @@ InputQueue::IsDragOnScrollbar(bool aHitS
   return mDragTracker.IsOnScrollbar(aHitScrollbar);
 }
 
 void
 InputQueue::ScheduleMainThreadTimeout(const RefPtr<AsyncPanZoomController>& aTarget,
                                       CancelableBlockState* aBlock) {
   INPQ_LOG("scheduling main thread timeout for target %p\n", aTarget.get());
   aBlock->StartContentResponseTimer();
-  RefPtr<Runnable> runnable =
-    NS_NewRunnableMethodWithArgs<uint64_t>(this, &InputQueue::MainThreadTimeout, aBlock->GetBlockId());
-  aTarget->PostDelayedTask(runnable.forget(),
+  aTarget->PostDelayedTask(
+    NewRunnableMethod(this, &InputQueue::MainThreadTimeout, aBlock->GetBlockId()),
     gfxPrefs::APZContentResponseTimeout());
 }
 
 void
 InputQueue::MainThreadTimeout(const uint64_t& aInputBlockId) {
   APZThreadUtils::AssertOnControllerThread();
 
   INPQ_LOG("got a main thread timeout; block=%" PRIu64 "\n", aInputBlockId);
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -683,17 +683,17 @@ public:
 
   void DidRefresh() override {
     if (!mPresShell) {
       MOZ_ASSERT_UNREACHABLE("Post-refresh observer fired again after failed attempt at unregistering it");
       return;
     }
 
     APZCCH_LOG("Got refresh, sending target APZCs for input block %" PRIu64 "\n", mInputBlockId);
-    SendLayersDependentApzcTargetConfirmation(mPresShell, mInputBlockId, Move(mTargets));
+    SendLayersDependentApzcTargetConfirmation(mPresShell, mInputBlockId, mTargets);
 
     if (!mPresShell->RemovePostRefreshObserver(this)) {
       MOZ_ASSERT_UNREACHABLE("Unable to unregister post-refresh observer! Leaking it instead of leaving garbage registered");
       // Graceful handling, just in case...
       mPresShell = nullptr;
       return;
     }
 
@@ -714,17 +714,17 @@ SendSetTargetAPZCNotificationHelper(nsIW
                                     const uint64_t& aInputBlockId,
                                     const nsTArray<ScrollableLayerGuid>& aTargets,
                                     bool aWaitForRefresh)
 {
   bool waitForRefresh = aWaitForRefresh;
   if (waitForRefresh) {
     APZCCH_LOG("At least one target got a new displayport, need to wait for refresh\n");
     waitForRefresh = aShell->AddPostRefreshObserver(
-      new DisplayportSetListener(aShell, aInputBlockId, Move(aTargets)));
+      new DisplayportSetListener(aShell, aInputBlockId, aTargets));
   }
   if (!waitForRefresh) {
     APZCCH_LOG("Sending target APZCs for input block %" PRIu64 "\n", aInputBlockId);
     aWidget->SetConfirmedTargetAPZC(aInputBlockId, aTargets);
   } else {
     APZCCH_LOG("Successfully registered post-refresh observer\n");
   }
 }
@@ -765,17 +765,17 @@ APZCCallbackHelper::SendSetTargetAPZCNot
       }
       // TODO: Do other types of events need to be handled?
 
       if (!targets.IsEmpty()) {
         SendSetTargetAPZCNotificationHelper(
           aWidget,
           shell,
           aInputBlockId,
-          Move(targets),
+          targets,
           waitForRefresh);
       }
     }
   }
 }
 
 void
 APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification(
@@ -785,17 +785,17 @@ APZCCallbackHelper::SendSetAllowedTouchB
         const SetAllowedTouchBehaviorCallback& aCallback)
 {
   nsTArray<TouchBehaviorFlags> flags;
   for (uint32_t i = 0; i < aEvent.mTouches.Length(); i++) {
     flags.AppendElement(
       widget::ContentHelper::GetAllowedTouchBehavior(
                                aWidget, aEvent.mTouches[i]->mRefPoint));
   }
-  aCallback(aInputBlockId, Move(flags));
+  aCallback(aInputBlockId, flags);
 }
 
 void
 APZCCallbackHelper::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent)
 {
   nsCOMPtr<nsIContent> targetContent = nsLayoutUtils::FindContentFor(aScrollId);
   if (!targetContent) {
     return;
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -136,19 +136,19 @@ public:
                                               nsIDocument* aDocument,
                                               const WidgetGUIEvent& aEvent,
                                               const ScrollableLayerGuid& aGuid,
                                               uint64_t aInputBlockId);
 
     /* Figure out the allowed touch behaviors of each touch point in |aEvent|
      * and send that information to the provided callback. */
     static void SendSetAllowedTouchBehaviorNotification(nsIWidget* aWidget,
-                                                        const WidgetTouchEvent& aEvent,
-                                                        uint64_t aInputBlockId,
-                                                        const SetAllowedTouchBehaviorCallback& aCallback);
+                                                         const WidgetTouchEvent& aEvent,
+                                                         uint64_t aInputBlockId,
+                                                         const SetAllowedTouchBehaviorCallback& aCallback);
 
     /* Notify content of a mouse scroll testing event. */
     static void NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent);
 
     /* Notify content that the repaint flush is complete. */
     static void NotifyFlushComplete(nsIPresShell* aShell);
 
     /* Temporarily ignore the Displayport for better paint performance. If at
--- a/gfx/layers/apz/util/ChromeProcessController.cpp
+++ b/gfx/layers/apz/util/ChromeProcessController.cpp
@@ -31,18 +31,18 @@ ChromeProcessController::ChromeProcessCo
   , mAPZCTreeManager(aAPZCTreeManager)
   , mUILoop(MessageLoop::current())
 {
   // Otherwise we're initializing mUILoop incorrectly.
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aAPZEventState);
   MOZ_ASSERT(aAPZCTreeManager);
 
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ChromeProcessController::InitializeRoot);
-  mUILoop->PostTask(runnable.forget());
+  mUILoop->PostTask(
+      NewRunnableMethod(this, &ChromeProcessController::InitializeRoot));
 }
 
 ChromeProcessController::~ChromeProcessController() {}
 
 void
 ChromeProcessController::InitializeRoot()
 {
   APZCCallbackHelper::InitializeRootDisplayport(GetPresShell());
@@ -66,18 +66,18 @@ ChromeProcessController::PostDelayedTask
 {
   MessageLoop::current()->PostDelayedTask(Move(aTask), aDelayMs);
 }
 
 void
 ChromeProcessController::Destroy()
 {
   if (MessageLoop::current() != mUILoop) {
-    RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ChromeProcessController::Destroy);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+      NewRunnableMethod(this, &ChromeProcessController::Destroy));
     return;
   }
 
   MOZ_ASSERT(MessageLoop::current() == mUILoop);
   mWidget = nullptr;
 }
 
 nsIPresShell*
@@ -116,22 +116,19 @@ ChromeProcessController::GetRootContentD
 }
 
 void
 ChromeProcessController::HandleDoubleTap(const mozilla::CSSPoint& aPoint,
                                          Modifiers aModifiers,
                                          const ScrollableLayerGuid& aGuid)
 {
   if (MessageLoop::current() != mUILoop) {
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<CSSPoint,
-                                   Modifiers,
-                                   ScrollableLayerGuid>(this, &ChromeProcessController::HandleDoubleTap,
-                                                        aPoint, aModifiers, aGuid);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+        NewRunnableMethod(this, &ChromeProcessController::HandleDoubleTap,
+                          aPoint, aModifiers, aGuid));
     return;
   }
 
   nsCOMPtr<nsIDocument> document = GetRootContentDocument(aGuid.mScrollId);
   if (!document.get()) {
     return;
   }
 
@@ -156,75 +153,62 @@ ChromeProcessController::HandleDoubleTap
 }
 
 void
 ChromeProcessController::HandleSingleTap(const CSSPoint& aPoint,
                                          Modifiers aModifiers,
                                          const ScrollableLayerGuid& aGuid)
 {
   if (MessageLoop::current() != mUILoop) {
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<CSSPoint,
-                                   Modifiers,
-                                   ScrollableLayerGuid>(this, &ChromeProcessController::HandleSingleTap,
-                                                        aPoint, aModifiers, aGuid);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+        NewRunnableMethod(this, &ChromeProcessController::HandleSingleTap,
+                          aPoint, aModifiers, aGuid));
     return;
   }
 
   mAPZEventState->ProcessSingleTap(aPoint, aModifiers, aGuid);
 }
 
 void
 ChromeProcessController::HandleLongTap(const mozilla::CSSPoint& aPoint, Modifiers aModifiers,
                                        const ScrollableLayerGuid& aGuid,
                                        uint64_t aInputBlockId)
 {
   if (MessageLoop::current() != mUILoop) {
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<mozilla::CSSPoint,
-                                   Modifiers,
-                                   ScrollableLayerGuid,
-                                   uint64_t>(this, &ChromeProcessController::HandleLongTap,
-                                             aPoint, aModifiers, aGuid, aInputBlockId);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+        NewRunnableMethod(this, &ChromeProcessController::HandleLongTap,
+                          aPoint, aModifiers, aGuid, aInputBlockId));
     return;
   }
 
   mAPZEventState->ProcessLongTap(GetPresShell(), aPoint, aModifiers, aGuid,
       aInputBlockId);
 }
 
 void
 ChromeProcessController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
                                               APZStateChange aChange,
                                               int aArg)
 {
   if (MessageLoop::current() != mUILoop) {
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<ScrollableLayerGuid,
-                                   APZStateChange,
-                                   int>(this, &ChromeProcessController::NotifyAPZStateChange,
-                                        aGuid, aChange, aArg);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+        NewRunnableMethod(this, &ChromeProcessController::NotifyAPZStateChange,
+                          aGuid, aChange, aArg));
     return;
   }
 
   mAPZEventState->ProcessAPZStateChange(GetRootDocument(), aGuid.mScrollId, aChange, aArg);
 }
 
 void
 ChromeProcessController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent)
 {
   if (MessageLoop::current() != mUILoop) {
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<FrameMetrics::ViewID,
-                                   nsString>(this, &ChromeProcessController::NotifyMozMouseScrollEvent,
-                                             aScrollId, aEvent);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+      NewRunnableMethod(this, &ChromeProcessController::NotifyMozMouseScrollEvent, aScrollId, aEvent));
     return;
   }
 
   APZCCallbackHelper::NotifyMozMouseScrollEvent(aScrollId, aEvent);
 }
 
 void
 ChromeProcessController::NotifyFlushComplete()
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -357,17 +357,17 @@ void
 CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable)
 {
   // SetDisplay() is usually called from nsScreenManager at main thread. Post
   // to compositor thread if needs.
   if (!CompositorBridgeParent::IsInCompositorThread()) {
     MOZ_ASSERT(NS_IsMainThread());
     MonitorAutoLock lock(mSetDisplayMonitor);
     RefPtr<CancelableRunnable> task =
-      NS_NewCancelableRunnableMethodWithArgs<bool>(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable);
+      NewRunnableMethod(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable);
     mSetDisplayTask = task;
     ScheduleTask(task.forget(), 0);
     return;
   } else {
     MonitorAutoLock lock(mSetDisplayMonitor);
     mSetDisplayTask = nullptr;
   }
 
@@ -977,35 +977,32 @@ CompositorBridgeParent::ActorDestroy(Act
   mCompositorScheduler->Destroy();
 
   // There are chances that the ref count reaches zero on the main thread shortly
   // after this function returns while some ipdl code still needs to run on
   // this thread.
   // We must keep the compositor parent alive untill the code handling message
   // reception is finished on this thread.
   mSelfRef = this;
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::DeferredDestroy);
-  MessageLoop::current()->PostTask(runnable.forget());
+  MessageLoop::current()->PostTask(NewRunnableMethod(this,&CompositorBridgeParent::DeferredDestroy));
 }
 
 
 void
 CompositorBridgeParent::ScheduleRenderOnCompositorThread()
 {
   MOZ_ASSERT(CompositorLoop());
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition);
-  CompositorLoop()->PostTask(runnable.forget());
+  CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition));
 }
 
 void
 CompositorBridgeParent::InvalidateOnCompositorThread()
 {
   MOZ_ASSERT(CompositorLoop());
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::Invalidate);
-  CompositorLoop()->PostTask(runnable.forget());
+  CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::Invalidate));
 }
 
 void
 CompositorBridgeParent::PauseComposition()
 {
   MOZ_ASSERT(IsInCompositorThread(),
              "PauseComposition() can only be called on the compositor thread");
 
@@ -1086,48 +1083,43 @@ CompositorBridgeParent::ResumeCompositio
  * really is paused.
  */
 void
 CompositorBridgeParent::SchedulePauseOnCompositorThread()
 {
   MonitorAutoLock lock(mPauseCompositionMonitor);
 
   MOZ_ASSERT(CompositorLoop());
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::PauseComposition);
-  CompositorLoop()->PostTask(runnable.forget());
+  CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::PauseComposition));
 
   // Wait until the pause has actually been processed by the compositor thread
   lock.Wait();
 }
 
 bool
 CompositorBridgeParent::ScheduleResumeOnCompositorThread()
 {
   MonitorAutoLock lock(mResumeCompositionMonitor);
 
   MOZ_ASSERT(CompositorLoop());
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ResumeComposition);
-  CompositorLoop()->PostTask(runnable.forget());
+  CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ResumeComposition));
 
   // Wait until the resume has actually been processed by the compositor thread
   lock.Wait();
 
   return !mPaused;
 }
 
 bool
 CompositorBridgeParent::ScheduleResumeOnCompositorThread(int width, int height)
 {
   MonitorAutoLock lock(mResumeCompositionMonitor);
 
   MOZ_ASSERT(CompositorLoop());
-  RefPtr<Runnable> runnable =
-    NS_NewRunnableMethodWithArgs<int, int>(this, &CompositorBridgeParent::ResumeCompositionAndResize,
-                                           width, height);
-  CompositorLoop()->PostTask(runnable.forget());
+  CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ResumeCompositionAndResize, width, height));
 
   // Wait until the resume has actually been processed by the compositor thread
   lock.Wait();
 
   return !mPaused;
 }
 
 void
@@ -2110,23 +2102,21 @@ CompositorBridgeParent::InvalidateRemote
 bool
 CompositorBridgeParent::ResetCompositor(const nsTArray<LayersBackend>& aBackendHints,
                                         TextureFactoryIdentifier* aOutIdentifier)
 {
   Maybe<TextureFactoryIdentifier> newIdentifier;
   {
     MonitorAutoLock lock(mResetCompositorMonitor);
 
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<StoreCopyPassByConstLRef<nsTArray<LayersBackend>>,
-                                   Maybe<TextureFactoryIdentifier>*>(this,
-                                                                     &CompositorBridgeParent::ResetCompositorTask,
-                                                                     aBackendHints,
-                                                                     &newIdentifier);
-    CompositorLoop()->PostTask(runnable.forget());
+    CompositorLoop()->PostTask(
+      NewRunnableMethod(this,
+                        &CompositorBridgeParent::ResetCompositorTask,
+                        aBackendHints,
+                        &newIdentifier));
 
     mResetCompositorMonitor.Wait();
   }
 
   if (!newIdentifier) {
     return false;
   }
 
@@ -2284,18 +2274,18 @@ CrossProcessCompositorBridgeParent::Acto
 
   if (mSubprocess) {
     mSubprocess->DissociateActor();
     mSubprocess = nullptr;
   }
 
   // We must keep this object alive untill the code handling message
   // reception is finished on this thread.
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy);
-  MessageLoop::current()->PostTask(runnable.forget());
+  MessageLoop::current()->PostTask(
+      NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy));
 }
 
 PLayerTransactionParent*
 CrossProcessCompositorBridgeParent::AllocPLayerTransactionParent(
   const nsTArray<LayersBackend>&,
   const uint64_t& aId,
   TextureFactoryIdentifier* aTextureFactoryIdentifier,
   bool *aSuccess)
@@ -2530,34 +2520,32 @@ CompositorBridgeParent::UpdatePluginWind
   mCachedPluginData = lts.mPluginData;
   return true;
 }
 
 void
 CompositorBridgeParent::ScheduleShowAllPluginWindows()
 {
   MOZ_ASSERT(CompositorLoop());
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows);
-  CompositorLoop()->PostTask(runnable.forget());
+  CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows));
 }
 
 void
 CompositorBridgeParent::ShowAllPluginWindows()
 {
   MOZ_ASSERT(!NS_IsMainThread());
   mDeferPluginWindows = false;
   ScheduleComposition();
 }
 
 void
 CompositorBridgeParent::ScheduleHideAllPluginWindows()
 {
   MOZ_ASSERT(CompositorLoop());
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows);
-  CompositorLoop()->PostTask(runnable.forget());
+  CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows));
 }
 
 void
 CompositorBridgeParent::HideAllPluginWindows()
 {
   MOZ_ASSERT(!NS_IsMainThread());
   // No plugins in the cache implies no plugins to manage
   // in this content.
--- a/gfx/layers/ipc/RemoteContentController.cpp
+++ b/gfx/layers/ipc/RemoteContentController.cpp
@@ -53,44 +53,38 @@ RemoteContentController::RequestContentR
 void
 RemoteContentController::HandleDoubleTap(const CSSPoint& aPoint,
                                          Modifiers aModifiers,
                                          const ScrollableLayerGuid& aGuid)
 {
   if (MessageLoop::current() != mUILoop) {
     // We have to send this message from the "UI thread" (main
     // thread).
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<CSSPoint,
-                                   Modifiers,
-                                   ScrollableLayerGuid>(this, &RemoteContentController::HandleDoubleTap,
-                                                        aPoint, aModifiers, aGuid);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+      NewRunnableMethod(this, &RemoteContentController::HandleDoubleTap,
+                        aPoint, aModifiers, aGuid));
     return;
   }
   if (CanSend()) {
     Unused << SendHandleDoubleTap(mBrowserParent->AdjustTapToChildWidget(aPoint),
             aModifiers, aGuid);
   }
 }
 
 void
 RemoteContentController::HandleSingleTap(const CSSPoint& aPoint,
                                          Modifiers aModifiers,
                                          const ScrollableLayerGuid& aGuid)
 {
   if (MessageLoop::current() != mUILoop) {
     // We have to send this message from the "UI thread" (main
     // thread).
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<CSSPoint,
-                                   Modifiers,
-                                   ScrollableLayerGuid>(this, &RemoteContentController::HandleSingleTap,
-                                                        aPoint, aModifiers, aGuid);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+      NewRunnableMethod(this, &RemoteContentController::HandleSingleTap,
+                        aPoint, aModifiers, aGuid));
     return;
   }
 
   bool callTakeFocusForClickFromTap;
   layout::RenderFrameParent* frame;
   if (mBrowserParent && (frame = mBrowserParent->GetRenderFrame()) &&
       mLayersId == frame->GetLayersId()) {
     // Avoid going over IPC and back for calling TakeFocusForClickFromTap,
@@ -111,23 +105,19 @@ void
 RemoteContentController::HandleLongTap(const CSSPoint& aPoint,
                                        Modifiers aModifiers,
                                        const ScrollableLayerGuid& aGuid,
                                        uint64_t aInputBlockId)
 {
   if (MessageLoop::current() != mUILoop) {
     // We have to send this message from the "UI thread" (main
     // thread).
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<CSSPoint,
-                                   Modifiers,
-                                   ScrollableLayerGuid,
-                                   uint64_t>(this, &RemoteContentController::HandleLongTap,
-                                             aPoint, aModifiers, aGuid, aInputBlockId);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+      NewRunnableMethod(this, &RemoteContentController::HandleLongTap,
+                        aPoint, aModifiers, aGuid, aInputBlockId));
     return;
   }
   if (CanSend()) {
     Unused << SendHandleLongTap(mBrowserParent->AdjustTapToChildWidget(aPoint),
             aModifiers, aGuid, aInputBlockId);
   }
 }
 
@@ -155,39 +145,34 @@ RemoteContentController::GetTouchSensiti
 }
 
 void
 RemoteContentController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
                                               APZStateChange aChange,
                                               int aArg)
 {
   if (MessageLoop::current() != mUILoop) {
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<ScrollableLayerGuid,
-                                   APZStateChange,
-                                   int>(this, &RemoteContentController::NotifyAPZStateChange,
-                                        aGuid, aChange, aArg);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+      NewRunnableMethod(this, &RemoteContentController::NotifyAPZStateChange,
+                        aGuid, aChange, aArg));
     return;
   }
   if (CanSend()) {
     Unused << SendNotifyAPZStateChange(aGuid.mScrollId, aChange, aArg);
   }
 }
 
 void
 RemoteContentController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId,
                                                    const nsString& aEvent)
 {
   if (MessageLoop::current() != mUILoop) {
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<FrameMetrics::ViewID,
-                                   nsString>(this, &RemoteContentController::NotifyMozMouseScrollEvent,
-                                             aScrollId, aEvent);
-    mUILoop->PostTask(runnable.forget());
+    mUILoop->PostTask(
+      NewRunnableMethod(this, &RemoteContentController::NotifyMozMouseScrollEvent,
+                        aScrollId, aEvent));
     return;
   }
 
   if (mBrowserParent) {
     Unused << mBrowserParent->SendMouseScrollTestEvent(mLayersId, aScrollId, aEvent);
   }
 }
 
@@ -227,40 +212,34 @@ RemoteContentController::RecvContentRece
                                                        const bool& aPreventDefault)
 {
   if (aGuid.mLayersId != mLayersId) {
     // Guard against bad data from hijacked child processes
     NS_ERROR("Unexpected layers id in RecvContentReceivedInputBlock; dropping message...");
     return false;
   }
   if (RefPtr<APZCTreeManager> apzcTreeManager = GetApzcTreeManager()) {
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<uint64_t,
-                                   bool>(apzcTreeManager,
-                                         &APZCTreeManager::ContentReceivedInputBlock,
-                                         aInputBlockId, aPreventDefault);
-    APZThreadUtils::RunOnControllerThread(runnable.forget());
-
+    APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
+        apzcTreeManager.get(), &APZCTreeManager::ContentReceivedInputBlock,
+        aInputBlockId, aPreventDefault));
   }
   return true;
 }
 
 bool
 RemoteContentController::RecvStartScrollbarDrag(const AsyncDragMetrics& aDragMetrics)
 {
   if (RefPtr<APZCTreeManager> apzcTreeManager = GetApzcTreeManager()) {
     ScrollableLayerGuid guid(mLayersId, aDragMetrics.mPresShellId,
                              aDragMetrics.mViewId);
 
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<ScrollableLayerGuid,
-                                   AsyncDragMetrics>(apzcTreeManager,
-                                                     &APZCTreeManager::StartScrollbarDrag,
-                                                     guid, aDragMetrics);
-    APZThreadUtils::RunOnControllerThread(runnable.forget());
+    APZThreadUtils::RunOnControllerThread(
+      NewRunnableMethod(apzcTreeManager.get(),
+                        &APZCTreeManager::StartScrollbarDrag,
+                        guid, aDragMetrics));
   }
   return true;
 }
 
 bool
 RemoteContentController::RecvSetTargetAPZC(const uint64_t& aInputBlockId,
                                            nsTArray<ScrollableLayerGuid>&& aTargets)
 {
@@ -270,37 +249,31 @@ RemoteContentController::RecvSetTargetAP
       NS_ERROR("Unexpected layers id in SetTargetAPZC; dropping message...");
       return false;
     }
   }
   if (RefPtr<APZCTreeManager> apzcTreeManager = GetApzcTreeManager()) {
     // need a local var to disambiguate between the SetTargetAPZC overloads.
     void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray<ScrollableLayerGuid>&)
         = &APZCTreeManager::SetTargetAPZC;
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<uint64_t,
-                                   StoreCopyPassByRRef<nsTArray<ScrollableLayerGuid>>>(apzcTreeManager, setTargetApzcFunc,
-                                                                                       aInputBlockId, aTargets);
-    APZThreadUtils::RunOnControllerThread(runnable.forget());
-
+    APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
+        apzcTreeManager.get(), setTargetApzcFunc,
+        aInputBlockId, aTargets));
   }
   return true;
 }
 
 bool
 RemoteContentController::RecvSetAllowedTouchBehavior(const uint64_t& aInputBlockId,
                                                      nsTArray<TouchBehaviorFlags>&& aFlags)
 {
   if (RefPtr<APZCTreeManager> apzcTreeManager = GetApzcTreeManager()) {
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<uint64_t,
-                                   StoreCopyPassByRRef<nsTArray<TouchBehaviorFlags>>>(apzcTreeManager,
-                                                                                      &APZCTreeManager::SetAllowedTouchBehavior,
-                                                                                      aInputBlockId, Move(aFlags));
-    APZThreadUtils::RunOnControllerThread(runnable.forget());
+    APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
+        apzcTreeManager.get(), &APZCTreeManager::SetAllowedTouchBehavior,
+        aInputBlockId, Move(aFlags)));
   }
   return true;
 }
 
 bool
 RemoteContentController::RecvUpdateZoomConstraints(const uint32_t& aPresShellId,
                                                    const ViewID& aViewId,
                                                    const MaybeZoomConstraints& aConstraints)
--- a/gfx/thebes/SoftwareVsyncSource.cpp
+++ b/gfx/thebes/SoftwareVsyncSource.cpp
@@ -40,18 +40,18 @@ SoftwareDisplay::EnableVsync()
 {
   MOZ_ASSERT(mVsyncThread->IsRunning());
   if (NS_IsMainThread()) {
     if (mVsyncEnabled) {
       return;
     }
     mVsyncEnabled = true;
 
-    RefPtr<mozilla::Runnable> runnable = NS_NewRunnableMethod(this, &SoftwareDisplay::EnableVsync);
-    mVsyncThread->message_loop()->PostTask(runnable.forget());
+    mVsyncThread->message_loop()->PostTask(
+      NewRunnableMethod(this, &SoftwareDisplay::EnableVsync));
     return;
   }
 
   MOZ_ASSERT(IsInSoftwareVsyncThread());
   NotifyVsync(mozilla::TimeStamp::Now());
 }
 
 void
@@ -59,18 +59,18 @@ SoftwareDisplay::DisableVsync()
 {
   MOZ_ASSERT(mVsyncThread->IsRunning());
   if (NS_IsMainThread()) {
     if (!mVsyncEnabled) {
       return;
     }
     mVsyncEnabled = false;
 
-    RefPtr<mozilla::Runnable> runnable = NS_NewRunnableMethod(this, &SoftwareDisplay::DisableVsync);
-    mVsyncThread->message_loop()->PostTask(runnable.forget());
+    mVsyncThread->message_loop()->PostTask(
+      NewRunnableMethod(this, &SoftwareDisplay::DisableVsync));
     return;
   }
 
   MOZ_ASSERT(IsInSoftwareVsyncThread());
   if (mCurrentVsyncTask) {
     mCurrentVsyncTask->Cancel();
     mCurrentVsyncTask = nullptr;
   }
--- a/gfx/vr/ipc/VRManagerParent.cpp
+++ b/gfx/vr/ipc/VRManagerParent.cpp
@@ -107,18 +107,18 @@ VRManagerParent::DeferredDestroy()
   mCompositorThreadHolder = nullptr;
   mSelfRef = nullptr;
 }
 
 void
 VRManagerParent::ActorDestroy(ActorDestroyReason why)
 {
   UnregisterFromManager();
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &VRManagerParent::DeferredDestroy);
-  MessageLoop::current()->PostTask(runnable.forget());
+  MessageLoop::current()->PostTask(
+    NewRunnableMethod(this, &VRManagerParent::DeferredDestroy));
 }
 
 mozilla::ipc::IToplevelProtocol*
 VRManagerParent::CloneToplevel(const InfallibleTArray<mozilla::ipc::ProtocolFdMapping>& aFds,
                                base::ProcessHandle aPeerProcess,
                                mozilla::ipc::ProtocolCloneContext* aCtx)
 {
   for (unsigned int i = 0; i < aFds.Length(); i++) {
--- a/ipc/chromium/src/base/task.h
+++ b/ipc/chromium/src/base/task.h
@@ -298,31 +298,26 @@ class RunnableMethod : public mozilla::C
 
   // This is owning because of the RetainCallee and ReleaseCallee calls in the
   // constructor and destructor.
   T* MOZ_OWNING_REF obj_;
   Method meth_;
   Params params_;
 };
 
-namespace dont_add_new_uses_of_this {
-
-// Don't add new uses of this!!!!
 template <class T, class Method, typename... Args>
 inline already_AddRefed<mozilla::Runnable>
 NewRunnableMethod(T* object, Method method, Args&&... args) {
   typedef mozilla::Tuple<typename mozilla::Decay<Args>::Type...> ArgsTuple;
   RefPtr<mozilla::Runnable> t =
     new RunnableMethod<T, Method, ArgsTuple>(object, method,
                                              mozilla::MakeTuple(mozilla::Forward<Args>(args)...));
   return t.forget();
 }
 
-} // namespace dont_add_new_uses_of_this
-
 // RunnableFunction and NewRunnableFunction implementation ---------------------
 
 template <class Function, class Params>
 class RunnableFunction : public mozilla::CancelableRunnable {
  public:
   RunnableFunction(Function function, Params&& params)
       : function_(function), params_(mozilla::Forward<Params>(params)) {
   }
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -961,33 +961,29 @@ void nsBaseWidget::ConfigureAPZCTreeMana
   RefPtr<APZCTreeManager> treeManager = mAPZC;  // for capture by the lambdas
 
   ContentReceivedInputBlockCallback callback(
       [treeManager](const ScrollableLayerGuid& aGuid,
                     uint64_t aInputBlockId,
                     bool aPreventDefault)
       {
         MOZ_ASSERT(NS_IsMainThread());
-        RefPtr<Runnable> runnable =
-          NS_NewRunnableMethodWithArgs<uint64_t, bool>(treeManager, &APZCTreeManager::ContentReceivedInputBlock,
-                                                       aInputBlockId, aPreventDefault);
-        APZThreadUtils::RunOnControllerThread(runnable.forget());
+        APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
+            treeManager.get(), &APZCTreeManager::ContentReceivedInputBlock,
+            aInputBlockId, aPreventDefault));
       });
   mAPZEventState = new APZEventState(this, mozilla::Move(callback));
 
   mSetAllowedTouchBehaviorCallback = [treeManager](uint64_t aInputBlockId,
                                                    const nsTArray<TouchBehaviorFlags>& aFlags)
   {
     MOZ_ASSERT(NS_IsMainThread());
-    RefPtr<Runnable> runnable =
-      NS_NewRunnableMethodWithArgs<uint64_t,
-                                   StoreCopyPassByLRef<nsTArray<TouchBehaviorFlags>>>(treeManager,
-                                                                                      &APZCTreeManager::SetAllowedTouchBehavior,
-                                                                                      aInputBlockId, aFlags);
-    APZThreadUtils::RunOnControllerThread(runnable.forget());
+    APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
+        treeManager.get(), &APZCTreeManager::SetAllowedTouchBehavior,
+        aInputBlockId, aFlags));
   };
 
   mRootContentController = CreateRootContentController();
   if (mRootContentController) {
     uint64_t rootLayerTreeId = mCompositorBridgeParent->RootLayerTreeId();
     CompositorBridgeParent::SetControllerForLayerTree(rootLayerTreeId, mRootContentController);
   }
 
@@ -1008,22 +1004,18 @@ void nsBaseWidget::ConfigureAPZControlle
 
 void
 nsBaseWidget::SetConfirmedTargetAPZC(uint64_t aInputBlockId,
                                      const nsTArray<ScrollableLayerGuid>& aTargets) const
 {
   // Need to specifically bind this since it's overloaded.
   void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray<ScrollableLayerGuid>&)
           = &APZCTreeManager::SetTargetAPZC;
-  RefPtr<Runnable> runnable =
-    NS_NewRunnableMethodWithArgs<uint64_t,
-                                 StoreCopyPassByRRef<nsTArray<ScrollableLayerGuid>>>(mAPZC,
-                                                                                     setTargetApzcFunc,
-                                                                                     aInputBlockId, aTargets);
-  APZThreadUtils::RunOnControllerThread(runnable.forget());
+  APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
+    mAPZC.get(), setTargetApzcFunc, aInputBlockId, aTargets));
 }
 
 void
 nsBaseWidget::UpdateZoomConstraints(const uint32_t& aPresShellId,
                                     const FrameMetrics::ViewID& aViewId,
                                     const Maybe<ZoomConstraints>& aConstraints)
 {
   if (!mCompositorBridgeParent || !mAPZC) {
@@ -1931,21 +1923,18 @@ nsBaseWidget::StartAsyncScrollbarDrag(co
     return;
   }
 
   MOZ_ASSERT(XRE_IsParentProcess() && mCompositorBridgeParent);
 
   int layersId = mCompositorBridgeParent->RootLayerTreeId();;
   ScrollableLayerGuid guid(layersId, aDragMetrics.mPresShellId, aDragMetrics.mViewId);
 
-  RefPtr<Runnable> runnable =
-    NS_NewRunnableMethodWithArgs<ScrollableLayerGuid,
-                                 AsyncDragMetrics>(mAPZC, &APZCTreeManager::StartScrollbarDrag,
-                                                   guid, aDragMetrics);
-  APZThreadUtils::RunOnControllerThread(runnable.forget());
+  APZThreadUtils::RunOnControllerThread(
+    NewRunnableMethod(mAPZC.get(), &APZCTreeManager::StartScrollbarDrag, guid, aDragMetrics));
 }
 
 already_AddRefed<nsIScreen>
 nsBaseWidget::GetWidgetScreen()
 {
   nsCOMPtr<nsIScreenManager> screenManager;
   screenManager = do_GetService("@mozilla.org/gfx/screenmanager;1");
   if (!screenManager) {
--- a/xpcom/base/nsDumpUtils.cpp
+++ b/xpcom/base/nsDumpUtils.cpp
@@ -69,18 +69,18 @@ NS_IMPL_ISUPPORTS(FdWatcher, nsIObserver
 void
 FdWatcher::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIObserverService> os = services::GetObserverService();
   os->AddObserver(this, "xpcom-shutdown", /* ownsWeak = */ false);
 
-  RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &FdWatcher::StartWatching);
-  XRE_GetIOMessageLoop()->PostTask(runnable.forget());
+  XRE_GetIOMessageLoop()->PostTask(
+    NewRunnableMethod(this, &FdWatcher::StartWatching));
 }
 
 // Implementations may call this function multiple times if they ensure that
 // it's safe to call OpenFd() multiple times and they call StopWatching()
 // first.
 void
 FdWatcher::StartWatching()
 {
--- a/xpcom/base/nsDumpUtils.h
+++ b/xpcom/base/nsDumpUtils.h
@@ -84,19 +84,18 @@ public:
   virtual void StopWatching();
 
   NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
                      const char16_t* aData) override
   {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(!strcmp(aTopic, "xpcom-shutdown"));
 
-    RefPtr<mozilla::Runnable> runnable =
-      NS_NewRunnableMethod(this, &FdWatcher::StopWatching);
-    XRE_GetIOMessageLoop()->PostTask(runnable.forget());
+    XRE_GetIOMessageLoop()->PostTask(
+      NewRunnableMethod(this, &FdWatcher::StopWatching));
 
     return NS_OK;
   }
 };
 
 typedef void (*FifoCallback)(const nsCString& aInputStr);
 struct FifoInfo
 {