Bug 1161627 - part 2 - machine-convert TemporaryRef<T> to already_AddRefed<T>; r=ehsan
authorNathan Froyd <froydnj@mozilla.com>
Wed, 17 Jun 2015 10:00:52 -0400
changeset 250746 c664375c0d5bed41821b4a9eaa298e3856efe1d2
parent 250745 c97c48655c828432b02e06775ec8ec74c4a6510c
child 250747 d418eb96a90d8dcf718683f5efb4965f4dc4e820
push id61649
push usernfroyd@mozilla.com
push dateTue, 30 Jun 2015 18:52:55 +0000
treeherdermozilla-inbound@d418eb96a90d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1161627
milestone42.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 1161627 - part 2 - machine-convert TemporaryRef<T> to already_AddRefed<T>; r=ehsan This conversion was done with the script: find . -name '*.cpp' -o -name '*.h' -o -name '*.mm' -o -name '*.idl' | \ egrep -v 'cairo-win32-refptr.h|RefPtr.h|TestRefPtr.cpp' | \ xargs sed -i -e 's/mozilla::TemporaryRef</already_AddRefed</g' \ -e 's/TemporaryRef</already_AddRefed</g' Manual fixups were performed in the following instances: - We handled mfbt/RefPtr.h manually so as to not convert TemporaryRef itself into already_AddRefed. - The following files had explicit Move() calls added to make up for the lack of a copy constructor on already_AddRefed: dom/base/ImageEncoder.cpp dom/media/MediaTaskQueue.{h,cpp} dom/media/webaudio/PannerNode.cpp - A redundant overload for MediaTaskQueue::Dispatch was deleted. - A few manual fixups were required in mfbt/tests/TestRefPtr.cpp. - Comments, using declarations, and forward declarations relating to TemporaryRef in dom/canvas/ and gfx/layers/ were changed to refer to already_AddRefed.
dom/base/ImageEncoder.cpp
dom/base/nsDOMWindowUtils.cpp
dom/canvas/CanvasPath.h
dom/canvas/CanvasRenderingContext2D.cpp
dom/canvas/CanvasRenderingContext2D.h
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextLossHandler.cpp
dom/canvas/WebGLProgram.cpp
dom/canvas/nsICanvasRenderingContextInternal.h
dom/html/HTMLCanvasElement.cpp
dom/html/HTMLCanvasElement.h
dom/media/MediaManager.cpp
dom/media/MediaTaskQueue.cpp
dom/media/MediaTaskQueue.h
dom/media/SharedThreadPool.cpp
dom/media/SharedThreadPool.h
dom/media/VideoUtils.cpp
dom/media/VideoUtils.h
dom/media/directshow/AudioSinkInputPin.cpp
dom/media/directshow/AudioSinkInputPin.h
dom/media/directshow/DirectShowUtils.cpp
dom/media/platforms/wmf/MFTDecoder.cpp
dom/media/platforms/wmf/MFTDecoder.h
dom/media/platforms/wmf/WMFAudioMFTManager.cpp
dom/media/platforms/wmf/WMFAudioMFTManager.h
dom/media/platforms/wmf/WMFMediaDataDecoder.h
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
dom/media/platforms/wmf/WMFVideoMFTManager.h
dom/media/webaudio/PannerNode.cpp
dom/media/webaudio/blink/HRTFDatabaseLoader.cpp
dom/media/webaudio/blink/HRTFDatabaseLoader.h
dom/media/webaudio/blink/HRTFPanner.cpp
dom/media/webaudio/blink/HRTFPanner.h
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/plugins/base/nsNPAPIPluginInstance.h
dom/svg/SVGCircleElement.cpp
dom/svg/SVGCircleElement.h
dom/svg/SVGContentUtils.cpp
dom/svg/SVGContentUtils.h
dom/svg/SVGEllipseElement.cpp
dom/svg/SVGEllipseElement.h
dom/svg/SVGImageElement.cpp
dom/svg/SVGImageElement.h
dom/svg/SVGLineElement.cpp
dom/svg/SVGLineElement.h
dom/svg/SVGMotionSMILPathUtils.cpp
dom/svg/SVGMotionSMILPathUtils.h
dom/svg/SVGPathData.cpp
dom/svg/SVGPathData.h
dom/svg/SVGPathElement.cpp
dom/svg/SVGPathElement.h
dom/svg/SVGPolygonElement.cpp
dom/svg/SVGPolygonElement.h
dom/svg/SVGPolylineElement.cpp
dom/svg/SVGPolylineElement.h
dom/svg/SVGRectElement.cpp
dom/svg/SVGRectElement.h
dom/svg/nsSVGPathGeometryElement.cpp
dom/svg/nsSVGPathGeometryElement.h
dom/system/gonk/MozMtpDatabase.cpp
dom/system/gonk/MozMtpDatabase.h
dom/system/gonk/VolumeManager.cpp
dom/system/gonk/VolumeManager.h
gfx/2d/2D.h
gfx/2d/DataSourceSurface.cpp
gfx/2d/DataSurfaceHelpers.cpp
gfx/2d/DataSurfaceHelpers.h
gfx/2d/DrawTarget.cpp
gfx/2d/DrawTargetCG.cpp
gfx/2d/DrawTargetCG.h
gfx/2d/DrawTargetCairo.cpp
gfx/2d/DrawTargetCairo.h
gfx/2d/DrawTargetCapture.cpp
gfx/2d/DrawTargetCapture.h
gfx/2d/DrawTargetD2D.cpp
gfx/2d/DrawTargetD2D.h
gfx/2d/DrawTargetD2D1.cpp
gfx/2d/DrawTargetD2D1.h
gfx/2d/DrawTargetDual.cpp
gfx/2d/DrawTargetDual.h
gfx/2d/DrawTargetRecording.cpp
gfx/2d/DrawTargetRecording.h
gfx/2d/DrawTargetSkia.cpp
gfx/2d/DrawTargetSkia.h
gfx/2d/DrawTargetTiled.cpp
gfx/2d/DrawTargetTiled.h
gfx/2d/Factory.cpp
gfx/2d/FilterNodeD2D1.cpp
gfx/2d/FilterNodeD2D1.h
gfx/2d/FilterNodeSoftware.cpp
gfx/2d/FilterNodeSoftware.h
gfx/2d/FilterProcessing.cpp
gfx/2d/FilterProcessing.h
gfx/2d/FilterProcessingSIMD-inl.h
gfx/2d/FilterProcessingSSE2.cpp
gfx/2d/FilterProcessingScalar.cpp
gfx/2d/HelpersD2D.h
gfx/2d/MacIOSurface.cpp
gfx/2d/MacIOSurface.h
gfx/2d/PathCG.cpp
gfx/2d/PathCG.h
gfx/2d/PathCairo.cpp
gfx/2d/PathCairo.h
gfx/2d/PathD2D.cpp
gfx/2d/PathD2D.h
gfx/2d/PathHelpers.h
gfx/2d/PathRecording.cpp
gfx/2d/PathRecording.h
gfx/2d/PathSkia.cpp
gfx/2d/PathSkia.h
gfx/2d/QuartzSupport.mm
gfx/2d/RadialGradientEffectD2D1.cpp
gfx/2d/RadialGradientEffectD2D1.h
gfx/2d/SVGTurbulenceRenderer-inl.h
gfx/2d/ScaledFontBase.cpp
gfx/2d/ScaledFontBase.h
gfx/2d/ScaledFontDWrite.cpp
gfx/2d/ScaledFontDWrite.h
gfx/2d/ScaledFontMac.cpp
gfx/2d/ScaledFontMac.h
gfx/2d/SourceSurfaceCG.cpp
gfx/2d/SourceSurfaceCG.h
gfx/2d/SourceSurfaceCairo.cpp
gfx/2d/SourceSurfaceCairo.h
gfx/2d/SourceSurfaceD2D.cpp
gfx/2d/SourceSurfaceD2D.h
gfx/2d/SourceSurfaceD2D1.cpp
gfx/2d/SourceSurfaceD2D1.h
gfx/2d/SourceSurfaceD2DTarget.cpp
gfx/2d/SourceSurfaceD2DTarget.h
gfx/2d/SourceSurfaceDual.h
gfx/gl/AndroidSurfaceTexture.cpp
gfx/gl/AndroidSurfaceTexture.h
gfx/gl/GLReadTexImageHelper.cpp
gfx/gl/GLReadTexImageHelper.h
gfx/gl/GLTextureImage.cpp
gfx/gl/GLTextureImage.h
gfx/gl/SharedSurface.cpp
gfx/gl/SharedSurface.h
gfx/layers/AtomicRefCountedWithFinalize.h
gfx/layers/Compositor.h
gfx/layers/D3D11ShareHandleImage.cpp
gfx/layers/D3D11ShareHandleImage.h
gfx/layers/D3D9SurfaceImage.cpp
gfx/layers/D3D9SurfaceImage.h
gfx/layers/Effects.h
gfx/layers/GLImages.cpp
gfx/layers/GLImages.h
gfx/layers/GrallocImages.cpp
gfx/layers/GrallocImages.h
gfx/layers/IMFYCbCrImage.cpp
gfx/layers/ImageContainer.cpp
gfx/layers/ImageContainer.h
gfx/layers/ImageDataSerializer.cpp
gfx/layers/ImageDataSerializer.h
gfx/layers/Layers.cpp
gfx/layers/Layers.h
gfx/layers/MacIOSurfaceImage.cpp
gfx/layers/MacIOSurfaceImage.h
gfx/layers/PersistentBufferProvider.h
gfx/layers/RotatedBuffer.cpp
gfx/layers/RotatedBuffer.h
gfx/layers/TextureDIB.cpp
gfx/layers/TextureDIB.h
gfx/layers/YCbCrImageDataSerializer.cpp
gfx/layers/YCbCrImageDataSerializer.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicCompositor.h
gfx/layers/basic/BasicImageLayer.cpp
gfx/layers/basic/BasicImages.cpp
gfx/layers/basic/BasicImplData.h
gfx/layers/basic/MacIOSurfaceTextureHostBasic.h
gfx/layers/basic/TextureClientX11.cpp
gfx/layers/basic/TextureClientX11.h
gfx/layers/basic/TextureHostBasic.cpp
gfx/layers/basic/X11BasicCompositor.cpp
gfx/layers/basic/X11BasicCompositor.h
gfx/layers/client/CanvasClient.cpp
gfx/layers/client/CanvasClient.h
gfx/layers/client/CompositableClient.cpp
gfx/layers/client/CompositableClient.h
gfx/layers/client/ContentClient.cpp
gfx/layers/client/ContentClient.h
gfx/layers/client/ImageClient.cpp
gfx/layers/client/ImageClient.h
gfx/layers/client/TextureClient.cpp
gfx/layers/client/TextureClient.h
gfx/layers/client/TextureClientPool.cpp
gfx/layers/client/TextureClientPool.h
gfx/layers/client/TextureClientRecycleAllocator.cpp
gfx/layers/client/TextureClientRecycleAllocator.h
gfx/layers/client/TextureClientSharedSurface.h
gfx/layers/composite/CompositableHost.cpp
gfx/layers/composite/CompositableHost.h
gfx/layers/composite/ContentHost.cpp
gfx/layers/composite/ContentHost.h
gfx/layers/composite/FPSCounter.h
gfx/layers/composite/ImageHost.cpp
gfx/layers/composite/ImageHost.h
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/composite/X11TextureHost.cpp
gfx/layers/composite/X11TextureHost.h
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/CompositorD3D11.h
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d11/TextureD3D11.h
gfx/layers/d3d9/CompositorD3D9.cpp
gfx/layers/d3d9/CompositorD3D9.h
gfx/layers/d3d9/DeviceManagerD3D9.cpp
gfx/layers/d3d9/DeviceManagerD3D9.h
gfx/layers/d3d9/TextureD3D9.cpp
gfx/layers/d3d9/TextureD3D9.h
gfx/layers/ipc/CompositorBench.cpp
gfx/layers/ipc/ISurfaceAllocator.cpp
gfx/layers/ipc/ISurfaceAllocator.h
gfx/layers/ipc/ImageBridgeChild.cpp
gfx/layers/ipc/ImageBridgeChild.h
gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
gfx/layers/ipc/SharedPlanarYCbCrImage.h
gfx/layers/ipc/SharedRGBImage.cpp
gfx/layers/ipc/SharedRGBImage.h
gfx/layers/opengl/CompositingRenderTargetOGL.cpp
gfx/layers/opengl/CompositingRenderTargetOGL.h
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/CompositorOGL.h
gfx/layers/opengl/GrallocTextureClient.cpp
gfx/layers/opengl/GrallocTextureClient.h
gfx/layers/opengl/GrallocTextureHost.cpp
gfx/layers/opengl/GrallocTextureHost.h
gfx/layers/opengl/MacIOSurfaceTextureClientOGL.cpp
gfx/layers/opengl/MacIOSurfaceTextureClientOGL.h
gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h
gfx/layers/opengl/TextureClientOGL.h
gfx/layers/opengl/TextureHostOGL.cpp
gfx/layers/opengl/TextureHostOGL.h
gfx/src/FilterSupport.cpp
gfx/tests/gtest/TestCompositor.cpp
gfx/thebes/gfxAndroidPlatform.cpp
gfx/thebes/gfxAndroidPlatform.h
gfx/thebes/gfxBlur.cpp
gfx/thebes/gfxBlur.h
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxContext.h
gfx/thebes/gfxDWriteFonts.cpp
gfx/thebes/gfxDWriteFonts.h
gfx/thebes/gfxFT2Fonts.cpp
gfx/thebes/gfxFT2Fonts.h
gfx/thebes/gfxFcPlatformFontList.cpp
gfx/thebes/gfxFcPlatformFontList.h
gfx/thebes/gfxFont.h
gfx/thebes/gfxFontconfigFonts.cpp
gfx/thebes/gfxImageSurface.cpp
gfx/thebes/gfxImageSurface.h
gfx/thebes/gfxMacFont.cpp
gfx/thebes/gfxMacFont.h
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformGtk.h
gfx/thebes/gfxPlatformMac.cpp
gfx/thebes/gfxPlatformMac.h
gfx/thebes/gfxQtPlatform.cpp
gfx/thebes/gfxQtPlatform.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
image/ClippedImage.cpp
image/ClippedImage.h
image/DynamicImage.cpp
image/FrozenImage.cpp
image/FrozenImage.h
image/ImageWrapper.cpp
image/OrientedImage.cpp
image/OrientedImage.h
image/RasterImage.cpp
image/RasterImage.h
image/VectorImage.cpp
image/imgFrame.cpp
image/imgFrame.h
image/imgIContainer.idl
layout/base/DisplayItemClip.cpp
layout/base/DisplayItemClip.h
layout/base/nsCSSRenderingBorders.cpp
layout/base/nsCSSRenderingBorders.h
layout/base/nsIPresShell.h
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
layout/svg/SVGTextFrame.cpp
layout/svg/SVGTextFrame.h
layout/svg/nsSVGMaskFrame.cpp
layout/svg/nsSVGMaskFrame.h
layout/svg/nsSVGPatternFrame.cpp
layout/svg/nsSVGPatternFrame.h
media/mtransport/dtlsidentity.cpp
media/mtransport/dtlsidentity.h
media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
mfbt/RefPtr.h
mfbt/tests/TestRefPtr.cpp
mozglue/linker/BaseElf.cpp
mozglue/linker/BaseElf.h
mozglue/linker/CustomElf.cpp
mozglue/linker/CustomElf.h
mozglue/linker/ElfLoader.cpp
mozglue/linker/ElfLoader.h
mozglue/linker/Zip.cpp
mozglue/linker/Zip.h
security/manager/ssl/nsCertTree.cpp
security/manager/ssl/nsCertTree.h
security/manager/ssl/nsNSSComponent.cpp
security/manager/ssl/nsNSSComponent.h
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
widget/gonk/nativewindow/GonkBufferQueueJB.cpp
widget/gonk/nativewindow/GonkBufferQueueJB.h
widget/gonk/nativewindow/GonkBufferQueueKK.cpp
widget/gonk/nativewindow/GonkBufferQueueKK.h
widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueConsumer.cpp
widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueConsumer.h
widget/gonk/nativewindow/GonkNativeWindowICS.cpp
widget/gonk/nativewindow/GonkNativeWindowICS.h
widget/gonk/nativewindow/GonkNativeWindowJB.cpp
widget/gonk/nativewindow/GonkNativeWindowJB.h
widget/gonk/nativewindow/GonkNativeWindowKK.cpp
widget/gonk/nativewindow/GonkNativeWindowKK.h
widget/gonk/nativewindow/GonkNativeWindowLL.cpp
widget/gonk/nativewindow/GonkNativeWindowLL.h
widget/gonk/nativewindow/IGonkGraphicBufferConsumerLL.cpp
widget/gonk/nativewindow/IGonkGraphicBufferConsumerLL.h
widget/gonk/nsWindow.cpp
widget/gonk/nsWindow.h
widget/gtk/nsWindow.cpp
widget/gtk/nsWindow.h
widget/nsBaseWidget.cpp
widget/nsBaseWidget.h
widget/nsIWidget.h
widget/qt/nsWindow.cpp
widget/qt/nsWindow.h
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/dom/base/ImageEncoder.cpp
+++ b/dom/base/ImageEncoder.cpp
@@ -17,17 +17,17 @@ using namespace mozilla::gfx;
 namespace mozilla {
 namespace dom {
 
 // This class should be placed inside GetBRGADataSourceSurfaceSync(). However,
 // due to B2G ICS uses old complier (C++98/03) which forbids local class as
 // template parameter, we need to move this class outside.
 class SurfaceHelper : public nsRunnable {
 public:
-  explicit SurfaceHelper(TemporaryRef<layers::Image> aImage) : mImage(aImage) {}
+  explicit SurfaceHelper(already_AddRefed<layers::Image> aImage) : mImage(aImage) {}
 
   // It retrieves a SourceSurface reference and convert color format on main
   // thread and passes DataSourceSurface to caller thread.
   NS_IMETHOD Run() {
     // It guarantees the reference will be released on main thread.
     nsCountedRef<nsMainThreadSourceSurfaceRef> surface;
     surface.own(mImage->GetAsSourceSurface().take());
 
@@ -36,17 +36,17 @@ public:
     } else {
       mDataSourceSurface = gfxUtils::
         CopySurfaceToDataSourceSurfaceWithFormat(surface,
                                                  gfx::SurfaceFormat::B8G8R8A8);
     }
     return NS_OK;
   }
 
-  TemporaryRef<gfx::DataSourceSurface> GetDataSurfaceSafe() {
+  already_AddRefed<gfx::DataSourceSurface> GetDataSurfaceSafe() {
     nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
     MOZ_ASSERT(mainThread);
     SyncRunnable::DispatchToThread(mainThread, this, false);
 
     return mDataSourceSurface.forget();
   }
 
 private:
@@ -54,20 +54,20 @@ private:
   RefPtr<gfx::DataSourceSurface> mDataSourceSurface;
 };
 
 // This function returns a DataSourceSurface in B8G8R8A8 format.
 // It uses SourceSurface to do format convert. Because most SourceSurface in
 // image formats should be referenced or dereferenced on main thread, it uses a
 // sync class SurfaceHelper to retrieve SourceSurface and convert to B8G8R8A8 on
 // main thread.
-TemporaryRef<DataSourceSurface>
-GetBRGADataSourceSurfaceSync(TemporaryRef<layers::Image> aImage)
+already_AddRefed<DataSourceSurface>
+GetBRGADataSourceSurfaceSync(already_AddRefed<layers::Image> aImage)
 {
-  nsRefPtr<SurfaceHelper> helper = new SurfaceHelper(aImage);
+  nsRefPtr<SurfaceHelper> helper = new SurfaceHelper(Move(aImage));
   return helper->GetDataSurfaceSafe();
 }
 
 class EncodingCompleteEvent : public nsRunnable
 {
   virtual ~EncodingCompleteEvent() {}
 
 public:
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1473,17 +1473,17 @@ nsDOMWindowUtils::GetTranslationNodes(ns
       }
     }
   }
 
   *aRetVal = list.forget().take();
   return NS_OK;
 }
 
-static TemporaryRef<DataSourceSurface>
+static already_AddRefed<DataSourceSurface>
 CanvasToDataSourceSurface(nsIDOMHTMLCanvasElement* aCanvas)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aCanvas);
   if (!node) {
     return nullptr;
   }
 
   MOZ_ASSERT(node->IsElement(),
--- a/dom/canvas/CanvasPath.h
+++ b/dom/canvas/CanvasPath.h
@@ -52,24 +52,24 @@ public:
            double startAngle, double endAngle, bool anticlockwise,
            ErrorResult& error);
 
   void LineTo(const gfx::Point& aPoint);
   void BezierTo(const gfx::Point& aCP1,
                 const gfx::Point& aCP2,
                 const gfx::Point& aCP3);
 
-  TemporaryRef<gfx::Path> GetPath(const CanvasWindingRule& aWinding,
+  already_AddRefed<gfx::Path> GetPath(const CanvasWindingRule& aWinding,
                                   const gfx::DrawTarget* aTarget) const;
 
   explicit CanvasPath(nsISupports* aParent);
-  // TemporaryRef arg because the return value from Path::CopyToBuilder() is
-  // passed directly and we can't drop the only ref to have a raw pointer.
+  // already_AddRefed arg because the return value from Path::CopyToBuilder()
+  // is passed directly and we can't drop the only ref to have a raw pointer.
   CanvasPath(nsISupports* aParent,
-             TemporaryRef<gfx::PathBuilder> aPathBuilder);
+             already_AddRefed<gfx::PathBuilder> aPathBuilder);
 
   void AddPath(CanvasPath& aCanvasPath,
                const Optional<NonNull<SVGMatrix>>& aMatrix);
 
 private:
   virtual ~CanvasPath() {}
 
   nsCOMPtr<nsISupports> mParent;
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -337,17 +337,17 @@ public:
       return;
     }
 
     mTarget->SetTransform(
       mFinalTarget->GetTransform().PostTranslate(-mSourceGraphicRect.TopLeft() + mOffset));
   }
 
   // Return a SourceSurface that contains the FillPaint or StrokePaint source.
-  TemporaryRef<SourceSurface>
+  already_AddRefed<SourceSurface>
   DoSourcePaint(mgfx::IntRect& aRect, CanvasRenderingContext2D::Style aStyle)
   {
     if (aRect.IsEmpty()) {
       return nullptr;
     }
 
     RefPtr<DrawTarget> dt =
       mFinalTarget->CreateSimilarDrawTarget(aRect.Size(), SurfaceFormat::B8G8R8A8);
@@ -4127,17 +4127,17 @@ bool CanvasRenderingContext2D::IsPointIn
                               state.dashOffset);
 
   return tempPath->StrokeContainsPoint(strokeOptions, Point(x, y), mTarget->GetTransform());
 }
 
 // Returns a surface that contains only the part needed to draw aSourceRect.
 // On entry, aSourceRect is relative to aSurface, and on return aSourceRect is
 // relative to the returned surface.
-static TemporaryRef<SourceSurface>
+static already_AddRefed<SourceSurface>
 ExtractSubrect(SourceSurface* aSurface, mgfx::Rect* aSourceRect, DrawTarget* aTargetDT)
 {
   mgfx::Rect roundedOutSourceRect = *aSourceRect;
   roundedOutSourceRect.RoundOut();
   mgfx::IntRect roundedOutSourceRectInt;
   if (!roundedOutSourceRect.ToIntRect(&roundedOutSourceRectInt)) {
     RefPtr<SourceSurface> surface(aSurface);
     return surface.forget();
@@ -5546,17 +5546,17 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(C
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CanvasPath, mParent)
 
 CanvasPath::CanvasPath(nsISupports* aParent)
   : mParent(aParent)
 {
   mPathBuilder = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()->CreatePathBuilder();
 }
 
-CanvasPath::CanvasPath(nsISupports* aParent, TemporaryRef<PathBuilder> aPathBuilder)
+CanvasPath::CanvasPath(nsISupports* aParent, already_AddRefed<PathBuilder> aPathBuilder)
   : mParent(aParent), mPathBuilder(aPathBuilder)
 {
   if (!mPathBuilder) {
     mPathBuilder = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()->CreatePathBuilder();
   }
 }
 
 JSObject*
@@ -5761,17 +5761,17 @@ CanvasPath::AddPath(CanvasPath& aCanvasP
       tempPath = tempBuilder->Finish();
     }
   }
 
   EnsurePathBuilder(); // in case a path is added to itself
   tempPath->StreamToSink(mPathBuilder);
 }
 
-TemporaryRef<gfx::Path>
+already_AddRefed<gfx::Path>
 CanvasPath::GetPath(const CanvasWindingRule& winding, const DrawTarget* aTarget) const
 {
   FillRule fillRule = FillRule::FILL_WINDING;
   if (winding == CanvasWindingRule::Evenodd) {
     fillRule = FillRule::FILL_EVEN_ODD;
   }
 
   if (mPath &&
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -440,17 +440,17 @@ public:
   }
   NS_IMETHOD SetDimensions(int32_t width, int32_t height) override;
   NS_IMETHOD InitializeWithSurface(nsIDocShell *shell, gfxASurface *surface, int32_t width, int32_t height) override;
 
   NS_IMETHOD GetInputStream(const char* aMimeType,
                             const char16_t* aEncoderOptions,
                             nsIInputStream **aStream) override;
 
-  mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot(bool* aPremultAlpha = nullptr) override
+  already_AddRefed<mozilla::gfx::SourceSurface> GetSurfaceSnapshot(bool* aPremultAlpha = nullptr) override
   {
     EnsureTarget();
     if (aPremultAlpha) {
       *aPremultAlpha = true;
     }
     return mTarget->Snapshot();
   }
 
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -1747,17 +1747,17 @@ WebGLContext::ForceRestoreContext()
 }
 
 void
 WebGLContext::MakeContextCurrent() const
 {
     gl->MakeCurrent();
 }
 
-mozilla::TemporaryRef<mozilla::gfx::SourceSurface>
+already_AddRefed<mozilla::gfx::SourceSurface>
 WebGLContext::GetSurfaceSnapshot(bool* out_premultAlpha)
 {
     if (!gl)
         return nullptr;
 
     bool hasAlpha = mOptions.alpha;
     SurfaceFormat surfFormat = hasAlpha ? SurfaceFormat::B8G8R8A8
                                         : SurfaceFormat::B8G8R8X8;
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -229,17 +229,17 @@ public:
     }
 
     virtual void GetImageBuffer(uint8_t** out_imageBuffer,
                                 int32_t* out_format) override;
     NS_IMETHOD GetInputStream(const char* mimeType,
                               const char16_t* encoderOptions,
                               nsIInputStream** out_stream) override;
 
-    mozilla::TemporaryRef<mozilla::gfx::SourceSurface>
+    already_AddRefed<mozilla::gfx::SourceSurface>
     GetSurfaceSnapshot(bool* out_premultAlpha) override;
 
     NS_IMETHOD SetIsOpaque(bool) override { return NS_OK; };
     bool GetIsOpaque() override { return false; }
     NS_IMETHOD SetContextOptions(JSContext* cx,
                                  JS::Handle<JS::Value> options) override;
 
     NS_IMETHOD SetIsIPC(bool) override {
--- a/dom/canvas/WebGLContextLossHandler.cpp
+++ b/dom/canvas/WebGLContextLossHandler.cpp
@@ -26,17 +26,17 @@ WebGLContextLossHandler::WebGLContextLos
 WebGLContextLossHandler::~WebGLContextLossHandler()
 {
     MOZ_ASSERT(!mIsTimerRunning);
 }
 
 void
 WebGLContextLossHandler::StartTimer(unsigned long delayMS)
 {
-    // We can't pass a TemporaryRef through InitWithFuncCallback, so we
+    // We can't pass an already_AddRefed through InitWithFuncCallback, so we
     // should do the AddRef/Release manually.
     this->AddRef();
 
     mTimer->InitWithFuncCallback(StaticTimerCallback,
                                  static_cast<void*>(this),
                                  delayMS,
                                  nsITimer::TYPE_ONE_SHOT);
 }
--- a/dom/canvas/WebGLProgram.cpp
+++ b/dom/canvas/WebGLProgram.cpp
@@ -85,17 +85,17 @@ AddActiveBlockInfo(const nsACString& bas
 {
     RefPtr<webgl::UniformBlockInfo> info = new webgl::UniformBlockInfo(baseUserName, baseMappedName);
 
     activeInfoList->push_back(info);
 }
 
 //#define DUMP_SHADERVAR_MAPPINGS
 
-static TemporaryRef<const webgl::LinkedProgramInfo>
+static already_AddRefed<const webgl::LinkedProgramInfo>
 QueryProgramInfo(WebGLProgram* prog, gl::GLContext* gl)
 {
     RefPtr<webgl::LinkedProgramInfo> info(new webgl::LinkedProgramInfo(prog));
 
     GLuint maxAttribLenWithNull = 0;
     gl->fGetProgramiv(prog->mGLName, LOCAL_GL_ACTIVE_ATTRIBUTE_MAX_LENGTH,
                       (GLint*)&maxAttribLenWithNull);
     if (maxAttribLenWithNull < 1)
--- a/dom/canvas/nsICanvasRenderingContextInternal.h
+++ b/dom/canvas/nsICanvasRenderingContextInternal.h
@@ -105,17 +105,17 @@ public:
                             const char16_t *aEncoderOptions,
                             nsIInputStream **aStream) = 0;
   
   // This gets an Azure SourceSurface for the canvas, this will be a snapshot
   // of the canvas at the time it was called.
   // If aPremultAlpha is provided, then it assumed the callee can handle
   // un-premultiplied surfaces, and *aPremultAlpha will be set to false
   // if one is returned.
-  virtual mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot(bool* aPremultAlpha = nullptr) = 0;
+  virtual already_AddRefed<mozilla::gfx::SourceSurface> GetSurfaceSnapshot(bool* aPremultAlpha = nullptr) = 0;
 
   // If this context is opaque, the backing store of the canvas should
   // be created as opaque; all compositing operators should assume the
   // dst alpha is always 1.0.  If this is never called, the context
   // defaults to false (not opaque).
   NS_IMETHOD SetIsOpaque(bool isOpaque) = 0;
   virtual bool GetIsOpaque() = 0;
 
--- a/dom/html/HTMLCanvasElement.cpp
+++ b/dom/html/HTMLCanvasElement.cpp
@@ -1029,17 +1029,17 @@ void
 HTMLCanvasElement::MarkContextClean()
 {
   if (!mCurrentContext)
     return;
 
   mCurrentContext->MarkContextClean();
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 HTMLCanvasElement::GetSurfaceSnapshot(bool* aPremultAlpha)
 {
   if (!mCurrentContext)
     return nullptr;
 
   return mCurrentContext->GetSurfaceSnapshot(aPremultAlpha);
 }
 
--- a/dom/html/HTMLCanvasElement.h
+++ b/dom/html/HTMLCanvasElement.h
@@ -163,17 +163,17 @@ public:
   nsICanvasRenderingContextInternal *GetContextAtIndex (int32_t index);
 
   /*
    * Returns true if the canvas context content is guaranteed to be opaque
    * across its entire area.
    */
   bool GetIsOpaque();
 
-  virtual TemporaryRef<gfx::SourceSurface> GetSurfaceSnapshot(bool* aPremultAlpha = nullptr);
+  virtual already_AddRefed<gfx::SourceSurface> GetSurfaceSnapshot(bool* aPremultAlpha = nullptr);
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult) override;
   nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, int32_t aModType) const override;
 
   // SetAttr override.  C++ is stupid, so have to override both
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -2130,17 +2130,17 @@ MediaManager::Observe(nsISupports* aSubj
     }
 
     // Because mMediaThread is not an nsThread, we must dispatch to it so it can
     // clean up BackgroundChild. Continue stopping thread once this is done.
 
     class ShutdownTask : public Task
     {
     public:
-      ShutdownTask(TemporaryRef<MediaEngine> aBackend,
+      ShutdownTask(already_AddRefed<MediaEngine> aBackend,
                    nsRunnable* aReply)
         : mReply(aReply)
         , mBackend(aBackend) {}
     private:
       virtual void
       Run()
       {
         LOG(("MediaManager Thread Shutdown"));
--- a/dom/media/MediaTaskQueue.cpp
+++ b/dom/media/MediaTaskQueue.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaTaskQueue.h"
 #include "nsThreadUtils.h"
 #include "SharedThreadPool.h"
 
 namespace mozilla {
 
-MediaTaskQueue::MediaTaskQueue(TemporaryRef<SharedThreadPool> aPool,
+MediaTaskQueue::MediaTaskQueue(already_AddRefed<SharedThreadPool> aPool,
                                bool aRequireTailDispatch)
   : AbstractThread(aRequireTailDispatch)
   , mPool(aPool)
   , mQueueMonitor("MediaTaskQueue::Queue")
   , mTailDispatcher(nullptr)
   , mIsRunning(false)
   , mIsShutdown(false)
   , mIsFlushing(false)
@@ -69,17 +69,17 @@ MediaTaskQueue::DispatchLocked(already_A
   }
   mIsRunning = true;
 
   return NS_OK;
 }
 
 class MediaTaskQueueSyncRunnable : public nsRunnable {
 public:
-  explicit MediaTaskQueueSyncRunnable(TemporaryRef<nsIRunnable> aRunnable)
+  explicit MediaTaskQueueSyncRunnable(already_AddRefed<nsIRunnable> aRunnable)
     : mRunnable(aRunnable)
     , mMonitor("MediaTaskQueueSyncRunnable")
     , mDone(false)
   {
   }
 
   NS_IMETHOD Run() {
     nsresult rv = mRunnable->Run();
@@ -99,19 +99,19 @@ public:
   }
 private:
   RefPtr<nsIRunnable> mRunnable;
   Monitor mMonitor;
   bool mDone;
 };
 
 void
-MediaTaskQueue::SyncDispatch(TemporaryRef<nsIRunnable> aRunnable) {
+MediaTaskQueue::SyncDispatch(already_AddRefed<nsIRunnable> aRunnable) {
   NS_WARNING("MediaTaskQueue::SyncDispatch is dangerous and deprecated. Stop using this!");
-  nsRefPtr<MediaTaskQueueSyncRunnable> task(new MediaTaskQueueSyncRunnable(aRunnable));
+  nsRefPtr<MediaTaskQueueSyncRunnable> task(new MediaTaskQueueSyncRunnable(Move(aRunnable)));
 
   // Tail dispatchers don't interact nicely with sync dispatch. We require that
   // nothing is already in the tail dispatcher, and then sidestep it for this
   // task.
   MOZ_ASSERT_IF(AbstractThread::GetCurrent(),
                 !AbstractThread::GetCurrent()->TailDispatcher().HasTasksFor(this));
   nsRefPtr<MediaTaskQueueSyncRunnable> taskRef = task;
   Dispatch(taskRef.forget(), AssertDispatchSuccess, TailDispatch);
@@ -178,17 +178,17 @@ FlushableMediaTaskQueue::Flush()
 {
   MonitorAutoLock mon(mQueueMonitor);
   AutoSetFlushing autoFlush(this);
   FlushLocked();
   AwaitIdleLocked();
 }
 
 nsresult
-FlushableMediaTaskQueue::FlushAndDispatch(TemporaryRef<nsIRunnable> aRunnable)
+FlushableMediaTaskQueue::FlushAndDispatch(already_AddRefed<nsIRunnable> aRunnable)
 {
   MonitorAutoLock mon(mQueueMonitor);
   AutoSetFlushing autoFlush(this);
   FlushLocked();
   nsCOMPtr<nsIRunnable> r = dont_AddRef(aRunnable.take());
   nsresult rv = DispatchLocked(r.forget(), IgnoreFlushing, AssertDispatchSuccess);
   NS_ENSURE_SUCCESS(rv, rv);
   AwaitIdleLocked();
--- a/dom/media/MediaTaskQueue.h
+++ b/dom/media/MediaTaskQueue.h
@@ -26,24 +26,17 @@ typedef MediaPromise<bool, bool, false> 
 
 // Abstracts executing runnables in order in a thread pool. The runnables
 // dispatched to the MediaTaskQueue will be executed in the order in which
 // they're received, and are guaranteed to not be executed concurrently.
 // They may be executed on different threads, and a memory barrier is used
 // to make this threadsafe for objects that aren't already threadsafe.
 class MediaTaskQueue : public AbstractThread {
 public:
-  explicit MediaTaskQueue(TemporaryRef<SharedThreadPool> aPool, bool aSupportsTailDispatch = false);
-
-  void Dispatch(TemporaryRef<nsIRunnable> aRunnable,
-                DispatchFailureHandling aFailureHandling = AssertDispatchSuccess)
-  {
-    nsCOMPtr<nsIRunnable> r = dont_AddRef(aRunnable.take());
-    return Dispatch(r.forget(), aFailureHandling);
-  }
+  explicit MediaTaskQueue(already_AddRefed<SharedThreadPool> aPool, bool aSupportsTailDispatch = false);
 
   TaskDispatcher& TailDispatcher() override;
 
   MediaTaskQueue* AsTaskQueue() override { return this; }
 
   void Dispatch(already_AddRefed<nsIRunnable> aRunnable,
                 DispatchFailureHandling aFailureHandling = AssertDispatchSuccess,
                 DispatchReason aReason = NormalDispatch) override
@@ -51,17 +44,17 @@ public:
     MonitorAutoLock mon(mQueueMonitor);
     nsresult rv = DispatchLocked(Move(aRunnable), AbortIfFlushing, aFailureHandling, aReason);
     MOZ_DIAGNOSTIC_ASSERT(aFailureHandling == DontAssertDispatchSuccess || NS_SUCCEEDED(rv));
     unused << rv;
   }
 
   // DEPRECATED! Do not us, if a flush happens at the same time, this function
   // can hang and block forever!
-  void SyncDispatch(TemporaryRef<nsIRunnable> aRunnable);
+  void SyncDispatch(already_AddRefed<nsIRunnable> aRunnable);
 
   // Puts the queue in a shutdown state and returns immediately. The queue will
   // remain alive at least until all the events are drained, because the Runners
   // hold a strong reference to the task queue, and one of them is always held
   // by the threadpool event queue when the task queue is non-empty.
   //
   // The returned promise is resolved when the queue goes empty.
   nsRefPtr<ShutdownPromise> BeginShutdown();
@@ -178,18 +171,18 @@ protected:
   private:
     RefPtr<MediaTaskQueue> mQueue;
   };
 };
 
 class FlushableMediaTaskQueue : public MediaTaskQueue
 {
 public:
-  explicit FlushableMediaTaskQueue(TemporaryRef<SharedThreadPool> aPool) : MediaTaskQueue(aPool) {}
-  nsresult FlushAndDispatch(TemporaryRef<nsIRunnable> aRunnable);
+  explicit FlushableMediaTaskQueue(already_AddRefed<SharedThreadPool> aPool) : MediaTaskQueue(Move(aPool)) {}
+  nsresult FlushAndDispatch(already_AddRefed<nsIRunnable> aRunnable);
   void Flush();
 
   bool IsDispatchReliable() override { return false; }
 
 private:
 
   class MOZ_STACK_CLASS AutoSetFlushing
   {
--- a/dom/media/SharedThreadPool.cpp
+++ b/dom/media/SharedThreadPool.cpp
@@ -53,17 +53,17 @@ SharedThreadPool::SpinUntilEmpty()
 {
   MOZ_ASSERT(NS_IsMainThread());
   while (!IsEmpty()) {
     sMonitor->AssertNotCurrentThreadIn();
     NS_ProcessNextEvent(NS_GetCurrentThread(), true);
   }
 }
 
-TemporaryRef<SharedThreadPool>
+already_AddRefed<SharedThreadPool>
 SharedThreadPool::Get(const nsCString& aName, uint32_t aThreadLimit)
 {
   MOZ_ASSERT(sMonitor && sPools);
   ReentrantMonitorAutoEnter mon(*sMonitor);
   SharedThreadPool* pool = nullptr;
   nsresult rv;
   if (!sPools->Get(aName, &pool)) {
     nsCOMPtr<nsIThreadPool> threadPool(CreateThreadPool(aName));
--- a/dom/media/SharedThreadPool.h
+++ b/dom/media/SharedThreadPool.h
@@ -27,17 +27,17 @@ namespace mozilla {
 // all threads in the pool have MSCOM initialized with COINIT_MULTITHREADED.
 class SharedThreadPool : public nsIThreadPool
 {
 public:
 
   // Gets (possibly creating) the shared thread pool singleton instance with
   // thread pool named aName.
   // *Must* be called on the main thread.
-  static TemporaryRef<SharedThreadPool> Get(const nsCString& aName,
+  static already_AddRefed<SharedThreadPool> Get(const nsCString& aName,
                                             uint32_t aThreadLimit = 4);
 
   // We implement custom threadsafe AddRef/Release pair, that destroys the
   // the shared pool singleton when the refcount drops to 0. The addref/release
   // are implemented using locking, so it's not recommended that you use them
   // in a tight loop.
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
   NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override;
--- a/dom/media/VideoUtils.cpp
+++ b/dom/media/VideoUtils.cpp
@@ -196,17 +196,17 @@ IsValidVideoRegion(const nsIntSize& aFra
     aPicture.width * aPicture.height <= MAX_VIDEO_WIDTH * MAX_VIDEO_HEIGHT &&
     aPicture.width * aPicture.height != 0 &&
     aDisplay.width <= PlanarYCbCrImage::MAX_DIMENSION &&
     aDisplay.height <= PlanarYCbCrImage::MAX_DIMENSION &&
     aDisplay.width * aDisplay.height <= MAX_VIDEO_WIDTH * MAX_VIDEO_HEIGHT &&
     aDisplay.width * aDisplay.height != 0;
 }
 
-TemporaryRef<SharedThreadPool> GetMediaThreadPool(MediaThreadType aType)
+already_AddRefed<SharedThreadPool> GetMediaThreadPool(MediaThreadType aType)
 {
   const char *name;
   switch (aType) {
     case MediaThreadType::PLATFORM_DECODER:
       name = "MediaPDecoder";
       break;
     default:
       MOZ_ASSERT(false);
--- a/dom/media/VideoUtils.h
+++ b/dom/media/VideoUtils.h
@@ -216,17 +216,17 @@ class SharedThreadPool;
 // made async supported by MediaPromise, making this unnecessary and
 // permitting unifying the pool.
 enum class MediaThreadType {
   PLAYBACK, // MediaDecoderStateMachine and MediaDecoderReader
   PLATFORM_DECODER
 };
 // Returns the thread pool that is shared amongst all decoder state machines
 // for decoding streams.
-TemporaryRef<SharedThreadPool> GetMediaThreadPool(MediaThreadType aType);
+already_AddRefed<SharedThreadPool> GetMediaThreadPool(MediaThreadType aType);
 
 enum H264_PROFILE {
   H264_PROFILE_UNKNOWN                     = 0,
   H264_PROFILE_BASE                        = 0x42,
   H264_PROFILE_MAIN                        = 0x4D,
   H264_PROFILE_EXTENDED                    = 0x58,
   H264_PROFILE_HIGH                        = 0x64,
 };
--- a/dom/media/directshow/AudioSinkInputPin.cpp
+++ b/dom/media/directshow/AudioSinkInputPin.cpp
@@ -126,17 +126,17 @@ AudioSinkInputPin::Receive(IMediaSample*
     hr = SetAbsoluteMediaTime(aSample);
     NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
     hr = GetSampleSink()->Receive(aSample);
     NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
   }
   return S_OK;
 }
 
-TemporaryRef<IMediaSeeking>
+already_AddRefed<IMediaSeeking>
 AudioSinkInputPin::GetConnectedPinSeeking()
 {
   RefPtr<IPin> peer = GetConnected();
   if (!peer)
     return nullptr;
   RefPtr<IMediaSeeking> seeking;
   peer->QueryInterface(static_cast<IMediaSeeking**>(byRef(seeking)));
   return seeking.forget();
--- a/dom/media/directshow/AudioSinkInputPin.h
+++ b/dom/media/directshow/AudioSinkInputPin.h
@@ -49,17 +49,17 @@ public:
                           REFERENCE_TIME tStop,
                           double dRate) override;
 
   STDMETHODIMP EndOfStream() override;
 
   // Returns the IMediaSeeking interface of the connected output pin.
   // We forward seeking requests upstream from the sink to the source
   // filters.
-  TemporaryRef<IMediaSeeking> GetConnectedPinSeeking();
+  already_AddRefed<IMediaSeeking> GetConnectedPinSeeking();
 
   SampleSink* GetSampleSink();
 
 private:
   AudioSinkFilter* GetAudioSinkFilter();
 
   // Sets the media time on the media sample, relative to the segment
   // start time.
--- a/dom/media/directshow/DirectShowUtils.cpp
+++ b/dom/media/directshow/DirectShowUtils.cpp
@@ -279,17 +279,17 @@ MatchUnconnectedPin(IPin* aPin,
   hr = aPin->QueryDirection(&pinDir);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   *aOutMatches = (pinDir == aPinDir);
   return S_OK;
 }
 
 // Return the first unconnected input pin or output pin.
-TemporaryRef<IPin>
+already_AddRefed<IPin>
 GetUnconnectedPin(IBaseFilter* aFilter, PIN_DIRECTION aPinDir)
 {
   RefPtr<IEnumPins> enumPins;
 
   HRESULT hr = aFilter->EnumPins(byRef(enumPins));
   NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
 
   // Test each pin to see if it matches the direction we're looking for.
--- a/dom/media/platforms/wmf/MFTDecoder.cpp
+++ b/dom/media/platforms/wmf/MFTDecoder.cpp
@@ -63,17 +63,17 @@ MFTDecoder::SetMediaTypes(IMFMediaType* 
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = SendMFTMessage(MFT_MESSAGE_NOTIFY_START_OF_STREAM, 0);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   return S_OK;
 }
 
-TemporaryRef<IMFAttributes>
+already_AddRefed<IMFAttributes>
 MFTDecoder::GetAttributes()
 {
   RefPtr<IMFAttributes> attr;
   HRESULT hr = mDecoder->GetAttributes(byRef(attr));
   NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
   return attr.forget();
 }
 
--- a/dom/media/platforms/wmf/MFTDecoder.h
+++ b/dom/media/platforms/wmf/MFTDecoder.h
@@ -38,17 +38,17 @@ public:
   //    of all the available output types of the MFT.
   typedef HRESULT (*ConfigureOutputCallback)(IMFMediaType* aOutputType, void* aData);
   HRESULT SetMediaTypes(IMFMediaType* aInputType,
                         IMFMediaType* aOutputType,
                         ConfigureOutputCallback aCallback = nullptr,
                         void* aData = nullptr);
 
   // Returns the MFT's IMFAttributes object.
-  TemporaryRef<IMFAttributes> GetAttributes();
+  already_AddRefed<IMFAttributes> GetAttributes();
 
   // Retrieves the media type being output. This may not be valid until
   //  the first sample is decoded.
   HRESULT GetOutputMediaType(RefPtr<IMFMediaType>& aMediaType);
 
   // Submits data into the MFT for processing.
   //
   // Returns:
--- a/dom/media/platforms/wmf/WMFAudioMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFAudioMFTManager.cpp
@@ -108,17 +108,17 @@ WMFAudioMFTManager::GetMediaSubtypeGUID(
   MOZ_ASSERT(mStreamType != Unknown);
   switch (mStreamType) {
     case AAC: return MFAudioFormat_AAC;
     case MP3: return MFAudioFormat_MP3;
     default: return GUID_NULL;
   };
 }
 
-TemporaryRef<MFTDecoder>
+already_AddRefed<MFTDecoder>
 WMFAudioMFTManager::Init()
 {
   NS_ENSURE_TRUE(mStreamType != Unknown, nullptr);
 
   RefPtr<MFTDecoder> decoder(new MFTDecoder());
 
   HRESULT hr = decoder->Create(GetMFTGUID());
   NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
--- a/dom/media/platforms/wmf/WMFAudioMFTManager.h
+++ b/dom/media/platforms/wmf/WMFAudioMFTManager.h
@@ -15,17 +15,17 @@
 
 namespace mozilla {
 
 class WMFAudioMFTManager : public MFTManager {
 public:
   WMFAudioMFTManager(const AudioInfo& aConfig);
   ~WMFAudioMFTManager();
 
-  virtual TemporaryRef<MFTDecoder> Init() override;
+  virtual already_AddRefed<MFTDecoder> Init() override;
 
   virtual HRESULT Input(MediaRawData* aSample) override;
 
   // Note WMF's AAC decoder sometimes output negatively timestamped samples,
   // presumably they're the preroll samples, and we strip them. We may return
   // a null aOutput in this case.
   virtual HRESULT Output(int64_t aStreamOffset,
                          nsRefPtr<MediaData>& aOutput) override;
--- a/dom/media/platforms/wmf/WMFMediaDataDecoder.h
+++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.h
@@ -19,17 +19,17 @@ namespace mozilla {
 // a given stream, and the process of converting the IMFSample produced
 // by the MFT into a MediaData object.
 class MFTManager {
 public:
   virtual ~MFTManager() {}
 
   // Creates an initializs the MFTDecoder.
   // Returns nullptr on failure.
-  virtual TemporaryRef<MFTDecoder> Init() = 0;
+  virtual already_AddRefed<MFTDecoder> Init() = 0;
 
   // Submit a compressed sample for decoding.
   // This should forward to the MFTDecoder after performing
   // any required sample formatting.
   virtual HRESULT Input(MediaRawData* aSample) = 0;
 
   // Produces decoded output, if possible. Blocks until output can be produced,
   // or until no more is able to be produced.
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -167,32 +167,32 @@ WMFVideoMFTManager::InitializeDXVA(bool 
   } else {
     NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
   }
   mDXVA2Manager = event->mDXVA2Manager;
 
   return mDXVA2Manager != nullptr;
 }
 
-TemporaryRef<MFTDecoder>
+already_AddRefed<MFTDecoder>
 WMFVideoMFTManager::Init()
 {
   RefPtr<MFTDecoder> decoder = InitInternal(/* aForceD3D9 = */ false);
 
   // If initialization failed with d3d11 DXVA then try falling back
   // to d3d9.
   if (!decoder && mDXVA2Manager && mDXVA2Manager->IsD3D11()) {
     mDXVA2Manager = nullptr;
     decoder = InitInternal(true);
   }
 
   return decoder.forget();
 }
 
-TemporaryRef<MFTDecoder>
+already_AddRefed<MFTDecoder>
 WMFVideoMFTManager::InitInternal(bool aForceD3D9)
 {
   mUseHwAccel = false; // default value; changed if D3D setup succeeds.
   bool useDxva = InitializeDXVA(aForceD3D9);
 
   RefPtr<MFTDecoder> decoder(new MFTDecoder());
 
   HRESULT hr = decoder->Create(GetMFTGUID());
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -21,32 +21,32 @@ class DXVA2Manager;
 class WMFVideoMFTManager : public MFTManager {
 public:
   WMFVideoMFTManager(const VideoInfo& aConfig,
                      mozilla::layers::LayersBackend aLayersBackend,
                      mozilla::layers::ImageContainer* aImageContainer,
                      bool aDXVAEnabled);
   ~WMFVideoMFTManager();
 
-  virtual TemporaryRef<MFTDecoder> Init() override;
+  virtual already_AddRefed<MFTDecoder> Init() override;
 
   virtual HRESULT Input(MediaRawData* aSample) override;
 
   virtual HRESULT Output(int64_t aStreamOffset,
                          nsRefPtr<MediaData>& aOutput) override;
 
   virtual void Shutdown() override;
 
   virtual bool IsHardwareAccelerated() const override;
 
 private:
 
   bool InitializeDXVA(bool aForceD3D9);
 
-  TemporaryRef<MFTDecoder> InitInternal(bool aForceD3D9);
+  already_AddRefed<MFTDecoder> InitInternal(bool aForceD3D9);
 
   HRESULT ConfigureVideoFrameGeometry();
 
   HRESULT CreateBasicVideoFrame(IMFSample* aSample,
                                 int64_t aStreamOffset,
                                 VideoData** aOutVideoData);
 
   HRESULT CreateD3DVideoFrame(IMFSample* aSample,
--- a/dom/media/webaudio/PannerNode.cpp
+++ b/dom/media/webaudio/PannerNode.cpp
@@ -58,19 +58,19 @@ public:
     , mConeOuterGain(0.)
     // These will be initialized when a PannerNode is created, so just initialize them
     // to some dummy values here.
     , mListenerDopplerFactor(0.)
     , mListenerSpeedOfSound(0.)
     , mLeftOverData(INT_MIN)
   {
     // HRTFDatabaseLoader needs to be fetched on the main thread.
-    TemporaryRef<HRTFDatabaseLoader> loader =
+    already_AddRefed<HRTFDatabaseLoader> loader =
       HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(aNode->Context()->SampleRate());
-    mHRTFPanner = new HRTFPanner(aNode->Context()->SampleRate(), loader);
+    mHRTFPanner = new HRTFPanner(aNode->Context()->SampleRate(), Move(loader));
   }
 
   virtual void SetInt32Parameter(uint32_t aIndex, int32_t aParam) override
   {
     switch (aIndex) {
     case PannerNode::PANNING_MODEL:
       switch (PanningModelType(aParam)) {
         case PanningModelType::Equalpower:
--- a/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp
+++ b/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp
@@ -37,17 +37,17 @@ namespace WebCore {
 nsTHashtable<HRTFDatabaseLoader::LoaderByRateEntry>*
     HRTFDatabaseLoader::s_loaderMap = nullptr;
 
 size_t HRTFDatabaseLoader::sizeOfLoaders(mozilla::MallocSizeOf aMallocSizeOf)
 {
     return s_loaderMap ? s_loaderMap->SizeOfIncludingThis(aMallocSizeOf) : 0;
 }
 
-TemporaryRef<HRTFDatabaseLoader> HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(float sampleRate)
+already_AddRefed<HRTFDatabaseLoader> HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(float sampleRate)
 {
     MOZ_ASSERT(NS_IsMainThread());
 
     RefPtr<HRTFDatabaseLoader> loader;
     
     if (!s_loaderMap) {
         s_loaderMap = new nsTHashtable<LoaderByRateEntry>();
     }
--- a/dom/media/webaudio/blink/HRTFDatabaseLoader.h
+++ b/dom/media/webaudio/blink/HRTFDatabaseLoader.h
@@ -43,17 +43,17 @@ namespace WebCore {
 // HRTFDatabaseLoader will asynchronously load the default HRTFDatabase in a new thread.
 
 class HRTFDatabaseLoader {
 public:
     // Lazily creates a HRTFDatabaseLoader (if not already created) for the given sample-rate
     // and starts loading asynchronously (when created the first time).
     // Returns the HRTFDatabaseLoader.
     // Must be called from the main thread.
-    static mozilla::TemporaryRef<HRTFDatabaseLoader> createAndLoadAsynchronouslyIfNecessary(float sampleRate);
+    static already_AddRefed<HRTFDatabaseLoader> createAndLoadAsynchronouslyIfNecessary(float sampleRate);
 
     // AddRef and Release may be called from any thread.
     void AddRef()
     {
 #if defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING)
         int count =
 #endif
           ++m_refCnt;
--- a/dom/media/webaudio/blink/HRTFPanner.cpp
+++ b/dom/media/webaudio/blink/HRTFPanner.cpp
@@ -36,17 +36,17 @@ namespace WebCore {
 
 // The value of 2 milliseconds is larger than the largest delay which exists in any HRTFKernel from the default HRTFDatabase (0.0136 seconds).
 // We ASSERT the delay values used in process() with this value.
 const double MaxDelayTimeSeconds = 0.002;
 
 const int UninitializedAzimuth = -1;
 const unsigned RenderingQuantum = WEBAUDIO_BLOCK_SIZE;
 
-HRTFPanner::HRTFPanner(float sampleRate, mozilla::TemporaryRef<HRTFDatabaseLoader> databaseLoader)
+HRTFPanner::HRTFPanner(float sampleRate, already_AddRefed<HRTFDatabaseLoader> databaseLoader)
     : m_databaseLoader(databaseLoader)
     , m_sampleRate(sampleRate)
     , m_crossfadeSelection(CrossfadeSelection1)
     , m_azimuthIndex1(UninitializedAzimuth)
     , m_azimuthIndex2(UninitializedAzimuth)
     // m_elevation1 and m_elevation2 are initialized in pan()
     , m_crossfadeX(0)
     , m_crossfadeIncr(0)
--- a/dom/media/webaudio/blink/HRTFPanner.h
+++ b/dom/media/webaudio/blink/HRTFPanner.h
@@ -38,17 +38,17 @@ namespace WebCore {
 typedef nsTArray<float> AudioFloatArray;
 
 class HRTFDatabaseLoader;
 
 using mozilla::AudioChunk;
 
 class HRTFPanner {
 public:
-    HRTFPanner(float sampleRate, mozilla::TemporaryRef<HRTFDatabaseLoader> databaseLoader);
+    HRTFPanner(float sampleRate, already_AddRefed<HRTFDatabaseLoader> databaseLoader);
     ~HRTFPanner();
 
     // chunk durations must be 128
     void pan(double azimuth, double elevation, const AudioChunk* inputBus, AudioChunk* outputBus);
     void reset();
 
     size_t fftSize() const { return m_convolverL1.fftSize(); }
 
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -950,17 +950,17 @@ nsNPAPIPluginInstance::TextureInfo nsNPA
 }
 
 void nsNPAPIPluginInstance::ReleaseContentTexture(nsNPAPIPluginInstance::TextureInfo& aTextureInfo)
 {
   EnsureSharedTexture();
   mContentTexture->Release(aTextureInfo);
 }
 
-TemporaryRef<AndroidSurfaceTexture> nsNPAPIPluginInstance::CreateSurfaceTexture()
+already_AddRefed<AndroidSurfaceTexture> nsNPAPIPluginInstance::CreateSurfaceTexture()
 {
   if (!EnsureGLContext())
     return nullptr;
 
   GLuint texture = TexturePoolOGL::AcquireTexture();
   if (!texture)
     return nullptr;
 
--- a/dom/plugins/base/nsNPAPIPluginInstance.h
+++ b/dom/plugins/base/nsNPAPIPluginInstance.h
@@ -381,17 +381,17 @@ private:
 #endif
 
   // Timestamp for the last time this plugin was stopped.
   // This is only valid when the plugin is actually stopped!
   mozilla::TimeStamp mStopTime;
 
 #ifdef MOZ_WIDGET_ANDROID
   void EnsureSharedTexture();
-  mozilla::TemporaryRef<mozilla::gl::AndroidSurfaceTexture> CreateSurfaceTexture();
+  already_AddRefed<mozilla::gl::AndroidSurfaceTexture> CreateSurfaceTexture();
 
   std::map<void*, VideoInfo*> mVideos;
   bool mOnScreen;
 
   nsIntSize mCurrentSize;
 #endif
 
   // is this instance Java and affected by bug 750480?
--- a/dom/svg/SVGCircleElement.cpp
+++ b/dom/svg/SVGCircleElement.cpp
@@ -104,17 +104,17 @@ SVGCircleElement::GetGeometryBounds(
     Rect rect(x - r, y - r, 2 * r, 2 * r);
     *aBounds = aTransform.TransformBounds(rect);
     return true;
   }
 
   return false;
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGCircleElement::BuildPath(PathBuilder* aBuilder)
 {
   float x, y, r;
   GetAnimatedLengthValues(&x, &y, &r, nullptr);
 
   if (r <= 0.0f) {
     return nullptr;
   }
--- a/dom/svg/SVGCircleElement.h
+++ b/dom/svg/SVGCircleElement.h
@@ -28,17 +28,17 @@ protected:
 
 public:
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const override;
 
   // nsSVGPathGeometryElement methods:
   virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
                                  const Matrix& aTransform) override;
-  virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder) override;
+  virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
   // WebIDL
   already_AddRefed<SVGAnimatedLength> Cx();
   already_AddRefed<SVGAnimatedLength> Cy();
   already_AddRefed<SVGAnimatedLength> R();
 
--- a/dom/svg/SVGContentUtils.cpp
+++ b/dom/svg/SVGContentUtils.cpp
@@ -792,17 +792,17 @@ SVGContentUtils::CoordToFloat(nsSVGEleme
     SVGSVGElement* ctx = aContent->GetCtx();
     return ctx ? aCoord.GetPercentValue() * ctx->GetLength(SVGContentUtils::XY) : 0.0f;
   }
   default:
     return 0.0f;
   }
 }
 
-TemporaryRef<gfx::Path>
+already_AddRefed<gfx::Path>
 SVGContentUtils::GetPath(const nsAString& aPathString)
 {
   SVGPathData pathData;
   nsSVGPathDataParser parser(aPathString, &pathData);
   if (!parser.Parse()) {
     return NULL;
   }
 
--- a/dom/svg/SVGContentUtils.h
+++ b/dom/svg/SVGContentUtils.h
@@ -316,17 +316,17 @@ public:
    */
   static float CoordToFloat(nsSVGElement *aContent,
                             const nsStyleCoord &aCoord);
   /**
    * Parse the SVG path string
    * Returns a path
    * string formatted as an SVG path
    */
-  static mozilla::TemporaryRef<mozilla::gfx::Path>
+  static already_AddRefed<mozilla::gfx::Path>
   GetPath(const nsAString& aPathString);
 
   /**
    *  Returns true if aContent is one of the elements whose stroke is guaranteed
    *  to have no corners: circle or ellipse
    */
   static bool ShapeTypeHasNoCorners(const nsIContent* aContent);
 };
--- a/dom/svg/SVGEllipseElement.cpp
+++ b/dom/svg/SVGEllipseElement.cpp
@@ -116,17 +116,17 @@ SVGEllipseElement::GetGeometryBounds(
     Rect rect(x - rx, y - ry, 2 * rx, 2 * ry);
     *aBounds = aTransform.TransformBounds(rect);
     return true;
   }
 
   return false;
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGEllipseElement::BuildPath(PathBuilder* aBuilder)
 {
   float x, y, rx, ry;
   GetAnimatedLengthValues(&x, &y, &rx, &ry, nullptr);
 
   if (rx <= 0.0f || ry <= 0.0f) {
     return nullptr;
   }
--- a/dom/svg/SVGEllipseElement.h
+++ b/dom/svg/SVGEllipseElement.h
@@ -28,17 +28,17 @@ protected:
 
 public:
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const override;
 
   // nsSVGPathGeometryElement methods:
   virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
                                  const Matrix& aTransform) override;
-  virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder) override;
+  virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
   // WebIDL
   already_AddRefed<SVGAnimatedLength> Cx();
   already_AddRefed<SVGAnimatedLength> Cy();
   already_AddRefed<SVGAnimatedLength> Rx();
   already_AddRefed<SVGAnimatedLength> Ry();
--- a/dom/svg/SVGImageElement.cpp
+++ b/dom/svg/SVGImageElement.cpp
@@ -237,17 +237,17 @@ SVGImageElement::GetGeometryBounds(
     // Rendering of the element disabled
     rect.SetEmpty(); // Make sure width/height are zero and not negative
   }
 
   *aBounds = aTransform.TransformBounds(rect);
   return true;
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGImageElement::BuildPath(PathBuilder* aBuilder)
 {
   // We get called in order to get bounds for this element, and for
   // hit-testing against it. For that we just pretend to be a rectangle.
 
   float x, y, width, height;
   GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
 
--- a/dom/svg/SVGImageElement.h
+++ b/dom/svg/SVGImageElement.h
@@ -51,17 +51,17 @@ public:
 
   virtual EventStates IntrinsicState() const override;
 
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const override;
 
   // nsSVGPathGeometryElement methods:
   virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
                                  const Matrix& aTransform) override;
-  virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder) override;
+  virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
 
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const override;
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
   nsresult CopyInnerTo(mozilla::dom::Element* aDest);
 
--- a/dom/svg/SVGLineElement.cpp
+++ b/dom/svg/SVGLineElement.cpp
@@ -110,17 +110,17 @@ SVGLineElement::GetMarkPoints(nsTArray<n
 void
 SVGLineElement::GetAsSimplePath(SimplePath* aSimplePath)
 {
   float x1, y1, x2, y2;
   GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
   aSimplePath->SetLine(x1, y1, x2, y2);
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGLineElement::BuildPath(PathBuilder* aBuilder)
 {
   float x1, y1, x2, y2;
   GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
 
   aBuilder->MoveTo(Point(x1, y1));
   aBuilder->LineTo(Point(x2, y2));
 
--- a/dom/svg/SVGLineElement.h
+++ b/dom/svg/SVGLineElement.h
@@ -29,17 +29,17 @@ protected:
 public:
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const override;
 
   // nsSVGPathGeometryElement methods:
   virtual bool IsMarkable() override { return true; }
   virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
   virtual void GetAsSimplePath(SimplePath* aSimplePath) override;
-  virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder) override;
+  virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
   virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
                                  const Matrix& aTransform) override;
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
   // WebIDL
   already_AddRefed<SVGAnimatedLength> X1();
   already_AddRefed<SVGAnimatedLength> Y1();
--- a/dom/svg/SVGMotionSMILPathUtils.cpp
+++ b/dom/svg/SVGMotionSMILPathUtils.cpp
@@ -75,17 +75,17 @@ SVGMotionSMILPathUtils::PathGenerator::
   if (!ParseCoordinatePair(aCoordPairStr, xVal, yVal)) {
     return false;
   }
   mPathBuilder->LineTo(mPathBuilder->CurrentPoint() + Point(xVal, yVal));
   aSegmentDistance = NS_hypot(xVal, yVal);
   return true;
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGMotionSMILPathUtils::PathGenerator::GetResultingPath()
 {
   return mPathBuilder->Finish();
 }
 
 //----------------------------------------------------------------------
 // Helper / protected methods
 
--- a/dom/svg/SVGMotionSMILPathUtils.h
+++ b/dom/svg/SVGMotionSMILPathUtils.h
@@ -57,17 +57,17 @@ public:
     bool LineToAbsolute(const nsAString& aCoordPairStr,
                           double& aSegmentDistance);
     bool LineToRelative(const nsAString& aCoordPairStr,
                           double& aSegmentDistance);
 
     // Accessor to let clients check if we've received any commands yet.
     inline bool HaveReceivedCommands() { return mHaveReceivedCommands; }
     // Accessor to get the finalized path
-    mozilla::TemporaryRef<Path> GetResultingPath();
+    already_AddRefed<Path> GetResultingPath();
 
   protected:
     // Helper methods
     bool ParseCoordinatePair(const nsAString& aStr,
                                float& aXVal, float& aYVal);
 
     // Member data
     const nsSVGElement* mSVGElement; // context for converting to user units
--- a/dom/svg/SVGPathData.cpp
+++ b/dom/svg/SVGPathData.cpp
@@ -268,17 +268,17 @@ ApproximateZeroLengthSubpathSquareCaps(P
     if (!subpathHasLength && hasLineCaps && aStrokeWidth > 0 &&               \
         subpathContainsNonMoveTo &&                                           \
         SVGPathSegUtils::IsValidType(prevSegType) &&                          \
         (!IsMoveto(prevSegType) || segType == PATHSEG_CLOSEPATH)) {           \
       ApproximateZeroLengthSubpathSquareCaps(builder, segStart, aStrokeWidth);\
     }                                                                         \
   } while(0)
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGPathData::BuildPath(PathBuilder* builder,
                        uint8_t aStrokeLineCap,
                        Float aStrokeWidth) const
 {
   if (mData.IsEmpty() || !IsMoveto(SVGPathSegUtils::DecodeType(mData[0]))) {
     return nullptr; // paths without an initial moveto are invalid
   }
 
@@ -502,17 +502,17 @@ SVGPathData::BuildPath(PathBuilder* buil
   MOZ_ASSERT(prevSegType == segType,
              "prevSegType should be left at the final segType");
 
   MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS_TO_DT;
 
   return builder->Finish();
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGPathData::BuildPathForMeasuring() const
 {
   // Since the path that we return will not be used for painting it doesn't
   // matter what we pass to CreatePathBuilder as aFillRule. Hawever, we do want
   // to pass something other than NS_STYLE_STROKE_LINECAP_SQUARE as
   // aStrokeLineCap to avoid the insertion of extra little lines (by
   // ApproximateZeroLengthSubpathSquareCaps), in which case the value that we
   // pass as aStrokeWidth doesn't matter (since it's only used to determine the
--- a/dom/svg/SVGPathData.h
+++ b/dom/svg/SVGPathData.h
@@ -159,19 +159,19 @@ public:
    */
   bool GetDistancesFromOriginToEndsOfVisibleSegments(FallibleTArray<double> *aArray) const;
 
   /**
    * This returns a path without the extra little line segments that
    * ApproximateZeroLengthSubpathSquareCaps can insert if we have square-caps.
    * See the comment for that function for more info on that.
    */
-  TemporaryRef<Path> BuildPathForMeasuring() const;
+  already_AddRefed<Path> BuildPathForMeasuring() const;
 
-  TemporaryRef<Path> BuildPath(PathBuilder* aBuilder,
+  already_AddRefed<Path> BuildPath(PathBuilder* aBuilder,
                                uint8_t aCapStyle,
                                Float aStrokeWidth) const;
 
   const_iterator begin() const { return mData.Elements(); }
   const_iterator end() const { return mData.Elements() + mData.Length(); }
 
   // memory reporting methods
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
--- a/dom/svg/SVGPathElement.cpp
+++ b/dom/svg/SVGPathElement.cpp
@@ -300,17 +300,17 @@ SVGPathElement::IsAttributeMapped(const 
   static const MappedAttributeEntry* const map[] = {
     sMarkersMap
   };
 
   return FindAttributeDependence(name, map) ||
     SVGPathElementBase::IsAttributeMapped(name);
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGPathElement::GetOrBuildPathForMeasuring()
 {
   return mD.GetAnimValue().BuildPathForMeasuring();
 }
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
@@ -359,17 +359,17 @@ SVGPathElement::GetPathLengthScale(PathL
         }
       }
       return path->ComputeLength() / authorsPathLengthEstimate;
     }
   }
   return 1.0;
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGPathElement::BuildPath(PathBuilder* aBuilder)
 {
   // The Moz2D PathBuilder that our SVGPathData will be using only cares about
   // the fill rule. However, in order to fulfill the requirements of the SVG
   // spec regarding zero length sub-paths when square line caps are in use,
   // SVGPathData needs to know our stroke-linecap style and, if "square", then
   // also our stroke width. See the comment for
   // ApproximateZeroLengthSubpathSquareCaps for more info.
--- a/dom/svg/SVGPathElement.h
+++ b/dom/svg/SVGPathElement.h
@@ -46,24 +46,24 @@ public:
 
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const override;
 
   // nsSVGPathGeometryElement methods:
   virtual bool AttributeDefinesGeometry(const nsIAtom *aName) override;
   virtual bool IsMarkable() override;
   virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
-  virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder) override;
+  virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
 
   /**
    * This returns a path without the extra little line segments that
    * ApproximateZeroLengthSubpathSquareCaps can insert if we have square-caps.
    * See the comment for that function for more info on that.
    */
-  virtual TemporaryRef<Path> GetOrBuildPathForMeasuring() override;
+  virtual already_AddRefed<Path> GetOrBuildPathForMeasuring() override;
 
   // nsIContent interface
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
   virtual SVGAnimatedPathSegList* GetAnimPathSegList() override {
     return &mD;
   }
 
--- a/dom/svg/SVGPolygonElement.cpp
+++ b/dom/svg/SVGPolygonElement.cpp
@@ -57,17 +57,17 @@ SVGPolygonElement::GetMarkPoints(nsTArra
   startMark->angle = SVGContentUtils::AngleBisect(angle, startMark->angle);
   // for a polygon (as opposed to a polyline) there's an implicit extra point
   // co-located with the start point that nsSVGPolyElement::GetMarkPoints
   // doesn't return
   aMarks->AppendElement(nsSVGMark(startMark->x, startMark->y, startMark->angle,
                                   nsSVGMark::eEnd));
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGPolygonElement::BuildPath(PathBuilder* aBuilder)
 {
   const SVGPointList &points = mPoints.GetAnimValue();
 
   if (points.IsEmpty()) {
     return nullptr;
   }
 
--- a/dom/svg/SVGPolygonElement.h
+++ b/dom/svg/SVGPolygonElement.h
@@ -24,17 +24,17 @@ protected:
   explicit SVGPolygonElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
   friend nsresult (::NS_NewSVGPolygonElement(nsIContent **aResult,
                                              already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
 public:
   // nsSVGPathGeometryElement methods:
   virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
-  virtual mozilla::TemporaryRef<Path> BuildPath(PathBuilder* aBuilder) override;
+  virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_SVGPolygonElement_h
--- a/dom/svg/SVGPolylineElement.cpp
+++ b/dom/svg/SVGPolylineElement.cpp
@@ -33,17 +33,17 @@ SVGPolylineElement::SVGPolylineElement(a
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPolylineElement)
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGPolylineElement::BuildPath(PathBuilder* aBuilder)
 {
   const SVGPointList &points = mPoints.GetAnimValue();
 
   if (points.IsEmpty()) {
     return nullptr;
   }
 
--- a/dom/svg/SVGPolylineElement.h
+++ b/dom/svg/SVGPolylineElement.h
@@ -21,17 +21,17 @@ class SVGPolylineElement final : public 
 {
 protected:
   explicit SVGPolylineElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
   friend nsresult (::NS_NewSVGPolylineElement(nsIContent **aResult,
                                               already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
   // nsSVGPathGeometryElement methods:
-  virtual mozilla::TemporaryRef<Path> BuildPath(PathBuilder* aBuilder) override;
+  virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
 
 public:
   // nsIContent interface
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 };
 
 } // namespace mozilla
 } // namespace dom
--- a/dom/svg/SVGRectElement.cpp
+++ b/dom/svg/SVGRectElement.cpp
@@ -163,17 +163,17 @@ SVGRectElement::GetAsSimplePath(SimplePa
   if (rx != 0 || ry != 0) {
     aSimplePath->Reset();
     return;
   }
 
   aSimplePath->SetRect(x, y, width, height);
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 SVGRectElement::BuildPath(PathBuilder* aBuilder)
 {
   float x, y, width, height, rx, ry;
   GetAnimatedLengthValues(&x, &y, &width, &height, &rx, &ry, nullptr);
 
   if (width <= 0 || height <= 0) {
     return nullptr;
   }
--- a/dom/svg/SVGRectElement.h
+++ b/dom/svg/SVGRectElement.h
@@ -29,17 +29,17 @@ protected:
 public:
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const override;
 
   // nsSVGPathGeometryElement methods:
   virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
                                  const Matrix& aTransform) override;
   virtual void GetAsSimplePath(SimplePath* aSimplePath) override;
-  virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder = nullptr) override;
+  virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder = nullptr) override;
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
   // WebIDL
   already_AddRefed<SVGAnimatedLength> X();
   already_AddRefed<SVGAnimatedLength> Y();
   already_AddRefed<SVGAnimatedLength> Height();
   already_AddRefed<SVGAnimatedLength> Width();
--- a/dom/svg/nsSVGPathGeometryElement.cpp
+++ b/dom/svg/nsSVGPathGeometryElement.cpp
@@ -70,17 +70,17 @@ nsSVGPathGeometryElement::IsMarkable()
   return false;
 }
 
 void
 nsSVGPathGeometryElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
 {
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 nsSVGPathGeometryElement::GetOrBuildPath(const DrawTarget& aDrawTarget,
                                          FillRule aFillRule)
 {
   // We only cache the path if it matches the backend used for screen painting:
   bool cacheable  = aDrawTarget.GetBackendType() ==
                       gfxPlatform::GetPlatform()->GetContentBackend();
 
   // Checking for and returning mCachedPath before checking the pref means
@@ -96,17 +96,17 @@ nsSVGPathGeometryElement::GetOrBuildPath
   RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder(aFillRule);
   RefPtr<Path> path = BuildPath(builder);
   if (cacheable && NS_SVGPathCachingEnabled()) {
     mCachedPath = path;
   }
   return path.forget();
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 nsSVGPathGeometryElement::GetOrBuildPathForMeasuring()
 {
   return nullptr;
 }
 
 FillRule
 nsSVGPathGeometryElement::GetFillRule()
 {
--- a/dom/svg/nsSVGPathGeometryElement.h
+++ b/dom/svg/nsSVGPathGeometryElement.h
@@ -141,42 +141,42 @@ public:
     aSimplePath->Reset();
   }
 
   /**
    * Returns a Path that can be used to paint, hit-test or calculate bounds for
    * this element. May return nullptr if there is no [valid] path. The path
    * that is created may be cached and returned on subsequent calls.
    */
-  virtual mozilla::TemporaryRef<Path> GetOrBuildPath(const DrawTarget& aDrawTarget,
+  virtual already_AddRefed<Path> GetOrBuildPath(const DrawTarget& aDrawTarget,
                                                      FillRule fillRule);
 
   /**
    * The same as GetOrBuildPath, but bypasses the cache (neither returns any
    * previously cached Path, nor caches the Path that in does return).
    * this element. May return nullptr if there is no [valid] path.
    */
-  virtual mozilla::TemporaryRef<Path> BuildPath(PathBuilder* aBuilder) = 0;
+  virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) = 0;
 
   /**
    * Returns a Path that can be used to measure the length of this elements
    * path, or to find the position at a given distance along it.
    *
    * This is currently equivalent to calling GetOrBuildPath, but it may not be
    * in the future. The reason for this function to be separate from
    * GetOrBuildPath is because SVGPathData::BuildPath inserts small lines into
    * the path if zero length subpaths are encountered, in order to implement
    * the SVG specifications requirements that zero length subpaths should
    * render circles/squares if stroke-linecap is round/square, respectively.
    * In principle these inserted lines could interfere with path measurement,
    * so we keep callers that are looking to do measurement separate in case we
    * run into problems with the inserted lines negatively affecting measuring
    * for content.
    */
-  virtual mozilla::TemporaryRef<Path> GetOrBuildPathForMeasuring();
+  virtual already_AddRefed<Path> GetOrBuildPathForMeasuring();
 
   /**
    * Returns the current computed value of the CSS property 'fill-rule' for
    * this element.
    */
   FillRule GetFillRule();
 
 protected:
--- a/dom/system/gonk/MozMtpDatabase.cpp
+++ b/dom/system/gonk/MozMtpDatabase.cpp
@@ -149,17 +149,17 @@ MozMtpDatabase::FindEntryByPath(const ns
     RefPtr<DbEntry> entry = mDb[entryIndex];
     if (entry && entry->mPath.Equals(aPath)) {
       return entryIndex;
     }
   }
   return 0;
 }
 
-TemporaryRef<MozMtpDatabase::DbEntry>
+already_AddRefed<MozMtpDatabase::DbEntry>
 MozMtpDatabase::GetEntry(MtpObjectHandle aHandle)
 {
   MutexAutoLock lock(mMutex);
 
   RefPtr<DbEntry> entry;
 
   if (aHandle > 0 && aHandle < mDb.Length()) {
     entry = mDb[aHandle];
--- a/dom/system/gonk/MozMtpDatabase.h
+++ b/dom/system/gonk/MozMtpDatabase.h
@@ -238,17 +238,17 @@ private:
   {
     return aHandle > 0 && aHandle < mDb.Length();
   }
 
   void AddEntry(DbEntry* aEntry);
   void AddEntryAndNotify(DbEntry* aEntr, RefCountedMtpServer* aMtpServer);
   void DumpEntries(const char* aLabel);
   MtpObjectHandle FindEntryByPath(const nsACString& aPath);
-  mozilla::TemporaryRef<DbEntry> GetEntry(MtpObjectHandle aHandle);
+  already_AddRefed<DbEntry> GetEntry(MtpObjectHandle aHandle);
   void RemoveEntry(MtpObjectHandle aHandle);
   void RemoveEntryAndNotify(MtpObjectHandle aHandle, RefCountedMtpServer* aMtpServer);
   void UpdateEntry(MtpObjectHandle aHandle, DeviceStorageFile* aFile);
   void UpdateEntryAndNotify(MtpObjectHandle aHandle, DeviceStorageFile* aFile,
                             RefCountedMtpServer* aMtpServer);
   void QueryEntries(MatchType aMatchType, uint32_t aMatchField1,
                     uint32_t aMatchField2, UnprotectedDbArray& aResult);
 
--- a/dom/system/gonk/VolumeManager.cpp
+++ b/dom/system/gonk/VolumeManager.cpp
@@ -66,17 +66,17 @@ VolumeManager::NumVolumes()
 {
   if (!sVolumeManager) {
     return 0;
   }
   return sVolumeManager->mVolumeArray.Length();
 }
 
 //static
-TemporaryRef<Volume>
+already_AddRefed<Volume>
 VolumeManager::GetVolume(size_t aIndex)
 {
   MOZ_ASSERT(aIndex < NumVolumes());
   RefPtr<Volume> vol = sVolumeManager->mVolumeArray[aIndex];
   return vol.forget();
 }
 
 //static
@@ -120,17 +120,17 @@ VolumeManager::RegisterStateObserver(Sta
 
 //static
 void VolumeManager::UnregisterStateObserver(StateObserver* aObserver)
 {
   mStateObserverList.RemoveObserver(aObserver);
 }
 
 //static
-TemporaryRef<Volume>
+already_AddRefed<Volume>
 VolumeManager::FindVolumeByName(const nsCSubstring& aName)
 {
   if (!sVolumeManager) {
     return nullptr;
   }
   VolumeArray::size_type  numVolumes = NumVolumes();
   VolumeArray::index_type volIndex;
   for (volIndex = 0; volIndex < numVolumes; volIndex++) {
@@ -138,17 +138,17 @@ VolumeManager::FindVolumeByName(const ns
     if (vol->Name().Equals(aName)) {
       return vol.forget();
     }
   }
   return nullptr;
 }
 
 //static
-TemporaryRef<Volume>
+already_AddRefed<Volume>
 VolumeManager::FindAddVolumeByName(const nsCSubstring& aName)
 {
   RefPtr<Volume> vol = FindVolumeByName(aName);
   if (vol) {
     return vol.forget();
   }
   // No volume found, create and add a new one.
   vol = new Volume(aName);
--- a/dom/system/gonk/VolumeManager.h
+++ b/dom/system/gonk/VolumeManager.h
@@ -120,19 +120,19 @@ public:
   static void UnregisterStateObserver(StateObserver* aObserver);
 
   //-----------------------------------------------------------------------
 
   static void Start();
   static void Dump(const char* aLabel);
 
   static VolumeArray::size_type NumVolumes();
-  static TemporaryRef<Volume> GetVolume(VolumeArray::index_type aIndex);
-  static TemporaryRef<Volume> FindVolumeByName(const nsCSubstring& aName);
-  static TemporaryRef<Volume> FindAddVolumeByName(const nsCSubstring& aName);
+  static already_AddRefed<Volume> GetVolume(VolumeArray::index_type aIndex);
+  static already_AddRefed<Volume> FindVolumeByName(const nsCSubstring& aName);
+  static already_AddRefed<Volume> FindAddVolumeByName(const nsCSubstring& aName);
   static void InitConfig();
 
   static void       PostCommand(VolumeCommand* aCommand);
 
 protected:
 
   virtual void OnLineRead(int aFd, nsDependentCSubstring& aMessage);
   virtual void OnFileCanWriteWithoutBlocking(int aFd);
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -334,17 +334,17 @@ public:
    * created.
    */
   virtual bool IsValid() const { return true; }
 
   /**
    * This function will get a DataSourceSurface for this surface, a
    * DataSourceSurface's data can be accessed directly.
    */
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface() = 0;
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface() = 0;
 
   /** Tries to get this SourceSurface's native surface.  This will fail if aType
    * is not the type of this SourceSurface's native surface.
    */
   virtual void *GetNativeSurface(NativeSurfaceType aType) {
     return nullptr;
   }
 
@@ -471,17 +471,17 @@ public:
     MOZ_ASSERT(mIsMapped);
     mIsMapped = false;
   }
 
   /**
    * Returns a DataSourceSurface with the same data as this one, but
    * guaranteed to have surface->GetType() == SurfaceType::DATA.
    */
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface() override;
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface() override;
 
 protected:
   bool mIsMapped;
 };
 
 /** This is an abstract object that accepts path segments. */
 class PathSink : public RefCounted<PathSink>
 {
@@ -528,18 +528,18 @@ public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(Path)
   virtual ~Path();
   
   virtual BackendType GetBackendType() const = 0;
 
   /** This returns a PathBuilder object that contains a copy of the contents of
    * this path and is still writable.
    */
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const = 0;
-  virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
+  virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const = 0;
+  virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FillRule::FILL_WINDING) const = 0;
 
   /** This function checks if a point lies within a path. It allows passing a
    * transform that will transform the path to the coordinate space in which
    * aPoint is given.
    */
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const = 0;
 
@@ -593,17 +593,17 @@ protected:
  */
 class PathBuilder : public PathSink
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilder)
   /** Finish writing to the path and return a Path object that can be used for
    * drawing. Future use of the builder results in a crash!
    */
-  virtual TemporaryRef<Path> Finish() = 0;
+  virtual already_AddRefed<Path> Finish() = 0;
 
   virtual BackendType GetBackendType() const = 0;
 };
 
 struct Glyph
 {
   uint32_t mIndex;
   Point mPosition;
@@ -633,17 +633,17 @@ public:
 
   virtual FontType GetType() const = 0;
 
   /** This allows getting a path that describes the outline of a set of glyphs.
    * A target is passed in so that the guarantee is made the returned path
    * can be used with any DrawTarget that has the same backend as the one
    * passed in.
    */
-  virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget) = 0;
+  virtual already_AddRefed<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget) = 0;
 
   /** This copies the path describing the glyphs into a PathBuilder. We use this
    * API rather than a generic API to append paths because it allows easier
    * implementation in some backends, and more efficient implementation in
    * others.
    */
   virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint = nullptr) = 0;
 
@@ -697,17 +697,17 @@ public:
   virtual DrawTargetType GetType() const = 0;
 
   virtual BackendType GetBackendType() const = 0;
   /**
    * Returns a SourceSurface which is a snapshot of the current contents of the DrawTarget.
    * Multiple calls to Snapshot() without any drawing operations in between will
    * normally return the same SourceSurface object.
    */
-  virtual TemporaryRef<SourceSurface> Snapshot() = 0;
+  virtual already_AddRefed<SourceSurface> Snapshot() = 0;
   virtual IntSize GetSize() = 0;
 
   /**
    * If possible returns the bits to this DrawTarget for direct manipulation. While
    * the bits is locked any modifications to this DrawTarget is forbidden.
    * Release takes the original data pointer for safety.
    */
   virtual bool LockBits(uint8_t** aData, IntSize* aSize,
@@ -933,96 +933,96 @@ public:
   virtual void PopClip() = 0;
 
   /**
    * Create a SourceSurface optimized for use with this DrawTarget from
    * existing bitmap data in memory.
    *
    * The SourceSurface does not take ownership of aData, and may be freed at any time.
    */
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
+  virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                                   const IntSize &aSize,
                                                                   int32_t aStride,
                                                                   SurfaceFormat aFormat) const = 0;
 
   /**
    * Create a SourceSurface optimized for use with this DrawTarget from an
    * arbitrary SourceSurface type supported by this backend. This may return
    * aSourceSurface or some other existing surface.
    */
-  virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const = 0;
+  virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const = 0;
 
   /**
    * Create a SourceSurface for a type of NativeSurface. This may fail if the
    * draw target does not know how to deal with the type of NativeSurface passed
    * in.
    */
-  virtual TemporaryRef<SourceSurface>
+  virtual already_AddRefed<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const = 0;
 
   /**
    * Create a DrawTarget whose snapshot is optimized for use with this DrawTarget.
    */
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const = 0;
 
   /**
    * Create a DrawTarget that captures the drawing commands and can be replayed
    * onto a compatible DrawTarget afterwards.
    *
    * @param aSize Size of the area this DT will capture. 
    */
-  virtual TemporaryRef<DrawTargetCapture> CreateCaptureDT(const IntSize& aSize);
+  virtual already_AddRefed<DrawTargetCapture> CreateCaptureDT(const IntSize& aSize);
 
   /**
    * Create a draw target optimized for drawing a shadow.
    *
    * Note that aSigma is the blur radius that must be used when we draw the
    * shadow. Also note that this doesn't affect the size of the allocated
    * surface, the caller is still responsible for including the shadow area in
    * its size.
    */
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat,
                            float aSigma) const
   {
     return CreateSimilarDrawTarget(aSize, aFormat);
   }
 
   /**
    * Create a path builder with the specified fillmode.
    *
    * We need the fill mode up front because of Direct2D.
    * ID2D1SimplifiedGeometrySink requires the fill mode
    * to be set before calling BeginFigure().
    */
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const = 0;
+  virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const = 0;
 
   /**
    * Create a GradientStops object that holds information about a set of
    * gradient stops, this object is required for linear or radial gradient
    * patterns to represent the color stops in the gradient.
    *
    * @param aStops An array of gradient stops
    * @param aNumStops Number of stops in the array aStops
    * @param aExtendNone This describes how to extend the stop color outside of the
    *                    gradient area.
    */
-  virtual TemporaryRef<GradientStops>
+  virtual already_AddRefed<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
                         ExtendMode aExtendMode = ExtendMode::CLAMP) const = 0;
 
   /**
    * Create a FilterNode object that can be used to apply a filter to various
    * inputs.
    *
    * @param aType Type of filter node to be created.
    */
-  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType) = 0;
+  virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType) = 0;
 
   Matrix GetTransform() const { return mTransform; }
 
   /**
    * Set a transform on the surface, this transform is applied at drawing time
    * to both the mask and source of the operation.
    *
    * Performance note: For some backends it is expensive to change the current
@@ -1139,144 +1139,144 @@ public:
    */
   static bool CheckSurfaceSize(const IntSize &sz, int32_t limit = 0);
 
   /** Make sure the given dimension satisfies the CheckSurfaceSize and is
    * within 8k limit.  The 8k value is chosen a bit randomly.
    */
   static bool ReasonableSurfaceSize(const IntSize &aSize);
 
-  static TemporaryRef<DrawTarget> CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr);
+  static already_AddRefed<DrawTarget> CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr);
 
-  static TemporaryRef<DrawTarget>
+  static already_AddRefed<DrawTarget>
     CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat);
 
-  static TemporaryRef<DrawTarget>
+  static already_AddRefed<DrawTarget>
     CreateRecordingDrawTarget(DrawEventRecorder *aRecorder, DrawTarget *aDT);
      
-  static TemporaryRef<DrawTarget>
+  static already_AddRefed<DrawTarget>
     CreateDrawTargetForData(BackendType aBackend, unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat);
 
-  static TemporaryRef<ScaledFont>
+  static already_AddRefed<ScaledFont>
     CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSize);
 
   /**
    * This creates a ScaledFont from TrueType data.
    *
    * @param aData Pointer to the data
    * @param aSize Size of the TrueType data
    * @param aFaceIndex Index of the font face in the truetype data this ScaledFont needs to represent.
    * @param aGlyphSize Size of the glyphs in this ScaledFont
    * @param aType Type of ScaledFont that should be created.
    */
-  static TemporaryRef<ScaledFont>
+  static already_AddRefed<ScaledFont>
     CreateScaledFontForTrueTypeData(uint8_t *aData, uint32_t aSize, uint32_t aFaceIndex, Float aGlyphSize, FontType aType);
 
   /**
    * This creates a scaled font with an associated cairo_scaled_font_t, and
    * must be used when using the Cairo backend. The NativeFont and
    * cairo_scaled_font_t* parameters must correspond to the same font.
    */
-  static TemporaryRef<ScaledFont>
+  static already_AddRefed<ScaledFont>
     CreateScaledFontWithCairo(const NativeFont &aNativeFont, Float aSize, cairo_scaled_font_t* aScaledFont);
 
   /**
    * This creates a simple data source surface for a certain size. It allocates
    * new memory for the surface. This memory is freed when the surface is
    * destroyed.  The caller is responsible for handing the case where nullptr
    * is returned. The surface is not zeroed unless requested.
    */
-  static TemporaryRef<DataSourceSurface>
+  static already_AddRefed<DataSourceSurface>
     CreateDataSourceSurface(const IntSize &aSize, SurfaceFormat aFormat, bool aZero = false);
 
   /**
    * This creates a simple data source surface for a certain size with a
    * specific stride, which must be large enough to fit all pixels.
    * It allocates new memory for the surface. This memory is freed when
    * the surface is destroyed.  The caller is responsible for handling the case
    * where nullptr is returned. The surface is not zeroed unless requested.
    */
-  static TemporaryRef<DataSourceSurface>
+  static already_AddRefed<DataSourceSurface>
     CreateDataSourceSurfaceWithStride(const IntSize &aSize, SurfaceFormat aFormat, int32_t aStride, bool aZero = false);
 
   /**
    * This creates a simple data source surface for some existing data. It will
    * wrap this data and the data for this source surface. The caller is
    * responsible for deallocating the memory only after destruction of the
    * surface.
    */
-  static TemporaryRef<DataSourceSurface>
+  static already_AddRefed<DataSourceSurface>
     CreateWrappingDataSourceSurface(uint8_t *aData, int32_t aStride,
                                     const IntSize &aSize, SurfaceFormat aFormat);
 
-  static TemporaryRef<DrawEventRecorder>
+  static already_AddRefed<DrawEventRecorder>
     CreateEventRecorderForFile(const char *aFilename);
 
   static void SetGlobalEventRecorder(DrawEventRecorder *aRecorder);
 
   // This is a little hacky at the moment, but we want to have this data. Bug 1068613.
   static void SetLogForwarder(LogForwarder* aLogFwd);
 
   static uint32_t GetMaxSurfaceSize(BackendType aType);
 
   static LogForwarder* GetLogForwarder() { return mLogForwarder; }
 
 private:
   static LogForwarder* mLogForwarder;
 public:
 
 #ifdef USE_SKIA_GPU
-  static TemporaryRef<DrawTarget>
+  static already_AddRefed<DrawTarget>
     CreateDrawTargetSkiaWithGrContext(GrContext* aGrContext,
                                       const IntSize &aSize,
                                       SurfaceFormat aFormat);
 #endif
 
   static void PurgeAllCaches();
 
 #if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
-  static TemporaryRef<GlyphRenderingOptions>
+  static already_AddRefed<GlyphRenderingOptions>
     CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHinting);
 #endif
-  static TemporaryRef<DrawTarget>
+  static already_AddRefed<DrawTarget>
     CreateDualDrawTarget(DrawTarget *targetA, DrawTarget *targetB);
 
   /*
    * This creates a new tiled DrawTarget. When a tiled drawtarget is used the
    * drawing is distributed over number of tiles which may each hold an
    * individual offset. The tiles in the set must each have the same backend
    * and format.
    */
-  static TemporaryRef<DrawTarget> CreateTiledDrawTarget(const TileSet& aTileSet);
+  static already_AddRefed<DrawTarget> CreateTiledDrawTarget(const TileSet& aTileSet);
 
   static bool DoesBackendSupportDataDrawtarget(BackendType aType);
 
 #ifdef XP_MACOSX
-  static TemporaryRef<DrawTarget> CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize);
-  static TemporaryRef<GlyphRenderingOptions>
+  static already_AddRefed<DrawTarget> CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize);
+  static already_AddRefed<GlyphRenderingOptions>
     CreateCGGlyphRenderingOptions(const Color &aFontSmoothingBackgroundColor);
 #endif
 
 #ifdef WIN32
-  static TemporaryRef<DrawTarget> CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
-  static TemporaryRef<DrawTarget>
+  static already_AddRefed<DrawTarget> CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
+  static already_AddRefed<DrawTarget>
     CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA,
                                          ID3D10Texture2D *aTextureB,
                                          SurfaceFormat aFormat);
 
   static void SetDirect3D10Device(ID3D10Device1 *aDevice);
   static ID3D10Device1 *GetDirect3D10Device();
-  static TemporaryRef<DrawTarget> CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat);
+  static already_AddRefed<DrawTarget> CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat);
 
   static void SetDirect3D11Device(ID3D11Device *aDevice);
   static ID3D11Device *GetDirect3D11Device();
   static ID2D1Device *GetD2D1Device();
   static bool SupportsD2D1();
 
-  static TemporaryRef<GlyphRenderingOptions>
+  static already_AddRefed<GlyphRenderingOptions>
     CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams);
 
   static uint64_t GetD2DVRAMUsageDrawTarget();
   static uint64_t GetD2DVRAMUsageSourceSurface();
   static void D2DCleanup();
 
 private:
   static ID2D1Device *mD2D1Device;
--- a/gfx/2d/DataSourceSurface.cpp
+++ b/gfx/2d/DataSourceSurface.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "2D.h"
 #include "DataSourceSurfaceWrapper.h"
 
 namespace mozilla {
 namespace gfx {
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 DataSourceSurface::GetDataSurface()
 {
   RefPtr<DataSourceSurface> surface =
     (GetType() == SurfaceType::DATA) ? this : new DataSourceSurfaceWrapper(this);
   return surface.forget();
 }
 
 }
--- a/gfx/2d/DataSurfaceHelpers.cpp
+++ b/gfx/2d/DataSurfaceHelpers.cpp
@@ -273,17 +273,17 @@ CopyRect(DataSourceSurface* aSrc, DataSo
     for (int32_t y = 0; y < aSrcRect.height; y++) {
       PodCopy(destData, sourceData, aSrcRect.width);
       sourceData += sourceStride;
       destData += destStride;
     }
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 CreateDataSourceSurfaceByCloning(DataSourceSurface* aSource)
 {
   RefPtr<DataSourceSurface> copy =
     Factory::CreateDataSourceSurface(aSource->GetSize(), aSource->GetFormat(), true);
   if (copy) {
     CopyRect(aSource, copy, IntRect(IntPoint(), aSource->GetSize()), IntPoint());
   }
   return copy.forget();
--- a/gfx/2d/DataSurfaceHelpers.h
+++ b/gfx/2d/DataSurfaceHelpers.h
@@ -78,17 +78,17 @@ CopyRect(DataSourceSurface* aSrc, DataSo
          IntRect aSrcRect, IntPoint aDestPoint);
 
 /**
  * Create a non aliasing copy of aSource. This creates a new DataSourceSurface
  * using the factory and copies the bits.
  *
  * @return a dss allocated by Factory that contains a copy a aSource.
  */
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 CreateDataSourceSurfaceByCloning(DataSourceSurface* aSource);
 
 /**
  * Return the byte at aPoint.
  */
 uint8_t*
 DataAtOffset(DataSourceSurface* aSurface,
              DataSourceSurface::MappedSurface* aMap,
--- a/gfx/2d/DrawTarget.cpp
+++ b/gfx/2d/DrawTarget.cpp
@@ -6,17 +6,17 @@
 #include "2D.h"
 #include "Logging.h"
 
 #include "DrawTargetCapture.h"
 
 namespace mozilla {
 namespace gfx {
 
-TemporaryRef<DrawTargetCapture>
+already_AddRefed<DrawTargetCapture>
 DrawTarget::CreateCaptureDT(const IntSize& aSize)
 {
   RefPtr<DrawTargetCaptureImpl> dt = new DrawTargetCaptureImpl();
 
   if (!dt->Init(aSize, this)) {
     gfxWarning() << "Failed to initialize Capture DrawTarget!";
     return nullptr;
   }
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -181,44 +181,44 @@ DrawTargetCG::GetBackendType() const
   // into seperate classes.
   if (GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE) {
     return BackendType::COREGRAPHICS_ACCELERATED;
   } else {
     return BackendType::COREGRAPHICS;
   }
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetCG::Snapshot()
 {
   if (!mSnapshot) {
     if (GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE) {
       return MakeAndAddRef<SourceSurfaceCGIOSurfaceContext>(this);
     }
     Flush();
     mSnapshot = new SourceSurfaceCGBitmapContext(this);
   }
 
   RefPtr<SourceSurface> snapshot(mSnapshot);
   return snapshot.forget();
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 DrawTargetCG::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   // XXX: in thebes we use CGLayers to do this kind of thing. It probably makes sense
   // to add that in somehow, but at a higher level
   RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
   if (newTarget->Init(GetBackendType(), aSize, aFormat)) {
     return newTarget.forget();
   }
   return nullptr;
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetCG::CreateSourceSurfaceFromData(unsigned char *aData,
                                            const IntSize &aSize,
                                            int32_t aStride,
                                            SurfaceFormat aFormat) const
 {
   RefPtr<SourceSurfaceCG> newSurf = new SourceSurfaceCG();
 
   if (!newSurf->InitFromData(aData, aSize, aStride, aFormat)) {
@@ -255,17 +255,17 @@ GetRetainedImageFromSourceSurface(Source
       data.get()->AddRef();
       return CreateCGImage(releaseDataSurface, data.get(),
                            data->GetData(), data->GetSize(),
                            data->Stride(), data->GetFormat());
     }
   }
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetCG::OptimizeSourceSurface(SourceSurface *aSurface) const
 {
   RefPtr<SourceSurface> surface(aSurface);
   return surface.forget();
 }
 
 class UnboundnessFixer
 {
@@ -387,17 +387,17 @@ DrawTargetCG::DrawSurface(SourceSurface 
     CGImageRelease(image);
   }
 
   fixer.Fix(this);
 
   CGContextRestoreGState(mCg);
 }
 
-TemporaryRef<FilterNode>
+already_AddRefed<FilterNode>
 DrawTargetCG::CreateFilter(FilterType aType)
 {
   return FilterNodeSoftware::Create(aType);
 }
 
 void
 DrawTargetCG::DrawFilter(FilterNode *aNode,
                          const Rect &aSourceRect,
@@ -463,17 +463,17 @@ class GradientStopsCG : public GradientS
   // with BackendType::COREGRAPHICS_ACCELERATED
   BackendType GetBackendType() const { return BackendType::COREGRAPHICS; }
   // XXX this should be a union
   CGGradientRef mGradient;
   std::vector<GradientStop> mStops;
   ExtendMode mExtend;
 };
 
-TemporaryRef<GradientStops>
+already_AddRefed<GradientStops>
 DrawTargetCG::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops,
                                   ExtendMode aExtendMode) const
 {
   std::vector<GradientStop> stops(aStops, aStops+aNumStops);
   return MakeAndAddRef<GradientStopsCG>(mColorSpace, stops, aExtendMode);
 }
 
 static void
@@ -1892,17 +1892,17 @@ bool
 DrawTargetCG::Init(BackendType aType, const IntSize &aSize, SurfaceFormat &aFormat)
 {
   int32_t stride = GetAlignedStride<16>(aSize.width * BytesPerPixel(aFormat));
   
   // Calling Init with aData == nullptr will allocate.
   return Init(aType, nullptr, aSize, stride, aFormat);
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 DrawTargetCG::CreatePathBuilder(FillRule aFillRule) const
 {
   return MakeAndAddRef<PathBuilderCG>(aFillRule);
 }
 
 void*
 DrawTargetCG::GetNativeSurface(NativeSurfaceType aType)
 {
--- a/gfx/2d/DrawTargetCG.h
+++ b/gfx/2d/DrawTargetCG.h
@@ -115,17 +115,17 @@ public:
   friend class BorrowedCGContext;
   friend class UnboundnessFixer;
   friend class SourceSurfaceCGBitmapContext;
   DrawTargetCG();
   virtual ~DrawTargetCG();
 
   virtual DrawTargetType GetType() const override;
   virtual BackendType GetBackendType() const override;
-  virtual TemporaryRef<SourceSurface> Snapshot() override;
+  virtual already_AddRefed<SourceSurface> Snapshot() override;
 
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions = DrawSurfaceOptions(),
                            const DrawOptions &aOptions = DrawOptions()) override;
   virtual void DrawFilter(FilterNode *aNode,
                           const Rect &aSourceRect,
@@ -158,35 +158,35 @@ public:
   virtual void Fill(const Path *, const Pattern &, const DrawOptions &) override;
   virtual void FillGlyphs(ScaledFont *, const GlyphBuffer&, const Pattern &, const DrawOptions &, const GlyphRenderingOptions *) override;
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions()) override;
   virtual void PushClip(const Path *) override;
   virtual void PushClipRect(const Rect &aRect) override;
   virtual void PopClip() override;
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromNativeSurface(const NativeSurface&) const override { return nullptr;}
-  virtual TemporaryRef<DrawTarget> CreateSimilarDrawTarget(const IntSize &, SurfaceFormat) const override;
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule) const override;
-  virtual TemporaryRef<GradientStops> CreateGradientStops(GradientStop *, uint32_t,
+  virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromNativeSurface(const NativeSurface&) const override { return nullptr;}
+  virtual already_AddRefed<DrawTarget> CreateSimilarDrawTarget(const IntSize &, SurfaceFormat) const override;
+  virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule) const override;
+  virtual already_AddRefed<GradientStops> CreateGradientStops(GradientStop *, uint32_t,
                                                           ExtendMode aExtendMode = ExtendMode::CLAMP) const override;
-  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType) override;
+  virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType) override;
 
   virtual void *GetNativeSurface(NativeSurfaceType) override;
 
   virtual IntSize GetSize() override { return mSize; }
 
   virtual void SetTransform(const Matrix &aTransform) override;
 
   /* This is for creating good compatible surfaces */
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
+  virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                             const IntSize &aSize,
                                                             int32_t aStride,
                                                             SurfaceFormat aFormat) const override;
-  virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override;
+  virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override;
   CGContextRef GetCGContext() {
       return mCg;
   }
 
   // 32767 is the maximum size supported by cairo. We clamp to that to make it
   // easier to interoperate.
   static size_t GetMaxSurfaceSize() {
     return 32767;
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -673,17 +673,17 @@ DrawTargetCairo::GetType() const
 }
 
 IntSize
 DrawTargetCairo::GetSize()
 {
   return mSize;
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetCairo::Snapshot()
 {
   if (mSnapshot) {
     RefPtr<SourceSurface> snapshot(mSnapshot);
     return snapshot.forget();
   }
 
   IntSize size = GetSize();
@@ -1364,17 +1364,17 @@ DrawTargetCairo::PopClip()
   cairo_restore(mContext);
 
   cairo_set_matrix(mContext, &mat);
 
   MOZ_ASSERT(cairo_status(mContext) || GetTransform() == Matrix(mat.xx, mat.yx, mat.xy, mat.yy, mat.x0, mat.y0),
              "Transforms are out of sync");
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 DrawTargetCairo::CreatePathBuilder(FillRule aFillRule /* = FillRule::FILL_WINDING */) const
 {
   return MakeAndAddRef<PathBuilderCairo>(aFillRule);
 }
 
 void
 DrawTargetCairo::ClearSurfaceForUnboundedSource(const CompositionOp &aOperator)
 {
@@ -1383,30 +1383,30 @@ DrawTargetCairo::ClearSurfaceForUnbounde
   cairo_set_operator(mContext, CAIRO_OPERATOR_CLEAR);
   // It doesn't really matter what the source is here, since Paint
   // isn't bounded by the source and the mask covers the entire clip
   // region.
   cairo_paint(mContext);
 }
 
 
-TemporaryRef<GradientStops>
+already_AddRefed<GradientStops>
 DrawTargetCairo::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops,
                                      ExtendMode aExtendMode) const
 {
   return MakeAndAddRef<GradientStopsCairo>(aStops, aNumStops, aExtendMode);
 }
 
-TemporaryRef<FilterNode>
+already_AddRefed<FilterNode>
 DrawTargetCairo::CreateFilter(FilterType aType)
 {
   return FilterNodeSoftware::Create(aType);
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetCairo::CreateSourceSurfaceFromData(unsigned char *aData,
                                              const IntSize &aSize,
                                              int32_t aStride,
                                              SurfaceFormat aFormat) const
 {
   if (!aData) {
     gfxWarning() << "DrawTargetCairo::CreateSourceSurfaceFromData null aData";
     return nullptr;
@@ -1438,17 +1438,17 @@ struct DestroyPixmapClosure {
 
 static void
 DestroyPixmap(void *data)
 {
   delete static_cast<DestroyPixmapClosure*>(data);
 }
 #endif
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
 {
   RefPtr<SourceSurface> surface(aSurface);
 #ifdef CAIRO_HAS_XLIB_SURFACE
   cairo_surface_type_t ctype = cairo_surface_get_type(mSurface);
   if (aSurface->GetType() == SurfaceType::CAIRO &&
       cairo_surface_get_type(
         static_cast<SourceSurfaceCairo*>(aSurface)->GetSurface()) == ctype) {
@@ -1527,33 +1527,33 @@ DrawTargetCairo::OptimizeSourceSurface(S
   dt->Flush();
 
   surface = new SourceSurfaceCairo(csurf, size, format);
 #endif
 
   return surface.forget();
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetCairo::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
 {
   if (aSurface.mType == NativeSurfaceType::CAIRO_SURFACE) {
     if (aSurface.mSize.width <= 0 ||
         aSurface.mSize.height <= 0) {
       gfxWarning() << "Can't create a SourceSurface without a valid size";
       return nullptr;
     }
     cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface);
     return MakeAndAddRef<SourceSurfaceCairo>(surf, aSurface.mSize, aSurface.mFormat);
   }
 
   return nullptr;
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   cairo_surface_t* similar = cairo_surface_create_similar(mSurface,
                                                           GfxFormatToCairoContent(aFormat),
                                                           aSize.width, aSize.height);
 
   if (!cairo_surface_status(similar)) {
     RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
@@ -1595,17 +1595,17 @@ DrawTargetCairo::InitAlreadyReferenced(c
     SetPermitSubpixelAA(false);
   } else {
     SetPermitSubpixelAA(true);
   }
 
   return true;
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 DrawTargetCairo::CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat,
                                         float aSigma) const
 {
   cairo_surface_t* similar = cairo_surface_create_similar(cairo_get_target(mContext),
                                                           GfxFormatToCairoContent(aFormat),
                                                           aSize.width, aSize.height);
 
   if (cairo_surface_status(similar)) {
--- a/gfx/2d/DrawTargetCairo.h
+++ b/gfx/2d/DrawTargetCairo.h
@@ -56,17 +56,17 @@ public:
   friend class BorrowedCairoContext;
   friend class BorrowedXlibDrawable;
 
   DrawTargetCairo();
   virtual ~DrawTargetCairo();
 
   virtual DrawTargetType GetType() const override;
   virtual BackendType GetBackendType() const override { return BackendType::CAIRO; }
-  virtual TemporaryRef<SourceSurface> Snapshot() override;
+  virtual already_AddRefed<SourceSurface> Snapshot() override;
   virtual IntSize GetSize() override;
 
   virtual void SetPermitSubpixelAA(bool aPermitSubpixelAA) override;
 
   virtual bool LockBits(uint8_t** aData, IntSize* aSize,
                         int32_t* aStride, SurfaceFormat* aFormat) override;
   virtual void ReleaseBits(uint8_t* aData) override;
 
@@ -129,37 +129,37 @@ public:
                            SourceSurface *aMask,
                            Point aOffset,
                            const DrawOptions &aOptions = DrawOptions()) override;
 
   virtual void PushClip(const Path *aPath) override;
   virtual void PushClipRect(const Rect &aRect) override;
   virtual void PopClip() override;
 
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override;
+  virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override;
 
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
+  virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                             const IntSize &aSize,
                                                             int32_t aStride,
                                                             SurfaceFormat aFormat) const override;
-  virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override;
-  virtual TemporaryRef<SourceSurface>
+  virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override;
+  virtual already_AddRefed<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override;
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override;
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat,
                            float aSigma) const override;
 
-  virtual TemporaryRef<GradientStops>
+  virtual already_AddRefed<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
                         ExtendMode aExtendMode = ExtendMode::CLAMP) const override;
 
-  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType) override;
+  virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType) override;
 
   virtual void *GetNativeSurface(NativeSurfaceType aType) override;
 
   bool Init(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr);
   bool Init(const IntSize& aSize, SurfaceFormat aFormat);
   bool Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat);
 
   virtual void SetTransform(const Matrix& aTransform) override;
--- a/gfx/2d/DrawTargetCapture.cpp
+++ b/gfx/2d/DrawTargetCapture.cpp
@@ -30,17 +30,17 @@ DrawTargetCaptureImpl::Init(const IntSiz
   }
 
   mRefDT = aRefDT;
 
   mSize = aSize;
   return true;
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetCaptureImpl::Snapshot()
 {
   RefPtr<DrawTarget> dt = mRefDT->CreateSimilarDrawTarget(mSize, mRefDT->GetFormat());
 
   ReplayToDrawTarget(dt, Matrix());
 
   return dt->Snapshot();
 }
--- a/gfx/2d/DrawTargetCapture.h
+++ b/gfx/2d/DrawTargetCapture.h
@@ -22,17 +22,17 @@ public:
   DrawTargetCaptureImpl()
   {}
 
   bool Init(const IntSize& aSize, DrawTarget* aRefDT);
 
   virtual BackendType GetBackendType() const { return mRefDT->GetBackendType(); }
   virtual DrawTargetType GetType() const { return mRefDT->GetType(); }
 
-  virtual TemporaryRef<SourceSurface> Snapshot();
+  virtual already_AddRefed<SourceSurface> Snapshot();
   virtual IntSize GetSize() { return mSize; }
 
   virtual void Flush() {}
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions,
                            const DrawOptions &aOptions);
@@ -85,53 +85,53 @@ public:
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void PushClip(const Path *aPath);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
 
   virtual void SetTransform(const Matrix &aTransform);
 
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
+  virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                                   const IntSize &aSize,
                                                                   int32_t aStride,
                                                                   SurfaceFormat aFormat) const
   {
     return mRefDT->CreateSourceSurfaceFromData(aData, aSize, aStride, aFormat);
   }
-  virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const
+  virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const
   {
     return mRefDT->OptimizeSourceSurface(aSurface);
   }
 
-  virtual TemporaryRef<SourceSurface>
+  virtual already_AddRefed<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
   {
     return mRefDT->CreateSourceSurfaceFromNativeSurface(aSurface);
   }
 
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
   {
     return mRefDT->CreateSimilarDrawTarget(aSize, aFormat);
   }
 
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const
+  virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const
   {
     return mRefDT->CreatePathBuilder(aFillRule);
   }
 
-  virtual TemporaryRef<GradientStops>
+  virtual already_AddRefed<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
                         ExtendMode aExtendMode = ExtendMode::CLAMP) const
   {
     return mRefDT->CreateGradientStops(aStops, aNumStops, aExtendMode);
   }
-  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType)
+  virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType)
   {
     return mRefDT->CreateFilter(aType);
   }
 
   void ReplayToDrawTarget(DrawTarget* aDT, const Matrix& aTransform);
 
 protected:
   ~DrawTargetCaptureImpl();
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -214,17 +214,17 @@ DrawTargetD2D::~DrawTargetD2D()
        iter != mDependingOnTargets.end(); iter++) {
     (*iter)->mDependentTargets.erase(this);
   }
 }
 
 /*
  * DrawTarget Implementation
  */
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetD2D::Snapshot()
 {
   if (!mSnapshot) {
     mSnapshot = new SourceSurfaceD2DTarget(this, mTexture, mFormat);
     Flush();
   }
 
   RefPtr<SourceSurface> snapshot(mSnapshot);
@@ -254,17 +254,17 @@ void
 DrawTargetD2D::AddDependencyOnSource(SourceSurfaceD2DTarget* aSource)
 {
   if (aSource->mDrawTarget && !mDependingOnTargets.count(aSource->mDrawTarget)) {
     aSource->mDrawTarget->mDependentTargets.insert(this);
     mDependingOnTargets.insert(aSource->mDrawTarget);
   }
 }
 
-TemporaryRef<ID2D1Bitmap>
+already_AddRefed<ID2D1Bitmap>
 DrawTargetD2D::GetBitmapForSurface(SourceSurface *aSurface,
                                    Rect &aSource)
 {
   RefPtr<ID2D1Bitmap> bitmap;
 
   switch (aSurface->GetType()) {
 
   case SurfaceType::D2D1_BITMAP:
@@ -332,17 +332,17 @@ DrawTargetD2D::GetBitmapForSurface(Sourc
       aSource.y -= (uint32_t)aSource.y;
     }
     break;
   }
 
   return bitmap.forget();
 }
 
-TemporaryRef<ID2D1Image>
+already_AddRefed<ID2D1Image>
 DrawTargetD2D::GetImageForSurface(SourceSurface *aSurface)
 {
   RefPtr<ID2D1Image> image;
 
   Rect r(Point(), Size(aSurface->GetSize()));
   image = GetBitmapForSurface(aSurface, r);
 
   return image.forget();
@@ -1190,32 +1190,32 @@ DrawTargetD2D::PopClip()
       PopCachedLayer(mRT);
     } else {
       mRT->PopAxisAlignedClip();
     }
   }
   mPushedClips.pop_back();
 }
 
-TemporaryRef<SourceSurface> 
+already_AddRefed<SourceSurface> 
 DrawTargetD2D::CreateSourceSurfaceFromData(unsigned char *aData,
                                            const IntSize &aSize,
                                            int32_t aStride,
                                            SurfaceFormat aFormat) const
 {
   RefPtr<SourceSurfaceD2D> newSurf = new SourceSurfaceD2D();
 
   if (!newSurf->InitFromData(aData, aSize, aStride, aFormat, mRT)) {
     return nullptr;
   }
 
   return newSurf.forget();
 }
 
-TemporaryRef<SourceSurface> 
+already_AddRefed<SourceSurface> 
 DrawTargetD2D::OptimizeSourceSurface(SourceSurface *aSurface) const
 {
   if (aSurface->GetType() == SurfaceType::D2D1_BITMAP ||
       aSurface->GetType() == SurfaceType::D2D1_DRAWTARGET) {
     RefPtr<SourceSurface> surface(aSurface);
     return surface.forget();
   }
 
@@ -1232,17 +1232,17 @@ DrawTargetD2D::OptimizeSourceSurface(Sou
   data->Unmap();
 
   if (!success) {
     return data.forget();
   }
   return newSurf.forget();
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetD2D::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
 {
   if (aSurface.mType != NativeSurfaceType::D3D10_TEXTURE) {
     gfxDebug() << *this << ": Failure to create source surface from non-D3D10 texture native surface.";
     return nullptr;
   }
   RefPtr<SourceSurfaceD2D> newSurf = new SourceSurfaceD2D();
 
@@ -1252,31 +1252,31 @@ DrawTargetD2D::CreateSourceSurfaceFromNa
   {
     gfxWarning() << *this << ": Failed to create SourceSurface from texture.";
     return nullptr;
   }
 
   return newSurf.forget();
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 DrawTargetD2D::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   RefPtr<DrawTargetD2D> newTarget =
     new DrawTargetD2D();
 
   if (!newTarget->Init(aSize, aFormat)) {
     gfxDebug() << *this << ": Failed to create optimal draw target. Size: " << aSize;
     return nullptr;
   }
 
   return newTarget.forget();
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 DrawTargetD2D::CreatePathBuilder(FillRule aFillRule) const
 {
   RefPtr<ID2D1PathGeometry> path;
   HRESULT hr = factory()->CreatePathGeometry(byRef(path));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create Direct2D Path Geometry. Code: " << hexa(hr);
     return nullptr;
@@ -1291,17 +1291,17 @@ DrawTargetD2D::CreatePathBuilder(FillRul
 
   if (aFillRule == FillRule::FILL_WINDING) {
     sink->SetFillMode(D2D1_FILL_MODE_WINDING);
   }
 
   return MakeAndAddRef<PathBuilderD2D>(sink, path, aFillRule, BackendType::DIRECT2D);
 }
 
-TemporaryRef<GradientStops>
+already_AddRefed<GradientStops>
 DrawTargetD2D::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops, ExtendMode aExtendMode) const
 {
   D2D1_GRADIENT_STOP *stops = new D2D1_GRADIENT_STOP[aNumStops];
 
   for (uint32_t i = 0; i < aNumStops; i++) {
     stops[i].position = rawStops[i].offset;
     stops[i].color = D2DColor(rawStops[i].color);
   }
@@ -1317,17 +1317,17 @@ DrawTargetD2D::CreateGradientStops(Gradi
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create GradientStopCollection. Code: " << hexa(hr);
     return nullptr;
   }
 
   return MakeAndAddRef<GradientStopsD2D>(stopCollection, Factory::GetDirect3D11Device());
 }
 
-TemporaryRef<FilterNode>
+already_AddRefed<FilterNode>
 DrawTargetD2D::CreateFilter(FilterType aType)
 {
   RefPtr<ID2D1DeviceContext> dc;
   HRESULT hr = mRT->QueryInterface((ID2D1DeviceContext**)byRef(dc));
 
   if (SUCCEEDED(hr)) {
     return FilterNodeD2D1::Create(dc, aType);
   }
@@ -1485,17 +1485,17 @@ DrawTargetD2D::InitD3D10Data()
  * Private helpers
  */
 uint32_t
 DrawTargetD2D::GetByteSize() const
 {
   return mSize.width * mSize.height * BytesPerPixel(mFormat);
 }
 
-TemporaryRef<ID2D1Layer>
+already_AddRefed<ID2D1Layer>
 DrawTargetD2D::GetCachedLayer()
 {
   RefPtr<ID2D1Layer> layer;
 
   if (mCurrentCachedLayer < 5) {
     if (!mCachedLayers[mCurrentCachedLayer]) {
       mRT->CreateLayer(byRef(mCachedLayers[mCurrentCachedLayer]));
       mVRAMUsageDT += GetByteSize();
@@ -1866,17 +1866,17 @@ DrawTargetD2D::GetDeviceSpaceClipRect(D2
     aClipRect = IntersectRect(aClipRect, iter->mBounds);
     if (!iter->mIsPixelAligned) {
       aIsPixelAligned = false;
     }
   }
   return true;
 }
 
-TemporaryRef<ID2D1Geometry>
+already_AddRefed<ID2D1Geometry>
 DrawTargetD2D::GetClippedGeometry(IntRect *aClipBounds)
 {
   if (mCurrentClippedGeometry) {
     *aClipBounds = mCurrentClipBounds;
     RefPtr<ID2D1Geometry> clippedGeometry(mCurrentClippedGeometry);
     return clippedGeometry.forget();
   }
 
@@ -1955,17 +1955,17 @@ DrawTargetD2D::GetClippedGeometry(IntRec
     pathGeom = ConvertRectToGeometry(pathRect);
   }
   mCurrentClippedGeometry = pathGeom.forget();
   *aClipBounds = mCurrentClipBounds;
   RefPtr<ID2D1Geometry> clippedGeometry(mCurrentClippedGeometry);
   return clippedGeometry.forget();
 }
 
-TemporaryRef<ID2D1RenderTarget>
+already_AddRefed<ID2D1RenderTarget>
 DrawTargetD2D::CreateRTForTexture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat)
 {
   HRESULT hr;
 
   RefPtr<IDXGISurface> surface;
   RefPtr<ID2D1RenderTarget> rt;
 
   hr = aTexture->QueryInterface((IDXGISurface**)byRef(surface));
@@ -2283,17 +2283,17 @@ DrawTargetD2D::FillGlyphsManual(ScaledFo
 
   rtViews = rtView;
   mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
   SetScissorToRect(clipBounds);
   mDevice->Draw(4, 0);
   return true;
 }
 
-TemporaryRef<ID2D1Brush>
+already_AddRefed<ID2D1Brush>
 DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
 {
   if (!IsPatternSupportedByD2D(aPattern)) {
     RefPtr<ID2D1SolidColorBrush> colBrush;
     mRT->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 1.0f), byRef(colBrush));
     return colBrush.forget();
   }
 
@@ -2449,17 +2449,17 @@ DrawTargetD2D::CreateBrushForPattern(con
     }
     return bmBrush.forget();
   }
 
   gfxWarning() << "Invalid pattern type detected.";
   return nullptr;
 }
 
-TemporaryRef<ID3D10Texture2D>
+already_AddRefed<ID3D10Texture2D>
 DrawTargetD2D::CreateGradientTexture(const GradientStopsD2D *aStops)
 {
   CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, 4096, 1, 1, 1);
 
   std::vector<D2D1_GRADIENT_STOP> rawStops;
   rawStops.resize(aStops->mStopCollection->GetGradientStopCount());
   aStops->mStopCollection->GetGradientStops(&rawStops.front(), rawStops.size());
 
@@ -2521,17 +2521,17 @@ DrawTargetD2D::CreateGradientTexture(con
   data.SysMemPitch = 4096 * 4;
 
   RefPtr<ID3D10Texture2D> tex;
   mDevice->CreateTexture2D(&desc, &data, byRef(tex));
 
   return tex.forget();
 }
 
-TemporaryRef<ID3D10Texture2D>
+already_AddRefed<ID3D10Texture2D>
 DrawTargetD2D::CreateTextureForAnalysis(IDWriteGlyphRunAnalysis *aAnalysis, const IntRect &aBounds)
 {
   HRESULT hr;
 
   uint32_t bufferSize = aBounds.width * aBounds.height * 3;
 
   RECT bounds;
   bounds.left = aBounds.x;
--- a/gfx/2d/DrawTargetD2D.h
+++ b/gfx/2d/DrawTargetD2D.h
@@ -40,17 +40,17 @@ class DrawTargetD2D : public DrawTarget
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetD2D)
   DrawTargetD2D();
   virtual ~DrawTargetD2D();
 
   virtual DrawTargetType GetType() const override { return DrawTargetType::HARDWARE_RASTER; }
   virtual BackendType GetBackendType() const { return BackendType::DIRECT2D; }
-  virtual TemporaryRef<SourceSurface> Snapshot();
+  virtual already_AddRefed<SourceSurface> Snapshot();
   virtual IntSize GetSize() { return mSize; }
 
   virtual void Flush();
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions = DrawSurfaceOptions(),
                            const DrawOptions &aOptions = DrawOptions());
@@ -101,49 +101,49 @@ public:
                           const GlyphRenderingOptions *aRenderingOptions = nullptr);
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void PushClip(const Path *aPath);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
 
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
+  virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                             const IntSize &aSize,
                                                             int32_t aStride,
                                                             SurfaceFormat aFormat) const;
-  virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const;
+  virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const;
 
-  virtual TemporaryRef<SourceSurface>
+  virtual already_AddRefed<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const;
   
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
 
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
+  virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
 
-  virtual TemporaryRef<GradientStops>
+  virtual already_AddRefed<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
                         ExtendMode aExtendMode = ExtendMode::CLAMP) const;
 
-  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType);
+  virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType);
 
   virtual bool SupportsRegionClipping() const { return false; }
 
   virtual void *GetNativeSurface(NativeSurfaceType aType);
 
   bool Init(const IntSize &aSize, SurfaceFormat aFormat);
   bool Init(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
   bool InitD3D10Data();
   uint32_t GetByteSize() const;
-  TemporaryRef<ID2D1Layer> GetCachedLayer();
+  already_AddRefed<ID2D1Layer> GetCachedLayer();
   void PopCachedLayer(ID2D1RenderTarget *aRT);
 
-  TemporaryRef<ID2D1Image> GetImageForSurface(SourceSurface *aSurface);
+  already_AddRefed<ID2D1Image> GetImageForSurface(SourceSurface *aSurface);
 
   static ID2D1Factory *factory();
   static void CleanupD2D();
   static IDWriteFactory *GetDWriteFactory();
   ID2D1RenderTarget *GetRT() { return mRT; }
 
   static uint32_t GetMaxSurfaceSize() {
     return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION;
@@ -154,17 +154,17 @@ public:
     stream << "DrawTargetD2D(" << this << ")";
     return stream.str();
   }
 
   static uint64_t mVRAMUsageDT;
   static uint64_t mVRAMUsageSS;
 
 private:
-  TemporaryRef<ID2D1Bitmap>
+  already_AddRefed<ID2D1Bitmap>
   GetBitmapForSurface(SourceSurface *aSurface,
                       Rect &aSource);
   friend class AutoSaveRestoreClippedOut;
   friend class SourceSurfaceD2DTarget;
 
   typedef std::unordered_set<DrawTargetD2D*> TargetSet;
 
   bool InitD2DRenderTarget();
@@ -194,30 +194,30 @@ private:
   void EnsureClipMaskTexture(IntRect *aClipBounds);
 
   bool FillGlyphsManual(ScaledFontDWrite *aFont,
                         const GlyphBuffer &aBuffer,
                         const Color &aColor,
                         IDWriteRenderingParams *aParams,
                         const DrawOptions &aOptions = DrawOptions());
 
-  TemporaryRef<ID2D1RenderTarget> CreateRTForTexture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
+  already_AddRefed<ID2D1RenderTarget> CreateRTForTexture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
 
   // This returns the clipped geometry, in addition it returns aClipBounds which
   // represents the intersection of all pixel-aligned rectangular clips that
   // are currently set. The returned clipped geometry must be clipped by these
   // bounds to correctly reflect the total clip. This is in device space.
-  TemporaryRef<ID2D1Geometry> GetClippedGeometry(IntRect *aClipBounds);
+  already_AddRefed<ID2D1Geometry> GetClippedGeometry(IntRect *aClipBounds);
 
   bool GetDeviceSpaceClipRect(D2D1_RECT_F& aClipRect, bool& aIsPixelAligned);
 
-  TemporaryRef<ID2D1Brush> CreateBrushForPattern(const Pattern &aPattern, Float aAlpha = 1.0f);
+  already_AddRefed<ID2D1Brush> CreateBrushForPattern(const Pattern &aPattern, Float aAlpha = 1.0f);
 
-  TemporaryRef<ID3D10Texture2D> CreateGradientTexture(const GradientStopsD2D *aStops);
-  TemporaryRef<ID3D10Texture2D> CreateTextureForAnalysis(IDWriteGlyphRunAnalysis *aAnalysis, const IntRect &aBounds);
+  already_AddRefed<ID3D10Texture2D> CreateGradientTexture(const GradientStopsD2D *aStops);
+  already_AddRefed<ID3D10Texture2D> CreateTextureForAnalysis(IDWriteGlyphRunAnalysis *aAnalysis, const IntRect &aBounds);
 
   void SetupEffectForRadialGradient(const RadialGradientPattern *aPattern);
   void SetupStateForRendering();
 
   // Set the scissor rect to a certain IntRects, resets the scissor rect to
   // surface bounds when nullptr is specified.
   void SetScissorToRect(IntRect *aRect);
 
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -60,17 +60,17 @@ DrawTargetD2D1::~DrawTargetD2D1()
   }
   // Our dependencies on other targets no longer matter.
   for (TargetSet::iterator iter = mDependingOnTargets.begin();
        iter != mDependingOnTargets.end(); iter++) {
     (*iter)->mDependentTargets.erase(this);
   }
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetD2D1::Snapshot()
 {
   if (mSnapshot) {
     RefPtr<SourceSurface> snapshot(mSnapshot);
     return snapshot.forget();
   }
   PopAllClips();
 
@@ -700,17 +700,17 @@ DrawTargetD2D1::PopClip()
       mDC->PopLayer();
     } else {
       mDC->PopAxisAlignedClip();
     }
   }
   mPushedClips.pop_back();
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetD2D1::CreateSourceSurfaceFromData(unsigned char *aData,
                                             const IntSize &aSize,
                                             int32_t aStride,
                                             SurfaceFormat aFormat) const
 {
   RefPtr<ID2D1Bitmap1> bitmap;
 
   HRESULT hr = mDC->CreateBitmap(D2DIntSize(aSize), aData, aStride,
@@ -720,29 +720,29 @@ DrawTargetD2D1::CreateSourceSurfaceFromD
   if (FAILED(hr) || !bitmap) {
     gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(aSize))) << "[D2D1.1] 1CreateBitmap failure " << aSize << " Code: " << hexa(hr);
     return nullptr;
   }
 
   return MakeAndAddRef<SourceSurfaceD2D1>(bitmap.get(), mDC, aFormat, aSize);
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 DrawTargetD2D1::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   RefPtr<DrawTargetD2D1> dt = new DrawTargetD2D1();
 
   if (!dt->Init(aSize, aFormat)) {
     return nullptr;
   }
 
   return dt.forget();
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 DrawTargetD2D1::CreatePathBuilder(FillRule aFillRule) const
 {
   RefPtr<ID2D1PathGeometry> path;
   HRESULT hr = factory()->CreatePathGeometry(byRef(path));
 
   if (FAILED(hr)) {
     gfxWarning() << *this << ": Failed to create Direct2D Path Geometry. Code: " << hexa(hr);
     return nullptr;
@@ -757,17 +757,17 @@ DrawTargetD2D1::CreatePathBuilder(FillRu
 
   if (aFillRule == FillRule::FILL_WINDING) {
     sink->SetFillMode(D2D1_FILL_MODE_WINDING);
   }
 
   return MakeAndAddRef<PathBuilderD2D>(sink, path, aFillRule, BackendType::DIRECT2D1_1);
 }
 
-TemporaryRef<GradientStops>
+already_AddRefed<GradientStops>
 DrawTargetD2D1::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops, ExtendMode aExtendMode) const
 {
   if (aNumStops == 0) {
     gfxWarning() << *this << ": Failed to create GradientStopCollection with no stops.";
     return nullptr;
   }
 
   D2D1_GRADIENT_STOP *stops = new D2D1_GRADIENT_STOP[aNumStops];
@@ -788,17 +788,17 @@ DrawTargetD2D1::CreateGradientStops(Grad
   if (FAILED(hr)) {
     gfxWarning() << *this << ": Failed to create GradientStopCollection. Code: " << hexa(hr);
     return nullptr;
   }
 
   return MakeAndAddRef<GradientStopsD2D>(stopCollection, Factory::GetDirect3D11Device());
 }
 
-TemporaryRef<FilterNode>
+already_AddRefed<FilterNode>
 DrawTargetD2D1::CreateFilter(FilterType aType)
 {
   return FilterNodeD2D1::Create(mDC, aType);
 }
 
 bool
 DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat)
 {
@@ -1193,17 +1193,17 @@ DrawTargetD2D1::GetDeviceSpaceClipRect(D
     aClipRect = IntersectRect(aClipRect, iter->mBounds);
     if (!iter->mIsPixelAligned) {
       aIsPixelAligned = false;
     }
   }
   return true;
 }
 
-TemporaryRef<ID2D1Geometry>
+already_AddRefed<ID2D1Geometry>
 DrawTargetD2D1::GetClippedGeometry(IntRect *aClipBounds)
 {
   if (mCurrentClippedGeometry) {
     *aClipBounds = mCurrentClipBounds;
     RefPtr<ID2D1Geometry> clippedGeometry(mCurrentClippedGeometry);
     return clippedGeometry.forget();
   }
 
@@ -1284,17 +1284,17 @@ DrawTargetD2D1::GetClippedGeometry(IntRe
     pathGeom = ConvertRectToGeometry(pathRect);
   }
   mCurrentClippedGeometry = pathGeom.forget();
   *aClipBounds = mCurrentClipBounds;
   RefPtr<ID2D1Geometry> clippedGeometry(mCurrentClippedGeometry);
   return clippedGeometry.forget();
 }
 
-TemporaryRef<ID2D1Geometry>
+already_AddRefed<ID2D1Geometry>
 DrawTargetD2D1::GetInverseClippedGeometry()
 {
   IntRect bounds;
   RefPtr<ID2D1Geometry> geom = GetClippedGeometry(&bounds);
   RefPtr<ID2D1RectangleGeometry> rectGeom;
   RefPtr<ID2D1PathGeometry> inverseGeom;
 
   factory()->CreateRectangleGeometry(D2D1::RectF(0, 0, mSize.width, mSize.height), byRef(rectGeom));
@@ -1350,31 +1350,31 @@ DrawTargetD2D1::PopClipsFromDC(ID2D1Devi
     if (mPushedClips[i].mPath) {
       aDC->PopLayer();
     } else {
       aDC->PopAxisAlignedClip();
     }
   }
 }
 
-TemporaryRef<ID2D1Brush>
+already_AddRefed<ID2D1Brush>
 DrawTargetD2D1::CreateTransparentBlackBrush()
 {
   return GetSolidColorBrush(D2D1::ColorF(0, 0));
 }
 
-TemporaryRef<ID2D1SolidColorBrush>
+already_AddRefed<ID2D1SolidColorBrush>
 DrawTargetD2D1::GetSolidColorBrush(const D2D_COLOR_F& aColor)
 {
   RefPtr<ID2D1SolidColorBrush> brush = mSolidColorBrush;
   brush->SetColor(aColor);
   return brush.forget();
 }
 
-TemporaryRef<ID2D1Brush>
+already_AddRefed<ID2D1Brush>
 DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
 {
   if (!IsPatternSupportedByD2D(aPattern)) {
     return GetSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 1.0f));
   }
 
   if (aPattern.GetType() == PatternType::COLOR) {
     Color color = static_cast<const ColorPattern*>(&aPattern)->mColor;
@@ -1508,17 +1508,17 @@ DrawTargetD2D1::CreateBrushForPattern(co
 
     return imageBrush.forget();
   }
 
   gfxWarning() << "Invalid pattern type detected.";
   return CreateTransparentBlackBrush();
 }
 
-TemporaryRef<ID2D1Image>
+already_AddRefed<ID2D1Image>
 DrawTargetD2D1::GetImageForSurface(SourceSurface *aSurface, Matrix &aSourceTransform,
                                    ExtendMode aExtendMode, const IntRect* aSourceRect)
 {
   RefPtr<ID2D1Image> image;
 
   switch (aSurface->GetType()) {
   case SurfaceType::D2D1_1_IMAGE:
     {
@@ -1538,17 +1538,17 @@ DrawTargetD2D1::GetImageForSurface(Sourc
                                            aSourceTransform, mDC, aSourceRect);
     }
     break;
   }
 
   return image.forget();
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetD2D1::OptimizeSourceSurface(SourceSurface* aSurface) const
 {
   if (aSurface->GetType() == SurfaceType::D2D1_1_IMAGE) {
     RefPtr<SourceSurface> surface(aSurface);
     return surface.forget();
   }
 
   RefPtr<DataSourceSurface> data = aSurface->GetDataSurface();
--- a/gfx/2d/DrawTargetD2D1.h
+++ b/gfx/2d/DrawTargetD2D1.h
@@ -30,17 +30,17 @@ class DrawTargetD2D1 : public DrawTarget
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetD2D1)
   DrawTargetD2D1();
   virtual ~DrawTargetD2D1();
 
   virtual DrawTargetType GetType() const override { return DrawTargetType::HARDWARE_RASTER; }
   virtual BackendType GetBackendType() const { return BackendType::DIRECT2D1_1; }
-  virtual TemporaryRef<SourceSurface> Snapshot();
+  virtual already_AddRefed<SourceSurface> Snapshot();
   virtual IntSize GetSize() { return mSize; }
 
   virtual void Flush();
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions,
                            const DrawOptions &aOptions);
@@ -90,49 +90,49 @@ public:
                           const GlyphRenderingOptions *aRenderingOptions = nullptr);
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void PushClip(const Path *aPath);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
 
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
+  virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                                   const IntSize &aSize,
                                                                   int32_t aStride,
                                                                   SurfaceFormat aFormat) const;
-  virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const;
+  virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const;
 
-  virtual TemporaryRef<SourceSurface>
+  virtual already_AddRefed<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const { return nullptr; }
   
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
 
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
+  virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
 
-  virtual TemporaryRef<GradientStops>
+  virtual already_AddRefed<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
                         ExtendMode aExtendMode = ExtendMode::CLAMP) const;
 
-  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType);
+  virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType);
 
   virtual bool SupportsRegionClipping() const { return false; }
 
   virtual void *GetNativeSurface(NativeSurfaceType aType) { return nullptr; }
 
   bool Init(const IntSize &aSize, SurfaceFormat aFormat);
   bool Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat);
   uint32_t GetByteSize() const;
 
-  TemporaryRef<ID2D1Image> GetImageForSurface(SourceSurface *aSurface, Matrix &aSourceTransform,
+  already_AddRefed<ID2D1Image> GetImageForSurface(SourceSurface *aSurface, Matrix &aSourceTransform,
                                               ExtendMode aExtendMode, const IntRect* aSourceRect = nullptr);
 
-  TemporaryRef<ID2D1Image> GetImageForSurface(SourceSurface *aSurface, ExtendMode aExtendMode) {
+  already_AddRefed<ID2D1Image> GetImageForSurface(SourceSurface *aSurface, ExtendMode aExtendMode) {
     Matrix mat;
     return GetImageForSurface(aSurface, mat, aExtendMode, nullptr);
   }
 
   static ID2D1Factory1 *factory();
   static void CleanupD2D();
   static IDWriteFactory *GetDWriteFactory();
 
@@ -166,30 +166,30 @@ private:
     }
   }
   void AddDependencyOnSource(SourceSurfaceD2D1* aSource);
 
   // This returns the clipped geometry, in addition it returns aClipBounds which
   // represents the intersection of all pixel-aligned rectangular clips that
   // are currently set. The returned clipped geometry must be clipped by these
   // bounds to correctly reflect the total clip. This is in device space.
-  TemporaryRef<ID2D1Geometry> GetClippedGeometry(IntRect *aClipBounds);
+  already_AddRefed<ID2D1Geometry> GetClippedGeometry(IntRect *aClipBounds);
 
-  TemporaryRef<ID2D1Geometry> GetInverseClippedGeometry();
+  already_AddRefed<ID2D1Geometry> GetInverseClippedGeometry();
 
   bool GetDeviceSpaceClipRect(D2D1_RECT_F& aClipRect, bool& aIsPixelAligned);
 
   void PopAllClips();
   void PushAllClips();
   void PushClipsToDC(ID2D1DeviceContext *aDC, bool aForceIgnoreAlpha = false, const D2D1_RECT_F& aMaxRect = D2D1::InfiniteRect());
   void PopClipsFromDC(ID2D1DeviceContext *aDC);
 
-  TemporaryRef<ID2D1Brush> CreateTransparentBlackBrush();
-  TemporaryRef<ID2D1SolidColorBrush> GetSolidColorBrush(const D2D_COLOR_F& aColor);
-  TemporaryRef<ID2D1Brush> CreateBrushForPattern(const Pattern &aPattern, Float aAlpha = 1.0f);
+  already_AddRefed<ID2D1Brush> CreateTransparentBlackBrush();
+  already_AddRefed<ID2D1SolidColorBrush> GetSolidColorBrush(const D2D_COLOR_F& aColor);
+  already_AddRefed<ID2D1Brush> CreateBrushForPattern(const Pattern &aPattern, Float aAlpha = 1.0f);
 
   void PushD2DLayer(ID2D1DeviceContext *aDC, ID2D1Geometry *aGeometry, const D2D1_MATRIX_3X2_F &aTransform,
                     bool aForceIgnoreAlpha = false, const D2D1_RECT_F& aLayerRect = D2D1::InfiniteRect());
 
   IntSize mSize;
 
   RefPtr<ID3D11Device> mDevice;
   RefPtr<ID3D11Texture2D> mTexture;
--- a/gfx/2d/DrawTargetDual.cpp
+++ b/gfx/2d/DrawTargetDual.cpp
@@ -176,17 +176,17 @@ void
 DrawTargetDual::Mask(const Pattern &aSource, const Pattern &aMask, const DrawOptions &aOptions)
 {
   DualPattern source(aSource);
   DualPattern mask(aMask);
   mA->Mask(*source.mA, *mask.mA, aOptions);
   mB->Mask(*source.mB, *mask.mB, aOptions);
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 DrawTargetDual::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   RefPtr<DrawTarget> dtA = mA->CreateSimilarDrawTarget(aSize, aFormat);
   RefPtr<DrawTarget> dtB = mB->CreateSimilarDrawTarget(aSize, aFormat);
 
   if (!dtA || !dtB) {
     gfxWarning() << "Failure to allocate a similar DrawTargetDual. Size: " << aSize;
     return nullptr;
--- a/gfx/2d/DrawTargetDual.h
+++ b/gfx/2d/DrawTargetDual.h
@@ -40,17 +40,17 @@ public:
     : mA(aA)
     , mB(aB)
   { 
     mFormat = aA->GetFormat();
   }
      
   virtual DrawTargetType GetType() const override { return mA->GetType(); }
   virtual BackendType GetBackendType() const override { return mA->GetBackendType(); }
-  virtual TemporaryRef<SourceSurface> Snapshot() override {
+  virtual already_AddRefed<SourceSurface> Snapshot() override {
     return MakeAndAddRef<SourceSurfaceDual>(mA, mB);
   }
   virtual IntSize GetSize() override { return mA->GetSize(); }
      
   FORWARD_FUNCTION(Flush)
   FORWARD_FUNCTION1(PushClip, const Path *, aPath)
   FORWARD_FUNCTION1(PushClipRect, const Rect &, aRect)
   FORWARD_FUNCTION(PopClip)
@@ -100,53 +100,53 @@ public:
   virtual void Fill(const Path *aPath, const Pattern &aPattern, const DrawOptions &aOptions) override;
 
   virtual void FillGlyphs(ScaledFont *aScaledFont, const GlyphBuffer &aBuffer,
                           const Pattern &aPattern, const DrawOptions &aOptions,
                           const GlyphRenderingOptions *aRenderingOptions) override;
   
   virtual void Mask(const Pattern &aSource, const Pattern &aMask, const DrawOptions &aOptions) override;
      
-  virtual TemporaryRef<SourceSurface>
+  virtual already_AddRefed<SourceSurface>
     CreateSourceSurfaceFromData(unsigned char *aData,
                                 const IntSize &aSize,
                                 int32_t aStride,
                                 SurfaceFormat aFormat) const override
   {
     return mA->CreateSourceSurfaceFromData(aData, aSize, aStride, aFormat);
   }
      
-  virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override
+  virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override
   {
     return mA->OptimizeSourceSurface(aSurface);
   }
      
-  virtual TemporaryRef<SourceSurface>
+  virtual already_AddRefed<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override
   {
     return mA->CreateSourceSurfaceFromNativeSurface(aSurface);
   }
      
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override;
      
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override
+  virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override
   {
     return mA->CreatePathBuilder(aFillRule);
   }
      
-  virtual TemporaryRef<GradientStops>
+  virtual already_AddRefed<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
                         ExtendMode aExtendMode = ExtendMode::CLAMP) const override
   {
     return mA->CreateGradientStops(aStops, aNumStops, aExtendMode);
   }
 
-  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType) override
+  virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType) override
   {
     return mA->CreateFilter(aType);
   }
 
   virtual void *GetNativeSurface(NativeSurfaceType aType) override
   {
     return nullptr;
   }
--- a/gfx/2d/DrawTargetRecording.cpp
+++ b/gfx/2d/DrawTargetRecording.cpp
@@ -26,17 +26,17 @@ public:
   ~SourceSurfaceRecording()
   {
     mRecorder->RecordEvent(RecordedSourceSurfaceDestruction(this));
   }
 
   virtual SurfaceType GetType() const { return SurfaceType::RECORDING; }
   virtual IntSize GetSize() const { return mFinalSurface->GetSize(); }
   virtual SurfaceFormat GetFormat() const { return mFinalSurface->GetFormat(); }
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface() { return mFinalSurface->GetDataSurface(); }
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface() { return mFinalSurface->GetDataSurface(); }
 
   RefPtr<SourceSurface> mFinalSurface;
   RefPtr<DrawEventRecorderPrivate> mRecorder;
 };
 
 class GradientStopsRecording : public GradientStops
 {
 public:
@@ -360,17 +360,17 @@ DrawTargetRecording::Stroke(const Path *
                             const DrawOptions &aOptions)
 {
   EnsureStored(aPath);
 
   mRecorder->RecordEvent(RecordedStroke(this, const_cast<Path*>(aPath), aPattern, aStrokeOptions, aOptions));
   mFinalDT->Stroke(GetPathForPathRecording(aPath), *AdjustedPattern(aPattern), aStrokeOptions, aOptions);
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetRecording::Snapshot()
 {
   RefPtr<SourceSurface> surf = mFinalDT->Snapshot();
 
   RefPtr<SourceSurface> retSurf = new SourceSurfaceRecording(surf, mRecorder);
 
   mRecorder->RecordEvent(RecordedSnapshot(retSurf, this));
 
@@ -405,17 +405,17 @@ DrawTargetRecording::DrawFilter(FilterNo
                                 const Rect &aSourceRect,
                                 const Point &aDestPoint,
                                 const DrawOptions &aOptions)
 {
   mRecorder->RecordEvent(RecordedDrawFilter(this, aNode, aSourceRect, aDestPoint, aOptions));
   mFinalDT->DrawFilter(GetFilterNode(aNode), aSourceRect, aDestPoint, aOptions);
 }
 
-TemporaryRef<FilterNode>
+already_AddRefed<FilterNode>
 DrawTargetRecording::CreateFilter(FilterType aType)
 {
   RefPtr<FilterNode> node = mFinalDT->CreateFilter(aType);
 
   RefPtr<FilterNode> retNode = new FilterNodeRecording(node, mRecorder);
 
   mRecorder->RecordEvent(RecordedFilterNodeCreation(retNode, aType));
 
@@ -456,32 +456,32 @@ DrawTargetRecording::PushClipRect(const 
 
 void
 DrawTargetRecording::PopClip()
 {
   mRecorder->RecordEvent(RecordedPopClip(this));
   mFinalDT->PopClip();
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetRecording::CreateSourceSurfaceFromData(unsigned char *aData,
                                                  const IntSize &aSize,
                                                  int32_t aStride,
                                                  SurfaceFormat aFormat) const
 {
   RefPtr<SourceSurface> surf = mFinalDT->CreateSourceSurfaceFromData(aData, aSize, aStride, aFormat);
 
   RefPtr<SourceSurface> retSurf = new SourceSurfaceRecording(surf, mRecorder);
 
   mRecorder->RecordEvent(RecordedSourceSurfaceCreation(retSurf, aData, aStride, aSize, aFormat));
 
   return retSurf.forget();
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetRecording::OptimizeSourceSurface(SourceSurface *aSurface) const
 {
   RefPtr<SourceSurface> surf = mFinalDT->OptimizeSourceSurface(aSurface);
 
   RefPtr<SourceSurface> retSurf = new SourceSurfaceRecording(surf, mRecorder);
 
   RefPtr<DataSourceSurface> dataSurf = surf->GetDataSurface();
 
@@ -504,17 +504,17 @@ DrawTargetRecording::OptimizeSourceSurfa
     mRecorder->RecordEvent(
       RecordedSourceSurfaceCreation(retSurf, dataSurf->GetData(), dataSurf->Stride(),
                                     dataSurf->GetSize(), dataSurf->GetFormat()));
   }
 
   return retSurf.forget();
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetRecording::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
 {
   RefPtr<SourceSurface> surf = mFinalDT->CreateSourceSurfaceFromNativeSurface(aSurface);
 
   RefPtr<SourceSurface> retSurf = new SourceSurfaceRecording(surf, mRecorder);
 
   RefPtr<DataSourceSurface> dataSurf = surf->GetDataSurface();
 
@@ -532,31 +532,31 @@ DrawTargetRecording::CreateSourceSurface
     mRecorder->RecordEvent(
       RecordedSourceSurfaceCreation(retSurf, dataSurf->GetData(), dataSurf->Stride(),
                                     dataSurf->GetSize(), dataSurf->GetFormat()));
   }
 
   return retSurf.forget();
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 DrawTargetRecording::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   RefPtr<DrawTarget> dt = mFinalDT->CreateSimilarDrawTarget(aSize, aFormat);
   return MakeAndAddRef<DrawTargetRecording>(mRecorder.get(), dt);
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 DrawTargetRecording::CreatePathBuilder(FillRule aFillRule) const
 {
   RefPtr<PathBuilder> builder = mFinalDT->CreatePathBuilder(aFillRule);
   return MakeAndAddRef<PathBuilderRecording>(builder, aFillRule);
 }
 
-TemporaryRef<GradientStops>
+already_AddRefed<GradientStops>
 DrawTargetRecording::CreateGradientStops(GradientStop *aStops,
                                          uint32_t aNumStops,
                                          ExtendMode aExtendMode) const
 {
   RefPtr<GradientStops> stops = mFinalDT->CreateGradientStops(aStops, aNumStops, aExtendMode);
 
   RefPtr<GradientStops> retStops = new GradientStopsRecording(stops, mRecorder);
 
--- a/gfx/2d/DrawTargetRecording.h
+++ b/gfx/2d/DrawTargetRecording.h
@@ -17,17 +17,17 @@ class DrawTargetRecording : public DrawT
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetRecording, override)
   DrawTargetRecording(DrawEventRecorder *aRecorder, DrawTarget *aDT, bool aHasData = false);
   ~DrawTargetRecording();
 
   virtual DrawTargetType GetType() const override { return mFinalDT->GetType(); }
   virtual BackendType GetBackendType() const override { return mFinalDT->GetBackendType(); }
 
-  virtual TemporaryRef<SourceSurface> Snapshot() override;
+  virtual already_AddRefed<SourceSurface> Snapshot() override;
 
   virtual IntSize GetSize() override { return mFinalDT->GetSize(); }
 
   /* Ensure that the DrawTarget backend has flushed all drawing operations to
    * this draw target. This must be called before using the backing surface of
    * this draw target outside of GFX 2D code.
    */
   virtual void Flush() override { mFinalDT->Flush(); }
@@ -205,67 +205,67 @@ public:
   virtual void PopClip() override;
 
   /*
    * Create a SourceSurface optimized for use with this DrawTarget from
    * existing bitmap data in memory.
    *
    * The SourceSurface does not take ownership of aData, and may be freed at any time.
    */
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
+  virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                                   const IntSize &aSize,
                                                                   int32_t aStride,
                                                                   SurfaceFormat aFormat) const override;
 
   /*
    * Create a SourceSurface optimized for use with this DrawTarget from
    * an arbitrary other SourceSurface. This may return aSourceSurface or some
    * other existing surface.
    */
-  virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override;
+  virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override;
 
   /*
    * Create a SourceSurface for a type of NativeSurface. This may fail if the
    * draw target does not know how to deal with the type of NativeSurface passed
    * in.
    */
-  virtual TemporaryRef<SourceSurface>
+  virtual already_AddRefed<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override;
 
   /*
    * Create a DrawTarget whose snapshot is optimized for use with this DrawTarget.
    */
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override;
 
   /*
    * Create a path builder with the specified fillmode.
    *
    * We need the fill mode up front because of Direct2D.
    * ID2D1SimplifiedGeometrySink requires the fill mode
    * to be set before calling BeginFigure().
    */
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override;
+  virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override;
 
   /*
    * Create a GradientStops object that holds information about a set of
    * gradient stops, this object is required for linear or radial gradient
    * patterns to represent the color stops in the gradient.
    *
    * aStops An array of gradient stops
    * aNumStops Number of stops in the array aStops
    * aExtendNone This describes how to extend the stop color outside of the
    *             gradient area.
    */
-  virtual TemporaryRef<GradientStops>
+  virtual already_AddRefed<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
                         ExtendMode aExtendMode = ExtendMode::CLAMP) const override;
 
-  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType) override;
+  virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType) override;
 
   /*
    * Set a transform on the surface, this transform is applied at drawing time
    * to both the mask and source of the operation.
    */
   virtual void SetTransform(const Matrix &aTransform) override;
 
   /* Tries to get a native surface for a DrawTarget, this may fail if the
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -129,17 +129,17 @@ DrawTargetSkia::DrawTargetSkia()
  mSnapshot(nullptr)
 {
 }
 
 DrawTargetSkia::~DrawTargetSkia()
 {
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetSkia::Snapshot()
 {
   RefPtr<SourceSurfaceSkia> snapshot = mSnapshot;
   if (!snapshot) {
     snapshot = new SourceSurfaceSkia();
     mSnapshot = snapshot;
     if (!snapshot->InitFromCanvas(mCanvas.get(), mFormat, this))
       return nullptr;
@@ -659,33 +659,33 @@ DrawTargetSkia::MaskSurface(const Patter
     paint.mPaint.setRasterizer(raster.get());
 
     IntSize size = aMask->GetSize();
     Rect rect = Rect(aOffset.x, aOffset.y, size.width, size.height);
     mCanvas->drawRect(RectToSkRect(rect), paint.mPaint);
   }
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetSkia::CreateSourceSurfaceFromData(unsigned char *aData,
                                             const IntSize &aSize,
                                             int32_t aStride,
                                             SurfaceFormat aFormat) const
 {
   RefPtr<SourceSurfaceSkia> newSurf = new SourceSurfaceSkia();
 
   if (!newSurf->InitFromData(aData, aSize, aStride, aFormat)) {
     gfxDebug() << *this << ": Failure to create source surface from data. Size: " << aSize;
     return nullptr;
   }
 
   return newSurf.forget();
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 DrawTargetSkia::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   RefPtr<DrawTargetSkia> target = new DrawTargetSkia();
   if (!target->Init(aSize, aFormat)) {
     return nullptr;
   }
   return target.forget();
 }
@@ -695,17 +695,17 @@ DrawTargetSkia::UsingSkiaGPU() const
 {
 #ifdef USE_SKIA_GPU
   return !!mTexture;
 #else
   return false;
 #endif
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetSkia::OptimizeSourceSurface(SourceSurface *aSurface) const
 {
   if (aSurface->GetType() == SurfaceType::SKIA) {
     RefPtr<SourceSurface> surface(aSurface);
     return surface.forget();
   }
 
   if (!UsingSkiaGPU()) {
@@ -727,17 +727,17 @@ DrawTargetSkia::OptimizeSourceSurface(So
   RefPtr<SourceSurface> result = CreateSourceSurfaceFromData(map.mData,
                                                              dataSurf->GetSize(),
                                                              map.mStride,
                                                              dataSurf->GetFormat());
   dataSurf->Unmap();
   return result.forget();
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetSkia::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
 {
   if (aSurface.mType == NativeSurfaceType::CAIRO_SURFACE) {
     if (aSurface.mSize.width <= 0 ||
         aSurface.mSize.height <= 0) {
       gfxWarning() << "Can't create a SourceSurface without a valid size";
       return nullptr;
     }
@@ -921,17 +921,17 @@ DrawTargetSkia::GetNativeSurface(NativeS
   if (aType == NativeSurfaceType::OPENGL_TEXTURE) {
     return (void*)((uintptr_t)mTexture);
   }
 #endif
   return nullptr;
 }
 
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 DrawTargetSkia::CreatePathBuilder(FillRule aFillRule) const
 {
   return MakeAndAddRef<PathBuilderSkia>(aFillRule);
 }
 
 void
 DrawTargetSkia::ClearRect(const Rect &aRect)
 {
@@ -967,30 +967,30 @@ DrawTargetSkia::PushClipRect(const Rect&
 }
 
 void
 DrawTargetSkia::PopClip()
 {
   mCanvas->restore();
 }
 
-TemporaryRef<GradientStops>
+already_AddRefed<GradientStops>
 DrawTargetSkia::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, ExtendMode aExtendMode) const
 {
   std::vector<GradientStop> stops;
   stops.resize(aNumStops);
   for (uint32_t i = 0; i < aNumStops; i++) {
     stops[i] = aStops[i];
   }
   std::stable_sort(stops.begin(), stops.end());
 
   return MakeAndAddRef<GradientStopsSkia>(stops, aNumStops, aExtendMode);
 }
 
-TemporaryRef<FilterNode>
+already_AddRefed<FilterNode>
 DrawTargetSkia::CreateFilter(FilterType aType)
 {
   return FilterNodeSoftware::Create(aType);
 }
 
 void
 DrawTargetSkia::MarkChanged()
 {
--- a/gfx/2d/DrawTargetSkia.h
+++ b/gfx/2d/DrawTargetSkia.h
@@ -29,17 +29,17 @@ class DrawTargetSkia : public DrawTarget
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetSkia, override)
   DrawTargetSkia();
   virtual ~DrawTargetSkia();
 
   virtual DrawTargetType GetType() const override;
   virtual BackendType GetBackendType() const override { return BackendType::SKIA; }
-  virtual TemporaryRef<SourceSurface> Snapshot() override;
+  virtual already_AddRefed<SourceSurface> Snapshot() override;
   virtual IntSize GetSize() override { return mSize; }
   virtual bool LockBits(uint8_t** aData, IntSize* aSize,
                         int32_t* aStride, SurfaceFormat* aFormat) override;
   virtual void ReleaseBits(uint8_t* aData) override;
   virtual void Flush() override;
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
@@ -88,28 +88,28 @@ public:
                     const DrawOptions &aOptions = DrawOptions()) override;
   virtual void MaskSurface(const Pattern &aSource,
                            SourceSurface *aMask,
                            Point aOffset,
                            const DrawOptions &aOptions = DrawOptions()) override;
   virtual void PushClip(const Path *aPath) override;
   virtual void PushClipRect(const Rect& aRect) override;
   virtual void PopClip() override;
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
+  virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                             const IntSize &aSize,
                                                             int32_t aStride,
                                                             SurfaceFormat aFormat) const override;
-  virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override;
-  virtual TemporaryRef<SourceSurface>
+  virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override;
+  virtual already_AddRefed<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override;
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override;
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override;
-  virtual TemporaryRef<GradientStops> CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, ExtendMode aExtendMode = ExtendMode::CLAMP) const override;
-  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType) override;
+  virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override;
+  virtual already_AddRefed<GradientStops> CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, ExtendMode aExtendMode = ExtendMode::CLAMP) const override;
+  virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType) override;
   virtual void SetTransform(const Matrix &aTransform) override;
   virtual void *GetNativeSurface(NativeSurfaceType aType) override;
 
   bool Init(const IntSize &aSize, SurfaceFormat aFormat);
   void Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat);
 
 #ifdef USE_SKIA_GPU
   bool InitWithGrContext(GrContext* aGrContext,
--- a/gfx/2d/DrawTargetTiled.cpp
+++ b/gfx/2d/DrawTargetTiled.cpp
@@ -43,17 +43,17 @@ DrawTargetTiled::Init(const TileSet& aTi
     mRect.height = newYMost - mRect.y;
     mTiles[i].mDrawTarget->SetTransform(Matrix::Translation(mTiles[i].mTileOrigin.x,
                                                             mTiles[i].mTileOrigin.y));
   }
   mFormat = mTiles[0].mDrawTarget->GetFormat();
   return true;
 }
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 DrawTargetTiled::Snapshot()
 {
   return MakeAndAddRef<SnapshotTiled>(mTiles, mRect);
 }
 
 // Skip the mClippedOut check since this is only used for Flush() which
 // should happen even if we're clipped.
 #define TILED_COMMAND(command) \
--- a/gfx/2d/DrawTargetTiled.h
+++ b/gfx/2d/DrawTargetTiled.h
@@ -35,17 +35,17 @@ public:
   DrawTargetTiled();
 
   bool Init(const TileSet& mTiles);
 
   virtual bool IsTiledDrawTarget() const override { return true; }
 
   virtual DrawTargetType GetType() const override { return mTiles[0].mDrawTarget->GetType(); }
   virtual BackendType GetBackendType() const override { return mTiles[0].mDrawTarget->GetBackendType(); }
-  virtual TemporaryRef<SourceSurface> Snapshot() override;
+  virtual already_AddRefed<SourceSurface> Snapshot() override;
   virtual IntSize GetSize() override {
     MOZ_ASSERT(mRect.width > 0 && mRect.height > 0);
     return IntSize(mRect.XMost(), mRect.YMost());
   }
 
   virtual void Flush() override;
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
@@ -101,53 +101,53 @@ public:
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions()) override;
   virtual void PushClip(const Path *aPath) override;
   virtual void PushClipRect(const Rect &aRect) override;
   virtual void PopClip() override;
 
   virtual void SetTransform(const Matrix &aTransform) override;
 
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
+  virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                                   const IntSize &aSize,
                                                                   int32_t aStride,
                                                                   SurfaceFormat aFormat) const override
   {
     return mTiles[0].mDrawTarget->CreateSourceSurfaceFromData(aData, aSize, aStride, aFormat);
   }
-  virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override
+  virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override
   {
     return mTiles[0].mDrawTarget->OptimizeSourceSurface(aSurface);
   }
 
-  virtual TemporaryRef<SourceSurface>
+  virtual already_AddRefed<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override
   {
     return mTiles[0].mDrawTarget->CreateSourceSurfaceFromNativeSurface(aSurface);
   }
 
-  virtual TemporaryRef<DrawTarget>
+  virtual already_AddRefed<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override
   {
     return mTiles[0].mDrawTarget->CreateSimilarDrawTarget(aSize, aFormat);
   }
 
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override
+  virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override
   {
     return mTiles[0].mDrawTarget->CreatePathBuilder(aFillRule);
   }
 
-  virtual TemporaryRef<GradientStops>
+  virtual already_AddRefed<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
                         ExtendMode aExtendMode = ExtendMode::CLAMP) const override
   {
     return mTiles[0].mDrawTarget->CreateGradientStops(aStops, aNumStops, aExtendMode);
   }
-  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType) override
+  virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType) override
   {
     return mTiles[0].mDrawTarget->CreateFilter(aType);
   }
 
 private:
   std::vector<TileInternal> mTiles;
   std::vector<std::vector<uint32_t> > mClippedOutTilesStack;
   IntRect mRect;
@@ -167,17 +167,17 @@ public:
 
   virtual SurfaceType GetType() const { return SurfaceType::TILED; }
   virtual IntSize GetSize() const {
     MOZ_ASSERT(mRect.width > 0 && mRect.height > 0);
     return IntSize(mRect.XMost(), mRect.YMost());
   }
   virtual SurfaceFormat GetFormat() const { return mSnapshots[0]->GetFormat(); }
 
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface()
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface()
   {
     RefPtr<DataSourceSurface> surf = Factory::CreateDataSourceSurface(GetSize(), GetFormat());
 
     DataSourceSurface::MappedSurface mappedSurf;
     if (!surf->Map(DataSourceSurface::MapType::WRITE, &mappedSurf)) {
       gfxCriticalError() << "DrawTargetTiled::GetDataSurface failed to map surface";
       return nullptr;
     }
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -263,17 +263,17 @@ Factory::CheckSurfaceSize(const IntSize 
   if (!numBytes.isValid()) {
     gfxDebug() << "Surface size too large (allocation size would overflow int32_t)!";
     return false;
   }
 
   return true;
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat)
 {
   if (!CheckSurfaceSize(aSize)) {
     gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "Failed to allocate a surface due to invalid size " << aSize;
     return nullptr;
   }
 
   RefPtr<DrawTarget> retVal;
@@ -343,23 +343,23 @@ Factory::CreateDrawTarget(BackendType aB
   if (!retVal) {
     // Failed
     gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize;
   }
 
   return retVal.forget();
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateRecordingDrawTarget(DrawEventRecorder *aRecorder, DrawTarget *aDT)
 {
   return MakeAndAddRef<DrawTargetRecording>(aRecorder, aDT);
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateDrawTargetForData(BackendType aBackend,
                                  unsigned char *aData,
                                  const IntSize &aSize,
                                  int32_t aStride,
                                  SurfaceFormat aFormat)
 {
   MOZ_ASSERT(aData);
   if (!CheckSurfaceSize(aSize)) {
@@ -411,17 +411,17 @@ Factory::CreateDrawTargetForData(Backend
 
   if (!retVal) {
     gfxDebug() << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize;
   }
 
   return retVal.forget();
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateTiledDrawTarget(const TileSet& aTileSet)
 {
   RefPtr<DrawTargetTiled> dt = new DrawTargetTiled();
 
   if (!dt->Init(aTileSet)) {
     return nullptr;
   }
 
@@ -466,17 +466,17 @@ Factory::GetMaxSurfaceSize(BackendType a
   case BackendType::DIRECT2D1_1:
     return DrawTargetD2D1::GetMaxSurfaceSize();
 #endif
   default:
     return 0;
   }
 }
 
-TemporaryRef<ScaledFont>
+already_AddRefed<ScaledFont>
 Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSize)
 {
   switch (aNativeFont.mType) {
 #ifdef WIN32
   case NativeFontType::DWRITE_FONT_FACE:
     {
       return MakeAndAddRef<ScaledFontDWrite>(static_cast<IDWriteFontFace*>(aNativeFont.mFont), aSize);
     }
@@ -500,17 +500,17 @@ Factory::CreateScaledFontForNativeFont(c
     }
 #endif
   default:
     gfxWarning() << "Invalid native font type specified.";
     return nullptr;
   }
 }
 
-TemporaryRef<ScaledFont>
+already_AddRefed<ScaledFont>
 Factory::CreateScaledFontForTrueTypeData(uint8_t *aData, uint32_t aSize,
                                          uint32_t aFaceIndex, Float aGlyphSize,
                                          FontType aType)
 {
   switch (aType) {
 #ifdef WIN32
   case FontType::DWRITE:
     {
@@ -518,33 +518,33 @@ Factory::CreateScaledFontForTrueTypeData
     }
 #endif
   default:
     gfxWarning() << "Unable to create requested font type from truetype data";
     return nullptr;
   }
 }
 
-TemporaryRef<ScaledFont>
+already_AddRefed<ScaledFont>
 Factory::CreateScaledFontWithCairo(const NativeFont& aNativeFont, Float aSize, cairo_scaled_font_t* aScaledFont)
 {
 #ifdef USE_CAIRO
   // In theory, we could pull the NativeFont out of the cairo_scaled_font_t*,
   // but that would require a lot of code that would be otherwise repeated in
   // various backends.
   // Therefore, we just reuse CreateScaledFontForNativeFont's implementation.
   RefPtr<ScaledFont> font = CreateScaledFontForNativeFont(aNativeFont, aSize);
   static_cast<ScaledFontBase*>(font.get())->SetCairoScaledFont(aScaledFont);
   return font.forget();
 #else
   return nullptr;
 #endif
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateDualDrawTarget(DrawTarget *targetA, DrawTarget *targetB)
 {
   MOZ_ASSERT(targetA && targetB);
 
   RefPtr<DrawTarget> newTarget =
     new DrawTargetDual(targetA, targetB);
 
   RefPtr<DrawTarget> retVal = newTarget;
@@ -553,17 +553,17 @@ Factory::CreateDualDrawTarget(DrawTarget
     retVal = new DrawTargetRecording(mRecorder, retVal);
   }
 
   return retVal.forget();
 }
 
 
 #ifdef WIN32
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat)
 {
   MOZ_ASSERT(aTexture);
 
   RefPtr<DrawTargetD2D> newTarget;
 
   newTarget = new DrawTargetD2D();
   if (newTarget->Init(aTexture, aFormat)) {
@@ -577,17 +577,17 @@ Factory::CreateDrawTargetForD3D10Texture
   }
 
   gfxWarning() << "Failed to create draw target for D3D10 texture.";
 
   // Failed
   return nullptr;
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA,
                                               ID3D10Texture2D *aTextureB,
                                               SurfaceFormat aFormat)
 {
   MOZ_ASSERT(aTextureA && aTextureB);
   RefPtr<DrawTargetD2D> newTargetA;
   RefPtr<DrawTargetD2D> newTargetB;
 
@@ -632,17 +632,17 @@ Factory::GetDirect3D10Device()
   if (mD3D10Device) {
     UINT mode = mD3D10Device->GetExceptionMode();
     MOZ_ASSERT(0 == mode);
   }
 #endif
   return mD3D10Device;
 }
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat)
 {
   MOZ_ASSERT(aTexture);
 
   RefPtr<DrawTargetD2D1> newTarget;
 
   newTarget = new DrawTargetD2D1();
   if (newTarget->Init(aTexture, aFormat)) {
@@ -698,17 +698,17 @@ Factory::GetD2D1Device()
 }
 
 bool
 Factory::SupportsD2D1()
 {
   return !!D2DFactory1();
 }
 
-TemporaryRef<GlyphRenderingOptions>
+already_AddRefed<GlyphRenderingOptions>
 Factory::CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams)
 {
   return MakeAndAddRef<GlyphRenderingOptionsDWrite>(aParams);
 }
 
 uint64_t
 Factory::GetD2DVRAMUsageDrawTarget()
 {
@@ -730,17 +730,17 @@ Factory::D2DCleanup()
   }
   DrawTargetD2D1::CleanupD2D();
   DrawTargetD2D::CleanupD2D();
 }
 
 #endif // XP_WIN
 
 #ifdef USE_SKIA_GPU
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateDrawTargetSkiaWithGrContext(GrContext* aGrContext,
                                            const IntSize &aSize,
                                            SurfaceFormat aFormat)
 {
   RefPtr<DrawTarget> newTarget = new DrawTargetSkia();
   if (!newTarget->InitWithGrContext(aGrContext, aSize, aFormat)) {
     return nullptr;
   }
@@ -750,29 +750,29 @@ Factory::CreateDrawTargetSkiaWithGrConte
 #endif // USE_SKIA_GPU
 
 void
 Factory::PurgeAllCaches()
 {
 }
 
 #ifdef USE_SKIA_FREETYPE
-TemporaryRef<GlyphRenderingOptions>
+already_AddRefed<GlyphRenderingOptions>
 Factory::CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHinting)
 {
   RefPtr<GlyphRenderingOptionsCairo> options =
     new GlyphRenderingOptionsCairo();
 
   options->SetHinting(aHinting);
   options->SetAutoHinting(aAutoHinting);
   return options.forget();
 }
 #endif
 
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat)
 {
   RefPtr<DrawTarget> retVal;
 
 #ifdef USE_CAIRO
   RefPtr<DrawTargetCairo> newTarget = new DrawTargetCairo();
 
   if (newTarget->Init(aSurface, aSize, aFormat)) {
@@ -782,41 +782,41 @@ Factory::CreateDrawTargetForCairoSurface
   if (mRecorder && retVal) {
     return MakeAndAddRef<DrawTargetRecording>(mRecorder, retVal, true);
   }
 #endif
   return retVal.forget();
 }
 
 #ifdef XP_MACOSX
-TemporaryRef<DrawTarget>
+already_AddRefed<DrawTarget>
 Factory::CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize)
 {
   RefPtr<DrawTarget> retVal;
 
   RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
 
   if (newTarget->Init(cg, aSize)) {
     retVal = newTarget;
   }
 
   if (mRecorder && retVal) {
     return MakeAndAddRef<DrawTargetRecording>(mRecorder, retVal);
   }
   return retVal.forget();
 }
 
-TemporaryRef<GlyphRenderingOptions>
+already_AddRefed<GlyphRenderingOptions>
 Factory::CreateCGGlyphRenderingOptions(const Color &aFontSmoothingBackgroundColor)
 {
   return MakeAndAddRef<GlyphRenderingOptionsCG>(aFontSmoothingBackgroundColor);
 }
 #endif
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 Factory::CreateWrappingDataSourceSurface(uint8_t *aData, int32_t aStride,
                                          const IntSize &aSize,
                                          SurfaceFormat aFormat)
 {
   MOZ_ASSERT(aData);
   if (aSize.width <= 0 || aSize.height <= 0) {
     return nullptr;
   }
@@ -825,17 +825,17 @@ Factory::CreateWrappingDataSourceSurface
 
   if (newSurf->InitWrappingData(aData, aSize, aStride, aFormat, false)) {
     return newSurf.forget();
   }
 
   return nullptr;
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 Factory::CreateDataSourceSurface(const IntSize &aSize,
                                  SurfaceFormat aFormat,
                                  bool aZero)
 {
   if (!CheckSurfaceSize(aSize)) {
     gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "Failed to allocate a surface due to invalid size " << aSize;
     return nullptr;
   }
@@ -844,17 +844,17 @@ Factory::CreateDataSourceSurface(const I
   if (newSurf->Init(aSize, aFormat, aZero)) {
     return newSurf.forget();
   }
 
   gfxWarning() << "CreateDataSourceSurface failed in init";
   return nullptr;
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 Factory::CreateDataSourceSurfaceWithStride(const IntSize &aSize,
                                            SurfaceFormat aFormat,
                                            int32_t aStride,
                                            bool aZero)
 {
   if (aStride < aSize.width * BytesPerPixel(aFormat)) {
     gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "CreateDataSourceSurfaceWithStride failed with bad stride " << aStride << ", " << aSize << ", " << aFormat;
     return nullptr;
@@ -864,17 +864,17 @@ Factory::CreateDataSourceSurfaceWithStri
   if (newSurf->InitWithStride(aSize, aFormat, aStride, aZero)) {
     return newSurf.forget();
   }
 
   gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "CreateDataSourceSurfaceWithStride failed to initialize " << aSize << ", " << aFormat << ", " << aStride << ", " << aZero;
   return nullptr;
 }
 
-TemporaryRef<DrawEventRecorder>
+already_AddRefed<DrawEventRecorder>
 Factory::CreateEventRecorderForFile(const char *aFilename)
 {
   return MakeAndAddRef<DrawEventRecorderFile>(aFilename);
 }
 
 void
 Factory::SetGlobalEventRecorder(DrawEventRecorder *aRecorder)
 {
--- a/gfx/2d/FilterNodeD2D1.cpp
+++ b/gfx/2d/FilterNodeD2D1.cpp
@@ -145,17 +145,17 @@ D2D1_CHANNEL_SELECTOR D2DChannelSelector
   case COLOR_CHANNEL_A:
     return D2D1_CHANNEL_SELECTOR_A;
   }
 
   MOZ_CRASH("Unknown enum value!");
   return D2D1_CHANNEL_SELECTOR_R;
 }
 
-TemporaryRef<ID2D1Image> GetImageForSourceSurface(DrawTarget *aDT, SourceSurface *aSurface)
+already_AddRefed<ID2D1Image> GetImageForSourceSurface(DrawTarget *aDT, SourceSurface *aSurface)
 {
   if (aDT->IsTiledDrawTarget() || aDT->IsDualDrawTarget()) {
       MOZ_CRASH("Incompatible draw target type!");
       return nullptr;
   }
   switch (aDT->GetBackendType()) {
     case BackendType::DIRECT2D1_1:
       return static_cast<DrawTargetD2D1*>(aDT)->GetImageForSurface(aSurface, ExtendMode::CLAMP);
@@ -532,17 +532,17 @@ IsTransferFilterType(FilterType aType)
     case FilterType::DISCRETE_TRANSFER:
       return true;
     default:
       return false;
   }
 }
 
 /* static */
-TemporaryRef<FilterNode>
+already_AddRefed<FilterNode>
 FilterNodeD2D1::Create(ID2D1DeviceContext *aDC, FilterType aType)
 {
   if (aType == FilterType::CONVOLVE_MATRIX) {
     return MakeAndAddRef<FilterNodeConvolveD2D1>(aDC);
   }
 
   RefPtr<ID2D1Effect> effect;
   HRESULT hr;
--- a/gfx/2d/FilterNodeD2D1.h
+++ b/gfx/2d/FilterNodeD2D1.h
@@ -14,17 +14,17 @@
 
 namespace mozilla {
 namespace gfx {
 
 class FilterNodeD2D1 : public FilterNode
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeD2D1)
-  static TemporaryRef<FilterNode> Create(ID2D1DeviceContext *aDC, FilterType aType);
+  static already_AddRefed<FilterNode> Create(ID2D1DeviceContext *aDC, FilterType aType);
 
   FilterNodeD2D1(ID2D1Effect *aEffect, FilterType aType)
     : mEffect(aEffect)
     , mType(aType)
   {
     InitUnmappedProperties();
   }
 
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -175,17 +175,17 @@ private:
 
 // from xpcom/ds/nsMathUtils.h
 static int32_t
 NS_lround(double x)
 {
   return x >= 0.0 ? int32_t(x + 0.5) : int32_t(x - 0.5);
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 CloneAligned(DataSourceSurface* aSource)
 {
   return CreateDataSourceSurfaceByCloning(aSource);
 }
 
 static void
 FillRectWithPixel(DataSourceSurface *aSurface, const IntRect &aFillRect, IntPoint aPixelPos)
 {
@@ -388,17 +388,17 @@ TileSurface(DataSourceSurface* aSource, 
       IntRect destRect(destPoint, sourceRect.Size());
       destRect = destRect.Intersect(targetRect);
       IntRect srcRect = destRect - destPoint;
       CopyRect(aSource, aTarget, srcRect, destRect.TopLeft());
     }
   }
 }
 
-static TemporaryRef<DataSourceSurface>
+static already_AddRefed<DataSourceSurface>
 GetDataSurfaceInRect(SourceSurface *aSurface,
                      const IntRect &aSurfaceRect,
                      const IntRect &aDestRect,
                      ConvolveMatrixEdgeMode aEdgeMode)
 {
   MOZ_ASSERT(aSurface ? aSurfaceRect.Size() == aSurface->GetSize() : aSurfaceRect.IsEmpty());
 
   if (aSurfaceRect.Overflows() || aDestRect.Overflows()) {
@@ -441,17 +441,17 @@ GetDataSurfaceInRect(SourceSurface *aSur
 
   if (aEdgeMode == EDGE_MODE_DUPLICATE) {
     DuplicateEdges(target, intersectInDestSpace);
   }
 
   return target.forget();
 }
 
-/* static */ TemporaryRef<FilterNode>
+/* static */ already_AddRefed<FilterNode>
 FilterNodeSoftware::Create(FilterType aType)
 {
   RefPtr<FilterNodeSoftware> filter;
   switch (aType) {
     case FilterType::BLEND:
       filter = new FilterNodeBlendSoftware();
       break;
     case FilterType::TRANSFORM:
@@ -596,17 +596,17 @@ FilterNodeSoftware::Draw(DrawTarget* aDr
     aDrawTarget->PopClip();
   } else {
     aDrawTarget->DrawSurface(result, renderedDestRect,
                              renderedSourceRect - Point(outputRect.TopLeft()),
                              DrawSurfaceOptions(), aOptions);
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeSoftware::GetOutput(const IntRect &aRect)
 {
   MOZ_ASSERT(GetOutputRectInRect(aRect).Contains(aRect));
 
   if (aRect.Overflows()) {
     return nullptr;
   }
 
@@ -657,17 +657,17 @@ FilterNodeSoftware::DesiredFormat(Surfac
                                   FormatHint aFormatHint)
 {
   if (aCurrentFormat == SurfaceFormat::A8 && aFormatHint == CAN_HANDLE_A8) {
     return SurfaceFormat::A8;
   }
   return SurfaceFormat::B8G8R8A8;
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex,
                                               const IntRect& aRect,
                                               FormatHint aFormatHint,
                                               ConvolveMatrixEdgeMode aEdgeMode,
                                               const IntRect *aTransparencyPaddedSourceRect)
 {
   if (aRect.Overflows()) {
     return nullptr;
@@ -956,17 +956,17 @@ static CompositionOp ToBlendOp(BlendMode
     return CompositionOp::OP_LUMINOSITY;
   default:
     return CompositionOp::OP_OVER;
   }
 
   return CompositionOp::OP_OVER;
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeBlendSoftware::Render(const IntRect& aRect)
 {
   RefPtr<DataSourceSurface> input1 =
     GetInputDataSourceSurface(IN_BLEND_IN, aRect, NEED_COLOR_CHANNELS);
   RefPtr<DataSourceSurface> input2 =
     GetInputDataSourceSurface(IN_BLEND_IN2, aRect, NEED_COLOR_CHANNELS);
 
   // Null inputs need to be treated as transparent.
@@ -1081,17 +1081,17 @@ FilterNodeTransformSoftware::SourceRectF
   neededRect.RoundOut();
   IntRect neededIntRect;
   if (!neededRect.ToIntRect(&neededIntRect)) {
     return IntRect();
   }
   return GetInputRectInRect(IN_TRANSFORM_IN, neededIntRect);
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeTransformSoftware::Render(const IntRect& aRect)
 {
   IntRect srcRect = SourceRectForOutputRect(aRect);
 
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_TRANSFORM_IN, srcRect);
 
   if (!input) {
@@ -1187,17 +1187,17 @@ void
 FilterNodeMorphologySoftware::SetAttribute(uint32_t aIndex,
                                            uint32_t aOperator)
 {
   MOZ_ASSERT(aIndex == ATT_MORPHOLOGY_OPERATOR);
   mOperator = static_cast<MorphologyOperator>(aOperator);
   Invalidate();
 }
 
-static TemporaryRef<DataSourceSurface>
+static already_AddRefed<DataSourceSurface>
 ApplyMorphology(const IntRect& aSourceRect, DataSourceSurface* aInput,
                 const IntRect& aDestRect, int32_t rx, int32_t ry,
                 MorphologyOperator aOperator)
 {
   IntRect srcRect = aSourceRect - aDestRect.TopLeft();
   IntRect destRect = aDestRect - aDestRect.TopLeft();
   IntRect tmpRect(destRect.x, srcRect.y, destRect.width, srcRect.height);
 #ifdef DEBUG
@@ -1251,17 +1251,17 @@ ApplyMorphology(const IntRect& aSourceRe
 
     FilterProcessing::ApplyMorphologyVertical(
       tmpData, tmpStride, destData, destStride, destRect, ry, aOperator);
   }
 
   return dest.forget();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeMorphologySoftware::Render(const IntRect& aRect)
 {
   IntRect srcRect = aRect;
   srcRect.Inflate(mRadii);
 
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_MORPHOLOGY_IN, srcRect, NEED_COLOR_CHANNELS);
   if (!input) {
@@ -1322,17 +1322,17 @@ void
 FilterNodeColorMatrixSoftware::SetAttribute(uint32_t aIndex,
                                             uint32_t aAlphaMode)
 {
   MOZ_ASSERT(aIndex == ATT_COLOR_MATRIX_ALPHA_MODE);
   mAlphaMode = (AlphaMode)aAlphaMode;
   Invalidate();
 }
 
-static TemporaryRef<DataSourceSurface>
+static already_AddRefed<DataSourceSurface>
 Premultiply(DataSourceSurface* aSurface)
 {
   if (aSurface->GetFormat() == SurfaceFormat::A8) {
     RefPtr<DataSourceSurface> surface(aSurface);
     return surface.forget();
   }
 
   IntSize size = aSurface->GetSize();
@@ -1354,17 +1354,17 @@ Premultiply(DataSourceSurface* aSurface)
   int32_t targetStride = targetMap.GetStride();
 
   FilterProcessing::DoPremultiplicationCalculation(
     size, targetData, targetStride, inputData, inputStride);
 
   return target.forget();
 }
 
-static TemporaryRef<DataSourceSurface>
+static already_AddRefed<DataSourceSurface>
 Unpremultiply(DataSourceSurface* aSurface)
 {
   if (aSurface->GetFormat() == SurfaceFormat::A8) {
     RefPtr<DataSourceSurface> surface(aSurface);
     return surface.forget();
   }
 
   IntSize size = aSurface->GetSize();
@@ -1386,17 +1386,17 @@ Unpremultiply(DataSourceSurface* aSurfac
   int32_t targetStride = targetMap.GetStride();
 
   FilterProcessing::DoUnpremultiplicationCalculation(
     size, targetData, targetStride, inputData, inputStride);
 
   return target.forget();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeColorMatrixSoftware::Render(const IntRect& aRect)
 {
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_COLOR_MATRIX_IN, aRect, NEED_COLOR_CHANNELS);
   if (!input) {
     return nullptr;
   }
 
@@ -1455,17 +1455,17 @@ static SurfaceFormat
 FormatForColor(Color aColor)
 {
   if (aColor.r == 0 && aColor.g == 0 && aColor.b == 0) {
     return SurfaceFormat::A8;
   }
   return SurfaceFormat::B8G8R8A8;
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeFloodSoftware::Render(const IntRect& aRect)
 {
   SurfaceFormat format = FormatForColor(mColor);
   RefPtr<DataSourceSurface> target =
     Factory::CreateDataSourceSurface(aRect.Size(), format);
   if (MOZ2D_WARN_IF(!target)) {
     return nullptr;
   }
@@ -1498,17 +1498,17 @@ FilterNodeFloodSoftware::Render(const In
     MOZ_CRASH();
   }
 
   return target.forget();
 }
 
 // Override GetOutput to get around caching. Rendering simple floods is
 // comparatively fast.
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeFloodSoftware::GetOutput(const IntRect& aRect)
 {
   return Render(aRect);
 }
 
 IntRect
 FilterNodeFloodSoftware::GetOutputRectInRect(const IntRect& aRect)
 {
@@ -1551,17 +1551,17 @@ struct CompareIntRects
     if (a.width != b.width) {
       return a.width < b.width;
     }
     return a.height < b.height;
   }
 };
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeTileSoftware::Render(const IntRect& aRect)
 {
   if (mSourceRect.IsEmpty()) {
     return nullptr;
   }
 
   if (mSourceRect.Contains(aRect)) {
     return GetInputDataSourceSurface(IN_TILE_IN, aRect);
@@ -1723,17 +1723,17 @@ IsAllZero(uint8_t aLookupTable[256])
   for (int32_t i = 0; i < 256; i++) {
     if (aLookupTable[i] != 0) {
       return false;
     }
   }
   return true;
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeComponentTransferSoftware::Render(const IntRect& aRect)
 {
   if (mDisableR && mDisableG && mDisableB && mDisableA) {
     return GetInputDataSourceSurface(IN_TRANSFER_IN, aRect);
   }
 
   uint8_t lookupTables[4][256];
   GenerateLookupTable(B8G8R8A8_COMPONENT_BYTEOFFSET_R, lookupTables, mDisableR);
@@ -2337,17 +2337,17 @@ ConvolvePixel(const uint8_t *aSourceData
       (clamped + roundingAddition) << shiftR >> shiftL;
   }
   if (aPreserveAlpha) {
     aTargetData[aY * aTargetStride + 4 * aX + B8G8R8A8_COMPONENT_BYTEOFFSET_A] =
       aSourceData[aY * aSourceStride + 4 * aX + B8G8R8A8_COMPONENT_BYTEOFFSET_A];
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeConvolveMatrixSoftware::Render(const IntRect& aRect)
 {
   if (mKernelUnitLength.width == floor(mKernelUnitLength.width) &&
       mKernelUnitLength.height == floor(mKernelUnitLength.height)) {
     return DoRender(aRect, (int32_t)mKernelUnitLength.width, (int32_t)mKernelUnitLength.height);
   }
   return DoRender(aRect, mKernelUnitLength.width, mKernelUnitLength.height);
 }
@@ -2404,17 +2404,17 @@ TranslateDoubleToShifts(double aDouble, 
   } else {
     while (1 << (aShiftL + 1) < aDouble) {
       aShiftL++;
     }
   }
 }
 
 template<typename CoordType>
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeConvolveMatrixSoftware::DoRender(const IntRect& aRect,
                                            CoordType aKernelUnitLengthX,
                                            CoordType aKernelUnitLengthY)
 {
   if (mKernelSize.width <= 0 || mKernelSize.height <= 0 ||
       mKernelMatrix.size() != uint32_t(mKernelSize.width * mKernelSize.height) ||
       !IntRect(IntPoint(0, 0), mKernelSize).Contains(mTarget) ||
       mDivisor == 0) {
@@ -2575,17 +2575,17 @@ FilterNodeDisplacementMapSoftware::SetAt
       mChannelY = static_cast<ColorChannel>(aValue);
       break;
     default:
       MOZ_CRASH();
   }
   Invalidate();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeDisplacementMapSoftware::Render(const IntRect& aRect)
 {
   IntRect srcRect = InflatedSourceOrDestRect(aRect);
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_DISPLACEMENT_MAP_IN, srcRect, NEED_COLOR_CHANNELS);
   RefPtr<DataSourceSurface> map =
     GetInputDataSourceSurface(IN_DISPLACEMENT_MAP_IN2, aRect, NEED_COLOR_CHANNELS);
   RefPtr<DataSourceSurface> target =
@@ -2724,17 +2724,17 @@ FilterNodeTurbulenceSoftware::SetAttribu
       break;
     default:
       MOZ_CRASH();
       break;
   }
   Invalidate();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeTurbulenceSoftware::Render(const IntRect& aRect)
 {
   return FilterProcessing::RenderTurbulence(
     aRect.Size(), aRect.TopLeft(), mBaseFrequency,
     mSeed, mNumOctaves, mType, mStitchable, Rect(mRenderRect));
 }
 
 IntRect
@@ -2769,17 +2769,17 @@ FilterNodeArithmeticCombineSoftware::Set
   mK1 = aFloat[0];
   mK2 = aFloat[1];
   mK3 = aFloat[2];
   mK4 = aFloat[3];
 
   Invalidate();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeArithmeticCombineSoftware::Render(const IntRect& aRect)
 {
   RefPtr<DataSourceSurface> input1 =
     GetInputDataSourceSurface(IN_ARITHMETIC_COMBINE_IN, aRect, NEED_COLOR_CHANNELS);
   RefPtr<DataSourceSurface> input2 =
     GetInputDataSourceSurface(IN_ARITHMETIC_COMBINE_IN2, aRect, NEED_COLOR_CHANNELS);
   if (!input1 && !input2) {
     return nullptr;
@@ -2843,17 +2843,17 @@ FilterNodeCompositeSoftware::InputIndex(
 void
 FilterNodeCompositeSoftware::SetAttribute(uint32_t aIndex, uint32_t aCompositeOperator)
 {
   MOZ_ASSERT(aIndex == ATT_COMPOSITE_OPERATOR);
   mOperator = static_cast<CompositeOperator>(aCompositeOperator);
   Invalidate();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeCompositeSoftware::Render(const IntRect& aRect)
 {
   RefPtr<DataSourceSurface> start =
     GetInputDataSourceSurface(IN_COMPOSITE_IN_START, aRect, NEED_COLOR_CHANNELS);
   RefPtr<DataSourceSurface> dest =
     Factory::CreateDataSourceSurface(aRect.Size(), SurfaceFormat::B8G8R8A8, true);
   if (MOZ2D_WARN_IF(!dest)) {
     return nullptr;
@@ -2919,17 +2919,17 @@ int32_t
 FilterNodeBlurXYSoftware::InputIndex(uint32_t aInputEnumIndex)
 {
   switch (aInputEnumIndex) {
     case IN_GAUSSIAN_BLUR_IN: return 0;
     default: return -1;
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeBlurXYSoftware::Render(const IntRect& aRect)
 {
   Size sigmaXY = StdDeviationXY();
   IntSize d = AlphaBoxBlur::CalculateBlurRadius(Point(sigmaXY.width, sigmaXY.height));
 
   if (d.width == 0 && d.height == 0) {
     return GetInputDataSourceSurface(IN_GAUSSIAN_BLUR_IN, aRect);
   }
@@ -3097,17 +3097,17 @@ FilterNodeCropSoftware::SetAttribute(uin
   Rect srcRect = aSourceRect;
   srcRect.Round();
   if (!srcRect.ToIntRect(&mCropRect)) {
     mCropRect = IntRect();
   }
   Invalidate();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeCropSoftware::Render(const IntRect& aRect)
 {
   return GetInputDataSourceSurface(IN_CROP_IN, aRect.Intersect(mCropRect));
 }
 
 void
 FilterNodeCropSoftware::RequestFromInputsForRect(const IntRect &aRect)
 {
@@ -3124,17 +3124,17 @@ int32_t
 FilterNodePremultiplySoftware::InputIndex(uint32_t aInputEnumIndex)
 {
   switch (aInputEnumIndex) {
     case IN_PREMULTIPLY_IN: return 0;
     default: return -1;
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodePremultiplySoftware::Render(const IntRect& aRect)
 {
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_PREMULTIPLY_IN, aRect);
   return input ? Premultiply(input) : nullptr;
 }
 
 void
@@ -3153,17 +3153,17 @@ int32_t
 FilterNodeUnpremultiplySoftware::InputIndex(uint32_t aInputEnumIndex)
 {
   switch (aInputEnumIndex) {
     case IN_UNPREMULTIPLY_IN: return 0;
     default: return -1;
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeUnpremultiplySoftware::Render(const IntRect& aRect)
 {
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_UNPREMULTIPLY_IN, aRect);
   return input ? Unpremultiply(input) : nullptr;
 }
 
 void
@@ -3433,17 +3433,17 @@ GenerateNormal(const uint8_t *data, int3
   Point3D normal;
   normal.x = -surfaceScale * normalX / 4.0f;
   normal.y = -surfaceScale * normalY / 4.0f;
   normal.z = 255;
   return Normalized(normal);
 }
 
 template<typename LightType, typename LightingType>
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeLightingSoftware<LightType, LightingType>::Render(const IntRect& aRect)
 {
   if (mKernelUnitLength.width == floor(mKernelUnitLength.width) &&
       mKernelUnitLength.height == floor(mKernelUnitLength.height)) {
     return DoRender(aRect, (int32_t)mKernelUnitLength.width, (int32_t)mKernelUnitLength.height);
   }
   return DoRender(aRect, mKernelUnitLength.width, mKernelUnitLength.height);
 }
@@ -3454,17 +3454,17 @@ FilterNodeLightingSoftware<LightType, Li
 {
   IntRect srcRect = aRect;
   srcRect.Inflate(ceil(mKernelUnitLength.width),
                   ceil(mKernelUnitLength.height));
   RequestInputRect(IN_LIGHTING_IN, srcRect);
 }
 
 template<typename LightType, typename LightingType> template<typename CoordType>
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterNodeLightingSoftware<LightType, LightingType>::DoRender(const IntRect& aRect,
                                                               CoordType aKernelUnitLengthX,
                                                               CoordType aKernelUnitLengthY)
 {
   IntRect srcRect = aRect;
   IntSize size = aRect.Size();
   srcRect.Inflate(ceil(float(aKernelUnitLengthX)),
                   ceil(float(aKernelUnitLengthY)));
--- a/gfx/2d/FilterNodeSoftware.h
+++ b/gfx/2d/FilterNodeSoftware.h
@@ -37,17 +37,17 @@ public:
 class FilterNodeSoftware : public FilterNode,
                            public FilterInvalidationListener
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeSoftware, override)
   virtual ~FilterNodeSoftware();
 
   // Factory method, intended to be called from DrawTarget*::CreateFilter.
-  static TemporaryRef<FilterNode> Create(FilterType aType);
+  static already_AddRefed<FilterNode> Create(FilterType aType);
 
   // Draw the filter, intended to be called by DrawTarget*::DrawFilter.
   void Draw(DrawTarget* aDrawTarget, const Rect &aSourceRect,
             const Point &aDestPoint, const DrawOptions &aOptions);
 
   virtual FilterBackend GetBackendType() override { return FILTER_BACKEND_SOFTWARE; }
   virtual void SetInput(uint32_t aIndex, SourceSurface *aSurface) override;
   virtual void SetInput(uint32_t aIndex, FilterNode *aFilter) override;
@@ -85,31 +85,31 @@ protected:
    * Return a surface with the rendered output which is of size aRect.Size().
    * aRect is required to be a subrect of this filter's output rect; in other
    * words, aRect == GetOutputRectInRect(aRect) must always be true.
    * May return nullptr in error conditions or for an empty aRect.
    * Implementations are not required to allocate a new surface and may even
    * pass through input surfaces unchanged.
    * Callers need to treat the returned surface as immutable.
    */
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) = 0;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) = 0;
 
   /**
    * Call RequestRect (see below) on any input filters with the desired input
    * rect, so that the input filter knows what to cache the next time it
    * renders.
    */
   virtual void RequestFromInputsForRect(const IntRect &aRect) {}
 
   /**
    * This method provides a caching default implementation but can be overriden
    * by subclasses that don't want to cache their output. Those classes should
    * call Render(aRect) directly from here.
    */
-  virtual TemporaryRef<DataSourceSurface> GetOutput(const IntRect &aRect);
+  virtual already_AddRefed<DataSourceSurface> GetOutput(const IntRect &aRect);
 
   // The following methods are non-virtual helper methods.
 
   /**
    * Format hints for GetInputDataSourceSurface. Some callers of
    * GetInputDataSourceSurface can handle both B8G8R8A8 and A8 surfaces, these
    * should pass CAN_HANDLE_A8 in order to avoid unnecessary conversions.
    * Callers that can only handle B8G8R8A8 surfaces pass NEED_COLOR_CHANNELS.
@@ -134,17 +134,17 @@ protected:
    * rect (or the input surface's dimensions), the remaining area is filled
    * according to aEdgeMode: The default, EDGE_MODE_NONE, simply pads with
    * transparent black.
    * If non-null, the returned surface is guaranteed to be of SurfaceFormat::A8 or
    * SurfaceFormat::B8G8R8A8. If aFormatHint is NEED_COLOR_CHANNELS, the returned
    * surface is guaranteed to be of SurfaceFormat::B8G8R8A8 always.
    * Each pixel row of the returned surface is guaranteed to be 16-byte aligned.
    */
-  TemporaryRef<DataSourceSurface>
+  already_AddRefed<DataSourceSurface>
     GetInputDataSourceSurface(uint32_t aInputEnumIndex, const IntRect& aRect,
                               FormatHint aFormatHint = CAN_HANDLE_A8,
                               ConvolveMatrixEdgeMode aEdgeMode = EDGE_MODE_NONE,
                               const IntRect *aTransparencyPaddedSourceRect = nullptr);
 
   /**
    * Returns the intersection of the input filter's or surface's output rect
    * with aInRect.
@@ -221,17 +221,17 @@ public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeTransformSoftware, override)
   FilterNodeTransformSoftware();
   virtual const char* GetName() override { return "Transform"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, uint32_t aGraphicsFilter) override;
   virtual void SetAttribute(uint32_t aIndex, const Matrix &aMatrix) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
   IntRect SourceRectForOutputRect(const IntRect &aRect);
 
 private:
   Matrix mMatrix;
   Filter mFilter;
@@ -242,17 +242,17 @@ class FilterNodeBlendSoftware : public F
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeBlendSoftware, override)
   FilterNodeBlendSoftware();
   virtual const char* GetName() override { return "Blend"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, uint32_t aBlendMode) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
 private:
   BlendMode mBlendMode;
 };
 
@@ -262,17 +262,17 @@ public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeMorphologySoftware, override)
   FilterNodeMorphologySoftware();
   virtual const char* GetName() override { return "Morphology"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, const IntSize &aRadii) override;
   virtual void SetAttribute(uint32_t aIndex, uint32_t aOperator) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
 private:
   IntSize mRadii;
   MorphologyOperator mOperator;
 };
@@ -282,17 +282,17 @@ class FilterNodeColorMatrixSoftware : pu
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeColorMatrixSoftware, override)
   virtual const char* GetName() override { return "ColorMatrix"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, const Matrix5x4 &aMatrix) override;
   virtual void SetAttribute(uint32_t aIndex, uint32_t aAlphaMode) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
 private:
   Matrix5x4 mMatrix;
   AlphaMode mAlphaMode;
 };
@@ -301,34 +301,34 @@ class FilterNodeFloodSoftware : public F
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeFloodSoftware, override)
   virtual const char* GetName() override { return "Flood"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, const Color &aColor) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> GetOutput(const IntRect &aRect) override;
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> GetOutput(const IntRect &aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
 
 private:
   Color mColor;
 };
 
 class FilterNodeTileSoftware : public FilterNodeSoftware
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeTileSoftware, override)
   virtual const char* GetName() override { return "Tile"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, const IntRect &aSourceRect) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
 private:
   IntRect mSourceRect;
 };
 
@@ -340,17 +340,17 @@ class FilterNodeComponentTransferSoftwar
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeComponentTransferSoftware, override)
   FilterNodeComponentTransferSoftware();
 
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, bool aDisable) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
   virtual void GenerateLookupTable(ptrdiff_t aComponent, uint8_t aTables[4][256],
                                    bool aDisabled);
   virtual void FillLookupTable(ptrdiff_t aComponent, uint8_t aTable[256]) = 0;
 
   bool mDisableR;
@@ -465,24 +465,24 @@ public:
   virtual void SetAttribute(uint32_t aIndex, Float aValue) override;
   virtual void SetAttribute(uint32_t aIndex, const Size &aKernelUnitLength) override;
   virtual void SetAttribute(uint32_t aIndex, const IntRect &aSourceRect) override;
   virtual void SetAttribute(uint32_t aIndex, const IntPoint &aTarget) override;
   virtual void SetAttribute(uint32_t aIndex, uint32_t aEdgeMode) override;
   virtual void SetAttribute(uint32_t aIndex, bool aPreserveAlpha) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
 private:
   template<typename CoordType>
-  TemporaryRef<DataSourceSurface> DoRender(const IntRect& aRect,
+  already_AddRefed<DataSourceSurface> DoRender(const IntRect& aRect,
                                            CoordType aKernelUnitLengthX,
                                            CoordType aKernelUnitLengthY);
 
   IntRect InflatedSourceRect(const IntRect &aDestRect);
   IntRect InflatedDestRect(const IntRect &aSourceRect);
 
   IntSize mKernelSize;
   std::vector<Float> mKernelMatrix;
@@ -501,17 +501,17 @@ public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeDisplacementMapSoftware, override)
   FilterNodeDisplacementMapSoftware();
   virtual const char* GetName() override { return "DisplacementMap"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, Float aScale) override;
   virtual void SetAttribute(uint32_t aIndex, uint32_t aValue) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
 private:
   IntRect InflatedSourceOrDestRect(const IntRect &aDestOrSourceRect);
 
   Float mScale;
@@ -527,17 +527,17 @@ public:
   virtual const char* GetName() override { return "Turbulence"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, const Size &aSize) override;
   virtual void SetAttribute(uint32_t aIndex, const IntRect &aRenderRect) override;
   virtual void SetAttribute(uint32_t aIndex, bool aStitchable) override;
   virtual void SetAttribute(uint32_t aIndex, uint32_t aValue) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
 
 private:
   IntRect mRenderRect;
   Size mBaseFrequency;
   uint32_t mNumOctaves;
   uint32_t mSeed;
@@ -550,17 +550,17 @@ class FilterNodeArithmeticCombineSoftwar
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeArithmeticCombineSoftware, override)
   FilterNodeArithmeticCombineSoftware();
   virtual const char* GetName() override { return "ArithmeticCombine"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, const Float* aFloat, uint32_t aSize) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
 private:
   Float mK1;
   Float mK2;
   Float mK3;
@@ -572,33 +572,33 @@ class FilterNodeCompositeSoftware : publ
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeCompositeSoftware, override)
   FilterNodeCompositeSoftware();
   virtual const char* GetName() override { return "Composite"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, uint32_t aOperator) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
 private:
   CompositeOperator mOperator;
 };
 
 // Base class for FilterNodeGaussianBlurSoftware and
 // FilterNodeDirectionalBlurSoftware.
 class FilterNodeBlurXYSoftware : public FilterNodeSoftware
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeBlurXYSoftware, override)
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   IntRect InflatedSourceOrDestRect(const IntRect &aDestRect);
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
   // Implemented by subclasses.
   virtual Size StdDeviationXY() = 0;
 };
@@ -641,44 +641,44 @@ class FilterNodeCropSoftware : public Fi
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeCropSoftware, override)
   virtual const char* GetName() override { return "Crop"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, const Rect &aSourceRect) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
 private:
   IntRect mCropRect;
 };
 
 class FilterNodePremultiplySoftware : public FilterNodeSoftware
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodePremultiplySoftware, override)
   virtual const char* GetName() override { return "Premultiply"; }
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 };
 
 class FilterNodeUnpremultiplySoftware : public FilterNodeSoftware
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeUnpremultiplySoftware, override)
   virtual const char* GetName() override { return "Unpremultiply"; }
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 };
 
 template<typename LightType, typename LightingType>
 class FilterNodeLightingSoftware : public FilterNodeSoftware
 {
@@ -692,24 +692,24 @@ public:
   virtual const char* GetName() override { return "Lighting"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, Float) override;
   virtual void SetAttribute(uint32_t aIndex, const Size &) override;
   virtual void SetAttribute(uint32_t aIndex, const Point3D &) override;
   virtual void SetAttribute(uint32_t aIndex, const Color &) override;
 
 protected:
-  virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) override;
+  virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
   virtual IntRect GetOutputRectInRect(const IntRect& aRect) override;
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) override;
   virtual void RequestFromInputsForRect(const IntRect &aRect) override;
 
 private:
   template<typename CoordType>
-  TemporaryRef<DataSourceSurface> DoRender(const IntRect& aRect,
+  already_AddRefed<DataSourceSurface> DoRender(const IntRect& aRect,
                                            CoordType aKernelUnitLengthX,
                                            CoordType aKernelUnitLengthY);
 
   LightType mLight;
   LightingType mLighting;
   Float mSurfaceScale;
   Size mKernelUnitLength;
   Color mColor;
--- a/gfx/2d/FilterProcessing.cpp
+++ b/gfx/2d/FilterProcessing.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "FilterProcessing.h"
 #include "Logging.h"
 
 namespace mozilla {
 namespace gfx {
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ExtractAlpha(DataSourceSurface* aSource)
 {
   IntSize size = aSource->GetSize();
   RefPtr<DataSourceSurface> alpha = Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
   if (MOZ2D_WARN_IF(!alpha)) {
     return nullptr;
   }
 
@@ -35,28 +35,28 @@ FilterProcessing::ExtractAlpha(DataSourc
 #endif
   } else {
     ExtractAlpha_Scalar(size, sourceData, sourceStride, alphaData, alphaStride);
   }
 
   return alpha.forget();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ConvertToB8G8R8A8(SourceSurface* aSurface)
 {
   if (Factory::HasSSE2()) {
 #ifdef USE_SSE2
     return ConvertToB8G8R8A8_SSE2(aSurface);
 #endif
   }
   return ConvertToB8G8R8A8_Scalar(aSurface);
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ApplyBlending(DataSourceSurface* aInput1, DataSourceSurface* aInput2,
                                 BlendMode aBlendMode)
 {
   if (Factory::HasSSE2()) {
 #ifdef USE_SSE2
     return ApplyBlending_SSE2(aInput1, aInput2, aBlendMode);
 #endif
   }
@@ -92,17 +92,17 @@ FilterProcessing::ApplyMorphologyVertica
       aSourceData, aSourceStride, aDestData, aDestStride, aDestRect, aRadius, aOp);
 #endif
   } else {
     ApplyMorphologyVertical_Scalar(
       aSourceData, aSourceStride, aDestData, aDestStride, aDestRect, aRadius, aOp);
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ApplyColorMatrix(DataSourceSurface* aInput, const Matrix5x4 &aMatrix)
 {
   if (Factory::HasSSE2()) {
 #ifdef USE_SSE2
     return ApplyColorMatrix_SSE2(aInput, aMatrix);
 #endif
   }
   return ApplyColorMatrix_Scalar(aInput, aMatrix);
@@ -159,17 +159,17 @@ FilterProcessing::SeparateColorChannels(
 #ifdef USE_SSE2
     SeparateColorChannels_SSE2(size, sourceData, sourceStride, channel0Data, channel1Data, channel2Data, channel3Data, channelStride);
 #endif
   } else {
     SeparateColorChannels_Scalar(size, sourceData, sourceStride, channel0Data, channel1Data, channel2Data, channel3Data, channelStride);
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::CombineColorChannels(DataSourceSurface* aChannel0, DataSourceSurface* aChannel1,
                                        DataSourceSurface* aChannel2, DataSourceSurface* aChannel3)
 {
   IntSize size = aChannel0->GetSize();
   RefPtr<DataSourceSurface> result =
     Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (MOZ2D_WARN_IF(!result)) {
     return nullptr;
@@ -230,29 +230,29 @@ FilterProcessing::DoUnpremultiplicationC
       aSize, aTargetData, aTargetStride, aSourceData, aSourceStride);
 #endif
   } else {
     DoUnpremultiplicationCalculation_Scalar(
       aSize, aTargetData, aTargetStride, aSourceData, aSourceStride);
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::RenderTurbulence(const IntSize &aSize, const Point &aOffset, const Size &aBaseFrequency,
                                    int32_t aSeed, int aNumOctaves, TurbulenceType aType, bool aStitch, const Rect &aTileRect)
 {
   if (Factory::HasSSE2()) {
 #ifdef USE_SSE2
     return RenderTurbulence_SSE2(aSize, aOffset, aBaseFrequency, aSeed, aNumOctaves, aType, aStitch, aTileRect);
 #endif
   }
   return RenderTurbulence_Scalar(aSize, aOffset, aBaseFrequency, aSeed, aNumOctaves, aType, aStitch, aTileRect);
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ApplyArithmeticCombine(DataSourceSurface* aInput1, DataSourceSurface* aInput2, Float aK1, Float aK2, Float aK3, Float aK4)
 {
   if (Factory::HasSSE2()) {
 #ifdef USE_SSE2
     return ApplyArithmeticCombine_SSE2(aInput1, aInput2, aK1, aK2, aK3, aK4);
 #endif
   }
   return ApplyArithmeticCombine_Scalar(aInput1, aInput2, aK1, aK2, aK3, aK4);
--- a/gfx/2d/FilterProcessing.h
+++ b/gfx/2d/FilterProcessing.h
@@ -26,103 +26,103 @@ public:
   // But it only uses two adds and two shifts instead of an
   // integer division (which is expensive on many processors).
   template<class B, class A>
   static B FastDivideBy255(A v)
   {
     return ((v << 8) + v + 255) >> 16;
   }
 
-  static TemporaryRef<DataSourceSurface> ExtractAlpha(DataSourceSurface* aSource);
-  static TemporaryRef<DataSourceSurface> ConvertToB8G8R8A8(SourceSurface* aSurface);
-  static TemporaryRef<DataSourceSurface> ApplyBlending(DataSourceSurface* aInput1, DataSourceSurface* aInput2, BlendMode aBlendMode);
+  static already_AddRefed<DataSourceSurface> ExtractAlpha(DataSourceSurface* aSource);
+  static already_AddRefed<DataSourceSurface> ConvertToB8G8R8A8(SourceSurface* aSurface);
+  static already_AddRefed<DataSourceSurface> ApplyBlending(DataSourceSurface* aInput1, DataSourceSurface* aInput2, BlendMode aBlendMode);
   static void ApplyMorphologyHorizontal(uint8_t* aSourceData, int32_t aSourceStride,
                                           uint8_t* aDestData, int32_t aDestStride,
                                           const IntRect& aDestRect, int32_t aRadius,
                                           MorphologyOperator aOperator);
   static void ApplyMorphologyVertical(uint8_t* aSourceData, int32_t aSourceStride,
                                           uint8_t* aDestData, int32_t aDestStride,
                                           const IntRect& aDestRect, int32_t aRadius,
                                           MorphologyOperator aOperator);
-  static TemporaryRef<DataSourceSurface> ApplyColorMatrix(DataSourceSurface* aInput, const Matrix5x4 &aMatrix);
+  static already_AddRefed<DataSourceSurface> ApplyColorMatrix(DataSourceSurface* aInput, const Matrix5x4 &aMatrix);
   static void ApplyComposition(DataSourceSurface* aSource, DataSourceSurface* aDest, CompositeOperator aOperator);
   static void SeparateColorChannels(DataSourceSurface* aSource,
                                     RefPtr<DataSourceSurface>& aChannel0,
                                     RefPtr<DataSourceSurface>& aChannel1,
                                     RefPtr<DataSourceSurface>& aChannel2,
                                     RefPtr<DataSourceSurface>& aChannel3);
-  static TemporaryRef<DataSourceSurface>
+  static already_AddRefed<DataSourceSurface>
     CombineColorChannels(DataSourceSurface* aChannel0, DataSourceSurface* aChannel1,
                          DataSourceSurface* aChannel2, DataSourceSurface* aChannel3);
   static void DoPremultiplicationCalculation(const IntSize& aSize,
                                         uint8_t* aTargetData, int32_t aTargetStride,
                                         uint8_t* aSourceData, int32_t aSourceStride);
   static void DoUnpremultiplicationCalculation(const IntSize& aSize,
                                                uint8_t* aTargetData, int32_t aTargetStride,
                                                uint8_t* aSourceData, int32_t aSourceStride);
-  static TemporaryRef<DataSourceSurface>
+  static already_AddRefed<DataSourceSurface>
     RenderTurbulence(const IntSize &aSize, const Point &aOffset, const Size &aBaseFrequency,
                      int32_t aSeed, int aNumOctaves, TurbulenceType aType, bool aStitch, const Rect &aTileRect);
-  static TemporaryRef<DataSourceSurface>
+  static already_AddRefed<DataSourceSurface>
     ApplyArithmeticCombine(DataSourceSurface* aInput1, DataSourceSurface* aInput2, Float aK1, Float aK2, Float aK3, Float aK4);
 
 protected:
   static void ExtractAlpha_Scalar(const IntSize& size, uint8_t* sourceData, int32_t sourceStride, uint8_t* alphaData, int32_t alphaStride);
-  static TemporaryRef<DataSourceSurface> ConvertToB8G8R8A8_Scalar(SourceSurface* aSurface);
+  static already_AddRefed<DataSourceSurface> ConvertToB8G8R8A8_Scalar(SourceSurface* aSurface);
   static void ApplyMorphologyHorizontal_Scalar(uint8_t* aSourceData, int32_t aSourceStride,
                                                uint8_t* aDestData, int32_t aDestStride,
                                                const IntRect& aDestRect, int32_t aRadius,
                                                MorphologyOperator aOperator);
   static void ApplyMorphologyVertical_Scalar(uint8_t* aSourceData, int32_t aSourceStride,
                                                uint8_t* aDestData, int32_t aDestStride,
                                                const IntRect& aDestRect, int32_t aRadius,
                                                MorphologyOperator aOperator);
-  static TemporaryRef<DataSourceSurface> ApplyColorMatrix_Scalar(DataSourceSurface* aInput, const Matrix5x4 &aMatrix);
+  static already_AddRefed<DataSourceSurface> ApplyColorMatrix_Scalar(DataSourceSurface* aInput, const Matrix5x4 &aMatrix);
   static void ApplyComposition_Scalar(DataSourceSurface* aSource, DataSourceSurface* aDest, CompositeOperator aOperator);
 
   static void SeparateColorChannels_Scalar(const IntSize &size, uint8_t* sourceData, int32_t sourceStride, uint8_t* channel0Data, uint8_t* channel1Data, uint8_t* channel2Data, uint8_t* channel3Data, int32_t channelStride);
   static void CombineColorChannels_Scalar(const IntSize &size, int32_t resultStride, uint8_t* resultData, int32_t channelStride, uint8_t* channel0Data, uint8_t* channel1Data, uint8_t* channel2Data, uint8_t* channel3Data);
   static void DoPremultiplicationCalculation_Scalar(const IntSize& aSize,
                                         uint8_t* aTargetData, int32_t aTargetStride,
                                         uint8_t* aSourceData, int32_t aSourceStride);
   static void DoUnpremultiplicationCalculation_Scalar(const IntSize& aSize,
                                                uint8_t* aTargetData, int32_t aTargetStride,
                                                uint8_t* aSourceData, int32_t aSourceStride);
-  static TemporaryRef<DataSourceSurface>
+  static already_AddRefed<DataSourceSurface>
     RenderTurbulence_Scalar(const IntSize &aSize, const Point &aOffset, const Size &aBaseFrequency,
                             int32_t aSeed, int aNumOctaves, TurbulenceType aType, bool aStitch, const Rect &aTileRect);
-  static TemporaryRef<DataSourceSurface>
+  static already_AddRefed<DataSourceSurface>
     ApplyArithmeticCombine_Scalar(DataSourceSurface* aInput1, DataSourceSurface* aInput2, Float aK1, Float aK2, Float aK3, Float aK4);
 
 #ifdef USE_SSE2
   static void ExtractAlpha_SSE2(const IntSize& size, uint8_t* sourceData, int32_t sourceStride, uint8_t* alphaData, int32_t alphaStride);
-  static TemporaryRef<DataSourceSurface> ConvertToB8G8R8A8_SSE2(SourceSurface* aSurface);
-  static TemporaryRef<DataSourceSurface> ApplyBlending_SSE2(DataSourceSurface* aInput1, DataSourceSurface* aInput2, BlendMode aBlendMode);
+  static already_AddRefed<DataSourceSurface> ConvertToB8G8R8A8_SSE2(SourceSurface* aSurface);
+  static already_AddRefed<DataSourceSurface> ApplyBlending_SSE2(DataSourceSurface* aInput1, DataSourceSurface* aInput2, BlendMode aBlendMode);
   static void ApplyMorphologyHorizontal_SSE2(uint8_t* aSourceData, int32_t aSourceStride,
                                              uint8_t* aDestData, int32_t aDestStride,
                                              const IntRect& aDestRect, int32_t aRadius,
                                              MorphologyOperator aOperator);
   static void ApplyMorphologyVertical_SSE2(uint8_t* aSourceData, int32_t aSourceStride,
                                              uint8_t* aDestData, int32_t aDestStride,
                                              const IntRect& aDestRect, int32_t aRadius,
                                              MorphologyOperator aOperator);
-  static TemporaryRef<DataSourceSurface> ApplyColorMatrix_SSE2(DataSourceSurface* aInput, const Matrix5x4 &aMatrix);
+  static already_AddRefed<DataSourceSurface> ApplyColorMatrix_SSE2(DataSourceSurface* aInput, const Matrix5x4 &aMatrix);
   static void ApplyComposition_SSE2(DataSourceSurface* aSource, DataSourceSurface* aDest, CompositeOperator aOperator);
   static void SeparateColorChannels_SSE2(const IntSize &size, uint8_t* sourceData, int32_t sourceStride, uint8_t* channel0Data, uint8_t* channel1Data, uint8_t* channel2Data, uint8_t* channel3Data, int32_t channelStride);
   static void CombineColorChannels_SSE2(const IntSize &size, int32_t resultStride, uint8_t* resultData, int32_t channelStride, uint8_t* channel0Data, uint8_t* channel1Data, uint8_t* channel2Data, uint8_t* channel3Data);
   static void DoPremultiplicationCalculation_SSE2(const IntSize& aSize,
                                         uint8_t* aTargetData, int32_t aTargetStride,
                                         uint8_t* aSourceData, int32_t aSourceStride);
   static void DoUnpremultiplicationCalculation_SSE2(const IntSize& aSize,
                                                uint8_t* aTargetData, int32_t aTargetStride,
                                                uint8_t* aSourceData, int32_t aSourceStride);
-  static TemporaryRef<DataSourceSurface>
+  static already_AddRefed<DataSourceSurface>
     RenderTurbulence_SSE2(const IntSize &aSize, const Point &aOffset, const Size &aBaseFrequency,
                           int32_t aSeed, int aNumOctaves, TurbulenceType aType, bool aStitch, const Rect &aTileRect);
-  static TemporaryRef<DataSourceSurface>
+  static already_AddRefed<DataSourceSurface>
     ApplyArithmeticCombine_SSE2(DataSourceSurface* aInput1, DataSourceSurface* aInput2, Float aK1, Float aK2, Float aK3, Float aK4);
 #endif
 };
 
 // Constant-time max and min functions for unsigned arguments
 static inline unsigned
 umax(unsigned a, unsigned b)
 {
--- a/gfx/2d/FilterProcessingSIMD-inl.h
+++ b/gfx/2d/FilterProcessingSIMD-inl.h
@@ -7,17 +7,17 @@
 
 #include "SIMD.h"
 #include "SVGTurbulenceRenderer-inl.h"
 
 namespace mozilla {
 namespace gfx {
 
 template<typename u8x16_t>
-inline TemporaryRef<DataSourceSurface>
+inline already_AddRefed<DataSourceSurface>
 ConvertToB8G8R8A8_SIMD(SourceSurface* aSurface)
 {
   IntSize size = aSurface->GetSize();
   RefPtr<DataSourceSurface> input = aSurface->GetDataSurface();
   RefPtr<DataSourceSurface> output =
     Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   uint8_t *inputData = input->GetData();
   uint8_t *outputData = output->GetData();
@@ -279,17 +279,17 @@ ShuffleAndPackComponents(i32x4_t bbbb123
   i16x8_t brbrbrbr1234 = simd::InterleaveLo16(bbbbgggg1234, rrrraaaa1234);
   i16x8_t gagagaga1234 = simd::InterleaveHi16(bbbbgggg1234, rrrraaaa1234);
   i16x8_t bgrabgra12 = simd::InterleaveLo16(brbrbrbr1234, gagagaga1234);
   i16x8_t bgrabgra34 = simd::InterleaveHi16(brbrbrbr1234, gagagaga1234);
   return simd::PackAndSaturate16To8(bgrabgra12, bgrabgra34);
 }
 
 template<typename i32x4_t, typename i16x8_t, typename u8x16_t, BlendMode mode>
-inline TemporaryRef<DataSourceSurface>
+inline already_AddRefed<DataSourceSurface>
 ApplyBlending_SIMD(DataSourceSurface* aInput1, DataSourceSurface* aInput2)
 {
   IntSize size = aInput1->GetSize();
   RefPtr<DataSourceSurface> target =
     Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
@@ -333,17 +333,17 @@ ApplyBlending_SIMD(DataSourceSurface* aI
       simd::Store8(&targetData[targetIndex], result1234);
     }
   }
 
   return target.forget();
 }
 
 template<typename i32x4_t, typename i16x8_t, typename u8x16_t>
-static TemporaryRef<DataSourceSurface>
+static already_AddRefed<DataSourceSurface>
 ApplyBlending_SIMD(DataSourceSurface* aInput1, DataSourceSurface* aInput2,
                       BlendMode aBlendMode)
 {
   switch (aBlendMode) {
     case BLEND_MODE_MULTIPLY:
       return ApplyBlending_SIMD<i32x4_t,i16x8_t,u8x16_t, BLEND_MODE_MULTIPLY>(aInput1, aInput2);
     case BLEND_MODE_SCREEN:
       return ApplyBlending_SIMD<i32x4_t,i16x8_t,u8x16_t, BLEND_MODE_SCREEN>(aInput1, aInput2);
@@ -504,17 +504,17 @@ ColorMatrixMultiply(i16x8_t p, i16x8_t r
   i32x4_t prodsum_ra = simd::MulAdd16x8x2To32x4(ra, rows_ra);
   sum = simd::Add32(sum, prodsum_ra);
 
   // int32_t sum[4] == { b * bB + g * gB + r * rB + a * aB + _B, ... }.
   return sum;
 }
 
 template<typename i32x4_t, typename i16x8_t, typename u8x16_t>
-static TemporaryRef<DataSourceSurface>
+static already_AddRefed<DataSourceSurface>
 ApplyColorMatrix_SIMD(DataSourceSurface* aInput, const Matrix5x4 &aMatrix)
 {
   IntSize size = aInput->GetSize();
   RefPtr<DataSourceSurface> target =
     Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
@@ -948,17 +948,17 @@ DoUnpremultiplicationCalculation_SIMD(co
 
       u8x16_t result = simd::PackAndSaturate16To8(p12, p34);
       simd::Store8(&aTargetData[targetIndex], result);
     }
   }
 }
 
 template<typename f32x4_t, typename i32x4_t, typename u8x16_t>
-static TemporaryRef<DataSourceSurface>
+static already_AddRefed<DataSourceSurface>
 RenderTurbulence_SIMD(const IntSize &aSize, const Point &aOffset, const Size &aBaseFrequency,
                       int32_t aSeed, int aNumOctaves, TurbulenceType aType, bool aStitch, const Rect &aTileRect)
 {
 #define RETURN_TURBULENCE(Type, Stitch) \
   SVGTurbulenceRenderer<Type,Stitch,f32x4_t,i32x4_t,u8x16_t> \
     renderer(aBaseFrequency, aSeed, aNumOctaves, aTileRect); \
   return renderer.Render(aSize, aOffset);
 
@@ -1008,17 +1008,17 @@ ArithmeticCombineTwoPixels(i16x8_t in1, 
 
   // Sum everything up and truncate the fractional part.
   i32x4_t result_1 = simd::ShiftRight32<7>(simd::Add32(inProdTimesK1PlusK4_1, inTimesK2K3_1));
   i32x4_t result_2 = simd::ShiftRight32<7>(simd::Add32(inProdTimesK1PlusK4_2, inTimesK2K3_2));
   return simd::PackAndSaturate32To16(result_1, result_2);
 }
 
 template<typename i32x4_t, typename i16x8_t, typename u8x16_t>
-static TemporaryRef<DataSourceSurface>
+static already_AddRefed<DataSourceSurface>
 ApplyArithmeticCombine_SIMD(DataSourceSurface* aInput1, DataSourceSurface* aInput2,
                             Float aK1, Float aK2, Float aK3, Float aK4)
 {
   IntSize size = aInput1->GetSize();
   RefPtr<DataSourceSurface> target =
   Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
--- a/gfx/2d/FilterProcessingSSE2.cpp
+++ b/gfx/2d/FilterProcessingSSE2.cpp
@@ -15,23 +15,23 @@ namespace mozilla {
 namespace gfx {
 
 void
 FilterProcessing::ExtractAlpha_SSE2(const IntSize& size, uint8_t* sourceData, int32_t sourceStride, uint8_t* alphaData, int32_t alphaStride)
 {
   ExtractAlpha_SIMD<__m128i>(size, sourceData, sourceStride, alphaData, alphaStride);
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ConvertToB8G8R8A8_SSE2(SourceSurface* aSurface)
 {
   return ConvertToB8G8R8A8_SIMD<__m128i>(aSurface);
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ApplyBlending_SSE2(DataSourceSurface* aInput1, DataSourceSurface* aInput2,
                                      BlendMode aBlendMode)
 {
   return ApplyBlending_SIMD<__m128i,__m128i,__m128i>(aInput1, aInput2, aBlendMode);
 }
 
 void
 FilterProcessing::ApplyMorphologyHorizontal_SSE2(uint8_t* aSourceData, int32_t aSourceStride,
@@ -48,17 +48,17 @@ FilterProcessing::ApplyMorphologyVertica
                                                  uint8_t* aDestData, int32_t aDestStride,
                                                  const IntRect& aDestRect, int32_t aRadius,
                                                  MorphologyOperator aOp)
 {
   ApplyMorphologyVertical_SIMD<__m128i,__m128i>(
     aSourceData, aSourceStride, aDestData, aDestStride, aDestRect, aRadius, aOp);
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ApplyColorMatrix_SSE2(DataSourceSurface* aInput, const Matrix5x4 &aMatrix)
 {
   return ApplyColorMatrix_SIMD<__m128i,__m128i,__m128i>(aInput, aMatrix);
 }
 
 void
 FilterProcessing::ApplyComposition_SSE2(DataSourceSurface* aSource, DataSourceSurface* aDest,
                                         CompositeOperator aOperator)
@@ -90,23 +90,23 @@ void
 FilterProcessing::DoUnpremultiplicationCalculation_SSE2(
                                  const IntSize& aSize,
                                  uint8_t* aTargetData, int32_t aTargetStride,
                                  uint8_t* aSourceData, int32_t aSourceStride)
 {
   DoUnpremultiplicationCalculation_SIMD<__m128i,__m128i>(aSize, aTargetData, aTargetStride, aSourceData, aSourceStride);
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::RenderTurbulence_SSE2(const IntSize &aSize, const Point &aOffset, const Size &aBaseFrequency,
                                         int32_t aSeed, int aNumOctaves, TurbulenceType aType, bool aStitch, const Rect &aTileRect)
 {
   return RenderTurbulence_SIMD<__m128,__m128i,__m128i>(aSize, aOffset, aBaseFrequency, aSeed, aNumOctaves, aType, aStitch, aTileRect);
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ApplyArithmeticCombine_SSE2(DataSourceSurface* aInput1, DataSourceSurface* aInput2, Float aK1, Float aK2, Float aK3, Float aK4)
 {
   return ApplyArithmeticCombine_SIMD<__m128i,__m128i,__m128i>(aInput1, aInput2, aK1, aK2, aK3, aK4);
 }
 
 } // namespace mozilla
 } // namespace gfx
--- a/gfx/2d/FilterProcessingScalar.cpp
+++ b/gfx/2d/FilterProcessingScalar.cpp
@@ -18,17 +18,17 @@ FilterProcessing::ExtractAlpha_Scalar(co
     for (int32_t x = 0; x < size.width; x++) {
       int32_t sourceIndex = y * sourceStride + 4 * x;
       int32_t targetIndex = y * alphaStride + x;
       alphaData[targetIndex] = sourceData[sourceIndex + B8G8R8A8_COMPONENT_BYTEOFFSET_A];
     }
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ConvertToB8G8R8A8_Scalar(SourceSurface* aSurface)
 {
   return ConvertToB8G8R8A8_SIMD<simd::Scalaru8x16_t>(aSurface);
 }
 
 template<MorphologyOperator Operator>
 static void
 ApplyMorphologyHorizontal_Scalar(uint8_t* aSourceData, int32_t aSourceStride,
@@ -129,17 +129,17 @@ FilterProcessing::ApplyMorphologyVertica
     gfx::ApplyMorphologyVertical_Scalar<MORPHOLOGY_OPERATOR_ERODE>(
       aSourceData, aSourceStride, aDestData, aDestStride, aDestRect, aRadius);
   } else {
     gfx::ApplyMorphologyVertical_Scalar<MORPHOLOGY_OPERATOR_DILATE>(
       aSourceData, aSourceStride, aDestData, aDestStride, aDestRect, aRadius);
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ApplyColorMatrix_Scalar(DataSourceSurface* aInput, const Matrix5x4 &aMatrix)
 {
   return ApplyColorMatrix_SIMD<simd::Scalari32x4_t,simd::Scalari16x8_t,simd::Scalaru8x16_t>(aInput, aMatrix);
 }
 
 void
 FilterProcessing::ApplyComposition_Scalar(DataSourceSurface* aSource, DataSourceSurface* aDest,
                                           CompositeOperator aOperator)
@@ -221,24 +221,24 @@ FilterProcessing::DoUnpremultiplicationC
         (aSourceData[inputIndex + B8G8R8A8_COMPONENT_BYTEOFFSET_G] * alphaFactor + 128) >> 8;
       aTargetData[targetIndex + B8G8R8A8_COMPONENT_BYTEOFFSET_B] =
         (aSourceData[inputIndex + B8G8R8A8_COMPONENT_BYTEOFFSET_B] * alphaFactor + 128) >> 8;
       aTargetData[targetIndex + B8G8R8A8_COMPONENT_BYTEOFFSET_A] = alpha;
     }
   }
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::RenderTurbulence_Scalar(const IntSize &aSize, const Point &aOffset, const Size &aBaseFrequency,
                                           int32_t aSeed, int aNumOctaves, TurbulenceType aType, bool aStitch, const Rect &aTileRect)
 {
    return RenderTurbulence_SIMD<simd::Scalarf32x4_t,simd::Scalari32x4_t,simd::Scalaru8x16_t>(
      aSize, aOffset, aBaseFrequency, aSeed, aNumOctaves, aType, aStitch, aTileRect);
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 FilterProcessing::ApplyArithmeticCombine_Scalar(DataSourceSurface* aInput1, DataSourceSurface* aInput2, Float aK1, Float aK2, Float aK3, Float aK4)
 {
   return ApplyArithmeticCombine_SIMD<simd::Scalari32x4_t,simd::Scalari16x8_t,simd::Scalaru8x16_t>(aInput1, aInput2, aK1, aK2, aK3, aK4);
 }
 
 } // namespace mozilla
 } // namespace gfx
--- a/gfx/2d/HelpersD2D.h
+++ b/gfx/2d/HelpersD2D.h
@@ -417,51 +417,51 @@ DWriteGlyphRunFromGlyphs(const GlyphBuff
     
   run->bidiLevel = 0;
   run->fontFace = aFont->mFontFace;
   run->fontEmSize = aFont->GetSize();
   run->glyphCount = aGlyphs.mNumGlyphs;
   run->isSideways = FALSE;
 }
 
-static inline TemporaryRef<ID2D1Geometry>
+static inline already_AddRefed<ID2D1Geometry>
 ConvertRectToGeometry(const D2D1_RECT_F& aRect)
 {
   RefPtr<ID2D1RectangleGeometry> rectGeom;
   D2DFactory()->CreateRectangleGeometry(&aRect, byRef(rectGeom));
   return rectGeom.forget();
 }
 
-static inline TemporaryRef<ID2D1Geometry>
+static inline already_AddRefed<ID2D1Geometry>
 GetTransformedGeometry(ID2D1Geometry *aGeometry, const D2D1_MATRIX_3X2_F &aTransform)
 {
   RefPtr<ID2D1PathGeometry> tmpGeometry;
   D2DFactory()->CreatePathGeometry(byRef(tmpGeometry));
   RefPtr<ID2D1GeometrySink> currentSink;
   tmpGeometry->Open(byRef(currentSink));
   aGeometry->Simplify(D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES,
                       aTransform, currentSink);
   currentSink->Close();
   return tmpGeometry.forget();
 }
 
-static inline TemporaryRef<ID2D1Geometry>
+static inline already_AddRefed<ID2D1Geometry>
 IntersectGeometry(ID2D1Geometry *aGeometryA, ID2D1Geometry *aGeometryB)
 {
   RefPtr<ID2D1PathGeometry> pathGeom;
   D2DFactory()->CreatePathGeometry(byRef(pathGeom));
   RefPtr<ID2D1GeometrySink> sink;
   pathGeom->Open(byRef(sink));
   aGeometryA->CombineWithGeometry(aGeometryB, D2D1_COMBINE_MODE_INTERSECT, nullptr, sink);
   sink->Close();
 
   return pathGeom.forget();
 }
 
-static inline TemporaryRef<ID2D1StrokeStyle>
+static inline already_AddRefed<ID2D1StrokeStyle>
 CreateStrokeStyleForOptions(const StrokeOptions &aStrokeOptions)
 {
   RefPtr<ID2D1StrokeStyle> style;
 
   D2D1_CAP_STYLE capStyle;
   D2D1_LINE_JOIN joinStyle;
 
   switch (aStrokeOptions.mLineCap) {
@@ -531,17 +531,17 @@ CreateStrokeStyleForOptions(const Stroke
   }
 
   return style.forget();
 }
 
 // This creates a (partially) uploaded bitmap for a DataSourceSurface. It
 // uploads the minimum requirement and possibly downscales. It adjusts the
 // input Matrix to compensate.
-static inline TemporaryRef<ID2D1Bitmap>
+static inline already_AddRefed<ID2D1Bitmap>
 CreatePartialBitmapForSurface(DataSourceSurface *aSurface, const Matrix &aDestinationTransform,
                               const IntSize &aDestinationSize, ExtendMode aExtendMode,
                               Matrix &aSourceTransform, ID2D1RenderTarget *aRT,
                               const IntRect* aSourceRect = nullptr)
 {
   RefPtr<ID2D1Bitmap> bitmap;
 
   // This is where things get complicated. The source surface was
--- a/gfx/2d/MacIOSurface.cpp
+++ b/gfx/2d/MacIOSurface.cpp
@@ -280,17 +280,17 @@ MacIOSurface::MacIOSurface(const void* a
   IncrementUseCount();
 }
 
 MacIOSurface::~MacIOSurface() {
   DecrementUseCount();
   CFRelease(mIOSurfacePtr);
 }
 
-TemporaryRef<MacIOSurface> MacIOSurface::CreateIOSurface(int aWidth, int aHeight,
+already_AddRefed<MacIOSurface> MacIOSurface::CreateIOSurface(int aWidth, int aHeight,
                                                          double aContentsScaleFactor,
                                                          bool aHasAlpha) {
   if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
     return nullptr;
 
   CFMutableDictionaryRef props = ::CFDictionaryCreateMutable(
                       kCFAllocatorDefault, 4,
                       &kCFTypeDictionaryKeyCallBacks,
@@ -333,17 +333,17 @@ TemporaryRef<MacIOSurface> MacIOSurface:
   }
 
   // Release the IOSurface because MacIOSurface retained it
   CFRelease(surfaceRef);
 
   return ioSurface.forget();
 }
 
-TemporaryRef<MacIOSurface> MacIOSurface::LookupSurface(IOSurfaceID aIOSurfaceID,
+already_AddRefed<MacIOSurface> MacIOSurface::LookupSurface(IOSurfaceID aIOSurfaceID,
                                                        double aContentsScaleFactor,
                                                        bool aHasAlpha) { 
   if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
     return nullptr;
 
   IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceLookup(aIOSurfaceID);
   if (!surfaceRef)
     return nullptr;
@@ -430,17 +430,17 @@ void MacIOSurface::Unlock() {
 }
 
 #include "SourceSurfaceRawData.h"
 using mozilla::gfx::SourceSurface;
 using mozilla::gfx::SourceSurfaceRawData;
 using mozilla::gfx::IntSize;
 using mozilla::gfx::SurfaceFormat;
 
-TemporaryRef<SourceSurface>
+already_AddRefed<SourceSurface>
 MacIOSurface::GetAsSurface() {
   Lock();
   size_t bytesPerRow = GetBytesPerRow();
   size_t ioWidth = GetDevicePixelWidth();
   size_t ioHeight = GetDevicePixelHeight();
 
   unsigned char* ioData = (unsigned char*)GetBaseAddress();
   unsigned char* dataCpy = (unsigned char*)malloc(bytesPerRow*ioHeight);
@@ -494,17 +494,17 @@ CGContextRef MacIOSurface::CreateIOSurfa
 
 CGImageRef MacIOSurface::CreateImageFromIOSurfaceContext(CGContextRef aContext) {
   if (!MacIOSurfaceLib::isInit())
     return nullptr;
 
   return MacIOSurfaceLib::IOSurfaceContextCreateImage(aContext);
 }
 
-TemporaryRef<MacIOSurface> MacIOSurface::IOSurfaceContextGetSurface(CGContextRef aContext,
+already_AddRefed<MacIOSurface> MacIOSurface::IOSurfaceContextGetSurface(CGContextRef aContext,
                                                                     double aContentsScaleFactor,
                                                                     bool aHasAlpha) {
   if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
     return nullptr;
 
   IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceContextGetSurface(aContext);
   if (!surfaceRef)
     return nullptr;
--- a/gfx/2d/MacIOSurface.h
+++ b/gfx/2d/MacIOSurface.h
@@ -64,21 +64,21 @@ class MacIOSurface : public mozilla::Ref
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(MacIOSurface)
   typedef mozilla::gfx::SourceSurface SourceSurface;
 
   // The usage count of the IOSurface is increased by 1 during the lifetime
   // of the MacIOSurface instance.
   // MacIOSurface holds a reference to the corresponding IOSurface.
 
-  static mozilla::TemporaryRef<MacIOSurface> CreateIOSurface(int aWidth, int aHeight,
+  static already_AddRefed<MacIOSurface> CreateIOSurface(int aWidth, int aHeight,
                                                              double aContentsScaleFactor = 1.0,
                                                              bool aHasAlpha = true);
   static void ReleaseIOSurface(MacIOSurface *aIOSurface);
-  static mozilla::TemporaryRef<MacIOSurface> LookupSurface(IOSurfaceID aSurfaceID,
+  static already_AddRefed<MacIOSurface> LookupSurface(IOSurfaceID aSurfaceID,
                                                            double aContentsScaleFactor = 1.0,
                                                            bool aHasAlpha = true);
 
   explicit MacIOSurface(const void *aIOSurfacePtr,
                         double aContentsScaleFactor = 1.0,
                         bool aHasAlpha = true);
   virtual ~MacIOSurface();
   IOSurfaceID GetIOSurfaceID();
@@ -98,22 +98,22 @@ public:
   void Lock();
   void Unlock();
   void IncrementUseCount();
   void DecrementUseCount();
   bool HasAlpha() { return mHasAlpha; }
   // We would like to forward declare NSOpenGLContext, but it is an @interface
   // and this file is also used from c++, so we use a void *.
   CGLError CGLTexImageIOSurface2D(CGLContextObj ctxt);
-  mozilla::TemporaryRef<SourceSurface> GetAsSurface();
+  already_AddRefed<SourceSurface> GetAsSurface();
   CGContextRef CreateIOSurfaceContext();
 
   // FIXME This doesn't really belong here
   static CGImageRef CreateImageFromIOSurfaceContext(CGContextRef aContext);
-  static mozilla::TemporaryRef<MacIOSurface> IOSurfaceContextGetSurface(CGContextRef aContext,
+  static already_AddRefed<MacIOSurface> IOSurfaceContextGetSurface(CGContextRef aContext,
                                                                         double aContentsScaleFactor = 1.0,
                                                                         bool aHasAlpha = true);
   static size_t GetMaxWidth();
   static size_t GetMaxHeight();
 
 private:
   friend class nsCARenderer;
   const void* mIOSurfacePtr;
--- a/gfx/2d/PathCG.cpp
+++ b/gfx/2d/PathCG.cpp
@@ -122,32 +122,32 @@ PathBuilderCG::CurrentPoint() const
   return ret;
 }
 
 void
 PathBuilderCG::EnsureActive(const Point &aPoint)
 {
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 PathBuilderCG::Finish()
 {
   return MakeAndAddRef<PathCG>(mCGPath, mFillRule);
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 PathCG::CopyToBuilder(FillRule aFillRule) const
 {
   CGMutablePathRef path = CGPathCreateMutableCopy(mPath);
   return MakeAndAddRef<PathBuilderCG>(path, aFillRule);
 }
 
 
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 PathCG::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) const
 {
   // 10.7 adds CGPathCreateMutableCopyByTransformingPath it might be faster than doing
   // this by hand
 
   struct TransformApplier {
     CGMutablePathRef path;
     CGAffineTransform transform;
--- a/gfx/2d/PathCG.h
+++ b/gfx/2d/PathCG.h
@@ -40,17 +40,17 @@ public:
                         const Point &aCP3);
   virtual void QuadraticBezierTo(const Point &aCP1,
                                  const Point &aCP2);
   virtual void Close();
   virtual void Arc(const Point &aOrigin, Float aRadius, Float aStartAngle,
                    Float aEndAngle, bool aAntiClockwise = false);
   virtual Point CurrentPoint() const;
 
-  virtual TemporaryRef<Path> Finish();
+  virtual already_AddRefed<Path> Finish();
 
   virtual BackendType GetBackendType() const { return BackendType::COREGRAPHICS; }
 
 private:
   friend class PathCG;
   friend class ScaledFontMac;
 
   void EnsureActive(const Point &aPoint);
@@ -72,18 +72,18 @@ public:
     CGPathRetain(mPath);
   }
   virtual ~PathCG() { CGPathRelease(mPath); }
 
   // Paths will always return BackendType::COREGRAPHICS, but note that they
   // are compatible with BackendType::COREGRAPHICS_ACCELERATED backend.
   virtual BackendType GetBackendType() const { return BackendType::COREGRAPHICS; }
 
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
-  virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
+  virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
+  virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
   virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
--- a/gfx/2d/PathCairo.cpp
+++ b/gfx/2d/PathCairo.cpp
@@ -117,17 +117,17 @@ PathBuilderCairo::Arc(const Point &aOrig
 }
 
 Point
 PathBuilderCairo::CurrentPoint() const
 {
   return mCurrentPoint;
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 PathBuilderCairo::Finish()
 {
   return MakeAndAddRef<PathCairo>(mFillRule, mPathData, mCurrentPoint);
 }
 
 PathCairo::PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t> &aPathData, const Point &aCurrentPoint)
   : mFillRule(aFillRule)
   , mContainingContext(nullptr)
@@ -154,28 +154,28 @@ PathCairo::PathCairo(cairo_t *aContext)
 
 PathCairo::~PathCairo()
 {
   if (mContainingContext) {
     cairo_destroy(mContainingContext);
   }
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 PathCairo::CopyToBuilder(FillRule aFillRule) const
 {
   RefPtr<PathBuilderCairo> builder = new PathBuilderCairo(aFillRule);
 
   builder->mPathData = mPathData;
   builder->mCurrentPoint = mCurrentPoint;
 
   return builder.forget();
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 PathCairo::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) const
 {
   RefPtr<PathBuilderCairo> builder = new PathBuilderCairo(aFillRule);
 
   AppendPathToBuilder(builder, &aTransform);
   builder->mCurrentPoint = aTransform * mCurrentPoint;
 
   return builder.forget();
--- a/gfx/2d/PathCairo.h
+++ b/gfx/2d/PathCairo.h
@@ -27,17 +27,17 @@ public:
                         const Point &aCP2,
                         const Point &aCP3);
   virtual void QuadraticBezierTo(const Point &aCP1,
                                  const Point &aCP2);
   virtual void Close();
   virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle,
                    float aEndAngle, bool aAntiClockwise = false);
   virtual Point CurrentPoint() const;
-  virtual TemporaryRef<Path> Finish();
+  virtual already_AddRefed<Path> Finish();
 
   virtual BackendType GetBackendType() const { return BackendType::CAIRO; }
 
 private: // data
   friend class PathCairo;
 
   FillRule mFillRule;
   std::vector<cairo_path_data_t> mPathData;
@@ -52,18 +52,18 @@ class PathCairo : public Path
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathCairo)
   PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t> &aPathData, const Point &aCurrentPoint);
   explicit PathCairo(cairo_t *aContext);
   ~PathCairo();
 
   virtual BackendType GetBackendType() const { return BackendType::CAIRO; }
 
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
-  virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
+  virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
+  virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
 
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
 
--- a/gfx/2d/PathD2D.cpp
+++ b/gfx/2d/PathD2D.cpp
@@ -285,39 +285,39 @@ PathBuilderD2D::EnsureActive(const Point
 {
   if (!mFigureActive) {
     mSink->BeginFigure(D2DPoint(aPoint), D2D1_FIGURE_BEGIN_FILLED);
     mBeginPoint = aPoint;
     mFigureActive = true;
   }
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 PathBuilderD2D::Finish()
 {
   if (mFigureActive) {
     mSink->EndFigure(D2D1_FIGURE_END_OPEN);
   }
 
   HRESULT hr = mSink->Close();
   if (FAILED(hr)) {
     gfxDebug() << "Failed to close PathSink. Code: " << hexa(hr);
     return nullptr;
   }
 
   return MakeAndAddRef<PathD2D>(mGeometry, mFigureActive, mCurrentPoint, mFillRule, mBackendType);
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 PathD2D::CopyToBuilder(FillRule aFillRule) const
 {
   return TransformedCopyToBuilder(Matrix(), aFillRule);
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 PathD2D::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) const
 {
   RefPtr<ID2D1PathGeometry> path;
   HRESULT hr = DrawTargetD2D::factory()->CreatePathGeometry(byRef(path));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create PathGeometry. Code: " << hexa(hr);
     return nullptr;
--- a/gfx/2d/PathD2D.h
+++ b/gfx/2d/PathD2D.h
@@ -36,17 +36,17 @@ public:
                         const Point &aCP3);
   virtual void QuadraticBezierTo(const Point &aCP1,
                                  const Point &aCP2);
   virtual void Close();
   virtual void Arc(const Point &aOrigin, Float aRadius, Float aStartAngle,
                    Float aEndAngle, bool aAntiClockwise = false);
   virtual Point CurrentPoint() const;
 
-  virtual TemporaryRef<Path> Finish();
+  virtual already_AddRefed<Path> Finish();
 
   virtual BackendType GetBackendType() const { return mBackendType; }
 
   ID2D1GeometrySink *GetSink() { return mSink; }
 
 private:
   friend class PathD2D;
 
@@ -72,18 +72,18 @@ public:
     , mEndedActive(aEndedActive)
     , mEndPoint(aEndPoint)
     , mFillRule(aFillRule)
     , mBackendType(aBackendType)
   {}
   
   virtual BackendType GetBackendType() const { return mBackendType; }
 
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
-  virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
+  virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
+  virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
 
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
 
--- a/gfx/2d/PathHelpers.h
+++ b/gfx/2d/PathHelpers.h
@@ -138,17 +138,17 @@ void EllipseToBezier(T* aSink, const Poi
  *                 left edge and draw clockwise. If set to false the path will
  *                 start at the right of the top left edge and draw counter-
  *                 clockwise.
  */
 GFX2D_API void AppendRectToPath(PathBuilder* aPathBuilder,
                                 const Rect& aRect,
                                 bool aDrawClockwise = true);
 
-inline TemporaryRef<Path> MakePathForRect(const DrawTarget& aDrawTarget,
+inline already_AddRefed<Path> MakePathForRect(const DrawTarget& aDrawTarget,
                                           const Rect& aRect,
                                           bool aDrawClockwise = true)
 {
   RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder();
   AppendRectToPath(builder, aRect, aDrawClockwise);
   return builder->Finish();
 }
 
@@ -230,17 +230,17 @@ struct RectCornerRadii {
  *                 start at the right of the top left edge and draw counter-
  *                 clockwise.
  */
 GFX2D_API void AppendRoundedRectToPath(PathBuilder* aPathBuilder,
                                        const Rect& aRect,
                                        const RectCornerRadii& aRadii,
                                        bool aDrawClockwise = true);
 
-inline TemporaryRef<Path> MakePathForRoundedRect(const DrawTarget& aDrawTarget,
+inline already_AddRefed<Path> MakePathForRoundedRect(const DrawTarget& aDrawTarget,
                                                  const Rect& aRect,
                                                  const RectCornerRadii& aRadii,
                                                  bool aDrawClockwise = true)
 {
   RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder();
   AppendRoundedRectToPath(builder, aRect, aRadii, aDrawClockwise);
   return builder->Finish();
 }
@@ -251,17 +251,17 @@ inline TemporaryRef<Path> MakePathForRou
  *
  * The ellipse extends aDimensions.width / 2.0 in the horizontal direction
  * from aCenter, and aDimensions.height / 2.0 in the vertical direction.
  */
 GFX2D_API void AppendEllipseToPath(PathBuilder* aPathBuilder,
                                    const Point& aCenter,
                                    const Size& aDimensions);
 
-inline TemporaryRef<Path> MakePathForEllipse(const DrawTarget& aDrawTarget,
+inline already_AddRefed<Path> MakePathForEllipse(const DrawTarget& aDrawTarget,
                                              const Point& aCenter,
                                              const Size& aDimensions)
 {
   RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder();
   AppendEllipseToPath(builder, aCenter, aDimensions);
   return builder->Finish();
 }
 
--- a/gfx/2d/PathRecording.cpp
+++ b/gfx/2d/PathRecording.cpp
@@ -64,41 +64,41 @@ PathBuilderRecording::Close()
 }
 
 Point
 PathBuilderRecording::CurrentPoint() const
 {
   return mPathBuilder->CurrentPoint();
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 PathBuilderRecording::Finish()
 {
   RefPtr<Path> path = mPathBuilder->Finish();
   return MakeAndAddRef<PathRecording>(path, mPathOps, mFillRule);
 }
 
 PathRecording::~PathRecording()
 {
   for (size_t i = 0; i < mStoredRecorders.size(); i++) {
     mStoredRecorders[i]->RemoveStoredPath(this);
     mStoredRecorders[i]->RecordEvent(RecordedPathDestruction(this));
   }
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 PathRecording::CopyToBuilder(FillRule aFillRule) const
 {
   RefPtr<PathBuilder> pathBuilder = mPath->CopyToBuilder(aFillRule);
   RefPtr<PathBuilderRecording> recording = new PathBuilderRecording(pathBuilder, aFillRule);
   recording->mPathOps = mPathOps;
   return recording.forget();
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 PathRecording::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) const
 {
   RefPtr<PathBuilder> pathBuilder = mPath->TransformedCopyToBuilder(aTransform, aFillRule);
   RefPtr<PathBuilderRecording> recording = new PathBuilderRecording(pathBuilder, aFillRule);
   typedef std::vector<PathOp> pathOpVec;
   for (pathOpVec::const_iterator iter = mPathOps.begin(); iter != mPathOps.end(); iter++) {
     PathOp newPathOp;
     newPathOp.mType = iter->mType;
--- a/gfx/2d/PathRecording.h
+++ b/gfx/2d/PathRecording.h
@@ -65,17 +65,17 @@ public:
   /* Add an arc to the current figure */
   virtual void Arc(const Point &, float, float, float, bool) { }
 
   /* Point the current subpath is at - or where the next subpath will start
    * if there is no active subpath.
    */
   virtual Point CurrentPoint() const;
 
-  virtual TemporaryRef<Path> Finish();
+  virtual already_AddRefed<Path> Finish();
 
   virtual BackendType GetBackendType() const { return BackendType::RECORDING; }
 
 private:
   friend class PathRecording;
 
   RefPtr<PathBuilder> mPathBuilder;
   FillRule mFillRule;
@@ -89,18 +89,18 @@ public:
   PathRecording(Path *aPath, const std::vector<PathOp> aOps, FillRule aFillRule)
     : mPath(aPath), mPathOps(aOps), mFillRule(aFillRule)
   {
   }
 
   ~PathRecording();
 
   virtual BackendType GetBackendType() const { return BackendType::RECORDING; }
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
-  virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
+  virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
+  virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FillRule::FILL_WINDING) const;
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const
   { return mPath->ContainsPoint(aPoint, aTransform); }
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const
   { return mPath->StrokeContainsPoint(aStrokeOptions, aPoint, aTransform); }
   
--- a/gfx/2d/PathSkia.cpp
+++ b/gfx/2d/PathSkia.cpp
@@ -97,35 +97,35 @@ PathBuilderSkia::CurrentPoint() const
   int pointCount = mPath.countPoints();
   if (!pointCount) {
     return Point(0, 0);
   }
   SkPoint point = mPath.getPoint(pointCount - 1);
   return Point(SkScalarToFloat(point.fX), SkScalarToFloat(point.fY));
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 PathBuilderSkia::Finish()
 {
   return MakeAndAddRef<PathSkia>(mPath, mFillRule);
 }
 
 void
 PathBuilderSkia::AppendPath(const SkPath &aPath)
 {
   mPath.addPath(aPath);
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 PathSkia::CopyToBuilder(FillRule aFillRule) const
 {
   return TransformedCopyToBuilder(Matrix(), aFillRule);
 }
 
-TemporaryRef<PathBuilder>
+already_AddRefed<PathBuilder>
 PathSkia::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) const
 {
   return MakeAndAddRef<PathBuilderSkia>(aTransform, mPath, aFillRule);
 }
 
 bool
 PathSkia::ContainsPoint(const Point &aPoint, const Matrix &aTransform) const
 {
--- a/gfx/2d/PathSkia.h
+++ b/gfx/2d/PathSkia.h
@@ -27,17 +27,17 @@ public:
                         const Point &aCP2,
                         const Point &aCP3);
   virtual void QuadraticBezierTo(const Point &aCP1,
                                  const Point &aCP2);
   virtual void Close();
   virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle,
                    float aEndAngle, bool aAntiClockwise = false);
   virtual Point CurrentPoint() const;
-  virtual TemporaryRef<Path> Finish();
+  virtual already_AddRefed<Path> Finish();
 
   void AppendPath(const SkPath &aPath);
 
   virtual BackendType GetBackendType() const { return BackendType::SKIA; }
 
 private:
 
   void SetFillRule(FillRule aFillRule);
@@ -53,18 +53,18 @@ public:
   PathSkia(SkPath& aPath, FillRule aFillRule)
     : mFillRule(aFillRule)
   {
     mPath.swap(aPath);
   }
   
   virtual BackendType GetBackendType() const { return BackendType::SKIA; }
 
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
-  virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
+  virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
+  virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
   
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
 
--- a/gfx/2d/QuartzSupport.mm
+++ b/gfx/2d/QuartzSupport.mm
@@ -21,17 +21,16 @@
   "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/CoreGraphics"
 
 @interface CALayer (ContentsScale)
 - (double)contentsScale;
 - (void)setContentsScale:(double)scale;
 @end
 
 using mozilla::RefPtr;
-using mozilla::TemporaryRef;
 
 CGColorSpaceRef CreateSystemColorSpace() {
   CGColorSpaceRef cspace = ::CGDisplayCopyColorSpace(::CGMainDisplayID());
   if (!cspace) {
     cspace = ::CGColorSpaceCreateDeviceRGB();
   }
   return cspace;
 }
--- a/gfx/2d/RadialGradientEffectD2D1.cpp
+++ b/gfx/2d/RadialGradientEffectD2D1.cpp
@@ -304,17 +304,17 @@ RadialGradientEffectD2D1::SetStopCollect
 {
   if (SUCCEEDED(aStopCollection->QueryInterface((ID2D1GradientStopCollection**)byRef(mStopCollection)))) {
     return S_OK;
   }
 
   return E_INVALIDARG;
 }
 
-TemporaryRef<ID2D1ResourceTexture>
+already_AddRefed<ID2D1ResourceTexture>
 RadialGradientEffectD2D1::CreateGradientTexture()
 {
   std::vector<D2D1_GRADIENT_STOP> rawStops;
   rawStops.resize(mStopCollection->GetGradientStopCount());
   mStopCollection->GetGradientStops(&rawStops.front(), rawStops.size());
 
   std::vector<unsigned char> textureData;
   textureData.resize(4096 * 4);
--- a/gfx/2d/RadialGradientEffectD2D1.h
+++ b/gfx/2d/RadialGradientEffectD2D1.h
@@ -74,17 +74,17 @@ public:
   static HRESULT Register(ID2D1Factory1* aFactory);
   static void Unregister(ID2D1Factory1* aFactory);
   static HRESULT __stdcall CreateEffect(IUnknown** aEffectImpl);
 
   HRESULT SetStopCollection(IUnknown *aStopCollection);
   IUnknown *GetStopCollection() const { return mStopCollection; }
 
 private:
-  TemporaryRef<ID2D1ResourceTexture> CreateGradientTexture();
+  already_AddRefed<ID2D1ResourceTexture> CreateGradientTexture();
 
   RadialGradientEffectD2D1();
 
   uint32_t mRefCount;
   RefPtr<ID2D1GradientStopCollection> mStopCollection;
   RefPtr<ID2D1EffectContext> mEffectContext;
   RefPtr<ID2D1DrawInfo> mDrawInfo;
   SIMPLE_PROP(D2D1_VECTOR_2F, Center1);
--- a/gfx/2d/SVGTurbulenceRenderer-inl.h
+++ b/gfx/2d/SVGTurbulenceRenderer-inl.h
@@ -12,17 +12,17 @@ namespace gfx {
 
 template<TurbulenceType Type, bool Stitch, typename f32x4_t, typename i32x4_t, typename u8x16_t>
 class SVGTurbulenceRenderer
 {
 public:
   SVGTurbulenceRenderer(const Size &aBaseFrequency, int32_t aSeed,
                         int aNumOctaves, const Rect &aTileRect);
 
-  TemporaryRef<DataSourceSurface> Render(const IntSize &aSize, const Point &aOffset) const;
+  already_AddRefed<DataSourceSurface> Render(const IntSize &aSize, const Point &aOffset) const;
 
 private:
   /* The turbulence calculation code is an adapted version of what
      appears in the SVG 1.1 specification:
          http://www.w3.org/TR/SVG11/filters.html#feTurbulence
   */
 
   struct StitchInfo {
@@ -322,17 +322,17 @@ SVGTurbulenceRenderer<Type,Stitch,f32x4_
                              Size(sBSize, sBSize);
   Size repeatingSize(basePeriod.width / mBaseFrequency.width,
                      basePeriod.height / mBaseFrequency.height);
   return Point(MakeNonNegative(aOffset.x, repeatingSize.width),
                MakeNonNegative(aOffset.y, repeatingSize.height));
 }
 
 template<TurbulenceType Type, bool Stitch, typename f32x4_t, typename i32x4_t, typename u8x16_t>
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 SVGTurbulenceRenderer<Type,Stitch,f32x4_t,i32x4_t,u8x16_t>::Render(const IntSize &aSize, const Point &aOffset) const
 {
   RefPtr<DataSourceSurface> target =
     Factory::CreateDataSourceSurface(aSize, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
 
--- a/gfx/2d/ScaledFontBase.cpp
+++ b/gfx/2d/ScaledFontBase.cpp
@@ -69,17 +69,17 @@ ScaledFontBase::GetSkiaPathForGlyphs(con
   }
 
   SkPath path;
   paint.getPosTextPath(&indices.front(), aBuffer.mNumGlyphs*2, &offsets.front(), &path);
   return path;
 }
 #endif
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 ScaledFontBase::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
 {
 #ifdef USE_SKIA
   if (aTarget->GetBackendType() == BackendType::SKIA) {
     SkPath path = GetSkiaPathForGlyphs(aBuffer);
     return MakeAndAddRef<PathSkia>(path, FillRule::FILL_WINDING);
   }
 #endif
--- a/gfx/2d/ScaledFontBase.h
+++ b/gfx/2d/ScaledFontBase.h
@@ -26,17 +26,17 @@ namespace gfx {
 
 class ScaledFontBase : public ScaledFont
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase)
   explicit ScaledFontBase(Float aSize);
   virtual ~ScaledFontBase();
 
-  virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
+  virtual already_AddRefed<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
 
   virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint);
 
   float GetSize() { return mSize; }
 
 #ifdef USE_SKIA
   virtual SkTypeface* GetSkTypeface() { return mTypeface; }
 #endif
--- a/gfx/2d/ScaledFontDWrite.cpp
+++ b/gfx/2d/ScaledFontDWrite.cpp
@@ -301,17 +301,17 @@ ScaledFontDWrite::ScaledFontDWrite(uint8
   }
 
   IDWriteFontFile *ff = fontFile;
   if (FAILED(factory->CreateFontFace(DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &ff, aIndex, DWRITE_FONT_SIMULATIONS_NONE, byRef(mFontFace)))) {
     gfxWarning() << "Failed to create font face from font file data!";
   }
 }
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 ScaledFontDWrite::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
 {
   if (aTarget->GetBackendType() != BackendType::DIRECT2D && aTarget->GetBackendType() != BackendType::DIRECT2D1_1) {
     return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget);
   }
 
   RefPtr<PathBuilder> pathBuilder = aTarget->CreatePathBuilder();
 
--- a/gfx/2d/ScaledFontDWrite.h
+++ b/gfx/2d/ScaledFontDWrite.h
@@ -21,17 +21,17 @@ public:
   ScaledFontDWrite(IDWriteFontFace *aFont, Float aSize)
     : mFontFace(aFont)
     , ScaledFontBase(aSize)
   {}
   ScaledFontDWrite(uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize);
 
   virtual FontType GetType() const { return FontType::DWRITE; }
 
-  virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
+  virtual already_AddRefed<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
   virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint);
 
   void CopyGlyphsToSink(const GlyphBuffer &aBuffer, ID2D1GeometrySink *aSink);
 
   virtual bool GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton);
 
   virtual AntialiasMode GetDefaultAAMode();
 
--- a/gfx/2d/ScaledFontMac.cpp
+++ b/gfx/2d/ScaledFontMac.cpp
@@ -71,17 +71,17 @@ SkTypeface* ScaledFontMac::GetSkTypeface
 
 // private API here are the public options on OS X
 // CTFontCreatePathForGlyph
 // ATSUGlyphGetCubicPaths
 // we've used this in cairo sucessfully for some time.
 // Note: cairo dlsyms it. We could do that but maybe it's
 // safe just to use?
 
-TemporaryRef<Path>
+already_AddRefed<Path>
 ScaledFontMac::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
 {
   if (aTarget->GetBackendType() == BackendType::COREGRAPHICS ||
       aTarget->GetBackendType() == BackendType::COREGRAPHICS_ACCELERATED) {
       CGMutablePathRef path = CGPathCreateMutable();
 
       for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) {
           // XXX: we could probably fold both of these transforms together to avoid extra work
--- a/gfx/2d/ScaledFontMac.h
+++ b/gfx/2d/ScaledFontMac.h
@@ -20,17 +20,17 @@ public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontMac)
   ScaledFontMac(CGFontRef aFont, Float aSize);
   virtual ~ScaledFontMac();
 
   virtual FontType GetType() const { return FontType::MAC; }
 #ifdef USE_SKIA
   virtual SkTypeface* GetSkTypeface();
 #endif
-  virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
+  virtual already_AddRefed<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
   virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint);
   virtual bool GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton);
 
 private:
   friend class DrawTargetCG;
   CGFontRef mFont;
   CTFontRef mCTFont; // only created if CTFontDrawGlyphs is available, otherwise null
 
--- a/gfx/2d/SourceSurfaceCG.cpp
+++ b/gfx/2d/SourceSurfaceCG.cpp
@@ -31,17 +31,17 @@ SourceSurfaceCG::GetSize() const
 }
 
 SurfaceFormat
 SourceSurfaceCG::GetFormat() const
 {
   return mFormat;
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 SourceSurfaceCG::GetDataSurface()
 {
   //XXX: we should be more disciplined about who takes a reference and where
   CGImageRetain(mImage);
   RefPtr<DataSourceSurface> dataSurf = new DataSourceSurfaceCG(mImage);
 
   // We also need to make sure that the returned surface has
   // surface->GetType() == SurfaceType::DATA.
--- a/gfx/2d/SourceSurfaceCG.h
+++ b/gfx/2d/SourceSurfaceCG.h
@@ -38,17 +38,17 @@ public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCG)
   SourceSurfaceCG() {}
   explicit SourceSurfaceCG(CGImageRef aImage) : mImage(aImage) {}
   ~SourceSurfaceCG();
 
   virtual SurfaceType GetType() const { return SurfaceType::COREGRAPHICS_IMAGE; }
   virtual IntSize GetSize() const;
   virtual SurfaceFormat GetFormat() const;
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface();
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface();
 
   CGImageRef GetImage() { return mImage; }
 
   bool InitFromData(unsigned char *aData,
                     const IntSize &aSize,
                     int32_t aStride,
                     SurfaceFormat aFormat);
 
@@ -110,17 +110,17 @@ class SourceSurfaceCGBitmapContext : pub
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceCGBitmapContext)
   explicit SourceSurfaceCGBitmapContext(DrawTargetCG *);
   ~SourceSurfaceCGBitmapContext();
 
   virtual SurfaceType GetType() const { return SurfaceType::COREGRAPHICS_CGCONTEXT; }
   virtual IntSize GetSize() const;
   virtual SurfaceFormat GetFormat() const { return mFormat; }
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface()
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface()
   {
     // This call to DrawTargetWillChange() is needed to make a local copy of
     // the data from mDrawTarget.  If we don't do that, the data can end up
     // getting deleted before the CGImageRef it belongs to.
     //
     // Another reason we need a local copy of the data is that the data in
     // mDrawTarget could change when someone touches the original DrawTargetCG
     // object.  But a SourceSurface object should be immutable.
--- a/gfx/2d/SourceSurfaceCairo.cpp
+++ b/gfx/2d/SourceSurfaceCairo.cpp
@@ -53,17 +53,17 @@ SourceSurfaceCairo::GetSize() const
 }
 
 SurfaceFormat
 SourceSurfaceCairo::GetFormat() const
 {
   return mFormat;
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 SourceSurfaceCairo::GetDataSurface()
 {
   RefPtr<DataSourceSurface> dataSurf;
 
   if (cairo_surface_get_type(mSurface) == CAIRO_SURFACE_TYPE_IMAGE) {
     dataSurf = new DataSourceSurfaceCairo(mSurface);
   } else {
     cairo_surface_t* imageSurf = cairo_image_surface_create(GfxFormatToCairoFormat(mFormat),
--- a/gfx/2d/SourceSurfaceCairo.h
+++ b/gfx/2d/SourceSurfaceCairo.h
@@ -25,17 +25,17 @@ public:
   SourceSurfaceCairo(cairo_surface_t* aSurface, const IntSize& aSize,
                      const SurfaceFormat& aFormat,
                      DrawTargetCairo* aDrawTarget = nullptr);
   virtual ~SourceSurfaceCairo();
 
   virtual SurfaceType GetType() const { return SurfaceType::CAIRO; }
   virtual IntSize GetSize() const;
   virtual SurfaceFormat GetFormat() const;
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface();
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface();
 
   cairo_surface_t* GetSurface() const;
 
 private: // methods
   friend class DrawTargetCairo;
   void DrawTargetWillChange();
 
 private: // data
--- a/gfx/2d/SourceSurfaceD2D.cpp
+++ b/gfx/2d/SourceSurfaceD2D.cpp
@@ -35,17 +35,17 @@ SourceSurfaceD2D::GetFormat() const
 }
 
 bool
 SourceSurfaceD2D::IsValid() const
 {
   return mDevice == Factory::GetDirect3D10Device();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 SourceSurfaceD2D::GetDataSurface()
 {
   RefPtr<DataSourceSurfaceD2D> result = new DataSourceSurfaceD2D(this);
   if (result->IsValid()) {
     return result.forget();
   }
   return nullptr;
 }
--- a/gfx/2d/SourceSurfaceD2D.h
+++ b/gfx/2d/SourceSurfaceD2D.h
@@ -22,17 +22,17 @@ public:
   SourceSurfaceD2D();
   ~SourceSurfaceD2D();
 
   virtual SurfaceType GetType() const { return SurfaceType::D2D1_BITMAP; }
   virtual IntSize GetSize() const;
   virtual SurfaceFormat GetFormat() const;
   virtual bool IsValid() const;
 
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface();
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface();
 
   ID2D1Bitmap *GetBitmap() { return mBitmap; }
 
   bool InitFromData(unsigned char *aData,
                     const IntSize &aSize,
                     int32_t aStride,
                     SurfaceFormat aFormat,
                     ID2D1RenderTarget *aRT);
--- a/gfx/2d/SourceSurfaceD2D1.cpp
+++ b/gfx/2d/SourceSurfaceD2D1.cpp
@@ -29,17 +29,17 @@ SourceSurfaceD2D1::~SourceSurfaceD2D1()
 }
 
 bool
 SourceSurfaceD2D1::IsValid() const
 {
   return mDevice == Factory::GetD2D1Device();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 SourceSurfaceD2D1::GetDataSurface()
 {
   HRESULT hr;
 
   EnsureRealizedBitmap();
 
   RefPtr<ID2D1Bitmap1> softwareBitmap;
   D2D1_BITMAP_PROPERTIES1 props;
--- a/gfx/2d/SourceSurfaceD2D1.h
+++ b/gfx/2d/SourceSurfaceD2D1.h
@@ -25,17 +25,17 @@ public:
                     SurfaceFormat aFormat, const IntSize &aSize,
                     DrawTargetD2D1 *aDT = nullptr);
   ~SourceSurfaceD2D1();
 
   virtual SurfaceType GetType() const { return SurfaceType::D2D1_1_IMAGE; }
   virtual IntSize GetSize() const { return mSize; }
   virtual SurfaceFormat GetFormat() const { return mFormat; }
   virtual bool IsValid() const;
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface();
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface();
 
   ID2D1Image *GetImage() { return mImage; }
 
   void EnsureIndependent() { if (!mDrawTarget) return; DrawTargetWillChange(); }
 
 private:
   friend class DrawTargetD2D1;
 
--- a/gfx/2d/SourceSurfaceD2DTarget.cpp
+++ b/gfx/2d/SourceSurfaceD2DTarget.cpp
@@ -45,17 +45,17 @@ SourceSurfaceD2DTarget::GetSize() const
 }
 
 SurfaceFormat
 SourceSurfaceD2DTarget::GetFormat() const
 {
   return mFormat;
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 SourceSurfaceD2DTarget::GetDataSurface()
 {
   RefPtr<DataSourceSurfaceD2DTarget> dataSurf =
     new DataSourceSurfaceD2DTarget(mFormat);
 
   D3D10_TEXTURE2D_DESC desc;
   mTexture->GetDesc(&desc);
 
--- a/gfx/2d/SourceSurfaceD2DTarget.h
+++ b/gfx/2d/SourceSurfaceD2DTarget.h
@@ -22,17 +22,17 @@ public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceD2DTarget)
   SourceSurfaceD2DTarget(DrawTargetD2D* aDrawTarget, ID3D10Texture2D* aTexture,
                          SurfaceFormat aFormat);
   ~SourceSurfaceD2DTarget();
 
   virtual SurfaceType GetType() const { return SurfaceType::D2D1_DRAWTARGET; }
   virtual IntSize GetSize() const;
   virtual SurfaceFormat GetFormat() const;
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface();
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface();
   virtual void *GetNativeSurface(NativeSurfaceType aType);
 
   DrawTargetD2D* GetDT() { return mDrawTarget; }
   ID2D1Bitmap *GetBitmap(ID2D1RenderTarget *aRT);
 
 private:
   friend class DrawTargetD2D;
 
--- a/gfx/2d/SourceSurfaceDual.h
+++ b/gfx/2d/SourceSurfaceDual.h
@@ -23,17 +23,17 @@ public:
     , mB(aDTB->Snapshot())
   { }
 
   virtual SurfaceType GetType() const { return SurfaceType::DUAL_DT; }
   virtual IntSize GetSize() const { return mA->GetSize(); }
   virtual SurfaceFormat GetFormat() const { return mA->GetFormat(); }
 
   /* Readback from this surface type is not supported! */
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface() { return nullptr; }
+  virtual already_AddRefed<DataSourceSurface> GetDataSurface() { return nullptr; }
 private:
   friend class DualSurface;
   friend class DualPattern;
 
   RefPtr<SourceSurface> mA;
   RefPtr<SourceSurface> mB;
 };
 
--- a/gfx/gl/AndroidSurfaceTexture.cpp
+++ b/gfx/gl/AndroidSurfaceTexture.cpp
@@ -31,23 +31,23 @@ static std::map<int, AndroidSurfaceTextu
 static int sNextID = 0;
 
 static bool
 IsSTSupported()
 {
   return AndroidBridge::Bridge()->GetAPIVersion() >= 14; /* ICS */
 }
 
-TemporaryRef<AndroidSurfaceTexture>
+already_AddRefed<AndroidSurfaceTexture>
 AndroidSurfaceTexture::Create()
 {
   return Create(nullptr, 0);
 }
 
-TemporaryRef<AndroidSurfaceTexture>
+already_AddRefed<AndroidSurfaceTexture>
 AndroidSurfaceTexture::Create(GLContext* aContext, GLuint aTexture)
 {
   if (!IsSTSupported()) {
     return nullptr;
   }
 
   RefPtr<AndroidSurfaceTexture> st = new AndroidSurfaceTexture();
   if (!st->Init(aContext, aTexture)) {
--- a/gfx/gl/AndroidSurfaceTexture.h
+++ b/gfx/gl/AndroidSurfaceTexture.h
@@ -36,23 +36,23 @@ class GLContext;
  */
 class AndroidSurfaceTexture {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AndroidSurfaceTexture)
 
 public:
 
   // The SurfaceTexture is created in an attached state. This method requires
   // Android Ice Cream Sandwich.
-  static TemporaryRef<AndroidSurfaceTexture> Create(GLContext* aGLContext, GLuint aTexture);
+  static already_AddRefed<AndroidSurfaceTexture> Create(GLContext* aGLContext, GLuint aTexture);
 
   // Here the SurfaceTexture will be created in a detached state. You must call
   // Attach() with the GLContext you wish to composite with. It must be done
   // on the thread where that GLContext is current. This method requires
   // Android Jelly Bean.
-  static TemporaryRef<AndroidSurfaceTexture> Create();
+  static already_AddRefed<AndroidSurfaceTexture> Create();
 
   static AndroidSurfaceTexture* Find(int id);
 
   // If we are on Jelly Bean, the SurfaceTexture can be detached and reattached
   // to allow consumption from different GLContexts. It is recommended to only
   // attach while you are consuming in order to allow this.
   //
   // Only one GLContext may be attached at any given time. If another is already
--- a/gfx/gl/GLReadTexImageHelper.cpp
+++ b/gfx/gl/GLReadTexImageHelper.cpp
@@ -527,17 +527,17 @@ ReadPixelsIntoDataSurface(GLContext* gl,
                     *itr |= alphaMask;
                 }
             }
         }
     }
 #endif
 }
 
-static TemporaryRef<DataSourceSurface>
+static already_AddRefed<DataSourceSurface>
 YInvertImageSurface(DataSourceSurface* aSurf)
 {
     RefPtr<DataSourceSurface> temp =
       Factory::CreateDataSourceSurfaceWithStride(aSurf->GetSize(),
                                                  aSurf->GetFormat(),
                                                  aSurf->Stride());
     if (NS_WARN_IF(!temp)) {
         return nullptr;
@@ -563,17 +563,17 @@ YInvertImageSurface(DataSourceSurface* a
                      Matrix::Scaling(1.0, -1.0));
     Rect rect(0, 0, aSurf->GetSize().width, aSurf->GetSize().height);
     dt->DrawSurface(aSurf, rect, rect, DrawSurfaceOptions(),
                     DrawOptions(1.0, CompositionOp::OP_SOURCE, AntialiasMode::NONE));
     temp->Unmap();
     return temp.forget();
 }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, SurfaceFormat aFormat)
 {
     gl->MakeCurrent();
     gl->GuaranteeResolve();
     gl->fActiveTexture(LOCAL_GL_TEXTURE0);
     gl->fBindTexture(LOCAL_GL_TEXTURE_2D, aTexture);
 
     IntSize size;
@@ -612,17 +612,17 @@ ReadBackSurface(GLContext* gl, GLuint aT
 }
 
 #define CLEANUP_IF_GLERROR_OCCURRED(x)                                      \
     if (DidGLErrorOccur(x)) {                                               \
         isurf = nullptr;                                                    \
         break;                                                              \
     }
 
-TemporaryRef<DataSourceSurface>
+already_AddRefed<DataSourceSurface>
 GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,
                                    GLenum aTextureTarget,
                                    const gfx::IntSize& aSize,
     /* ShaderConfigOGL.mFeature */ int aConfig,
                                    bool aYInvert)
 {
     MOZ_ASSERT(aTextureTarget == LOCAL_GL_TEXTURE_2D ||
                aTextureTarget == LOCAL_GL_TEXTURE_EXTERNAL ||
--- a/gfx/gl/GLReadTexImageHelper.h
+++ b/gfx/gl/GLReadTexImageHelper.h
@@ -26,17 +26,17 @@ namespace gl {
 // `read{Format,Type}`.
 bool GetActualReadFormats(GLContext* gl,
                           GLenum destFormat, GLenum destType,
                           GLenum* out_readFormat, GLenum* out_readType);
 
 void ReadPixelsIntoDataSurface(GLContext* aGL,
                                gfx::DataSourceSurface* aSurface);
 
-TemporaryRef<gfx::DataSourceSurface>
+already_AddRefed<gfx::DataSourceSurface>
 ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, gfx::SurfaceFormat aFormat);
 
 class GLReadTexImageHelper final
 {
     // The GLContext is the sole owner of the GLBlitHelper.
     GLContext* mGL;
 
     GLuint mPrograms[4];
@@ -59,17 +59,17 @@ public:
       *
       * THIS IS EXPENSIVE.  It is ridiculously expensive.  Only do this
       * if you absolutely positively must, and never in any performance
       * critical path.
       *
       * NOTE: aShaderProgram is really mozilla::layers::ShaderProgramType. It is
       * passed as int to eliminate including LayerManagerOGLProgram.h here.
       */
-    TemporaryRef<gfx::DataSourceSurface> ReadTexImage(GLuint aTextureId,
+    already_AddRefed<gfx::DataSourceSurface> ReadTexImage(GLuint aTextureId,
                                                       GLenum aTextureTarget,
                                                       const gfx::IntSize& aSize,
                               /* ShaderProgramType */ int aShaderProgram,
                                                       bool aYInvert = false);
 
 
 };
 
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -180,17 +180,17 @@ BasicTextureImage::EndUpdate()
 void
 BasicTextureImage::BindTexture(GLenum aTextureUnit)
 {
     mGLContext->fActiveTexture(aTextureUnit);
     mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
     mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
 }
 
-TemporaryRef<gfx::DrawTarget>
+already_AddRefed<gfx::DrawTarget>
 BasicTextureImage::GetDrawTargetForUpdate(const gfx::IntSize& aSize, gfx::SurfaceFormat aFmt)
 {
     return gfx::Factory::CreateDrawTarget(gfx::BackendType::CAIRO, aSize, aFmt);
 }
 
 bool
 BasicTextureImage::FinishedSurfaceUpdate()
 {
--- a/gfx/gl/GLTextureImage.h
+++ b/gfx/gl/GLTextureImage.h
@@ -253,17 +253,17 @@ public:
 
     virtual void BindTexture(GLenum aTextureUnit);
 
     virtual gfx::DrawTarget* BeginUpdate(nsIntRegion& aRegion);
     virtual void GetUpdateRegion(nsIntRegion& aForRegion);
     virtual void EndUpdate();
     virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0));
     virtual GLuint GetTextureID() { return mTexture; }
-    virtual TemporaryRef<gfx::DrawTarget>
+    virtual already_AddRefed<gfx::DrawTarget>
       GetDrawTargetForUpdate(const gfx::IntSize& aSize, gfx::SurfaceFormat aFmt);
 
     virtual void MarkValid() { mTextureState = Valid; }
 
     // Call when drawing into the update surface is complete.
     // Returns true if textures should be upload with a relative
     // offset - See UploadSurfaceToTexture.
     virtual bool FinishedSurfaceUpdate();
--- a/gfx/gl/SharedSurface.cpp
+++ b/gfx/gl/SharedSurface.cpp
@@ -322,17 +322,17 @@ SurfaceFactory::~SurfaceFactory()
 
     MOZ_RELEASE_ASSERT(mRecycleTotalPool.empty());
 
     // If we mRecycleFreePool.clear() before StopRecycling(), we may try to recycle it,
     // fail, call StopRecycling(), then return here and call it again.
     mRecycleFreePool.clear();
 }
 
-TemporaryRef<layers::SharedSurfaceTextureClient>
+already_AddRefed<layers::SharedSurfaceTextureClient>
 SurfaceFactory::NewTexClient(const gfx::IntSize& size)
 {
     while (!mRecycleFreePool.empty()) {
         RefPtr<layers::SharedSurfaceTextureClient> cur = mRecycleFreePool.front();
         mRecycleFreePool.pop();
 
         if (cur->Surf()->mSize == size) {
             return cur.forget();
--- a/gfx/gl/SharedSurface.h
+++ b/gfx/gl/SharedSurface.h
@@ -323,18 +323,18 @@ protected:
     virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) = 0;
 
     void StartRecycling(layers::SharedSurfaceTextureClient* tc);
     void SetRecycleCallback(layers::SharedSurfaceTextureClient* tc);
     void StopRecycling(layers::SharedSurfaceTextureClient* tc);
 
 public:
     UniquePtr<SharedSurface> NewSharedSurface(const gfx::IntSize& size);
-    //TemporaryRef<ShSurfHandle> NewShSurfHandle(const gfx::IntSize& size);
-    TemporaryRef<layers::SharedSurfaceTextureClient> NewTexClient(const gfx::IntSize& size);
+    //already_AddRefed<ShSurfHandle> NewShSurfHandle(const gfx::IntSize& size);
+    already_AddRefed<layers::SharedSurfaceTextureClient> NewTexClient(const gfx::IntSize& size);
 
     static void RecycleCallback(layers::TextureClient* tc, void* /*closure*/);
 
     // Auto-deletes surfs of the wrong type.
     bool Recycle(layers::SharedSurfaceTextureClient* texClient);
 };
 
 class ScopedReadbackFB
--- a/gfx/layers/AtomicRefCountedWithFinalize.h
+++ b/gfx/layers/AtomicRefCountedWithFinalize.h
@@ -63,19 +63,16 @@ protected:
 public:
     // Mark user classes that are considered flawless.
     template<typename U>
     friend class RefPtr;
 
     template<class U>
     friend class ::mozilla::StaticRefPtr;
 
-    template<typename U>
-    friend class TemporaryRef;
-
     template<class U>
     friend class ::nsRefPtr;
 
     template<class U>
     friend struct ::RunnableMethodTraits;
 
     template<typename U>
     friend class ::mozilla::gl::RefSet;
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -3,17 +3,17 @@
 * 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_COMPOSITOR_H
 #define MOZILLA_GFX_COMPOSITOR_H
 
 #include "Units.h"                      // for ScreenPoint
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/RefPtr.h"             // for TemporaryRef, RefCounted
+#include "mozilla/RefPtr.h"             // for already_AddRefed, RefCounted
 #include "mozilla/gfx/Point.h"          // for IntSize, Point
 #include "mozilla/gfx/Rect.h"           // for Rect, IntRect
 #include "mozilla/gfx/Types.h"          // for Float
 #include "mozilla/layers/CompositorTypes.h"  // for DiagnosticTypes, etc
 #include "mozilla/layers/FenceUtils.h"  // for FenceHandle
 #include "mozilla/layers/LayersTypes.h"  // for LayersBackend
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsRegion.h"
@@ -186,17 +186,17 @@ public:
   explicit Compositor(PCompositorParent* aParent = nullptr)
     : mCompositorID(0)
     , mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC)
     , mParent(aParent)
     , mScreenRotation(ROTATION_0)
   {
   }
 
-  virtual TemporaryRef<DataTextureSource> CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) = 0;
+  virtual already_AddRefed<DataTextureSource> CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) = 0;
   virtual bool Initialize() = 0;
   virtual void Destroy() = 0;
 
   /**
    * Return true if the effect type is supported.
    *
    * By default Compositor implementations should support all effects but in
    * some rare cases it is not possible to support an effect efficiently.
@@ -248,27 +248,27 @@ public:
    * underlying API even if it is already the current context.
    */
   virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) = 0;
 
   /**
    * Creates a Surface that can be used as a rendering target by this
    * compositor.
    */
-  virtual TemporaryRef<CompositingRenderTarget>
+  virtual already_AddRefed<CompositingRenderTarget>
   CreateRenderTarget(const gfx::IntRect& aRect, SurfaceInitMode aInit) = 0;
 
   /**
    * Creates a Surface that can be used as a rendering target by this
    * compositor, and initializes the surface by copying from aSource.
    * If aSource is null, then the current screen buffer is used as source.
    *
    * aSourcePoint specifies the point in aSource to copy data from.
    */
-  virtual TemporaryRef<CompositingRenderTarget>
+  virtual already_AddRefed<CompositingRenderTarget>
   CreateRenderTargetFromSource(const gfx::IntRect& aRect,
                                const CompositingRenderTarget* aSource,
                                const gfx::IntPoint& aSourcePoint) = 0;
 
   /**
    * Sets the given surface as the target for subsequent calls to DrawQuad.
    * Passing null as aSurface sets the screen as the target.
    */
--- a/gfx/layers/D3D11ShareHandleImage.cpp
+++ b/gfx/layers/D3D11ShareHandleImage.cpp
@@ -47,17 +47,17 @@ D3D11ShareHandleImage::GetTextureClient(
                                                 mFormat,
                                                 TextureFlags::DEFAULT,
                                                 mTexture,
                                                 mSize);
   }
   return mTextureClient;
 }
 
-TemporaryRef<gfx::SourceSurface>
+already_AddRefed<gfx::SourceSurface>
 D3D11ShareHandleImage::GetAsSourceSurface()
 {
   if (!mTexture) {
     NS_WARNING("Cannot readback from shared texture because no texture is available.");
     return nullptr;
   }
 
   RefPtr<ID3D11Device> device;
--- a/gfx/layers/D3D11ShareHandleImage.h
+++ b/gfx/layers/D3D11ShareHandleImage.h
@@ -41,17 +41,17 @@ public:
   virtual ~D3D11ShareHandleImage() {}
 
   // Copies the surface into a sharable texture's surface, and initializes
   // the image.
   HRESULT SetData(const Data& aData);
 
   gfx::IntSize GetSize() override;
 
-  virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() override;
+  virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
 
   virtual TextureClient* GetTextureClient(CompositableClient* aClient) override;
 
   ID3D11Texture2D* GetTexture() const;
 
   virtual gfx::IntRect GetPictureRect() override { return mPictureRect; }
 
 private:
--- a/gfx/layers/D3D9SurfaceImage.cpp
+++ b/gfx/layers/D3D9SurfaceImage.cpp
@@ -207,17 +207,17 @@ D3D9SurfaceImage::GetTextureClient(Compo
                                                      TextureFlags::DEFAULT,
                                                      mTexture,
                                                      mShareHandle,
                                                      mDesc);
   }
   return mTextureClient;
 }
 
-TemporaryRef<gfx::SourceSurface>
+already_AddRefed<gfx::SourceSurface>
 D3D9SurfaceImage::GetAsSourceSurface()
 {
   NS_ENSURE_TRUE(mTexture, nullptr);
 
   HRESULT hr;
   RefPtr<gfx::DataSourceSurface> surface = gfx::Factory::CreateDataSourceSurface(mSize, gfx::SurfaceFormat::B8G8R8X8);
   if (NS_WARN_IF(!surface)) {
     return nullptr;
--- a/gfx/layers/D3D9SurfaceImage.h
+++ b/gfx/layers/D3D9SurfaceImage.h
@@ -35,17 +35,17 @@ public:
   // the image.
   HRESULT SetData(const Data& aData);
 
   // Returns the description of the shared surface.
   const D3DSURFACE_DESC& GetDesc() const;
 
   gfx::IntSize GetSize() override;
 
-  virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() override;
+  virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
 
   virtual TextureClient* GetTextureClient(CompositableClient* aClient) override;
 
   virtual bool IsValid() override;
 
 private:
 
   // Blocks the calling thread until the copy operation started in SetData()
--- a/gfx/layers/Effects.h
+++ b/gfx/layers/Effects.h
@@ -2,17 +2,17 @@
 * 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_LAYERS_EFFECTS_H
 #define MOZILLA_LAYERS_EFFECTS_H
 
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef, etc
+#include "mozilla/RefPtr.h"             // for RefPtr, already_AddRefed, etc
 #include "mozilla/gfx/Matrix.h"         // for Matrix4x4
 #include "mozilla/gfx/Point.h"          // for IntSize
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/gfx/Types.h"          // for Filter, etc
 #include "mozilla/layers/CompositorTypes.h"  // for EffectTypes, etc
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/layers/TextureHost.h"  // for CompositingRenderTarget, etc
 #include "mozilla/mozalloc.h"           // for operator delete, etc
@@ -240,17 +240,17 @@ struct EffectChain
  * Create a Textured effect corresponding to aFormat and using
  * aSource as the (first) texture source.
  *
  * Note that aFormat can be different form aSource->GetFormat if, we are
  * creating an effect that takes several texture sources (like with YCBCR
  * where aFormat would be FOMRAT_YCBCR and each texture source would be
  * a one-channel A8 texture)
  */
-inline TemporaryRef<TexturedEffect>
+inline already_AddRefed<TexturedEffect>
 CreateTexturedEffect(gfx::SurfaceFormat aFormat,
                      TextureSource* aSource,
                      const gfx::Filter& aFilter,
                      bool isAlphaPremultiplied,
                      const LayerRenderState &state = LayerRenderState())
 {
   MOZ_ASSERT(aSource);
   RefPtr<TexturedEffect> result;
@@ -276,17 +276,17 @@ CreateTexturedEffect(gfx::SurfaceFormat 
 }
 
 /**
  * Create a textured effect based on aSource format and the presence of
  * aSourceOnWhite.
  *
  * aSourceOnWhite can be null.
  */
-inline TemporaryRef<TexturedEffect>
+inline already_AddRefed<TexturedEffect>
 CreateTexturedEffect(TextureSource* aSource,
                      TextureSource* aSourceOnWhite,
                      const gfx::Filter& aFilter,
                      bool isAlphaPremultiplied,
                      const LayerRenderState &state = LayerRenderState())
 {
   MOZ_ASSERT(aSource);
   if (aSourceOnWhite) {
@@ -303,17 +303,17 @@ CreateTexturedEffect(TextureSource* aSou
                               state);
 }
 
 /**
  * Create a textured effect based on aSource format.
  *
  * This version excudes the possibility of component alpha.
  */
-inline TemporaryRef<TexturedEffect>
+inline already_AddRefed<TexturedEffect>
 CreateTexturedEffect(TextureSource *aTexture,
                      const gfx::Filter& aFilter,
                      const LayerRenderState &state = LayerRenderState())
 {
   return CreateTexturedEffect(aTexture, nullptr, aFilter, true, state);
 }
 
 
--- a/gfx/layers/GLImages.cpp
+++ b/gfx/layers/GLImages.cpp
@@ -28,17 +28,17 @@ EGLImageImage::~EGLImageImage()
   }
 
   if (mData.mSync) {
     sEGLLibrary.fDestroySync(EGL_DISPLAY(), mData.mSync);
     mData.mSync = nullptr;
   }
 }
 
-TemporaryRef<gfx::SourceSurface>
+already_AddRefed<gfx::SourceSurface>
 GLImage::GetAsSourceSurface()
 {
   MOZ_ASSERT(NS_IsMainThread(), "Should be on the main thread");
 
   if (!sSnapshotContext) {
     sSnapshotContext = GLContextProvider::CreateHeadless(false);
     if (!sSnapshotContext) {
       NS_WARNING("Failed to create snapshot GLContext");
--- a/gfx/layers/GLImages.h
+++ b/gfx/layers/GLImages.h
@@ -18,17 +18,17 @@ namespace gl {
 class AndroidSurfaceTexture;
 }
 namespace layers {
 
 class GLImage : public Image {
 public:
   explicit GLImage(ImageFormat aFormat) : Image(nullptr, aFormat){}
 
-  virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() override;
+  virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
 };
 
 class EGLImageImage : public GLImage {
 public:
   struct Data {
     EGLImage mImage;
     EGLSync mSync;
     gfx::IntSize mSize;
--- a/gfx/layers/GrallocImages.cpp
+++ b/gfx/layers/GrallocImages.cpp
@@ -376,17 +376,17 @@ ConvertOmxYUVFormatToRGB565(android::sp<
   if (rv) {
     NS_WARNING("OMX color conversion failed");
     return BAD_VALUE;
   }
 
   return OK;
 }
 
-TemporaryRef<gfx::SourceSurface>
+already_AddRefed<gfx::SourceSurface>
 GrallocImage::GetAsSourceSurface()
 {
   if (!mTextureClient) {
     return nullptr;
   }
 
   android::sp<GraphicBuffer> graphicBuffer =
     mTextureClient->GetGraphicBuffer();
--- a/gfx/layers/GrallocImages.h
+++ b/gfx/layers/GrallocImages.h
@@ -79,17 +79,17 @@ public:
     HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED     = 0x7FA30C03,
     HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS     = 0x7FA30C04,
   };
 
   enum {
     GRALLOC_SW_UAGE = android::GraphicBuffer::USAGE_SOFTWARE_MASK,
   };
 
-  virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() override;
+  virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
 
   android::sp<android::GraphicBuffer> GetGraphicBuffer() const;
 
   void* GetNativeBuffer();
 
   virtual bool IsValid() { return !!mTextureClient; }
 
   virtual TextureClient* GetTextureClient(CompositableClient* aClient) override;
--- a/gfx/layers/IMFYCbCrImage.cpp
+++ b/gfx/layers/IMFYCbCrImage.cpp
@@ -51,17 +51,17 @@ struct AutoLockTexture
     if (FAILED(hr)) {
       NS_WARNING("Failed to unlock the texture");
     }
   }
 
   RefPtr<IDXGIKeyedMutex> mMutex;
 };
 
-static TemporaryRef<IDirect3DTexture9>
+static already_AddRefed<IDirect3DTexture9>
 InitTextures(IDirect3DDevice9* aDevice,
              const IntSize &aSize,
             _D3DFORMAT aFormat,
             RefPtr<IDirect3DSurface9>& aSurface,
             HANDLE& aHandle,
             D3DLOCKED_RECT& aLockedRect)
 {
   if (!aDevice) {
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -5,17 +5,17 @@
 
 
 #include "ImageContainer.h"
 #include <string.h>                     // for memcpy, memset
 #include "GLImages.h"                   // for SurfaceTextureImage
 #include "gfx2DGlue.h"
 #include "gfxPlatform.h"                // for gfxPlatform
 #include "gfxUtils.h"                   // for gfxUtils
-#include "mozilla/RefPtr.h"             // for TemporaryRef
+#include "mozilla/RefPtr.h"             // for already_AddRefed
 #include "mozilla/ipc/CrossProcessMutex.h"  // for CrossProcessMutex, etc
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/ImageBridgeChild.h"  // for ImageBridgeChild
 #include "mozilla/layers/ImageClient.h"  // for ImageClient
 #include "nsISupportsUtils.h"           // for NS_IF_ADDREF
 #include "YCbCrUtils.h"                 // for YCbCr conversions
 #ifdef MOZ_WIDGET_GONK
 #include "GrallocImages.h"
@@ -288,17 +288,17 @@ already_AddRefed<Image>
 ImageContainer::LockCurrentImage()
 {
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   nsRefPtr<Image> retval = mActiveImage;
   return retval.forget();
 }
 
-TemporaryRef<gfx::SourceSurface>
+already_AddRefed<gfx::SourceSurface>
 ImageContainer::LockCurrentAsSourceSurface(gfx::IntSize *aSize, Image** aCurrentImage)
 {
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   if (aCurrentImage) {
     nsRefPtr<Image> activeImage(mActiveImage);
     activeImage.forget(aCurrentImage);
   }
@@ -311,17 +311,17 @@ ImageContainer::LockCurrentAsSourceSurfa
   return mActiveImage->GetAsSourceSurface();
 }
 
 void
 ImageContainer::UnlockCurrentImage()
 {
 }
 
-TemporaryRef<gfx::SourceSurface>
+already_AddRefed<gfx::SourceSurface>
 ImageContainer::GetCurrentAsSourceSurface(gfx::IntSize *aSize)
 {
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   if (!mActiveImage)
     return nullptr;
   *aSize = mActiveImage->GetSize();
   return mActiveImage->GetAsSourceSurface();
@@ -462,17 +462,17 @@ PlanarYCbCrImage::AllocateAndGetNewBuffe
   mBuffer = AllocateBuffer(aSize);
   if (mBuffer) {
     // update buffer size
     mBufferSize = aSize;