Bug 1320752 - remove mozilla/Function.h; r=gerald
authorNathan Froyd <froydnj@mozilla.com>
Mon, 28 Nov 2016 11:03:53 -0500
changeset 371717 1e5621e43ac66ff8e06fe9a682780c3a187996d3
parent 371716 9acaf2d4db150126a2670e6a1a284b3d7fcb73c1
child 371718 564fbfb9ca4599d4c767af2c1a1428c71678e2ce
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1320752
milestone53.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 1320752 - remove mozilla/Function.h; r=gerald We have std::function available now, which is likely to be somewhat more efficient.
build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp
dom/audiochannel/AudioChannelService.cpp
dom/audiochannel/AudioChannelService.h
dom/base/IdleRequest.cpp
dom/base/nsIScriptTimeoutHandler.h
dom/base/nsJSTimeoutHandler.cpp
dom/canvas/ImageBitmapUtils.cpp
dom/media/VideoUtils.cpp
dom/media/platforms/PDMFactory.cpp
dom/media/platforms/PDMFactory.h
dom/presentation/PresentationSessionInfo.cpp
gfx/2d/SFNTNameTable.h
gfx/config/gfxConfig.h
gfx/config/gfxFeature.h
gfx/ipc/GPUProcessHost.h
gfx/layers/apz/util/APZCCallbackHelper.h
gfx/layers/apz/util/APZEventState.h
gfx/layers/ipc/LayerTreeOwnerTracker.cpp
gfx/layers/ipc/LayerTreeOwnerTracker.h
gfx/src/DriverCrashGuard.h
gfx/thebes/gfxPrefs.h
ipc/glue/MessageChannel.cpp
ipc/glue/MessageChannel.h
ipc/mscom/EnsureMTA.h
layout/generic/nsGridContainerFrame.cpp
layout/painting/FrameLayerBuilder.cpp
layout/style/nsRuleNode.cpp
mfbt/Function.h
mfbt/moz.build
mfbt/tests/TestFunction.cpp
mfbt/tests/moz.build
testing/cppunittest.ini
testing/gtest/mozilla/MozGTestBench.cpp
testing/gtest/mozilla/MozGTestBench.h
xpcom/base/NSPRLogModulesParser.cpp
xpcom/base/NSPRLogModulesParser.h
xpcom/glue/nsTArray.h
xpcom/glue/nsTObserverArray.h
xpcom/tests/gtest/TestAllocReplacement.cpp
--- a/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp
+++ b/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp
@@ -1,10 +1,9 @@
 #include <functional>
-#include "mozilla/Function.h"
 #define MOZ_STRONG_REF __attribute__((annotate("moz_strong_ref")))
 
 struct RefCountedBase {
   void AddRef();
   void Release();
 };
 
 template <class T>
@@ -215,117 +214,16 @@ void b() {
   std::function<void(SmartPtr<R>)>([&sp](SmartPtr<R> argsp) {
     SmartPtr<R> localsp;
     take(sp);
     take(argsp);
     take(localsp);
   });
 }
 
-void c() {
-  R* ptr;
-  SmartPtr<R> sp;
-  mozilla::function<void(R*)>([&](R* argptr) {
-    R* localptr;
-    ptr->method();
-    argptr->method();
-    localptr->method();
-  });
-  mozilla::function<void(SmartPtr<R>)>([&](SmartPtr<R> argsp) {
-    SmartPtr<R> localsp;
-    sp->method();
-    argsp->method();
-    localsp->method();
-  });
-  mozilla::function<void(R*)>([&](R* argptr) {
-    R* localptr;
-    take(ptr);
-    take(argptr);
-    take(localptr);
-  });
-  mozilla::function<void(SmartPtr<R>)>([&](SmartPtr<R> argsp) {
-    SmartPtr<R> localsp;
-    take(sp);
-    take(argsp);
-    take(localsp);
-  });
-  mozilla::function<void(R*)>([=](R* argptr) {
-    R* localptr;
-    ptr->method(); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
-    argptr->method();
-    localptr->method();
-  });
-  mozilla::function<void(SmartPtr<R>)>([=](SmartPtr<R> argsp) {
-    SmartPtr<R> localsp;
-    sp->method();
-    argsp->method();
-    localsp->method();
-  });
-  mozilla::function<void(R*)>([=](R* argptr) {
-    R* localptr;
-    take(ptr); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
-    take(argptr);
-    take(localptr);
-  });
-  mozilla::function<void(SmartPtr<R>)>([=](SmartPtr<R> argsp) {
-    SmartPtr<R> localsp;
-    take(sp);
-    take(argsp);
-    take(localsp);
-  });
-  mozilla::function<void(R*)>([ptr](R* argptr) { // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
-    R* localptr;
-    ptr->method();
-    argptr->method();
-    localptr->method();
-  });
-  mozilla::function<void(SmartPtr<R>)>([sp](SmartPtr<R> argsp) {
-    SmartPtr<R> localsp;
-    sp->method();
-    argsp->method();
-    localsp->method();
-  });
-  mozilla::function<void(R*)>([ptr](R* argptr) { // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
-    R* localptr;
-    take(ptr);
-    take(argptr);
-    take(localptr);
-  });
-  mozilla::function<void(SmartPtr<R>)>([sp](SmartPtr<R> argsp) {
-    SmartPtr<R> localsp;
-    take(sp);
-    take(argsp);
-    take(localsp);
-  });
-  mozilla::function<void(R*)>([&ptr](R* argptr) {
-    R* localptr;
-    ptr->method();
-    argptr->method();
-    localptr->method();
-  });
-  mozilla::function<void(SmartPtr<R>)>([&sp](SmartPtr<R> argsp) {
-    SmartPtr<R> localsp;
-    sp->method();
-    argsp->method();
-    localsp->method();
-  });
-  mozilla::function<void(R*)>([&ptr](R* argptr) {
-    R* localptr;
-    take(ptr);
-    take(argptr);
-    take(localptr);
-  });
-  mozilla::function<void(SmartPtr<R>)>([&sp](SmartPtr<R> argsp) {
-    SmartPtr<R> localsp;
-    take(sp);
-    take(argsp);
-    take(localsp);
-  });
-}
-
 // These tests would check c++14 deduced return types, if they were supported in
 // our codebase. They are being kept here for convenience in the future if we do
 // add support for c++14 deduced return types
 #if 0
 auto d1() {
   R* ptr;
   SmartPtr<R> sp;
   return ([&](R* argptr) {
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -608,17 +608,17 @@ AudioChannelService::RefreshAgentsVolume
                                                    winData->mChannels[(uint32_t)aAudioChannel].mMuted);
   }
 
   RefreshAgentsVolume(aWindow);
 }
 
 void
 AudioChannelService::RefreshAgents(nsPIDOMWindowOuter* aWindow,
-                                   mozilla::function<void(AudioChannelAgent*)> aFunc)
+                                   std::function<void(AudioChannelAgent*)> aFunc)
 {
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aWindow->IsOuterWindow());
 
   nsCOMPtr<nsPIDOMWindowOuter> topWindow = aWindow->GetScriptableTop();
   if (!topWindow) {
     return;
   }
--- a/dom/audiochannel/AudioChannelService.h
+++ b/dom/audiochannel/AudioChannelService.h
@@ -11,17 +11,18 @@
 #include "nsAutoPtr.h"
 #include "nsIObserver.h"
 #include "nsTObserverArray.h"
 #include "nsTArray.h"
 
 #include "AudioChannelAgent.h"
 #include "nsAttrValue.h"
 #include "mozilla/dom/AudioChannelBinding.h"
-#include "mozilla/Function.h"
+
+#include <functional>
 
 class nsIRunnable;
 class nsPIDOMWindowOuter;
 struct PRLogModuleInfo;
 
 namespace mozilla {
 namespace dom {
 
@@ -190,17 +191,17 @@ public:
   void ChildStatusReceived(uint64_t aChildID, bool aTelephonyChannel,
                            bool aContentOrNormalChannel, bool aAnyChannel);
 
 private:
   AudioChannelService();
   ~AudioChannelService();
 
   void RefreshAgents(nsPIDOMWindowOuter* aWindow,
-                     mozilla::function<void(AudioChannelAgent*)> aFunc);
+                     std::function<void(AudioChannelAgent*)> aFunc);
 
   static void CreateServiceIfNeeded();
 
   /**
    * Shutdown the singleton.
    */
   static void Shutdown();
 
--- a/dom/base/IdleRequest.cpp
+++ b/dom/base/IdleRequest.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "IdleRequest.h"
 
-#include "mozilla/Function.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/IdleDeadline.h"
 #include "mozilla/dom/Performance.h"
 #include "mozilla/dom/PerformanceTiming.h"
 #include "mozilla/dom/WindowBinding.h"
 #include "nsComponentManagerUtils.h"
 #include "nsGlobalWindow.h"
 #include "nsISupportsPrimitives.h"
--- a/dom/base/nsIScriptTimeoutHandler.h
+++ b/dom/base/nsIScriptTimeoutHandler.h
@@ -4,17 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef nsIScriptTimeoutHandler_h___
 #define nsIScriptTimeoutHandler_h___
 
 #include "nsITimeoutHandler.h"
 #include "nsTArray.h"
 #include "js/TypeDecls.h"
-#include "mozilla/Function.h"
 #include "mozilla/Maybe.h"
 
 namespace mozilla {
 namespace dom {
 class Function;
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <algorithm>
 
 #include "mozilla/Attributes.h"
-#include "mozilla/Function.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/dom/FunctionBinding.h"
 #include "nsAXPCNativeCallContext.h"
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include "nsError.h"
 #include "nsGlobalWindow.h"
--- a/dom/canvas/ImageBitmapUtils.cpp
+++ b/dom/canvas/ImageBitmapUtils.cpp
@@ -4,19 +4,20 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ImageBitmapUtils.h"
 #include "ImageBitmapColorUtils.h"
 #include "ImageContainer.h"
 #include "libyuv.h"
 #include "mozilla/dom/ImageBitmapBinding.h"
-#include "mozilla/Function.h"
 #include "mozilla/gfx/2D.h"
 
+#include <functional>
+
 using namespace libyuv;
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace dom {
 namespace imagebitmapformat {
 
 class Utils;
@@ -320,17 +321,17 @@ Utils::GetUtils(ImageBitmapFormat aForma
 /*
  * Helper functions.
  */
 template<typename SrcType, typename DstType>
 static UniquePtr<ImagePixelLayout>
 CvtSimpleImgToSimpleImg(Utils* aSrcUtils, const SrcType* aSrcBuffer,
                         const ImagePixelLayout* aSrcLayout, DstType* aDstBuffer,
                         ImageBitmapFormat aDstFormat, int aDstChannelCount,
-                        mozilla::function<int (const SrcType*, int, DstType*, int, int, int)> converter)
+                        std::function<int (const SrcType*, int, DstType*, int, int, int)> converter)
 {
   MOZ_ASSERT(aSrcUtils, "Convert color from a null utility object.");
   MOZ_ASSERT(aSrcBuffer, "Convert color from a null buffer.");
   MOZ_ASSERT(aSrcLayout, "Convert color from a null layout.");
   MOZ_ASSERT(aDstBuffer, "Convert color to a null buffer.");
 
   const nsTArray<ChannelPixelLayout>& channels = *aSrcLayout;
   MOZ_ASSERT(channels.Length() == aSrcUtils->GetChannelCount(),
@@ -348,17 +349,17 @@ CvtSimpleImgToSimpleImg(Utils* aSrcUtils
   return CreateDefaultPixelLayout(aDstFormat, channels[0].mWidth,
                                   channels[0].mHeight, dstStride);
 }
 
 static UniquePtr<ImagePixelLayout>
 CvtYUVImgToSimpleImg(Utils* aSrcUtils, const uint8_t* aSrcBuffer,
                      const ImagePixelLayout* aSrcLayout, uint8_t* aDstBuffer,
                      ImageBitmapFormat aDstFormat, int aDstChannelCount,
-                     mozilla::function<int (const uint8_t*, int, const uint8_t*, int, const uint8_t*, int, uint8_t*, int, int, int)> converter)
+                     std::function<int (const uint8_t*, int, const uint8_t*, int, const uint8_t*, int, uint8_t*, int, int, int)> converter)
 {
   MOZ_ASSERT(aSrcUtils, "Convert color from a null utility object.");
   MOZ_ASSERT(aSrcBuffer, "Convert color from a null buffer.");
   MOZ_ASSERT(aSrcLayout, "Convert color from a null layout.");
   MOZ_ASSERT(aDstBuffer, "Convert color to a null buffer.");
 
   const nsTArray<ChannelPixelLayout>& channels = *aSrcLayout;
   MOZ_ASSERT(channels.Length() == aSrcUtils->GetChannelCount(),
@@ -378,17 +379,17 @@ CvtYUVImgToSimpleImg(Utils* aSrcUtils, c
   return CreateDefaultPixelLayout(aDstFormat, channels[0].mWidth,
                                   channels[0].mHeight, dstStride);
 }
 
 static UniquePtr<ImagePixelLayout>
 CvtNVImgToSimpleImg(Utils* aSrcUtils, const uint8_t* aSrcBuffer,
                     const ImagePixelLayout* aSrcLayout, uint8_t* aDstBuffer,
                     ImageBitmapFormat aDstFormat, int aDstChannelCount,
-                    mozilla::function<int (const uint8_t*, int, const uint8_t*, int, uint8_t*, int, int, int)> converter)
+                    std::function<int (const uint8_t*, int, const uint8_t*, int, uint8_t*, int, int, int)> converter)
 {
   MOZ_ASSERT(aSrcUtils, "Convert color from a null utility object.");
   MOZ_ASSERT(aSrcBuffer, "Convert color from a null buffer.");
   MOZ_ASSERT(aSrcLayout, "Convert color from a null layout.");
   MOZ_ASSERT(aDstBuffer, "Convert color to a null buffer.");
 
   const nsTArray<ChannelPixelLayout>& channels = *aSrcLayout;
   MOZ_ASSERT(channels.Length() == aSrcUtils->GetChannelCount(),
@@ -407,17 +408,17 @@ CvtNVImgToSimpleImg(Utils* aSrcUtils, co
   return CreateDefaultPixelLayout(aDstFormat, channels[0].mWidth,
                                   channels[0].mHeight, dstStride);
 }
 
 static UniquePtr<ImagePixelLayout>
 CvtSimpleImgToYUVImg(Utils* aSrcUtils, const uint8_t* aSrcBuffer,
                      const ImagePixelLayout* aSrcLayout, uint8_t* aDstBuffer,
                      ImageBitmapFormat aDstFormat,
-                     mozilla::function<int (const uint8_t*, int, uint8_t*, int, uint8_t*, int, uint8_t*, int, int, int)> converter)
+                     std::function<int (const uint8_t*, int, uint8_t*, int, uint8_t*, int, uint8_t*, int, int, int)> converter)
 {
   MOZ_ASSERT(aSrcUtils, "Convert color from a null utility object.");
   MOZ_ASSERT(aSrcBuffer, "Convert color from a null buffer.");
   MOZ_ASSERT(aSrcLayout, "Convert color from a null layout.");
   MOZ_ASSERT(aDstBuffer, "Convert color to a null buffer.");
 
   UniquePtr<ImagePixelLayout> layout =
     CreateDefaultPixelLayout(aDstFormat, (*aSrcLayout)[0].mWidth,
@@ -439,17 +440,17 @@ CvtSimpleImgToYUVImg(Utils* aSrcUtils, c
 
   return layout;
 }
 
 static UniquePtr<ImagePixelLayout>
 CvtSimpleImgToNVImg(Utils* aSrcUtils, const uint8_t* aSrcBuffer,
                     const ImagePixelLayout* aSrcLayout, uint8_t* aDstBuffer,
                     ImageBitmapFormat aDstFormat,
-                    mozilla::function<int (const uint8_t*, int, uint8_t*, int, uint8_t*, int, int, int)> converter)
+                    std::function<int (const uint8_t*, int, uint8_t*, int, uint8_t*, int, int, int)> converter)
 {
   MOZ_ASSERT(aSrcUtils, "Convert color from a null utility object.");
   MOZ_ASSERT(aSrcBuffer, "Convert color from a null buffer.");
   MOZ_ASSERT(aSrcLayout, "Convert color from a null layout.");
   MOZ_ASSERT(aDstBuffer, "Convert color to a null buffer.");
 
   UniquePtr<ImagePixelLayout> layout =
     CreateDefaultPixelLayout(aDstFormat, (*aSrcLayout)[0].mWidth,
--- a/dom/media/VideoUtils.cpp
+++ b/dom/media/VideoUtils.cpp
@@ -2,17 +2,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "VideoUtils.h"
 
 #include "mozilla/Base64.h"
 #include "mozilla/TaskQueue.h"
 #include "mozilla/Telemetry.h"
-#include "mozilla/Function.h"
 
 #include "MediaContentType.h"
 #include "MediaPrefs.h"
 #include "MediaResource.h"
 #include "TimeUnits.h"
 #include "nsMathUtils.h"
 #include "nsSize.h"
 #include "VorbisUtils.h"
@@ -21,16 +20,17 @@
 #include "nsIRandomGenerator.h"
 #include "nsIServiceManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIConsoleService.h"
 #include "nsThreadUtils.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsContentTypeParser.h"
 
+#include <functional>
 #include <stdint.h>
 
 namespace mozilla {
 
 NS_NAMED_LITERAL_CSTRING(kEMEKeySystemClearkey, "org.w3.clearkey");
 NS_NAMED_LITERAL_CSTRING(kEMEKeySystemWidevine, "com.widevine.alpha");
 NS_NAMED_LITERAL_CSTRING(kEMEKeySystemPrimetime, "com.adobe.primetime");
 
--- a/dom/media/platforms/PDMFactory.cpp
+++ b/dom/media/platforms/PDMFactory.cpp
@@ -47,16 +47,18 @@
 #include "mozilla/dom/RemoteVideoDecoder.h"
 
 #ifdef XP_WIN
 #include "mozilla/WindowsVersion.h"
 #endif
 
 #include "mp4_demuxer/H264.h"
 
+#include <functional>
+
 namespace mozilla {
 
 extern already_AddRefed<PlatformDecoderModule> CreateAgnosticDecoderModule();
 extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
 
 class PDMFactoryImpl final {
 public:
   PDMFactoryImpl()
@@ -150,17 +152,17 @@ public:
       }
     }
     return CheckResult(SupportChecker::Reason::kSupported);
   }
 
   void Clear() { mCheckerList.Clear(); }
 
 private:
-  nsTArray<mozilla::function<CheckResult()>> mCheckerList;
+  nsTArray<std::function<CheckResult()>> mCheckerList;
 }; // SupportChecker
 
 PDMFactory::PDMFactory()
 {
   EnsureInit();
   CreatePDMs();
   CreateBlankPDM();
 }
--- a/dom/media/platforms/PDMFactory.h
+++ b/dom/media/platforms/PDMFactory.h
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #if !defined(PDMFactory_h_)
 #define PDMFactory_h_
 
 #include "PlatformDecoderModule.h"
-#include "mozilla/Function.h"
 #include "mozilla/StaticMutex.h"
 
 class CDMProxy;
 
 namespace mozilla {
 
 class DecoderDoctorDiagnostics;
 class PDMFactoryImpl;
--- a/dom/presentation/PresentationSessionInfo.cpp
+++ b/dom/presentation/PresentationSessionInfo.cpp
@@ -2,17 +2,16 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/HTMLIFrameElementBinding.h"
 #include "mozilla/dom/TabParent.h"
-#include "mozilla/Function.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Move.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "nsContentUtils.h"
 #include "nsGlobalWindow.h"
 #include "nsIDocShell.h"
 #include "nsFrameLoader.h"
--- a/gfx/2d/SFNTNameTable.h
+++ b/gfx/2d/SFNTNameTable.h
@@ -2,29 +2,30 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_gfx_SFNTNameTable_h
 #define mozilla_gfx_SFNTNameTable_h
 
-#include "mozilla/Function.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/Vector.h"
 #include "u16string.h"
 
+#include <functional>
+
 namespace mozilla {
 namespace gfx {
 
 struct NameHeader;
 struct NameRecord;
 enum ENameDecoder : int;
 
-typedef Vector<function<ENameDecoder(const NameRecord*)>> NameRecordMatchers;
+typedef Vector<std::function<ENameDecoder(const NameRecord*)>> NameRecordMatchers;
 
 class SFNTNameTable final
 {
 public:
 
   /**
    * Creates a SFNTNameTable if the header data is valid. Note that the data is
    * NOT copied, so must exist for the lifetime of the table.
--- a/gfx/config/gfxConfig.h
+++ b/gfx/config/gfxConfig.h
@@ -1,20 +1,20 @@
 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim: set sts=2 ts=8 sw=2 tw=99 et: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef mozilla_gfx_config_gfxConfig_h
 #define mozilla_gfx_config_gfxConfig_h
 
+#include <functional>
 #include "gfxFeature.h"
 #include "gfxFallback.h"
 #include "mozilla/Assertions.h"
-#include "mozilla/Function.h"
 
 namespace mozilla {
 namespace gfx {
 
 // Defined in GraphicsMessages.ipdlh.
 class FeatureChange;
 
 // Manages the history and state of a graphics feature. The flow of a feature
@@ -163,23 +163,23 @@ public:
 
   // Query whether a fallback has been toggled.
   static bool UseFallback(Fallback aFallback);
 
   // Enable a fallback.
   static void EnableFallback(Fallback aFallback, const char* aMessage);
 
   // Run a callback for each initialized FeatureState.
-  typedef mozilla::function<void(const char* aName,
-                                 const char* aDescription,
-                                 FeatureState& aFeature)> FeatureIterCallback;
+  typedef std::function<void(const char* aName,
+                             const char* aDescription,
+                             FeatureState& aFeature)> FeatureIterCallback;
   static void ForEachFeature(const FeatureIterCallback& aCallback);
 
   // Run a callback for each enabled fallback.
-  typedef mozilla::function<void(const char* aName, const char* aMsg)> 
+  typedef std::function<void(const char* aName, const char* aMsg)> 
     FallbackIterCallback;
   static void ForEachFallback(const FallbackIterCallback& aCallback);
 
   // Get the most descriptive failure id message for this feature.
   static const nsCString& GetFailureId(Feature aFeature);
 
   static void ImportChange(Feature aFeature, const FeatureChange& aChange);
 
--- a/gfx/config/gfxFeature.h
+++ b/gfx/config/gfxFeature.h
@@ -1,20 +1,20 @@
 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim: set sts=2 ts=8 sw=2 tw=99 et: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef mozilla_gfx_config_gfxFeature_h
 #define mozilla_gfx_config_gfxFeature_h
 
+#include <functional>
 #include <stdint.h>
 #include "gfxTelemetry.h"
 #include "mozilla/Assertions.h"
-#include "mozilla/Function.h"
 #include "nsString.h"
 
 namespace mozilla {
 namespace gfx {
 
 #define GFX_FEATURE_MAP(_)                                                        \
   /* Name,                        Type,         Description */                    \
   _(HW_COMPOSITING,               Feature,      "Compositing")                    \
@@ -59,19 +59,19 @@ class FeatureState
     SetFailed(aStatus, aMessage, aFailureId);
   }
   void SetFailed(FeatureStatus aStatus, const char* aMessage, const nsACString& aFailureId);
   bool MaybeSetFailed(bool aEnable, FeatureStatus aStatus, const char* aMessage, const nsACString& aFailureId);
   bool MaybeSetFailed(FeatureStatus aStatus, const char* aMessage, const nsACString& aFailureId);
 
   // aType is "base", "user", "env", or "runtime".
   // aMessage may be null.
-  typedef mozilla::function<void(const char* aType,
-                                 FeatureStatus aStatus,
-                                 const char* aMessage)> StatusIterCallback;
+  typedef std::function<void(const char* aType,
+                             FeatureStatus aStatus,
+                             const char* aMessage)> StatusIterCallback;
   void ForEachStatusChange(const StatusIterCallback& aCallback) const;
 
   const char* GetFailureMessage() const;
   const nsCString& GetFailureId() const;
 
   bool DisabledByDefault() const;
 
  private:
--- a/gfx/ipc/GPUProcessHost.h
+++ b/gfx/ipc/GPUProcessHost.h
@@ -2,17 +2,16 @@
  * vim: sts=8 sw=2 ts=2 tw=99 et :
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _include_mozilla_gfx_ipc_GPUProcessHost_h_
 #define _include_mozilla_gfx_ipc_GPUProcessHost_h_
 
-#include "mozilla/Function.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/ipc/GeckoChildProcessHost.h"
 #include "mozilla/ipc/ProtocolUtils.h"
 #include "mozilla/ipc/TaskFactory.h"
 
 class nsITimer;
 
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -4,32 +4,33 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_layers_APZCCallbackHelper_h
 #define mozilla_layers_APZCCallbackHelper_h
 
 #include "FrameMetrics.h"
 #include "InputData.h"
 #include "mozilla/EventForwards.h"
-#include "mozilla/Function.h"
 #include "mozilla/layers/APZUtils.h"
 #include "nsIDOMWindowUtils.h"
 
+#include <functional>
+
 class nsIContent;
 class nsIDocument;
 class nsIPresShell;
 class nsIScrollableFrame;
 class nsIWidget;
 template<class T> struct already_AddRefed;
 template<class T> class nsCOMPtr;
 
 namespace mozilla {
 namespace layers {
 
-typedef function<void(uint64_t, const nsTArray<TouchBehaviorFlags>&)>
+typedef std::function<void(uint64_t, const nsTArray<TouchBehaviorFlags>&)>
         SetAllowedTouchBehaviorCallback;
 
 /* This class contains some helper methods that facilitate implementing the
    GeckoContentController callback interface required by the AsyncPanZoomController.
    Since different platforms need to implement this interface in similar-but-
    not-quite-the-same ways, this utility class provides some helpful methods
    to hold code that can be shared across the different platform implementations.
  */
--- a/gfx/layers/apz/util/APZEventState.h
+++ b/gfx/layers/apz/util/APZEventState.h
@@ -6,36 +6,37 @@
 #ifndef mozilla_layers_APZEventState_h
 #define mozilla_layers_APZEventState_h
 
 #include <stdint.h>
 
 #include "FrameMetrics.h"     // for ScrollableLayerGuid
 #include "Units.h"
 #include "mozilla/EventForwards.h"
-#include "mozilla/Function.h"
 #include "mozilla/layers/GeckoContentController.h"  // for APZStateChange
 #include "mozilla/RefPtr.h"
 #include "nsCOMPtr.h"
 #include "nsISupportsImpl.h"  // for NS_INLINE_DECL_REFCOUNTING
 #include "nsIWeakReferenceUtils.h"  // for nsWeakPtr
 
+#include <functional>
+
 template <class> class nsCOMPtr;
 class nsIDocument;
 class nsIPresShell;
 class nsIWidget;
 
 namespace mozilla {
 namespace layers {
 
 class ActiveElementManager;
 
-typedef function<void(const ScrollableLayerGuid&,
-                      uint64_t /* input block id */,
-                      bool /* prevent default */)>
+typedef std::function<void(const ScrollableLayerGuid&,
+                           uint64_t /* input block id */,
+                           bool /* prevent default */)>
         ContentReceivedInputBlockCallback;
 
 /**
  * A content-side component that keeps track of state for handling APZ
  * gestures and sending APZ notifications.
  */
 class APZEventState {
   typedef GeckoContentController::APZStateChange APZStateChange;
--- a/gfx/layers/ipc/LayerTreeOwnerTracker.cpp
+++ b/gfx/layers/ipc/LayerTreeOwnerTracker.cpp
@@ -6,16 +6,17 @@
 
 #include "LayerTreeOwnerTracker.h"
 
 #include "mozilla/StaticPtr.h"              // for StaticAutoPtr
 #include "mozilla/dom/ContentParent.h"      // for ContentParent
 #include "mozilla/gfx/GPUChild.h"           // for GPUChild
 #include "mozilla/gfx/GPUProcessManager.h"  // for GPUProcessManager
 
+#include <functional>
 #include <utility> // for std::make_pair
 
 namespace mozilla {
 namespace layers {
 
 static StaticAutoPtr<LayerTreeOwnerTracker> sSingleton;
 
 LayerTreeOwnerTracker::LayerTreeOwnerTracker() :
@@ -65,17 +66,17 @@ LayerTreeOwnerTracker::IsMapped(uint64_t
 {
   MutexAutoLock lock(mLayerIdsLock);
 
   auto iter = mLayerIds.find(aLayersId);
   return iter != mLayerIds.end() && iter->second == aProcessId;
 }
 
 void
-LayerTreeOwnerTracker::Iterate(function<void(uint64_t aLayersId, base::ProcessId aProcessId)> aCallback)
+LayerTreeOwnerTracker::Iterate(std::function<void(uint64_t aLayersId, base::ProcessId aProcessId)> aCallback)
 {
   MutexAutoLock lock(mLayerIdsLock);
 
   for (const auto& iter : mLayerIds) {
     aCallback(iter.first, iter.second);
   }
 }
 
--- a/gfx/layers/ipc/LayerTreeOwnerTracker.h
+++ b/gfx/layers/ipc/LayerTreeOwnerTracker.h
@@ -4,18 +4,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_layers_LayerTreeOwnerTracker_h
 #define mozilla_layers_LayerTreeOwnerTracker_h
 
 #include "base/process.h"  // for base::ProcessId
 #include "mozilla/Mutex.h" // for mozilla::Mutex
-#include "mozilla/Function.h"
 
+#include <functional>
 #include <map>
 
 namespace mozilla {
 
 namespace dom {
   class ContentParent;
 }
 
@@ -51,17 +51,17 @@ public:
   */
   void Unmap(uint64_t aLayersId, base::ProcessId aProcessId);
 
   /**
    * Checks whether it is okay for aProcessId to access aLayersId.
    */
   bool IsMapped(uint64_t aLayersId, base::ProcessId aProcessId);
 
-  void Iterate(function<void(uint64_t aLayersId, base::ProcessId aProcessId)> aCallback);
+  void Iterate(std::function<void(uint64_t aLayersId, base::ProcessId aProcessId)> aCallback);
 
 private:
   LayerTreeOwnerTracker();
 
   mozilla::Mutex mLayerIdsLock;
   std::map<uint64_t, base::ProcessId> mLayerIds;
 };
 
--- a/gfx/src/DriverCrashGuard.h
+++ b/gfx/src/DriverCrashGuard.h
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef gfx_src_DriverCrashGuard_h__
 #define gfx_src_DriverCrashGuard_h__
 
 #include "nsCOMPtr.h"
 #include "nsIGfxInfo.h"
 #include "nsIFile.h"
 #include "nsString.h"
-#include "mozilla/Function.h"
+#include <functional>
 #include <string>
 
 namespace mozilla {
 
 namespace dom {
 class ContentParent;
 } // namespace dom
 
@@ -78,17 +78,17 @@ public:
   enum class Mode {
     // Normal operation.
     Normal,
 
     // Acting as a proxy between the parent and child process.
     Proxy
   };
 
-  typedef mozilla::function<void(const char* aName, const char* aPrefName)>
+  typedef std::function<void(const char* aName, const char* aPrefName)>
     CrashGuardCallback;
   static void ForEachActiveCrashGuard(const CrashGuardCallback& aCallback);
 
 protected:
   virtual void Initialize();
   virtual bool UpdateEnvironment() = 0;
   virtual void LogCrashRecovery() = 0;
   virtual void LogFeatureDisabled() = 0;
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -5,17 +5,16 @@
 
 #ifndef GFX_PREFS_H
 #define GFX_PREFS_H
 
 #include <cmath>                 // for M_PI
 #include <stdint.h>
 #include <string>
 #include "mozilla/Assertions.h"
-#include "mozilla/Function.h"
 #include "mozilla/gfx/LoggingConstants.h"
 #include "nsTArray.h"
 
 // First time gfxPrefs::GetSingleton() needs to be called on the main thread,
 // before any of the methods accessing the values are used, but after
 // the Preferences system has been initialized.
 
 // The static methods to access the preference value are safe to call
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -987,17 +987,17 @@ MessageChannel::OnMessageReceivedFromLin
     }
 
     if (shouldPostTask) {
         task->Post();
     }
 }
 
 void
-MessageChannel::PeekMessages(mozilla::function<bool(const Message& aMsg)> aInvoke)
+MessageChannel::PeekMessages(std::function<bool(const Message& aMsg)> aInvoke)
 {
     // FIXME: We shouldn't be holding the lock for aInvoke!
     MonitorAutoLock lock(*mMonitor);
 
     for (RefPtr<MessageTask> it : mPending) {
         const Message &msg = it->Msg();
         if (!aInvoke(msg)) {
             break;
--- a/ipc/glue/MessageChannel.h
+++ b/ipc/glue/MessageChannel.h
@@ -6,31 +6,31 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef ipc_glue_MessageChannel_h
 #define ipc_glue_MessageChannel_h 1
 
 #include "base/basictypes.h"
 #include "base/message_loop.h"
 
-#include "mozilla/Function.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/Vector.h"
 #if defined(OS_WIN)
 #include "mozilla/ipc/Neutering.h"
 #endif // defined(OS_WIN)
 #include "mozilla/ipc/Transport.h"
 #if defined(MOZ_CRASHREPORTER) && defined(OS_WIN)
 #include "mozilla/mozalloc_oom.h"
 #include "nsExceptionHandler.h"
 #endif
 #include "MessageLink.h"
 
 #include <deque>
+#include <functional>
 #include <stack>
 #include <math.h>
 
 namespace mozilla {
 namespace ipc {
 
 class MessageChannel;
 class IToplevelProtocol;
@@ -125,17 +125,17 @@ class MessageChannel : HasResultCodes
     void SetAbortOnError(bool abort)
     {
         mAbortOnError = abort;
     }
 
     // Call aInvoke for each pending message until it returns false.
     // XXX: You must get permission from an IPC peer to use this function
     //      since it requires custom deserialization and re-orders events.
-    void PeekMessages(mozilla::function<bool(const Message& aMsg)> aInvoke);
+    void PeekMessages(std::function<bool(const Message& aMsg)> aInvoke);
 
     // Misc. behavioral traits consumers can request for this channel
     enum ChannelFlags {
       REQUIRE_DEFAULT                         = 0,
       // Windows: if this channel operates on the UI thread, indicates
       // WindowsMessageLoop code should enable deferred native message
       // handling to prevent deadlocks. Should only be used for protocols
       // that manage child processes which might create native UI, like
--- a/ipc/mscom/EnsureMTA.h
+++ b/ipc/mscom/EnsureMTA.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_mscom_EnsureMTA_h
 #define mozilla_mscom_EnsureMTA_h
 
 #include "MainThreadUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
-#include "mozilla/Function.h"
 #include "mozilla/mscom/COMApartmentRegion.h"
 #include "mozilla/mscom/Utils.h"
 #include "nsCOMPtr.h"
 #include "nsIThread.h"
 #include "nsThreadUtils.h"
 
 #include <windows.h>
 
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -4,20 +4,20 @@
  * version 2.0 (the "License"). You can obtain a copy of the License at
  * http://mozilla.org/MPL/2.0/. */
 
 /* rendering object for CSS "display: grid | inline-grid" */
 
 #include "nsGridContainerFrame.h"
 
 #include <algorithm> // for std::stable_sort
+#include <functional>
 #include <limits>
 #include "mozilla/CSSAlignUtils.h"
 #include "mozilla/dom/GridBinding.h"
-#include "mozilla/Function.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/PodOperations.h" // for PodZero
 #include "mozilla/Poison.h"
 #include "nsAbsoluteContainingBlock.h"
 #include "nsAlgorithm.h" // for clamped()
 #include "nsCSSAnonBoxes.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsDataHashtable.h"
@@ -1462,17 +1462,17 @@ struct nsGridContainerFrame::Tracks
     for (uint32_t track : aTracks) {
       MOZ_ASSERT(mSizes[track].mLimit == NS_UNCONSTRAINEDSIZE ||
                  mSizes[track].mLimit <= aPlan[track].mBase);
       mSizes[track].mLimit = aPlan[track].mBase;
     }
   }
 
   using FitContentClamper =
-    function<bool(uint32_t aTrack, nscoord aMinSize, nscoord* aSize)>;
+    std::function<bool(uint32_t aTrack, nscoord aMinSize, nscoord* aSize)>;
   /**
    * Grow the planned size for tracks in aGrowableTracks up to their limit
    * and then freeze them (all aGrowableTracks must be unfrozen on entry).
    * Subtract the space added from aAvailableSpace and return that.
    */
   nscoord GrowTracksToLimit(nscoord                   aAvailableSpace,
                             nsTArray<TrackSize>&      aPlan,
                             const nsTArray<uint32_t>& aGrowableTracks,
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -48,16 +48,17 @@
 #include "mozilla/layers/TextureClient.h"
 #include "mozilla/layers/TextureWrapperImage.h"
 #include "mozilla/Unused.h"
 #include "GeckoProfiler.h"
 #include "LayersLogging.h"
 #include "gfxPrefs.h"
 
 #include <algorithm>
+#include <functional>
 
 using namespace mozilla::layers;
 using namespace mozilla::gfx;
 
 namespace mozilla {
 
 class PaintedDisplayItemLayerUserData;
 
@@ -1263,17 +1264,17 @@ protected:
    * Since mask layers can exist either on the layer directly, or as a side-
    * attachment to FrameMetrics (for ancestor scrollframe clips), we key the
    * recycle operation on both the originating layer and the mask layer's
    * index in the layer, if any.
    */
   struct MaskLayerKey;
   already_AddRefed<ImageLayer>
   CreateOrRecycleMaskImageLayerFor(const MaskLayerKey& aKey,
-                                   mozilla::function<void(Layer* aLayer)> aSetUserData);
+                                   std::function<void(Layer* aLayer)> aSetUserData);
   /**
    * Grabs all PaintedLayers and ColorLayers from the ContainerLayer and makes them
    * available for recycling.
    */
   void CollectOldLayers();
   /**
    * If aItem used to belong to a PaintedLayer, invalidates the area of
    * aItem in that layer. If aNewLayer is a PaintedLayer, invalidates the area of
@@ -2211,17 +2212,17 @@ ContainerState::CreateOrRecycleImageLaye
     // Remove other layer types we might have stored for this PaintedLayer
     data->mColorLayer = nullptr;
   }
   return layer.forget();
 }
 
 already_AddRefed<ImageLayer>
 ContainerState::CreateOrRecycleMaskImageLayerFor(const MaskLayerKey& aKey,
-                                                 mozilla::function<void(Layer* aLayer)> aSetUserData)
+                                                 std::function<void(Layer* aLayer)> aSetUserData)
 {
   RefPtr<ImageLayer> result = mRecycledMaskImageLayers.Get(aKey);
   if (result) {
     mRecycledMaskImageLayers.Remove(aKey);
     aKey.mLayer->ClearExtraDumpInfo();
     // XXX if we use clip on mask layers, null it out here
   } else {
     // Create a new layer
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -5,21 +5,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * a node in the lexicographic tree of rules that match an element,
  * responsible for converting the rules' information into computed style
  */
 
 #include <algorithm>
+#include <functional>
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/DebugOnly.h"
-#include "mozilla/Function.h"
 #include "mozilla/dom/AnimationEffectReadOnlyBinding.h" // for PlaybackDirection
 #include "mozilla/Likely.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/OperatorNewExtensions.h"
 #include "mozilla/Unused.h"
 
 #include "mozilla/css/Declaration.h"
 
@@ -111,28 +111,28 @@ nsConditionalResetStyleData::GetConditio
 
 // Creates an imgRequestProxy based on the specified value in
 // aValue and calls aCallback with it.  If the nsPresContext
 // is static (e.g. for printing), then a static request (i.e.
 // showing the first frame, without animation) will be created.
 // (The expectation is then that aCallback will set the resulting
 // imgRequestProxy in a style struct somewhere.)
 static void
-SetImageRequest(function<void(imgRequestProxy*)> aCallback,
+SetImageRequest(std::function<void(imgRequestProxy*)> aCallback,
                 nsPresContext* aPresContext,
                 const nsCSSValue& aValue)
 {
   RefPtr<imgRequestProxy> req =
     aValue.GetPossiblyStaticImageValue(aPresContext->Document(),
                                        aPresContext);
   aCallback(req);
 }
 
 static void
-SetStyleImageRequest(function<void(nsStyleImageRequest*)> aCallback,
+SetStyleImageRequest(std::function<void(nsStyleImageRequest*)> aCallback,
                      nsPresContext* aPresContext,
                      const nsCSSValue& aValue,
                      nsStyleImageRequest::Mode aModeFlags =
                        nsStyleImageRequest::Mode::Track)
 {
   SetImageRequest([&](imgRequestProxy* aProxy) {
     css::ImageValue* imageValue = aValue.GetImageStructValue();
     ImageTracker* imageTracker =
deleted file mode 100644
--- a/mfbt/Function.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* A type-erased callable wrapper. */
-
-#ifndef mozilla_Function_h
-#define mozilla_Function_h
-
-#include "mozilla/Attributes.h"  // for MOZ_IMPLICIT
-#include "mozilla/Move.h"
-#include "mozilla/RefCounted.h"
-#include "mozilla/RefPtr.h"
-
-// |function<Signature>| is a wrapper that can hold any type of callable
-// object that can be invoked in a way that's compatible with |Signature|.
-// The standard "type erasure" technique is used to avoid the type of the
-// wrapper depending on the concrete type of the wrapped callable.
-//
-// Supported callable types include non-member functions, static member
-// functions, and function objects (that is to say, objects with an overloaded
-// call operator; this includes C++11 lambdas). Member functions aren't
-// directly supported; they first need to be wrapped into a function object
-// using |std::mem_fn()| or an equivalent.
-//
-// |Signature| is a type of the form |ReturnType(Arguments...)|. Syntactically,
-// this is a function type; it's not used in any way other than serving as a
-// vehicle to encode the return and argument types into a single type.
-//
-// |function| is default-constructible. A default-constructed instance is
-// considered "empty". Invoking an empty instance is undefined behaviour.
-// An empty instance can be populated with a callable by assigning to it.
-//
-// This class is intended to provide functionality similar to the C++11
-// standard library class |std::function|.
-
-namespace mozilla {
-
-namespace detail {
-
-template<typename ReturnType, typename... Arguments>
-class FunctionImplBase : public mozilla::RefCounted<FunctionImplBase<ReturnType, Arguments...>>
-{
-public:
-  MOZ_DECLARE_REFCOUNTED_TYPENAME(FunctionImplBase)
-
-  virtual ~FunctionImplBase() {}
-  virtual ReturnType call(Arguments... aArguments) = 0;
-};
-
-// Normal Callable Object.
-template <typename Callable, typename ReturnType, typename... Arguments>
-class FunctionImpl : public FunctionImplBase<ReturnType, Arguments...>
-{
-  public:
-    explicit FunctionImpl(const Callable& aCallable)
-      : mCallable(aCallable) {}
-
-    ReturnType call(Arguments... aArguments) override
-    {
-      return mCallable(Forward<Arguments>(aArguments)...);
-    }
-  private:
-    Callable mCallable;
-};
-
-// Base class for passing pointer to member function.
-template <typename Callable, typename ReturnType, typename... Arguments>
-class MemberFunctionImplBase : public FunctionImplBase<ReturnType, Arguments...>
-{
-public:
-  explicit MemberFunctionImplBase(const Callable& aCallable)
-    : mCallable(aCallable) {}
-
-  ReturnType call(Arguments... aArguments) override
-  {
-    return callInternal(Forward<Arguments>(aArguments)...);
-  }
-private:
-  template<typename ThisType, typename... Args>
-  ReturnType callInternal(ThisType* aThis, Args&&... aArguments)
-  {
-    return (aThis->*mCallable)(Forward<Args>(aArguments)...);
-  }
-
-  template<typename ThisType, typename... Args>
-  ReturnType callInternal(ThisType&& aThis, Args&&... aArguments)
-  {
-    return (aThis.*mCallable)(Forward<Args>(aArguments)...);
-  }
-  Callable mCallable;
-};
-
-// For non-const member function specialization of FunctionImpl.
-template <typename ThisType, typename... Args, typename ReturnType, typename... Arguments>
-class FunctionImpl<ReturnType(ThisType::*)(Args...),
-                   ReturnType, Arguments...>
-  : public MemberFunctionImplBase<ReturnType(ThisType::*)(Args...),
-                                  ReturnType, Arguments...>
-{
-public:
-  explicit FunctionImpl(ReturnType(ThisType::*aMemberFunc)(Args...))
-    : MemberFunctionImplBase<ReturnType(ThisType::*)(Args...),
-                             ReturnType, Arguments...>(aMemberFunc)
-  {}
-};
-
-// For const member function specialization of FunctionImpl.
-template <typename ThisType, typename... Args, typename ReturnType, typename... Arguments>
-class FunctionImpl<ReturnType(ThisType::*)(Args...) const,
-                   ReturnType, Arguments...>
-  : public MemberFunctionImplBase<ReturnType(ThisType::*)(Args...) const,
-                                  ReturnType, Arguments...>
-{
-public:
-  explicit FunctionImpl(ReturnType(ThisType::*aConstMemberFunc)(Args...) const)
-    : MemberFunctionImplBase<ReturnType(ThisType::*)(Args...) const,
-                             ReturnType, Arguments...>(aConstMemberFunc)
-  {}
-};
-
-} // namespace detail
-
-// The primary template is never defined. As |Signature| is required to be
-// of the form |ReturnType(Arguments...)|, we only define a partial
-// specialization that matches this form. This allows us to use |ReturnType|
-// and |Arguments| in the definition of the specialization without having to
-// introspect |Signature|.
-template<typename Signature>
-class function;
-
-template<typename ReturnType, typename... Arguments>
-class function<ReturnType(Arguments...)>
-{
-public:
-  function() {}
-
-  // This constructor is implicit to match the interface of |std::function|.
-  template <typename Callable>
-  MOZ_IMPLICIT function(const Callable& aCallable)
-    : mImpl(new detail::FunctionImpl<Callable, ReturnType, Arguments...>(aCallable))
-  {}
-  MOZ_IMPLICIT function(const function& aFunction)
-    : mImpl(aFunction.mImpl)
-  {}
-  MOZ_IMPLICIT function(decltype(nullptr))
-  {}
-
-  // Move constructor and move assingment operator.
-  // These should be generated automatically, but MSVC doesn't do that yet.
-  function(function&& aOther) : mImpl(Move(aOther.mImpl)) {}
-  function& operator=(function&& aOther) {
-    mImpl = Move(aOther.mImpl);
-    return *this;
-  }
-
-  template <typename Callable>
-  function& operator=(const Callable& aCallable)
-  {
-    mImpl = new detail::FunctionImpl<Callable, ReturnType, Arguments...>(aCallable);
-    return *this;
-  }
-  function& operator=(const function& aFunction)
-  {
-    mImpl = aFunction.mImpl;
-    return *this;
-  }
-  function& operator=(decltype(nullptr))
-  {
-    mImpl = nullptr;
-    return *this;
-  }
-
-  template<typename... Args>
-  ReturnType operator()(Args&&... aArguments) const
-  {
-    MOZ_ASSERT(mImpl);
-    return mImpl->call(Forward<Args>(aArguments)...);
-  }
-
-  explicit operator bool() const
-  {
-    return bool(mImpl);
-  }
-
-private:
-  // TODO: Consider implementing a small object optimization.
-  RefPtr<detail::FunctionImplBase<ReturnType, Arguments...>> mImpl;
-};
-
-template<typename Signature>
-bool
-operator==(const function<Signature>& aX, decltype(nullptr))
-{
-  return !aX;
-}
-
-template<typename Signature>
-bool
-operator==(decltype(nullptr), const function<Signature>& aX)
-{
-  return !aX;
-}
-
-template<typename Signature>
-bool
-operator!=(const function<Signature>& aX, decltype(nullptr))
-{
-  return bool(aX);
-}
-
-template<typename Signature>
-bool
-operator!=(decltype(nullptr), const function<Signature>& aX)
-{
-  return bool(aX);
-}
-
-} // namespace mozilla
-
-#endif /* mozilla_Function_h */
--- a/mfbt/moz.build
+++ b/mfbt/moz.build
@@ -37,17 +37,16 @@ EXPORTS.mozilla = [
     'double-conversion/utils.h',
     'EndianUtils.h',
     'EnumeratedArray.h',
     'EnumeratedRange.h',
     'EnumSet.h',
     'EnumTypeTraits.h',
     'FastBernoulliTrial.h',
     'FloatingPoint.h',
-    'Function.h',
     'GuardObjects.h',
     'HashFunctions.h',
     'IndexSequence.h',
     'IntegerPrintfMacros.h',
     'IntegerRange.h',
     'IntegerTypeTraits.h',
     'JSONWriter.h',
     'Likely.h',
deleted file mode 100644
--- a/mfbt/tests/TestFunction.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-   /* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/Assertions.h"
-#include "mozilla/Function.h"
-
-using mozilla::function;
-
-#define CHECK(c) \
-  do { \
-    bool cond = !!(c); \
-    MOZ_RELEASE_ASSERT(cond, "Failed assertion: " #c); \
-  } while (false)
-
-struct ConvertibleToInt
-{
-  operator int() const { return 42; }
-};
-
-int increment(int arg) { return arg + 1; }
-
-struct S {
-  S() {}
-  static int increment(int arg) { return arg + 1; }
-  int decrement(int arg) { return arg - 1;}
-  int sum(int arg1, int arg2) const { return arg1 + arg2;}
-};
-
-struct Incrementor {
-  int operator()(int arg) { return arg + 1; }
-};
-
-static void
-TestNonmemberFunction()
-{
-  function<int(int)> f = &increment;
-  CHECK(f(42) == 43);
-}
-
-static void
-TestStaticMemberFunction()
-{
-  function<int(int)> f = &S::increment;
-  CHECK(f(42) == 43);
-}
-
-static void
-TestFunctionObject()
-{
-  function<int(int)> f = Incrementor();
-  CHECK(f(42) == 43);
-}
-
-static void
-TestLambda()
-{
-  // Test non-capturing lambda
-  function<int(int)> f = [](int arg){ return arg + 1; };
-  CHECK(f(42) == 43);
-
-  // Test capturing lambda
-  int one = 1;
-  function<int(int)> g = [one](int arg){ return arg + one; };
-  CHECK(g(42) == 43);
-}
-
-static void
-TestDefaultConstructionAndAssignmentLater()
-{
-  function<int(int)> f;  // allowed
-  // Would get an assertion if we tried calling f now.
-  f = &increment;
-  CHECK(f(42) == 43);
-}
-
-static void
-TestReassignment()
-{
-  function<int(int)> f = &increment;
-  CHECK(f(42) == 43);
-  f = [](int arg){ return arg + 2; };
-  CHECK(f(42) == 44);
-}
-
-static void
-TestMemberFunction()
-{
-  function<int(S&, int)> f = &S::decrement;
-  S s;
-  CHECK((f(s, 1) == 0));
-}
-
-static void
-TestConstMemberFunction()
-{
-  function<int(const S*, int, int)> f = &S::sum;
-  const S s;
-  CHECK((f(&s, 1, 1) == 2));
-}
-int
-main()
-{
-  TestNonmemberFunction();
-  TestStaticMemberFunction();
-  TestFunctionObject();
-  TestLambda();
-  TestDefaultConstructionAndAssignmentLater();
-  TestReassignment();
-  TestMemberFunction();
-  TestConstMemberFunction();
-  return 0;
-}
--- a/mfbt/tests/moz.build
+++ b/mfbt/tests/moz.build
@@ -17,17 +17,16 @@ CppUnitTests([
     'TestCountPopulation',
     'TestCountZeroes',
     'TestEndian',
     'TestEnumeratedArray',
     'TestEnumSet',
     'TestEnumTypeTraits',
     'TestFastBernoulliTrial',
     'TestFloatingPoint',
-    'TestFunction',
     'TestIntegerPrintfMacros',
     'TestIntegerRange',
     'TestJSONWriter',
     'TestLinkedList',
     'TestMacroArgs',
     'TestMacroForEach',
     'TestMathAlgorithms',
     'TestMaybe',
--- a/testing/cppunittest.ini
+++ b/testing/cppunittest.ini
@@ -15,17 +15,16 @@
 [TestDllInterceptor]
 skip-if = os != 'win'
 [TestEndian]
 [TestEnumeratedArray]
 [TestEnumSet]
 [TestEnumTypeTraits]
 [TestFastBernoulliTrial]
 [TestFloatingPoint]
-[TestFunction]
 [TestIntegerPrintfMacros]
 [TestIntegerRange]
 [TestJSONWriter]
 [TestLinkedList]
 [TestMacroArgs]
 [TestMacroForEach]
 [TestMathAlgorithms]
 [TestMaybe]
--- a/testing/gtest/mozilla/MozGTestBench.cpp
+++ b/testing/gtest/mozilla/MozGTestBench.cpp
@@ -8,17 +8,17 @@
 #include <stdio.h>
 
 #define MOZ_GTEST_BENCH_FRAMEWORK "platform_microbench"
 
 using mozilla::TimeStamp;
 
 namespace mozilla {
 void GTestBench(const char* aSuite, const char* aName,
-                const mozilla::function<void()>& aTest)
+                const std::function<void()>& aTest)
 {
 #ifdef DEBUG
   // Run the test to make sure that it doesn't fail but don't log
   // any measurements since it's not an optimized build.
   aTest();
 #else
   mozilla::TimeStamp start = TimeStamp::Now();
 
--- a/testing/gtest/mozilla/MozGTestBench.h
+++ b/testing/gtest/mozilla/MozGTestBench.h
@@ -1,21 +1,21 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GTEST_MOZGTESTBENCH_H
 #define GTEST_MOZGTESTBENCH_H
 
-#include "mozilla/Function.h"
+#include <functional>
 
 namespace mozilla {
 
-void GTestBench(const char* aSuite, const char* aName, const mozilla::function<void()>& aTest);
+void GTestBench(const char* aSuite, const char* aName, const std::function<void()>& aTest);
 
 } //mozilla
 
 #define MOZ_GTEST_BENCH(suite, test, lambdaOrFunc) \
 TEST(suite, test) { \
   mozilla::GTestBench(#suite, #test, lambdaOrFunc); \
 }
 
--- a/xpcom/base/NSPRLogModulesParser.cpp
+++ b/xpcom/base/NSPRLogModulesParser.cpp
@@ -10,17 +10,17 @@
 
 const char kDelimiters[] = ", ";
 const char kAdditionalWordChars[] = "_-";
 
 namespace mozilla {
 
 void
 NSPRLogModulesParser(const char* aLogModules,
-                     function<void(const char*, LogLevel, int32_t)> aCallback)
+                     std::function<void(const char*, LogLevel, int32_t)> aCallback)
 {
   if (!aLogModules) {
     return;
   }
 
   Tokenizer parser(aLogModules, kDelimiters, kAdditionalWordChars);
   nsAutoCString moduleName;
 
--- a/xpcom/base/NSPRLogModulesParser.h
+++ b/xpcom/base/NSPRLogModulesParser.h
@@ -1,22 +1,23 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Logging.h"
-#include "mozilla/Function.h"
+
+#include <functional>
 
 namespace mozilla {
 
 /**
  * Helper function that parses the legacy NSPR_LOG_MODULES env var format
  * for specifying log levels and logging options.
  *
  * @param aLogModules The log modules configuration string.
  * @param aCallback The callback to invoke for each log module config entry.
  */
 void NSPRLogModulesParser(const char* aLogModules,
-                          function<void(const char*, LogLevel, int32_t)> aCallback);
+                          std::function<void(const char*, LogLevel, int32_t)> aCallback);
 
 } // namespace mozilla
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -8,32 +8,32 @@
 #define nsTArray_h__
 
 #include "nsTArrayForwardDeclare.h"
 #include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/BinarySearch.h"
 #include "mozilla/fallible.h"
-#include "mozilla/Function.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/ReverseIterator.h"
 #include "mozilla/TypeTraits.h"
 
 #include <string.h>
 
 #include "nsCycleCollectionNoteChild.h"
 #include "nsAlgorithm.h"
 #include "nscore.h"
 #include "nsQuickSort.h"
 #include "nsDebug.h"
 #include "nsISupportsImpl.h"
 #include "nsRegionFwd.h"
+#include <functional>
 #include <initializer_list>
 #include <new>
 
 namespace JS {
 template<class T>
 class Heap;
 } /* namespace JS */
 
@@ -732,16 +732,22 @@ DECLARE_USE_COPY_CONSTRUCTORS(mozilla::S
 DECLARE_USE_COPY_CONSTRUCTORS(mozilla::dom::ipc::StructuredCloneData)
 DECLARE_USE_COPY_CONSTRUCTORS(mozilla::dom::ClonedMessageData)
 DECLARE_USE_COPY_CONSTRUCTORS(mozilla::dom::indexedDB::StructuredCloneReadInfo);
 DECLARE_USE_COPY_CONSTRUCTORS(mozilla::dom::indexedDB::ObjectStoreCursorResponse)
 DECLARE_USE_COPY_CONSTRUCTORS(mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo);
 DECLARE_USE_COPY_CONSTRUCTORS(JSStructuredCloneData)
 DECLARE_USE_COPY_CONSTRUCTORS(mozilla::dom::MessagePortMessage)
 
+template<typename T>
+struct nsTArray_CopyChooser<std::function<T>>
+{
+  typedef nsTArray_CopyWithConstructors<std::function<T>> Type;
+};
+
 
 //
 // Base class for nsTArray_Impl that is templated on element type and derived
 // nsTArray_Impl class, to allow extra conversions to be added for specific
 // types.
 //
 template<class E, class Derived>
 struct nsTArray_TypedBase : public nsTArray_SafeElementAtHelper<E, Derived>
--- a/xpcom/glue/nsTObserverArray.h
+++ b/xpcom/glue/nsTObserverArray.h
@@ -6,16 +6,18 @@
 
 #ifndef nsTObserverArray_h___
 #define nsTObserverArray_h___
 
 #include "mozilla/MemoryReporting.h"
 #include "nsTArray.h"
 #include "nsCycleCollectionNoteChild.h"
 
+#include <functional>
+
 /**
  * An array of observers. Like a normal array, but supports iterators that are
  * stable even if the array is modified during iteration.
  * The template parameter T is the observer type the array will hold;
  * N is the number of built-in storage slots that come with the array.
  * NOTE: You probably want to use nsTObserverArray, unless you specifically
  * want built-in storage. See below.
  * @see nsTObserverArray, nsTArray
@@ -244,17 +246,17 @@ public:
     }
 
     mArray.RemoveElementAt(index);
     AdjustIterators(index, -1);
     return true;
   }
 
   // See nsTArray::RemoveElementsBy.
-  void RemoveElementsBy(mozilla::function<bool(const elem_type&)> aPredicate)
+  void RemoveElementsBy(std::function<bool(const elem_type&)> aPredicate)
   {
     index_type i = 0;
     mArray.RemoveElementsBy([&](const elem_type& aItem) {
       if (aPredicate(aItem)) {
         // This element is going to be removed.
         AdjustIterators(i, -1);
         return true;
       }
--- a/xpcom/tests/gtest/TestAllocReplacement.cpp
+++ b/xpcom/tests/gtest/TestAllocReplacement.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Attributes.h"
-#include "mozilla/Function.h"
 #include "mozilla/mozalloc.h"
 #include "mozilla/ScopeExit.h"
 #include "nsCOMPtr.h"
 #include "nsIMemoryReporter.h"
 #include "nsServiceManagerUtils.h"
 #include "gtest/gtest.h"
 
 // We want to ensure that various functions are hooked properly and that