Bug 1207245 - part 3 - switch all uses of mozilla::RefPtr<T> to nsRefPtr<T>; r=ehsan
authorNathan Froyd <froydnj@mozilla.com>
Sun, 18 Oct 2015 00:40:10 -0400
changeset 268182 ca86c21a96b4
parent 268181 e2ee8f447aa1
child 268183 12d944fcb09d
push id29543
push userphilringnalda@gmail.com
push date2015-10-18 02:55 +0000
treeherdermozilla-central@e8c7dfe727cd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1207245
milestone44.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 1207245 - part 3 - switch all uses of mozilla::RefPtr<T> to nsRefPtr<T>; r=ehsan This commit was generated using the following script, executed at the top level of a typical source code checkout. # Don't modify select files in mfbt/ because it's not worth trying to # tease out the dependencies currently. # # Don't modify anything in media/gmp-clearkey/0.1/ because those files # use their own RefPtr, defined in their own RefCounted.h. find . -name '*.cpp' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ grep -v 'mfbt/RefPtr.h' | \ grep -v 'mfbt/nsRefPtr.h' | \ grep -v 'mfbt/RefCounted.h' | \ grep -v 'media/gmp-clearkey/0.1/' | \ xargs perl -p -i -e ' s/mozilla::RefPtr/nsRefPtr/g; # handle declarations in headers s/\bRefPtr</nsRefPtr</g; # handle local variables in functions s#mozilla/RefPtr.h#mozilla/nsRefPtr.h#; # handle #includes s#mfbt/RefPtr.h#mfbt/nsRefPtr.h#; # handle strange #includes ' # |using mozilla::RefPtr;| is OK; |using nsRefPtr;| is invalid syntax. find . -name '*.cpp' -o -name '*.mm' | xargs sed -i -e '/using nsRefPtr/d' # RefPtr.h used |byRef| for dealing with COM-style outparams. # nsRefPtr.h uses |getter_AddRefs|. # Fixup that mismatch. find . -name '*.cpp' -o -name '*.h'| \ xargs perl -p -i -e 's/byRef/getter_AddRefs/g'
browser/components/shell/nsWindowsShellService.cpp
devtools/shared/heapsnapshot/HeapSnapshot.h
devtools/shared/security/LocalCertService.cpp
dom/base/ImageEncoder.cpp
dom/base/nsContentUtils.cpp
dom/base/nsDOMWindowUtils.cpp
dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
dom/bluetooth/bluedroid/BluetoothOppManager.cpp
dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
dom/bluetooth/bluedroid/BluetoothSocket.cpp
dom/bluetooth/bluez/BluetoothOppManager.cpp
dom/bluetooth/bluez/BluetoothSocket.cpp
dom/camera/GonkCameraHwMgr.cpp
dom/camera/GonkRecorder.h
dom/canvas/CanvasGradient.h
dom/canvas/CanvasImageCache.cpp
dom/canvas/CanvasPath.h
dom/canvas/CanvasPattern.h
dom/canvas/CanvasRenderingContext2D.cpp
dom/canvas/CanvasRenderingContext2D.h
dom/canvas/DocumentRendererChild.cpp
dom/canvas/DocumentRendererParent.cpp
dom/canvas/ImageBitmap.cpp
dom/canvas/ImageBitmap.h
dom/canvas/OffscreenCanvas.h
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLProgram.cpp
dom/canvas/WebGLProgram.h
dom/canvas/WebGLTextureUpload.cpp
dom/canvas/nsICanvasRenderingContextInternal.h
dom/devicestorage/DeviceStorage.h
dom/html/HTMLCanvasElement.cpp
dom/ipc/ContentParent.cpp
dom/ipc/StructuredCloneData.h
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
dom/media/AudioStream.h
dom/media/DOMMediaStream.cpp
dom/media/MediaDecoderReader.cpp
dom/media/MediaDecoderReader.h
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaFormatReader.cpp
dom/media/MediaManager.cpp
dom/media/MediaManager.h
dom/media/MediaResource.cpp
dom/media/MediaShutdownManager.h
dom/media/MediaTimer.cpp
dom/media/VideoUtils.h
dom/media/directshow/AudioSinkFilter.cpp
dom/media/directshow/AudioSinkFilter.h
dom/media/directshow/AudioSinkInputPin.cpp
dom/media/directshow/AudioSinkInputPin.h
dom/media/directshow/DirectShowReader.cpp
dom/media/directshow/DirectShowReader.h
dom/media/directshow/DirectShowUtils.cpp
dom/media/directshow/SampleSink.cpp
dom/media/directshow/SampleSink.h
dom/media/directshow/SourceFilter.cpp
dom/media/directshow/SourceFilter.h
dom/media/eme/MediaKeySession.cpp
dom/media/eme/MediaKeys.h
dom/media/encoder/VP8TrackEncoder.cpp
dom/media/gmp/GMPAudioDecoderParent.h
dom/media/gmp/GMPDecryptorParent.h
dom/media/gmp/GMPVideoDecoderParent.h
dom/media/gmp/GMPVideoEncoderParent.h
dom/media/mediasink/DecodedAudioDataSink.cpp
dom/media/mediasource/MediaSourceDemuxer.h
dom/media/mediasource/TrackBuffersManager.h
dom/media/omx/MPAPI.h
dom/media/omx/MediaCodecReader.cpp
dom/media/omx/OMXCodecWrapper.cpp
dom/media/omx/OmxDecoder.cpp
dom/media/platforms/PlatformDecoderModule.h
dom/media/platforms/agnostic/BlankDecoderModule.cpp
dom/media/platforms/agnostic/OpusDecoder.cpp
dom/media/platforms/agnostic/OpusDecoder.h
dom/media/platforms/agnostic/VPXDecoder.h
dom/media/platforms/agnostic/VorbisDecoder.h
dom/media/platforms/agnostic/eme/SamplesWaitingForKey.cpp
dom/media/platforms/android/AndroidDecoderModule.cpp
dom/media/platforms/gonk/GonkAudioDecoderManager.h
dom/media/platforms/gonk/GonkMediaDataDecoder.h
dom/media/platforms/gonk/GonkVideoDecoderManager.cpp
dom/media/platforms/gonk/GonkVideoDecoderManager.h
dom/media/platforms/wmf/DXVA2Manager.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/WMFDecoderModule.cpp
dom/media/platforms/wmf/WMFMediaDataDecoder.h
dom/media/platforms/wmf/WMFUtils.cpp
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
dom/media/platforms/wmf/WMFVideoMFTManager.h
dom/media/systemservices/LoadMonitor.cpp
dom/media/systemservices/LoadMonitor.h
dom/media/webaudio/MediaBufferDecoder.cpp
dom/media/webaudio/blink/HRTFDatabaseLoader.cpp
dom/media/webaudio/blink/HRTFDatabaseLoader.h
dom/media/webaudio/blink/HRTFPanner.h
dom/media/webrtc/MediaEngine.h
dom/media/webrtc/MediaEngineGonkVideoSource.cpp
dom/media/webrtc/MediaEngineGonkVideoSource.h
dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
dom/media/webrtc/MediaEngineTabVideoSource.cpp
dom/media/webrtc/RTCCertificate.cpp
dom/media/webrtc/RTCCertificate.h
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/plugins/base/nsNPAPIPluginInstance.h
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/base/nsPluginInstanceOwner.h
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginInstanceChild.h
dom/plugins/ipc/PluginInstanceParent.cpp
dom/plugins/ipc/PluginInstanceParent.h
dom/plugins/ipc/PluginUtilsOSX.h
dom/plugins/ipc/PluginUtilsOSX.mm
dom/svg/SVGContentUtils.cpp
dom/svg/SVGEllipseElement.cpp
dom/svg/SVGFEBlendElement.cpp
dom/svg/SVGFEBlendElement.h
dom/svg/SVGFEColorMatrixElement.cpp
dom/svg/SVGFEColorMatrixElement.h
dom/svg/SVGFEComponentTransferElement.cpp
dom/svg/SVGFEComponentTransferElement.h
dom/svg/SVGFECompositeElement.cpp
dom/svg/SVGFECompositeElement.h
dom/svg/SVGFEConvolveMatrixElement.cpp
dom/svg/SVGFEConvolveMatrixElement.h
dom/svg/SVGFEDiffuseLightingElement.cpp
dom/svg/SVGFEDiffuseLightingElement.h
dom/svg/SVGFEDisplacementMapElement.cpp
dom/svg/SVGFEDisplacementMapElement.h
dom/svg/SVGFEDropShadowElement.cpp
dom/svg/SVGFEDropShadowElement.h
dom/svg/SVGFEFloodElement.cpp
dom/svg/SVGFEFloodElement.h
dom/svg/SVGFEGaussianBlurElement.cpp
dom/svg/SVGFEGaussianBlurElement.h
dom/svg/SVGFEImageElement.cpp
dom/svg/SVGFEImageElement.h
dom/svg/SVGFEMergeElement.cpp
dom/svg/SVGFEMergeElement.h
dom/svg/SVGFEMorphologyElement.cpp
dom/svg/SVGFEMorphologyElement.h
dom/svg/SVGFEOffsetElement.cpp
dom/svg/SVGFEOffsetElement.h
dom/svg/SVGFESpecularLightingElement.cpp
dom/svg/SVGFESpecularLightingElement.h
dom/svg/SVGFETileElement.cpp
dom/svg/SVGFETileElement.h
dom/svg/SVGFETurbulenceElement.cpp
dom/svg/SVGFETurbulenceElement.h
dom/svg/SVGMotionSMILAnimationFunction.h
dom/svg/SVGMotionSMILPathUtils.h
dom/svg/SVGPathData.cpp
dom/svg/SVGPathData.h
dom/svg/SVGPathElement.cpp
dom/svg/SVGPathElement.h
dom/svg/nsSVGFilters.h
dom/svg/nsSVGPathGeometryElement.cpp
dom/svg/nsSVGPathGeometryElement.h
dom/system/gonk/AutoMounter.cpp
dom/system/gonk/MozMtpDatabase.cpp
dom/system/gonk/MozMtpDatabase.h
dom/system/gonk/MozMtpStorage.h
dom/system/gonk/Volume.cpp
dom/system/gonk/VolumeCommand.h
dom/system/gonk/VolumeManager.cpp
dom/system/gonk/VolumeManager.h
dom/system/gonk/VolumeServiceIOThread.cpp
dom/system/gonk/VolumeServiceIOThread.h
dom/system/gonk/nsVolumeService.h
dom/wifi/WifiCertService.cpp
gfx/2d/2D.h
gfx/2d/DataSourceSurface.cpp
gfx/2d/DataSourceSurfaceWrapper.h
gfx/2d/DataSurfaceHelpers.cpp
gfx/2d/DrawCommand.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/DrawTargetTiled.h
gfx/2d/DrawingJob.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/Filters.h
gfx/2d/GenericRefCounted.h
gfx/2d/GradientStopsD2D.h
gfx/2d/Helpers.h
gfx/2d/HelpersD2D.h
gfx/2d/JobScheduler.cpp
gfx/2d/JobScheduler.h
gfx/2d/JobScheduler_posix.h
gfx/2d/JobScheduler_win32.h
gfx/2d/MacIOSurface.cpp
gfx/2d/MacIOSurface.h
gfx/2d/PathCairo.cpp
gfx/2d/PathD2D.cpp
gfx/2d/PathD2D.h
gfx/2d/PathHelpers.h
gfx/2d/PathRecording.cpp
gfx/2d/PathRecording.h
gfx/2d/QuartzSupport.h
gfx/2d/QuartzSupport.mm
gfx/2d/RadialGradientEffectD2D1.cpp
gfx/2d/RadialGradientEffectD2D1.h
gfx/2d/RecordedEvent.cpp
gfx/2d/RecordedEvent.h
gfx/2d/SVGTurbulenceRenderer-inl.h
gfx/2d/ScaledFontBase.cpp
gfx/2d/ScaledFontDWrite.cpp
gfx/2d/ScaledFontDWrite.h
gfx/2d/ScaledFontMac.cpp
gfx/2d/SourceSurfaceCG.cpp
gfx/2d/SourceSurfaceCG.h
gfx/2d/SourceSurfaceCairo.cpp
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/2d/SourceSurfaceSkia.h
gfx/2d/unittest/TestBugs.cpp
gfx/2d/unittest/TestDrawTargetBase.cpp
gfx/2d/unittest/TestDrawTargetBase.h
gfx/2d/unittest/TestDrawTargetD2D.cpp
gfx/2d/unittest/TestDrawTargetD2D.h
gfx/cairo/cairo/src/cairo-d2d-private.h
gfx/cairo/cairo/src/cairo-d2d-surface.cpp
gfx/cairo/cairo/src/cairo-dwrite-font.cpp
gfx/cairo/cairo/src/cairo-win32-refptr.h
gfx/gl/AndroidSurfaceTexture.cpp
gfx/gl/AndroidSurfaceTexture.h
gfx/gl/GLContext.h
gfx/gl/GLContextProviderCGL.mm
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/GLContextProviderWGL.cpp
gfx/gl/GLLibraryEGL.h
gfx/gl/GLReadTexImageHelper.cpp
gfx/gl/GLReadTexImageHelper.h
gfx/gl/GLScreenBuffer.cpp
gfx/gl/GLScreenBuffer.h
gfx/gl/GLTextureImage.cpp
gfx/gl/GLTextureImage.h
gfx/gl/SharedSurface.cpp
gfx/gl/SharedSurface.h
gfx/gl/SharedSurfaceANGLE.cpp
gfx/gl/SharedSurfaceANGLE.h
gfx/gl/SharedSurfaceEGL.cpp
gfx/gl/SharedSurfaceEGL.h
gfx/gl/SharedSurfaceGLX.cpp
gfx/gl/SharedSurfaceGLX.h
gfx/gl/SharedSurfaceGralloc.cpp
gfx/gl/SharedSurfaceGralloc.h
gfx/gl/SharedSurfaceIO.cpp
gfx/gl/SharedSurfaceIO.h
gfx/gl/SkiaGLGlue.h
gfx/gl/SurfaceTypes.h
gfx/gl/TextureImageEGL.cpp
gfx/gl/TextureImageEGL.h
gfx/layers/AsyncCanvasRenderer.cpp
gfx/layers/AsyncCanvasRenderer.h
gfx/layers/AtomicRefCountedWithFinalize.h
gfx/layers/Compositor.h
gfx/layers/CopyableCanvasLayer.cpp
gfx/layers/CopyableCanvasLayer.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/GrallocImages.cpp
gfx/layers/GrallocImages.h
gfx/layers/IMFYCbCrImage.cpp
gfx/layers/IMFYCbCrImage.h
gfx/layers/ImageContainer.cpp
gfx/layers/ImageContainer.h
gfx/layers/ImageDataSerializer.cpp
gfx/layers/ImageDataSerializer.h
gfx/layers/LayerScope.cpp
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/apz/src/AsyncPanZoomAnimation.h
gfx/layers/apz/src/AsyncPanZoomController.h
gfx/layers/basic/AutoMaskData.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicCompositor.h
gfx/layers/basic/BasicImageLayer.cpp
gfx/layers/basic/BasicImages.cpp
gfx/layers/basic/BasicLayerManager.cpp
gfx/layers/basic/BasicLayersImpl.cpp
gfx/layers/basic/BasicPaintedLayer.h
gfx/layers/basic/MacIOSurfaceTextureHostBasic.h
gfx/layers/basic/TextureClientX11.cpp
gfx/layers/basic/TextureClientX11.h
gfx/layers/basic/X11BasicCompositor.cpp
gfx/layers/basic/X11BasicCompositor.h
gfx/layers/basic/X11TextureSourceBasic.h
gfx/layers/client/CanvasClient.cpp
gfx/layers/client/CanvasClient.h
gfx/layers/client/ClientCanvasLayer.h
gfx/layers/client/ClientImageLayer.cpp
gfx/layers/client/ClientLayerManager.cpp
gfx/layers/client/ClientLayerManager.h
gfx/layers/client/ClientPaintedLayer.h
gfx/layers/client/ClientTiledPaintedLayer.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/SingleTiledContentClient.cpp
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/client/TiledContentClient.cpp
gfx/layers/client/TiledContentClient.h
gfx/layers/composite/AsyncCompositionManager.h
gfx/layers/composite/CanvasLayerComposite.cpp
gfx/layers/composite/CanvasLayerComposite.h
gfx/layers/composite/ColorLayerComposite.cpp
gfx/layers/composite/CompositableHost.cpp
gfx/layers/composite/CompositableHost.h
gfx/layers/composite/ContainerLayerComposite.cpp
gfx/layers/composite/ContainerLayerComposite.h
gfx/layers/composite/ContentHost.cpp
gfx/layers/composite/ContentHost.h
gfx/layers/composite/FPSCounter.cpp
gfx/layers/composite/FPSCounter.h
gfx/layers/composite/ImageHost.cpp
gfx/layers/composite/ImageHost.h
gfx/layers/composite/ImageLayerComposite.cpp
gfx/layers/composite/ImageLayerComposite.h
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
gfx/layers/composite/PaintedLayerComposite.cpp
gfx/layers/composite/PaintedLayerComposite.h
gfx/layers/composite/TextRenderer.cpp
gfx/layers/composite/TextRenderer.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/composite/TiledContentHost.cpp
gfx/layers/composite/TiledContentHost.h
gfx/layers/composite/X11TextureHost.cpp
gfx/layers/composite/X11TextureHost.h
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/CompositorD3D11.h
gfx/layers/d3d11/ReadbackManagerD3D11.cpp
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/AsyncTransactionTracker.cpp
gfx/layers/ipc/AsyncTransactionTracker.h
gfx/layers/ipc/CompositableForwarder.h
gfx/layers/ipc/CompositableTransactionParent.cpp
gfx/layers/ipc/CompositorBench.cpp
gfx/layers/ipc/CompositorChild.cpp
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/ipc/CompositorParent.h
gfx/layers/ipc/ISurfaceAllocator.h
gfx/layers/ipc/ImageBridgeChild.cpp
gfx/layers/ipc/ImageBridgeChild.h
gfx/layers/ipc/ImageBridgeParent.cpp
gfx/layers/ipc/LayerTransactionChild.cpp
gfx/layers/ipc/LayerTransactionChild.h
gfx/layers/ipc/LayerTransactionParent.cpp
gfx/layers/ipc/ShadowLayers.h
gfx/layers/ipc/SharedPlanarYCbCrImage.h
gfx/layers/ipc/SharedRGBImage.h
gfx/layers/opengl/CompositingRenderTargetOGL.h
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/CompositorOGL.h
gfx/layers/opengl/CompositorOGLVR.cpp
gfx/layers/opengl/GLManager.cpp
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.cpp
gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h
gfx/layers/opengl/OGLShaderProgram.h
gfx/layers/opengl/TextureClientOGL.h
gfx/layers/opengl/TextureHostOGL.cpp
gfx/layers/opengl/TextureHostOGL.h
gfx/layers/opengl/X11TextureSourceOGL.h
gfx/skia/skia/include/record/SkRecording.h
gfx/src/FilterSupport.cpp
gfx/src/FilterSupport.h
gfx/src/nsDeviceContext.cpp
gfx/tests/gtest/TestCompositor.cpp
gfx/tests/gtest/TestJobScheduler.cpp
gfx/tests/gtest/TestTextures.cpp
gfx/tests/gtest/gfxFontSelectionTest.cpp
gfx/tests/gtest/gfxTextRunPerfTest.cpp
gfx/tests/gtest/gfxWordCacheTest.cpp
gfx/thebes/SoftwareVsyncSource.h
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxBlur.cpp
gfx/thebes/gfxBlur.h
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxContext.h
gfx/thebes/gfxDWriteFonts.cpp
gfx/thebes/gfxDrawable.cpp
gfx/thebes/gfxDrawable.h
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxFontMissingGlyphs.cpp
gfx/thebes/gfxGradientCache.cpp
gfx/thebes/gfxImageSurface.cpp
gfx/thebes/gfxImageSurface.h
gfx/thebes/gfxMacFont.cpp
gfx/thebes/gfxPattern.h
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxQuartzNativeDrawing.cpp
gfx/thebes/gfxQuartzNativeDrawing.h
gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
gfx/thebes/gfxWindowsNativeDrawing.cpp
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
gfx/thebes/gfxXlibNativeRenderer.cpp
hal/gonk/GonkHal.cpp
hal/gonk/GonkSwitch.cpp
image/ClippedImage.cpp
image/ClippedImage.h
image/Decoder.h
image/DynamicImage.cpp
image/FrozenImage.h
image/ImageOps.cpp
image/ImageWrapper.cpp
image/OrientedImage.cpp
image/OrientedImage.h
image/ProgressTracker.h
image/RasterImage.cpp
image/RasterImage.h
image/SourceBuffer.h
image/SurfaceCache.cpp
image/VectorImage.cpp
image/imgFrame.cpp
image/imgFrame.h
image/imgIContainer.idl
image/imgTools.cpp
ipc/dbus/DBusUtils.h
ipc/netd/Netd.cpp
ipc/ril/RilSocket.cpp
ipc/unixsocket/ListenSocket.cpp
ipc/unixsocket/StreamSocket.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/vm/Interpreter.cpp
js/src/vm/Runtime.cpp
js/src/vm/Runtime.h
layout/base/DisplayItemClip.cpp
layout/base/DisplayItemClip.h
layout/base/FrameLayerBuilder.cpp
layout/base/nsCSSRendering.cpp
layout/base/nsCSSRenderingBorders.cpp
layout/base/nsCSSRenderingBorders.h
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/base/nsPresShell.cpp
layout/forms/nsGfxCheckboxControlFrame.cpp
layout/forms/nsGfxRadioControlFrame.cpp
layout/generic/nsBulletFrame.cpp
layout/generic/nsCanvasFrame.cpp
layout/generic/nsImageFrame.cpp
layout/generic/nsImageMap.cpp
layout/mathml/nsMathMLmencloseFrame.cpp
layout/mathml/nsMathMLmfracFrame.cpp
layout/svg/SVGTextFrame.cpp
layout/svg/SVGTextFrame.h
layout/svg/nsFilterInstance.cpp
layout/svg/nsFilterInstance.h
layout/svg/nsSVGClipPathFrame.cpp
layout/svg/nsSVGFilterInstance.cpp
layout/svg/nsSVGFilterInstance.h
layout/svg/nsSVGIntegrationUtils.cpp
layout/svg/nsSVGMaskFrame.cpp
layout/svg/nsSVGMaskFrame.h
layout/svg/nsSVGPathGeometryFrame.cpp
layout/svg/nsSVGPatternFrame.cpp
layout/svg/nsSVGPatternFrame.h
layout/svg/nsSVGUtils.cpp
media/mtransport/dtlsidentity.cpp
media/mtransport/dtlsidentity.h
media/mtransport/nr_socket_prsock.cpp
media/mtransport/nr_socket_prsock.h
media/mtransport/nricectx.cpp
media/mtransport/nricectx.h
media/mtransport/nricemediastream.cpp
media/mtransport/nricemediastream.h
media/mtransport/runnable_utils.h
media/mtransport/test/ice_unittest.cpp
media/mtransport/test/runnable_utils_unittest.cpp
media/mtransport/test/sctp_unittest.cpp
media/mtransport/test/transport_unittests.cpp
media/mtransport/test_nr_socket.cpp
media/mtransport/transportlayer.h
media/mtransport/transportlayerdtls.cpp
media/mtransport/transportlayerdtls.h
media/mtransport/transportlayerice.cpp
media/mtransport/transportlayerice.h
media/webrtc/signaling/src/jsep/JsepSession.h
media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
media/webrtc/signaling/src/jsep/JsepSessionImpl.h
media/webrtc/signaling/src/jsep/JsepTrack.cpp
media/webrtc/signaling/src/jsep/JsepTrack.h
media/webrtc/signaling/src/jsep/JsepTransport.h
media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
media/webrtc/signaling/src/media-conduit/AudioConduit.h
media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/signaling/src/media-conduit/VideoConduit.h
media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp
media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp
media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.h
media/webrtc/signaling/src/media/CSFAudioControlWrapper.h
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
media/webrtc/signaling/src/mediapipeline/SrtpFlow.cpp
media/webrtc/signaling/src/mediapipeline/SrtpFlow.h
media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp
media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.h
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
media/webrtc/signaling/test/jsep_session_unittest.cpp
media/webrtc/signaling/test/mediaconduit_unittests.cpp
media/webrtc/signaling/test/mediapipeline_unittest.cpp
media/webrtc/signaling/test/signaling_unittests.cpp
memory/volatile/VolatileBuffer.h
memory/volatile/tests/TestVolatileBuffer.cpp
mfbt/RefPtr.h
mfbt/WeakPtr.h
mfbt/tests/TestRefPtr.cpp
mozglue/android/nsGeckoUtils.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/Mappable.h
mozglue/linker/Zip.cpp
mozglue/linker/Zip.h
mozglue/linker/tests/TestZip.cpp
netwerk/protocol/http/PackagedAppService.cpp
netwerk/protocol/http/PackagedAppVerifier.cpp
security/apps/AppSignatureVerification.cpp
security/manager/ssl/SSLServerCertVerification.cpp
security/manager/ssl/SharedCertVerifier.h
security/manager/ssl/SharedSSLState.cpp
security/manager/ssl/SharedSSLState.h
security/manager/ssl/TransportSecurityInfo.cpp
security/manager/ssl/TransportSecurityInfo.h
security/manager/ssl/nsCertPicker.cpp
security/manager/ssl/nsCertTree.cpp
security/manager/ssl/nsCertTree.h
security/manager/ssl/nsCertVerificationThread.cpp
security/manager/ssl/nsClientAuthRemember.cpp
security/manager/ssl/nsDataSignatureVerifier.cpp
security/manager/ssl/nsNSSCallbacks.cpp
security/manager/ssl/nsNSSCertificate.cpp
security/manager/ssl/nsNSSCertificateDB.cpp
security/manager/ssl/nsNSSCertificateDB.h
security/manager/ssl/nsNSSComponent.cpp
security/manager/ssl/nsNSSComponent.h
security/manager/ssl/nsNSSIOLayer.cpp
security/manager/ssl/nsSiteSecurityService.cpp
security/manager/ssl/nsUsageArrayHelper.cpp
tools/profiler/core/GeckoSampler.h
tools/profiler/core/ProfileBuffer.h
tools/profiler/core/ProfileEntry.h
tools/profiler/core/ThreadProfile.h
tools/profiler/tests/gtest/ThreadProfileTest.cpp
widget/PuppetWidget.cpp
widget/PuppetWidget.h
widget/android/AndroidBridge.cpp
widget/cocoa/OSXNotificationCenter.h
widget/cocoa/nsChildView.mm
widget/cocoa/nsClipboard.mm
widget/cocoa/nsCocoaUtils.mm
widget/cocoa/nsDragService.mm
widget/cocoa/nsMenuItemIconX.mm
widget/gonk/GonkClipboardData.cpp
widget/gonk/GonkClipboardData.h
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/GonkBufferQueueProducer.cpp
widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferSlot.h
widget/gonk/nativewindow/GonkNativeWindowICS.cpp
widget/gonk/nativewindow/GonkNativeWindowICS.h
widget/gonk/nativewindow/GonkNativeWindowJB.cpp
widget/gonk/nativewindow/GonkNativeWindowKK.cpp
widget/gonk/nativewindow/GonkNativeWindowLL.cpp
widget/gonk/nativewindow/IGonkGraphicBufferConsumerLL.h
widget/gonk/nsClipboard.cpp
widget/gonk/nsWindow.cpp
widget/gonk/nsWindow.h
widget/gtk/nsClipboard.cpp
widget/gtk/nsDragService.cpp
widget/gtk/nsImageToPixbuf.cpp
widget/gtk/nsNativeThemeGTK.cpp
widget/gtk/nsWindow.cpp
widget/nsBaseDragService.cpp
widget/nsBaseDragService.h
widget/nsBaseWidget.cpp
widget/nsBaseWidget.h
widget/nsDragServiceProxy.cpp
widget/nsIWidget.h
widget/qt/nsClipboard.cpp
widget/uikit/nsWindow.mm
widget/windows/WinUtils.cpp
widget/windows/nsDragService.cpp
widget/windows/nsImageClipboard.cpp
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
widget/windows/nsWindowGfx.cpp
xpcom/build/IOInterposer.cpp
xpcom/threads/BackgroundHangMonitor.cpp
xpcom/threads/BackgroundHangMonitor.h
xpcom/threads/SharedThreadPool.cpp
xpcom/threads/SharedThreadPool.h
--- a/browser/components/shell/nsWindowsShellService.cpp
+++ b/browser/components/shell/nsWindowsShellService.cpp
@@ -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/. */
 
 #include "nsWindowsShellService.h"
 
 #include "imgIContainer.h"
 #include "imgIRequest.h"
 #include "mozilla/gfx/2D.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "nsIImageLoadingContent.h"
 #include "nsIPrefService.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
 #include "nsNetUtil.h"
@@ -1070,29 +1070,29 @@ nsWindowsShellService::SetShouldCheckDef
   return prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
 }
 
 static nsresult
 WriteBitmap(nsIFile* aFile, imgIContainer* aImage)
 {
   nsresult rv;
 
-  RefPtr<SourceSurface> surface =
+  nsRefPtr<SourceSurface> surface =
     aImage->GetFrame(imgIContainer::FRAME_FIRST,
                      imgIContainer::FLAG_SYNC_DECODE);
   NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
 
   // For either of the following formats we want to set the biBitCount member
   // of the BITMAPINFOHEADER struct to 32, below. For that value the bitmap
   // format defines that the A8/X8 WORDs in the bitmap byte stream be ignored
   // for the BI_RGB value we use for the biCompression member.
   MOZ_ASSERT(surface->GetFormat() == SurfaceFormat::B8G8R8A8 ||
              surface->GetFormat() == SurfaceFormat::B8G8R8X8);
 
-  RefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();
+  nsRefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();
   NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
 
   int32_t width = dataSurface->GetSize().width;
   int32_t height = dataSurface->GetSize().height;
   int32_t bytesPerPixel = 4 * sizeof(uint8_t);
   uint32_t bytesPerRow = bytesPerPixel * width;
 
   // initialize these bitmap structs which we will later
--- a/devtools/shared/heapsnapshot/HeapSnapshot.h
+++ b/devtools/shared/heapsnapshot/HeapSnapshot.h
@@ -8,17 +8,17 @@
 
 #include "js/HashTable.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/devtools/DeserializedNode.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/RefCounted.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/UniquePtr.h"
 
 #include "CoreDump.pb.h"
 #include "nsCOMPtr.h"
 #include "nsCRTGlue.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupports.h"
--- a/devtools/shared/security/LocalCertService.cpp
+++ b/devtools/shared/security/LocalCertService.cpp
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "LocalCertService.h"
 
 #include "mozilla/ModuleUtils.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "cert.h"
 #include "CryptoTask.h"
 #include "nsIPK11Token.h"
 #include "nsIPK11TokenDB.h"
 #include "nsIX509Cert.h"
 #include "nsIX509CertDB.h"
 #include "nsIX509CertValidity.h"
 #include "nsLiteralString.h"
@@ -414,17 +414,17 @@ LocalCertService::GetOrCreateCert(const 
 
   // Before sending off the task, login to key slot if needed
   nsresult rv = LoginToKeySlot();
   if (NS_FAILED(rv)) {
     aCallback->HandleCert(nullptr, rv);
     return NS_OK;
   }
 
-  RefPtr<LocalCertGetTask> task(new LocalCertGetTask(aNickname, aCallback));
+  nsRefPtr<LocalCertGetTask> task(new LocalCertGetTask(aNickname, aCallback));
   return task->Dispatch("LocalCertGet");
 }
 
 NS_IMETHODIMP
 LocalCertService::RemoveCert(const nsACString& aNickname,
                              nsILocalCertCallback* aCallback)
 {
   if (NS_WARN_IF(aNickname.IsEmpty())) {
@@ -436,17 +436,17 @@ LocalCertService::RemoveCert(const nsACS
 
   // Before sending off the task, login to key slot if needed
   nsresult rv = LoginToKeySlot();
   if (NS_FAILED(rv)) {
     aCallback->HandleResult(rv);
     return NS_OK;
   }
 
-  RefPtr<LocalCertRemoveTask> task(
+  nsRefPtr<LocalCertRemoveTask> task(
     new LocalCertRemoveTask(aNickname, aCallback));
   return task->Dispatch("LocalCertRm");
 }
 
 NS_IMETHODIMP
 LocalCertService::GetLoginPromptRequired(bool* aRequired)
 {
   nsresult rv;
--- a/dom/base/ImageEncoder.cpp
+++ b/dom/base/ImageEncoder.cpp
@@ -4,17 +4,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/. */
 
 #include "ImageEncoder.h"
 #include "mozilla/dom/CanvasRenderingContext2D.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/DataSurfaceHelpers.h"
 #include "mozilla/layers/AsyncCanvasRenderer.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/SyncRunnable.h"
 #include "mozilla/unused.h"
 #include "gfxUtils.h"
 #include "nsNetUtil.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
@@ -48,18 +48,18 @@ public:
     nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
     MOZ_ASSERT(mainThread);
     SyncRunnable::DispatchToThread(mainThread, this, false);
 
     return mDataSourceSurface.forget();
   }
 
 private:
-  RefPtr<layers::Image> mImage;
-  RefPtr<gfx::DataSourceSurface> mDataSourceSurface;
+  nsRefPtr<layers::Image> mImage;
+  nsRefPtr<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.
 already_AddRefed<DataSourceSurface>
@@ -397,18 +397,18 @@ ImageEncoder::ExtractDataInternal(const 
       rv = aEncoder->InitFromData(data.Elements(),
                                   aSize.width * aSize.height * 4,
                                   aSize.width,
                                   aSize.height,
                                   aSize.width * 4,
                                   imgIEncoder::INPUT_FORMAT_HOSTARGB,
                                   aOptions);
     } else {
-      RefPtr<gfx::DataSourceSurface> dataSurface;
-      RefPtr<layers::Image> image(aImage);
+      nsRefPtr<gfx::DataSourceSurface> dataSurface;
+      nsRefPtr<layers::Image> image(aImage);
       dataSurface = GetBRGADataSourceSurfaceSync(image.forget());
 
       DataSourceSurface::MappedSurface map;
       if (!dataSurface->Map(gfx::DataSourceSurface::MapType::READ, &map)) {
         return NS_ERROR_INVALID_ARG;
       }
       rv = aEncoder->InitFromData(map.mData,
                                   aSize.width * aSize.height * 4,
@@ -423,17 +423,17 @@ ImageEncoder::ExtractDataInternal(const 
     if (NS_SUCCEEDED(rv)) {
       imgStream = do_QueryInterface(aEncoder);
     }
   } else {
     // no context, so we have to encode an empty image
     // note that if we didn't have a current context, the spec says we're
     // supposed to just return transparent black pixels of the canvas
     // dimensions.
-    RefPtr<DataSourceSurface> emptyCanvas =
+    nsRefPtr<DataSourceSurface> emptyCanvas =
       Factory::CreateDataSourceSurfaceWithStride(IntSize(aSize.width, aSize.height),
                                                  SurfaceFormat::B8G8R8A8,
                                                  4 * aSize.width, true);
     if (NS_WARN_IF(!emptyCanvas)) {
       return NS_ERROR_INVALID_ARG;
     }
 
     DataSourceSurface::MappedSurface map;
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -7492,21 +7492,21 @@ nsContentUtils::TransferableToIPCTransfe
             NS_ConsumeStream(stream, UINT32_MAX, imageData);
             item->data() = imageData;
             continue;
           }
 
           // Images to be placed on the clipboard are imgIContainers.
           nsCOMPtr<imgIContainer> image(do_QueryInterface(data));
           if (image) {
-            RefPtr<mozilla::gfx::SourceSurface> surface =
+            nsRefPtr<mozilla::gfx::SourceSurface> surface =
               image->GetFrame(imgIContainer::FRAME_CURRENT,
                               imgIContainer::FLAG_SYNC_DECODE);
             if (surface) {
-              mozilla::RefPtr<mozilla::gfx::DataSourceSurface> dataSurface =
+              nsRefPtr<mozilla::gfx::DataSourceSurface> dataSurface =
                 surface->GetDataSurface();
               size_t length;
               int32_t stride;
               mozilla::UniquePtr<char[]> surfaceData =
                 nsContentUtils::GetSurfaceData(dataSurface, &length, &stride);
               
               IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
               item->flavor() = nsCString(flavorStr);
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1420,18 +1420,18 @@ nsDOMWindowUtils::CompareCanvases(nsIDOM
                                   uint32_t* aMaxDifference,
                                   uint32_t* retVal)
 {
   if (aCanvas1 == nullptr ||
       aCanvas2 == nullptr ||
       retVal == nullptr)
     return NS_ERROR_FAILURE;
 
-  RefPtr<DataSourceSurface> img1 = CanvasToDataSourceSurface(aCanvas1);
-  RefPtr<DataSourceSurface> img2 = CanvasToDataSourceSurface(aCanvas2);
+  nsRefPtr<DataSourceSurface> img1 = CanvasToDataSourceSurface(aCanvas1);
+  nsRefPtr<DataSourceSurface> img2 = CanvasToDataSourceSurface(aCanvas2);
 
   DataSourceSurface::ScopedMap map1(img1, DataSourceSurface::READ);
   DataSourceSurface::ScopedMap map2(img2, DataSourceSurface::READ);
 
   if (img1 == nullptr || img2 == nullptr ||
       !map1.IsMapped() || !map2.IsMapped() ||
       img1->GetSize() != img2->GetSize() ||
       map1.GetStride() != map2.GetStride()) {
@@ -2263,32 +2263,32 @@ nsDOMWindowUtils::AdvanceTimeAndRefresh(
     }
   }
 
   nsPresContext* presContext = GetPresContext();
   if (presContext) {
     nsRefreshDriver* driver = presContext->RefreshDriver();
     driver->AdvanceTimeAndRefresh(aMilliseconds);
 
-    RefPtr<LayerTransactionChild> transaction = GetLayerTransaction();
+    nsRefPtr<LayerTransactionChild> transaction = GetLayerTransaction();
     if (transaction && transaction->IPCOpen()) {
       transaction->SendSetTestSampleTime(driver->MostRecentRefresh());
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::RestoreNormalRefresh()
 {
   // Kick the compositor out of test mode before the refresh driver, so that
   // the refresh driver doesn't send an update that gets ignored by the
   // compositor.
-  RefPtr<LayerTransactionChild> transaction = GetLayerTransaction();
+  nsRefPtr<LayerTransactionChild> transaction = GetLayerTransaction();
   if (transaction && transaction->IPCOpen()) {
     transaction->SendLeaveTestMode();
   }
 
   if (nsPresContext* pc = GetPresContext()) {
     nsRefreshDriver* driver = pc->RefreshDriver();
     driver->RestoreNormalRefresh();
   }
--- a/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
@@ -12,17 +12,17 @@
 #include "BluetoothUtils.h"
 #include "BluetoothUuid.h"
 #include "ObexBase.h"
 
 #include "mozilla/dom/BluetoothMapParametersBinding.h"
 #include "mozilla/dom/ipc/BlobParent.h"
 #include "mozilla/dom/File.h"
 
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsAutoPtr.h"
 #include "nsIInputStream.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 
 #define FILTER_NO_SMS_GSM   0x01
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
@@ -11,17 +11,17 @@
 #include "BluetoothSocket.h"
 #include "BluetoothUtils.h"
 #include "BluetoothUuid.h"
 #include "ObexBase.h"
 
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 #include "mozilla/dom/ipc/BlobParent.h"
 #include "mozilla/dom/File.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsAutoPtr.h"
 #include "nsCExternalHandlerService.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIFile.h"
 #include "nsIInputStream.h"
--- a/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
@@ -10,17 +10,17 @@
 #include "BluetoothService.h"
 #include "BluetoothSocket.h"
 #include "BluetoothUtils.h"
 #include "BluetoothUuid.h"
 
 #include "mozilla/dom/BluetoothPbapParametersBinding.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/ipc/BlobParent.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsAutoPtr.h"
 #include "nsIInputStream.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 
 USING_BLUETOOTH_NAMESPACE
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -7,17 +7,17 @@
 #include "BluetoothSocket.h"
 #include <fcntl.h>
 #include <sys/socket.h>
 #include "BluetoothSocketObserver.h"
 #include "BluetoothInterface.h"
 #include "BluetoothUtils.h"
 #include "mozilla/ipc/UnixSocketWatcher.h"
 #include "mozilla/FileUtils.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
 #include "nsXULAppAPI.h"
 
 using namespace mozilla::ipc;
 USING_BLUETOOTH_NAMESPACE
 
 static const size_t MAX_READ_SIZE = 1 << 16;
 static BluetoothSocketInterface* sBluetoothSocketInterface;
--- a/dom/bluetooth/bluez/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothOppManager.cpp
@@ -11,17 +11,17 @@
 #include "BluetoothSocket.h"
 #include "BluetoothUtils.h"
 #include "BluetoothUuid.h"
 #include "ObexBase.h"
 
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/ipc/BlobParent.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsAutoPtr.h"
 #include "nsCExternalHandlerService.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIFile.h"
 #include "nsIInputStream.h"
--- a/dom/bluetooth/bluez/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluez/BluetoothSocket.cpp
@@ -3,17 +3,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/. */
 
 #include "BluetoothSocket.h"
 #include <fcntl.h>
 #include "BluetoothSocketObserver.h"
 #include "BluetoothUnixSocketConnector.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
 #include "nsXULAppAPI.h"
 
 using namespace mozilla::ipc;
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 static const size_t MAX_READ_SIZE = 1 << 16;
--- a/dom/camera/GonkCameraHwMgr.cpp
+++ b/dom/camera/GonkCameraHwMgr.cpp
@@ -22,17 +22,17 @@
 #include <sys/system_properties.h>
 #include "GonkNativeWindow.h"
 #endif
 
 #include "base/basictypes.h"
 #include "nsDebug.h"
 #include "mozilla/layers/TextureClient.h"
 #include "CameraPreferences.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
 #include "GonkBufferQueueProducer.h"
 #endif
 #include "GonkCameraControl.h"
 #include "CameraCommon.h"
 
 using namespace mozilla;
 using namespace mozilla::layers;
@@ -66,17 +66,17 @@ GonkCameraHardware::OnRateLimitPreview(b
 
 #ifdef MOZ_WIDGET_GONK
 void
 GonkCameraHardware::OnNewFrame()
 {
   if (mClosing) {
     return;
   }
-  RefPtr<TextureClient> buffer = mNativeWindow->getCurrentBuffer();
+  nsRefPtr<TextureClient> buffer = mNativeWindow->getCurrentBuffer();
   if (!buffer) {
     DOM_CAMERA_LOGE("received null frame");
     return;
   }
   OnNewPreviewFrame(mTarget, buffer);
 }
 
 // Android data callback
--- a/dom/camera/GonkRecorder.h
+++ b/dom/camera/GonkRecorder.h
@@ -24,17 +24,17 @@
 #include <camera/CameraParameters.h>
 #include <utils/String8.h>
 #include <system/audio.h>
 #if ANDROID_VERSION >= 21
 #include <media/stagefright/foundation/ALooper.h>
 #include <media/stagefright/foundation/AMessage.h>
 #endif
 
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "GonkCameraHwMgr.h"
 
 namespace android {
 
 class GonkCameraSource;
 struct MOZ_EXPORT MediaSource;
 struct MediaWriter;
 class MOZ_EXPORT MetaData;
--- a/dom/canvas/CanvasGradient.h
+++ b/dom/canvas/CanvasGradient.h
@@ -2,17 +2,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_dom_CanvasGradient_h
 #define mozilla_dom_CanvasGradient_h
 
 #include "mozilla/Attributes.h"
 #include "nsTArray.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/dom/CanvasRenderingContext2DBinding.h"
 #include "mozilla/dom/CanvasRenderingContext2D.h"
 #include "mozilla/gfx/2D.h"
 #include "nsWrapperCache.h"
 #include "gfxGradientCache.h"
 
 namespace mozilla {
 namespace dom {
@@ -65,17 +65,17 @@ protected:
   CanvasGradient(CanvasRenderingContext2D* aContext, Type aType)
     : mContext(aContext)
     , mType(aType)
   {
   }
 
   nsRefPtr<CanvasRenderingContext2D> mContext;
   nsTArray<mozilla::gfx::GradientStop> mRawStops;
-  mozilla::RefPtr<mozilla::gfx::GradientStops> mStops;
+  nsRefPtr<mozilla::gfx::GradientStops> mStops;
   Type mType;
   virtual ~CanvasGradient() {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_CanvasGradient_h
--- a/dom/canvas/CanvasImageCache.cpp
+++ b/dom/canvas/CanvasImageCache.cpp
@@ -47,17 +47,17 @@ struct ImageCacheEntryData {
   size_t SizeInBytes() { return mSize.width * mSize.height * 4; }
 
   // Key
   nsRefPtr<Element> mImage;
   nsIImageLoadingContent* mILC;
   nsRefPtr<HTMLCanvasElement> mCanvas;
   // Value
   nsCOMPtr<imgIRequest> mRequest;
-  RefPtr<SourceSurface> mSourceSurface;
+  nsRefPtr<SourceSurface> mSourceSurface;
   IntSize mSize;
   nsExpirationState mState;
 };
 
 class ImageCacheEntry : public PLDHashEntryHdr {
 public:
   typedef ImageCacheKey KeyType;
   typedef const ImageCacheKey* KeyTypePointer;
@@ -105,17 +105,17 @@ public:
   static KeyTypePointer KeyToPointer(KeyType key) { return &key; }
   static PLDHashNumber HashKey(KeyTypePointer key)
   {
     return NS_PTR_TO_UINT32(key) >> 2;
   }
   enum { ALLOW_MEMMOVE = true };
 
   nsCOMPtr<imgIRequest> mRequest;
-  RefPtr<SourceSurface> mSourceSurface;
+  nsRefPtr<SourceSurface> mSourceSurface;
 };
 
 static bool sPrefsInitialized = false;
 static int32_t sCanvasImageCacheLimit = 0;
 
 class ImageCacheObserver;
 
 class ImageCache final : public nsExpirationTracker<ImageCacheEntryData,4> {
--- a/dom/canvas/CanvasPath.h
+++ b/dom/canvas/CanvasPath.h
@@ -1,17 +1,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 CanvasPath_h
 #define CanvasPath_h
 
 #include "mozilla/Attributes.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsWrapperCache.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/ErrorResult.h"
 
 namespace mozilla {
 namespace dom {
 
@@ -70,18 +70,18 @@ public:
                const Optional<NonNull<SVGMatrix>>& aMatrix);
 
 private:
   virtual ~CanvasPath() {}
 
   nsCOMPtr<nsISupports> mParent;
   static gfx::Float ToFloat(double aValue) { return gfx::Float(aValue); }
 
-  mutable RefPtr<gfx::Path> mPath;
-  mutable RefPtr<gfx::PathBuilder> mPathBuilder;
+  mutable nsRefPtr<gfx::Path> mPath;
+  mutable nsRefPtr<gfx::PathBuilder> mPathBuilder;
 
   void EnsurePathBuilder() const;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* CanvasPath_h */
--- a/dom/canvas/CanvasPattern.h
+++ b/dom/canvas/CanvasPattern.h
@@ -3,17 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_CanvasPattern_h
 #define mozilla_dom_CanvasPattern_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/CanvasRenderingContext2DBinding.h"
 #include "mozilla/dom/CanvasRenderingContext2D.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsISupports.h"
 #include "nsWrapperCache.h"
 
 class nsIPrincipal;
 
 namespace mozilla {
 namespace gfx {
 class SourceSurface;
@@ -61,17 +61,17 @@ public:
   {
     return mContext;
   }
 
   // WebIDL
   void SetTransform(SVGMatrix& matrix);
 
   nsRefPtr<CanvasRenderingContext2D> mContext;
-  RefPtr<gfx::SourceSurface> mSurface;
+  nsRefPtr<gfx::SourceSurface> mSurface;
   nsCOMPtr<nsIPrincipal> mPrincipal;
   mozilla::gfx::Matrix mTransform;
   const bool mForceWriteOnly;
   const bool mCORSUsed;
   const RepeatMode mRepeat;
 };
 
 } // namespace dom
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -345,17 +345,17 @@ public:
   // Return a SourceSurface that contains the FillPaint or StrokePaint source.
   already_AddRefed<SourceSurface>
   DoSourcePaint(gfx::IntRect& aRect, CanvasRenderingContext2D::Style aStyle)
   {
     if (aRect.IsEmpty()) {
       return nullptr;
     }
 
-    RefPtr<DrawTarget> dt =
+    nsRefPtr<DrawTarget> dt =
       mFinalTarget->CreateSimilarDrawTarget(aRect.Size(), SurfaceFormat::B8G8R8A8);
     if (!dt) {
       aRect.SetEmpty();
       return nullptr;
     }
 
     Matrix transform =
       mFinalTarget->GetTransform().PostTranslate(-aRect.TopLeft() + mOffset);
@@ -371,21 +371,21 @@ public:
   }
 
   ~AdjustedTargetForFilter()
   {
     if (!mCtx) {
       return;
     }
 
-    RefPtr<SourceSurface> snapshot = mTarget->Snapshot();
-
-    RefPtr<SourceSurface> fillPaint =
+    nsRefPtr<SourceSurface> snapshot = mTarget->Snapshot();
+
+    nsRefPtr<SourceSurface> fillPaint =
       DoSourcePaint(mFillPaintRect, CanvasRenderingContext2D::Style::FILL);
-    RefPtr<SourceSurface> strokePaint =
+    nsRefPtr<SourceSurface> strokePaint =
       DoSourcePaint(mStrokePaintRect, CanvasRenderingContext2D::Style::STROKE);
 
     AutoRestoreTransform autoRestoreTransform(mFinalTarget);
     mFinalTarget->SetTransform(Matrix());
 
     gfx::FilterSupport::RenderFilterDescription(
       mFinalTarget, mCtx->CurrentState().filter,
       gfx::Rect(mPostFilterBounds),
@@ -398,18 +398,18 @@ public:
   }
 
   DrawTarget* DT()
   {
     return mTarget;
   }
 
 private:
-  RefPtr<DrawTarget> mTarget;
-  RefPtr<DrawTarget> mFinalTarget;
+  nsRefPtr<DrawTarget> mTarget;
+  nsRefPtr<DrawTarget> mFinalTarget;
   CanvasRenderingContext2D *mCtx;
   gfx::IntRect mSourceGraphicRect;
   gfx::IntRect mFillPaintRect;
   gfx::IntRect mStrokePaintRect;
   gfx::IntRect mPostFilterBounds;
   gfx::IntPoint mOffset;
   gfx::CompositionOp mCompositionOp;
 };
@@ -466,17 +466,17 @@ public:
   }
 
   ~AdjustedTargetForShadow()
   {
     if (!mCtx) {
       return;
     }
 
-    RefPtr<SourceSurface> snapshot = mTarget->Snapshot();
+    nsRefPtr<SourceSurface> snapshot = mTarget->Snapshot();
 
     mFinalTarget->DrawSurfaceWithShadow(snapshot, mTempRect.TopLeft(),
                                         Color::FromABGR(mCtx->CurrentState().shadowColor),
                                         mCtx->CurrentState().shadowOffset, mSigma,
                                         mCompositionOp);
   }
 
   DrawTarget* DT()
@@ -485,18 +485,18 @@ public:
   }
 
   gfx::IntPoint OffsetToFinalDT()
   {
     return mTempRect.TopLeft();
   }
 
 private:
-  RefPtr<DrawTarget> mTarget;
-  RefPtr<DrawTarget> mFinalTarget;
+  nsRefPtr<DrawTarget> mTarget;
+  nsRefPtr<DrawTarget> mFinalTarget;
   CanvasRenderingContext2D *mCtx;
   Float mSigma;
   gfx::IntRect mTempRect;
   gfx::CompositionOp mCompositionOp;
 };
 
 /* This is an RAII based class that can be used as a drawtarget for
  * operations that need a shadow or a filter drawn. It will automatically
@@ -640,17 +640,17 @@ private:
     }
 
     nsIntRegion extents =
       gfx::FilterSupport::ComputePostFilterExtents(ctx->CurrentState().filter,
                                                    intBounds);
     return gfx::Rect(extents.GetBounds());
   }
 
-  RefPtr<DrawTarget> mTarget;
+  nsRefPtr<DrawTarget> mTarget;
   UniquePtr<AdjustedTargetForShadow> mShadowTarget;
   UniquePtr<AdjustedTargetForFilter> mFilterTarget;
 };
 
 void
 CanvasPattern::SetTransform(SVGMatrix& aMatrix)
 {
   mTransform = ToMatrix(aMatrix.GetMatrix());
@@ -1200,17 +1200,17 @@ bool CanvasRenderingContext2D::SwitchRen
       gfxPlatform::GetPlatform()->GetSkiaGLGlue()->GetGLContext()->MakeCurrent();
       gfxPlatform::GetPlatform()->GetSkiaGLGlue()->GetGLContext()->fDeleteTextures(1, &mVideoTexture);
     }
 	  mCurrentVideoSize.width = 0;
 	  mCurrentVideoSize.height = 0;
   }
 #endif
 
-  RefPtr<SourceSurface> snapshot;
+  nsRefPtr<SourceSurface> snapshot;
   Matrix transform;
 
   if (mTarget) {
     snapshot = mTarget->Snapshot();
     transform = mTarget->GetTransform();
   } else {
     MOZ_ASSERT(mBufferProvider);
     // When mBufferProvider is true but we have no mTarget, our current state's
@@ -1639,22 +1639,22 @@ CanvasRenderingContext2D::SetContextOpti
 void
 CanvasRenderingContext2D::GetImageBuffer(uint8_t** aImageBuffer,
                                          int32_t* aFormat)
 {
   *aImageBuffer = nullptr;
   *aFormat = 0;
 
   EnsureTarget();
-  RefPtr<SourceSurface> snapshot = mTarget->Snapshot();
+  nsRefPtr<SourceSurface> snapshot = mTarget->Snapshot();
   if (!snapshot) {
     return;
   }
 
-  RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
+  nsRefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
   if (!data || data->GetSize() != IntSize(mWidth, mHeight)) {
     return;
   }
 
   *aImageBuffer = SurfaceToPackedBGRA(data);
   *aFormat = imgIEncoder::INPUT_FORMAT_HOSTARGB;
 }
 
@@ -2052,17 +2052,17 @@ CanvasRenderingContext2D::CreatePattern(
       error.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
       return nullptr;
     }
 
     // Special case for Canvas, which could be an Azure canvas!
     nsICanvasRenderingContextInternal *srcCanvas = canvas->GetContextAtIndex(0);
     if (srcCanvas) {
       // This might not be an Azure canvas!
-      RefPtr<SourceSurface> srcSurf = srcCanvas->GetSurfaceSnapshot();
+      nsRefPtr<SourceSurface> srcSurf = srcCanvas->GetSurfaceSnapshot();
 
       nsRefPtr<CanvasPattern> pat =
         new CanvasPattern(this, srcSurf, repeatMode, htmlElement->NodePrincipal(), canvas->IsWriteOnly(), false);
 
       return pat.forget();
     }
   } else if (source.IsHTMLImageElement()) {
     HTMLImageElement* img = &source.GetAsHTMLImageElement();
@@ -2073,17 +2073,17 @@ CanvasRenderingContext2D::CreatePattern(
 
     htmlElement = img;
   } else if (source.IsHTMLVideoElement()) {
     htmlElement = &source.GetAsHTMLVideoElement();
   } else {
     // Special case for ImageBitmap
     ImageBitmap& imgBitmap = source.GetAsImageBitmap();
     EnsureTarget();
-    RefPtr<SourceSurface> srcSurf = imgBitmap.PrepareForDrawTarget(mTarget);
+    nsRefPtr<SourceSurface> srcSurf = imgBitmap.PrepareForDrawTarget(mTarget);
 
     // An ImageBitmap never taints others so we set principalForSecurityCheck to
     // nullptr and set CORSUsed to true for passing the security check in
     // CanvasUtils::DoDrawImageSecurityCheck().
     nsRefPtr<CanvasPattern> pat =
       new CanvasPattern(this, srcSurf, repeatMode, nullptr, false, true);
 
     return pat.forget();
@@ -2695,17 +2695,17 @@ CanvasRenderingContext2D::Fill(const Can
 
   Redraw();
 }
 
 void CanvasRenderingContext2D::Fill(const CanvasPath& path, const CanvasWindingRule& winding)
 {
   EnsureTarget();
 
-  RefPtr<gfx::Path> gfxpath = path.GetPath(winding, mTarget);
+  nsRefPtr<gfx::Path> gfxpath = path.GetPath(winding, mTarget);
 
   if (!gfxpath) {
     return;
   }
 
   gfx::Rect bounds;
 
   if (NeedToCalculateBounds()) {
@@ -2748,17 +2748,17 @@ CanvasRenderingContext2D::Stroke()
   Redraw();
 }
 
 void
 CanvasRenderingContext2D::Stroke(const CanvasPath& path)
 {
   EnsureTarget();
 
-  RefPtr<gfx::Path> gfxpath = path.GetPath(CanvasWindingRule::Nonzero, mTarget);
+  nsRefPtr<gfx::Path> gfxpath = path.GetPath(CanvasWindingRule::Nonzero, mTarget);
 
   if (!gfxpath) {
     return;
   }
 
   const ContextState &state = CurrentState();
 
   StrokeOptions strokeOptions(state.lineWidth, state.lineJoin,
@@ -2867,17 +2867,17 @@ CanvasRenderingContext2D::Clip(const Can
   CurrentState().clipsPushed.AppendElement(mPath);
 }
 
 void
 CanvasRenderingContext2D::Clip(const CanvasPath& path, const CanvasWindingRule& winding)
 {
   EnsureTarget();
 
-  RefPtr<gfx::Path> gfxpath = path.GetPath(winding, mTarget);
+  nsRefPtr<gfx::Path> gfxpath = path.GetPath(winding, mTarget);
 
   if (!gfxpath) {
     return;
   }
 
   mTarget->PushClip(gfxpath);
   CurrentState().clipsPushed.AppendElement(gfxpath);
 }
@@ -3053,17 +3053,17 @@ CanvasRenderingContext2D::EnsureUserSpac
       mPathTransformWillUpdate) {
     mDSPathBuilder =
       mPath->TransformedCopyToBuilder(mPathToDS, fillRule);
     mPath = nullptr;
     mPathTransformWillUpdate = false;
   }
 
   if (mDSPathBuilder) {
-    RefPtr<Path> dsPath;
+    nsRefPtr<Path> dsPath;
     dsPath = mDSPathBuilder->Finish();
     mDSPathBuilder = nullptr;
 
     Matrix inverse = mTarget->GetTransform();
     if (!inverse.Invert()) {
       NS_WARNING("Could not invert transform");
       return;
     }
@@ -3309,17 +3309,17 @@ CanvasRenderingContext2D::MeasureText(co
   }
 
   return new TextMetrics(width);
 }
 
 void
 CanvasRenderingContext2D::AddHitRegion(const HitRegionOptions& options, ErrorResult& error)
 {
-  RefPtr<gfx::Path> path;
+  nsRefPtr<gfx::Path> path;
   if (options.mPath) {
     EnsureTarget();
     path = options.mPath->GetPath(CanvasWindingRule::Nonzero, mTarget);
   }
 
   if (!path) {
     // check if the path is valid
     EnsureUserSpacePath(CanvasWindingRule::Nonzero);
@@ -3356,17 +3356,17 @@ CanvasRenderingContext2D::AddHitRegion(c
                                 nsINode::DeleteProperty<bool>);
 #endif
   }
 
   // finally, add the region to the list
   RegionInfo info;
   info.mId = options.mId;
   info.mElement = options.mControl;
-  RefPtr<PathBuilder> pathBuilder = path->TransformedCopyToBuilder(mTarget->GetTransform());
+  nsRefPtr<PathBuilder> pathBuilder = path->TransformedCopyToBuilder(mTarget->GetTransform());
   info.mPath = pathBuilder->Finish();
 
   mHitRegionsOptions.InsertElementAt(0, info);
 }
 
 void
 CanvasRenderingContext2D::RemoveHitRegion(const nsAString& id)
 {
@@ -3525,17 +3525,17 @@ struct MOZ_STACK_CLASS CanvasBidiProcess
       if (c + 1 < numRuns) {
         endRun = runs[c + 1].mCharacterOffset;
       } else {
         endRun = mTextRun->GetLength();
       }
 
       const gfxTextRun::CompressedGlyph *glyphs = mTextRun->GetCharacterGlyphs();
 
-      RefPtr<ScaledFont> scaledFont =
+      nsRefPtr<ScaledFont> scaledFont =
         gfxPlatform::GetPlatform()->GetScaledFontForFont(mCtx->mTarget, font);
 
       if (!scaledFont) {
         // This can occur when something switched DirectWrite off.
         return;
       }
 
       AutoRestoreTransform sidewaysRestore;
@@ -3560,17 +3560,17 @@ struct MOZ_STACK_CLASS CanvasBidiProcess
                               // offset the (alphabetic) baseline of the
                               // horizontally-shaped text from the (centered)
                               // default baseline used for vertical
         }
 
         mCtx->mTarget->SetTransform(mat);
       }
 
-      RefPtr<GlyphRenderingOptions> renderingOptions = font->GetGlyphRenderingOptions();
+      nsRefPtr<GlyphRenderingOptions> renderingOptions = font->GetGlyphRenderingOptions();
 
       GlyphBuffer buffer;
 
       std::vector<Glyph> glyphBuf;
 
       // TODO:
       // This more-or-less duplicates the code found in gfxTextRun::Draw
       // and the gfxFont methods that uses (Draw, DrawGlyphs, DrawOneGlyph);
@@ -3673,17 +3673,17 @@ struct MOZ_STACK_CLASS CanvasBidiProcess
         AdjustedTarget target(mCtx, &bounds);
 
         CanvasGeneralPattern cgp;
         const Pattern& patForStyle
           (cgp.ForStyle(mCtx, CanvasRenderingContext2D::Style::STROKE, mCtx->mTarget));
         const DrawOptions drawOpts(state.globalAlpha, mCtx->UsedOperation());
 
         for (unsigned i = glyphBuf.size(); i > 0; --i) {
-          RefPtr<Path> path = scaledFont->GetPathForGlyphs(buffer, mCtx->mTarget);
+          nsRefPtr<Path> path = scaledFont->GetPathForGlyphs(buffer, mCtx->mTarget);
           target->Stroke(path, patForStyle, strokeOpts, drawOpts);
           buffer.mGlyphs++;
         }
       }
     }
   }
 
   // current text run
@@ -4184,17 +4184,17 @@ CanvasRenderingContext2D::IsPointInPath(
 
 bool CanvasRenderingContext2D::IsPointInPath(const CanvasPath& mPath, double x, double y, const CanvasWindingRule& mWinding)
 {
   if (!FloatValidate(x,y)) {
     return false;
   }
 
   EnsureTarget();
-  RefPtr<gfx::Path> tempPath = mPath.GetPath(mWinding, mTarget);
+  nsRefPtr<gfx::Path> tempPath = mPath.GetPath(mWinding, mTarget);
 
   return tempPath->ContainsPoint(Point(x, y), mTarget->GetTransform());
 }
 
 bool
 CanvasRenderingContext2D::IsPointInStroke(double x, double y)
 {
   if (!FloatValidate(x,y)) {
@@ -4224,17 +4224,17 @@ CanvasRenderingContext2D::IsPointInStrok
 
 bool CanvasRenderingContext2D::IsPointInStroke(const CanvasPath& mPath, double x, double y)
 {
   if (!FloatValidate(x,y)) {
     return false;
   }
 
   EnsureTarget();
-  RefPtr<gfx::Path> tempPath = mPath.GetPath(CanvasWindingRule::Nonzero, mTarget);
+  nsRefPtr<gfx::Path> tempPath = mPath.GetPath(CanvasWindingRule::Nonzero, mTarget);
 
   const ContextState &state = CurrentState();
 
   StrokeOptions strokeOptions(state.lineWidth,
                               state.lineJoin,
                               state.lineCap,
                               state.miterLimit,
                               state.dash.Length(),
@@ -4249,25 +4249,25 @@ bool CanvasRenderingContext2D::IsPointIn
 // relative to the returned surface.
 static already_AddRefed<SourceSurface>
 ExtractSubrect(SourceSurface* aSurface, gfx::Rect* aSourceRect, DrawTarget* aTargetDT)
 {
   gfx::Rect roundedOutSourceRect = *aSourceRect;
   roundedOutSourceRect.RoundOut();
   gfx::IntRect roundedOutSourceRectInt;
   if (!roundedOutSourceRect.ToIntRect(&roundedOutSourceRectInt)) {
-    RefPtr<SourceSurface> surface(aSurface);
+    nsRefPtr<SourceSurface> surface(aSurface);
     return surface.forget();
   }
 
-  RefPtr<DrawTarget> subrectDT =
+  nsRefPtr<DrawTarget> subrectDT =
     aTargetDT->CreateSimilarDrawTarget(roundedOutSourceRectInt.Size(), SurfaceFormat::B8G8R8A8);
 
   if (!subrectDT) {
-    RefPtr<SourceSurface> surface(aSurface);
+    nsRefPtr<SourceSurface> surface(aSurface);
     return surface.forget();
   }
 
   *aSourceRect -= roundedOutSourceRect.TopLeft();
 
   subrectDT->CopySurface(aSurface, roundedOutSourceRectInt, IntPoint());
   return subrectDT->Snapshot();
 }
@@ -4371,17 +4371,17 @@ CanvasRenderingContext2D::DrawImage(cons
 
   MOZ_ASSERT(optional_argc == 0 || optional_argc == 2 || optional_argc == 6);
 
   if (optional_argc == 6) {
     NormalizeRect(sx, sy, sw, sh);
     NormalizeRect(dx, dy, dw, dh);
   }
 
-  RefPtr<SourceSurface> srcSurf;
+  nsRefPtr<SourceSurface> srcSurf;
   gfx::IntSize imgSize;
 
   Element* element = nullptr;
 
   EnsureTarget();
   if (image.IsHTMLCanvasElement()) {
     HTMLCanvasElement* canvas = &image.GetAsHTMLCanvasElement();
     element = canvas;
@@ -4852,17 +4852,17 @@ CanvasRenderingContext2D::DrawWindow(nsG
   Matrix matrix = mTarget->GetTransform();
   double sw = matrix._11 * w;
   double sh = matrix._22 * h;
   if (!sw || !sh) {
     return;
   }
 
   nsRefPtr<gfxContext> thebes;
-  RefPtr<DrawTarget> drawDT;
+  nsRefPtr<DrawTarget> drawDT;
   // Rendering directly is faster and can be done if mTarget supports Azure
   // and does not need alpha blending.
   if (gfxPlatform::GetPlatform()->SupportsAzureContentForDrawTarget(mTarget) &&
       GlobalAlpha() == 1.0f)
   {
     thebes = new gfxContext(mTarget);
     thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
                                 matrix._22, matrix._31, matrix._32));
@@ -4877,25 +4877,25 @@ CanvasRenderingContext2D::DrawWindow(nsG
 
     thebes = new gfxContext(drawDT);
     thebes->SetMatrix(gfxMatrix::Scaling(matrix._11, matrix._22));
   }
 
   nsCOMPtr<nsIPresShell> shell = presContext->PresShell();
   unused << shell->RenderDocument(r, renderDocFlags, backgroundColor, thebes);
   if (drawDT) {
-    RefPtr<SourceSurface> snapshot = drawDT->Snapshot();
-    RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
+    nsRefPtr<SourceSurface> snapshot = drawDT->Snapshot();
+    nsRefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
 
     DataSourceSurface::MappedSurface rawData;
     if (NS_WARN_IF(!data->Map(DataSourceSurface::READ, &rawData))) {
         error.Throw(NS_ERROR_FAILURE);
         return;
     }
-    RefPtr<SourceSurface> source =
+    nsRefPtr<SourceSurface> source =
       mTarget->CreateSourceSurfaceFromData(rawData.mData,
                                            data->GetSize(),
                                            rawData.mStride,
                                            data->GetFormat());
     data->Unmap();
 
     if (!source) {
       error.Throw(NS_ERROR_FAILURE);
@@ -5032,17 +5032,17 @@ CanvasRenderingContext2D::DrawWidgetAsOn
     return;
   }
 
   nsIWidget* widget = presContext->GetRootWidget();
   if (!widget) {
     error.Throw(NS_ERROR_FAILURE);
     return;
   }
-  RefPtr<SourceSurface> snapshot = widget->SnapshotWidgetOnScreen();
+  nsRefPtr<SourceSurface> snapshot = widget->SnapshotWidgetOnScreen();
   if (!snapshot) {
     error.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   gfx::Rect sourceRect(gfx::Point(0, 0), gfx::Size(snapshot->GetSize()));
   mTarget->DrawSurface(snapshot, sourceRect, sourceRect,
                        DrawSurfaceOptions(gfx::Filter::POINT),
@@ -5174,20 +5174,20 @@ CanvasRenderingContext2D::GetImageDataAr
   if (mZero) {
     *aRetval = darray;
     return NS_OK;
   }
 
   IntRect srcRect(0, 0, mWidth, mHeight);
   IntRect destRect(aX, aY, aWidth, aHeight);
   IntRect srcReadRect = srcRect.Intersect(destRect);
-  RefPtr<DataSourceSurface> readback;
+  nsRefPtr<DataSourceSurface> readback;
   DataSourceSurface::MappedSurface rawData;
   if (!srcReadRect.IsEmpty()) {
-    RefPtr<SourceSurface> snapshot = mTarget->Snapshot();
+    nsRefPtr<SourceSurface> snapshot = mTarget->Snapshot();
     if (snapshot) {
       readback = snapshot->GetDataSurface();
     }
     if (!readback || !readback->Map(DataSourceSurface::READ, &rawData)) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
@@ -5269,17 +5269,17 @@ CanvasRenderingContext2D::GetImageDataAr
 
 void
 CanvasRenderingContext2D::EnsureErrorTarget()
 {
   if (sErrorTarget) {
     return;
   }
 
-  RefPtr<DrawTarget> errorTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(IntSize(1, 1), SurfaceFormat::B8G8R8A8);
+  nsRefPtr<DrawTarget> errorTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(IntSize(1, 1), SurfaceFormat::B8G8R8A8);
   MOZ_ASSERT(errorTarget, "Failed to allocate the error target!");
 
   sErrorTarget = errorTarget;
   NS_ADDREF(sErrorTarget);
 }
 
 void
 CanvasRenderingContext2D::FillRuleChanged()
@@ -5439,17 +5439,17 @@ CanvasRenderingContext2D::PutImageData_e
     srcLine += w * 4;
   }
 
   EnsureTarget();
   if (!IsTargetValid()) {
     return NS_ERROR_FAILURE;
   }
 
-  RefPtr<SourceSurface> sourceSurface =
+  nsRefPtr<SourceSurface> sourceSurface =
     mTarget->CreateSourceSurfaceFromData(imgsurf->Data(), IntSize(copyWidth, copyHeight), imgsurf->Stride(), SurfaceFormat::B8G8R8A8);
 
   // In certain scenarios, requesting larger than 8k image fails.  Bug 803568
   // covers the details of how to run into it, but the full detailed
   // investigation hasn't been done to determine the underlying cause.  We
   // will just handle the failure to allocate the surface to avoid a crash.
   if (!sourceSurface) {
     return NS_ERROR_FAILURE;
@@ -5716,27 +5716,27 @@ CanvasPath::Constructor(const GlobalObje
 {
   nsRefPtr<CanvasPath> path = new CanvasPath(aGlobal.GetAsSupports());
   return path.forget();
 }
 
 already_AddRefed<CanvasPath>
 CanvasPath::Constructor(const GlobalObject& aGlobal, CanvasPath& aCanvasPath, ErrorResult& aRv)
 {
-  RefPtr<gfx::Path> tempPath = aCanvasPath.GetPath(CanvasWindingRule::Nonzero,
+  nsRefPtr<gfx::Path> tempPath = aCanvasPath.GetPath(CanvasWindingRule::Nonzero,
                                                    gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
 
   nsRefPtr<CanvasPath> path = new CanvasPath(aGlobal.GetAsSupports(), tempPath->CopyToBuilder());
   return path.forget();
 }
 
 already_AddRefed<CanvasPath>
 CanvasPath::Constructor(const GlobalObject& aGlobal, const nsAString& aPathString, ErrorResult& aRv)
 {
-  RefPtr<gfx::Path> tempPath = SVGContentUtils::GetPath(aPathString);
+  nsRefPtr<gfx::Path> tempPath = SVGContentUtils::GetPath(aPathString);
   if (!tempPath) {
     return Constructor(aGlobal, aRv);
   }
 
   nsRefPtr<CanvasPath> path = new CanvasPath(aGlobal.GetAsSupports(), tempPath->CopyToBuilder());
   return path.forget();
 }
 
@@ -5890,25 +5890,25 @@ CanvasPath::BezierTo(const gfx::Point& a
   EnsurePathBuilder();
 
   mPathBuilder->BezierTo(aCP1, aCP2, aCP3);
 }
 
 void
 CanvasPath::AddPath(CanvasPath& aCanvasPath, const Optional<NonNull<SVGMatrix>>& aMatrix)
 {
-  RefPtr<gfx::Path> tempPath = aCanvasPath.GetPath(CanvasWindingRule::Nonzero,
+  nsRefPtr<gfx::Path> tempPath = aCanvasPath.GetPath(CanvasWindingRule::Nonzero,
                                                    gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
 
   if (aMatrix.WasPassed()) {
     const SVGMatrix& m = aMatrix.Value();
     Matrix transform(m.A(), m.B(), m.C(), m.D(), m.E(), m.F());
 
     if (!transform.IsIdentity()) {
-      RefPtr<PathBuilder> tempBuilder = tempPath->TransformedCopyToBuilder(transform, FillRule::FILL_WINDING);
+      nsRefPtr<PathBuilder> tempBuilder = tempPath->TransformedCopyToBuilder(transform, FillRule::FILL_WINDING);
       tempPath = tempBuilder->Finish();
     }
   }
 
   EnsurePathBuilder(); // in case a path is added to itself
   tempPath->StreamToSink(mPathBuilder);
 }
 
@@ -5918,43 +5918,43 @@ CanvasPath::GetPath(const CanvasWindingR
   FillRule fillRule = FillRule::FILL_WINDING;
   if (winding == CanvasWindingRule::Evenodd) {
     fillRule = FillRule::FILL_EVEN_ODD;
   }
 
   if (mPath &&
       (mPath->GetBackendType() == aTarget->GetBackendType()) &&
       (mPath->GetFillRule() == fillRule)) {
-    RefPtr<gfx::Path> path(mPath);
+    nsRefPtr<gfx::Path> path(mPath);
     return path.forget();
   }
 
   if (!mPath) {
     // if there is no path, there must be a pathbuilder
     MOZ_ASSERT(mPathBuilder);
     mPath = mPathBuilder->Finish();
     if (!mPath) {
-      RefPtr<gfx::Path> path(mPath);
+      nsRefPtr<gfx::Path> path(mPath);
       return path.forget();
     }
 
     mPathBuilder = nullptr;
   }
 
   // retarget our backend if we're used with a different backend
   if (mPath->GetBackendType() != aTarget->GetBackendType()) {
-    RefPtr<PathBuilder> tmpPathBuilder = aTarget->CreatePathBuilder(fillRule);
+    nsRefPtr<PathBuilder> tmpPathBuilder = aTarget->CreatePathBuilder(fillRule);
     mPath->StreamToSink(tmpPathBuilder);
     mPath = tmpPathBuilder->Finish();
   } else if (mPath->GetFillRule() != fillRule) {
-    RefPtr<PathBuilder> tmpPathBuilder = mPath->CopyToBuilder(fillRule);
+    nsRefPtr<PathBuilder> tmpPathBuilder = mPath->CopyToBuilder(fillRule);
     mPath = tmpPathBuilder->Finish();
   }
 
-  RefPtr<gfx::Path> path(mPath);
+  nsRefPtr<gfx::Path> path(mPath);
   return path.forget();
 }
 
 void
 CanvasPath::EnsurePathBuilder() const
 {
   if (mPathBuilder) {
     return;
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -4,17 +4,17 @@
 
 #ifndef CanvasRenderingContext2D_h
 #define CanvasRenderingContext2D_h
 
 #include "mozilla/Attributes.h"
 #include <vector>
 #include "nsIDOMCanvasRenderingContext2D.h"
 #include "nsICanvasRenderingContextInternal.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsColor.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "gfxTextRun.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/CanvasGradient.h"
 #include "mozilla/dom/CanvasRenderingContext2DBinding.h"
 #include "mozilla/dom/CanvasPattern.h"
@@ -724,19 +724,19 @@ protected:
   nsTArray<CanvasRenderingContext2DUserData*> mUserDatas;
 
   // If mCanvasElement is not provided, then a docshell is
   nsCOMPtr<nsIDocShell> mDocShell;
 
   // This is created lazily so it is necessary to call EnsureTarget before
   // accessing it. In the event of an error it will be equal to
   // sErrorTarget.
-  mozilla::RefPtr<mozilla::gfx::DrawTarget> mTarget;
+  nsRefPtr<mozilla::gfx::DrawTarget> mTarget;
 
-  mozilla::RefPtr<mozilla::layers::PersistentBufferProvider> mBufferProvider;
+  nsRefPtr<mozilla::layers::PersistentBufferProvider> mBufferProvider;
 
   uint32_t SkiaGLTex() const;
 
   // This observes our draw calls at the beginning of the canvas
   // lifetime and switches to software or GPU mode depending on
   // what it thinks is best
   CanvasDrawObserver* mDrawObserver;
   void RemoveDrawObserver();
@@ -783,19 +783,19 @@ protected:
     *
     * There's never both a device space path builder and a user space path
     * builder present at the same time. There is also never a path and a
     * path builder present at the same time. When writing proceeds on an
     * existing path the Path is cleared and a new builder is created.
     *
     * mPath is always in user-space.
     */
-  mozilla::RefPtr<mozilla::gfx::Path> mPath;
-  mozilla::RefPtr<mozilla::gfx::PathBuilder> mDSPathBuilder;
-  mozilla::RefPtr<mozilla::gfx::PathBuilder> mPathBuilder;
+  nsRefPtr<mozilla::gfx::Path> mPath;
+  nsRefPtr<mozilla::gfx::PathBuilder> mDSPathBuilder;
+  nsRefPtr<mozilla::gfx::PathBuilder> mPathBuilder;
   bool mPathTransformWillUpdate;
   mozilla::gfx::Matrix mPathToDS;
 
   /**
     * Number of times we've invalidated before calling redraw
     */
   uint32_t mInvalidateCount;
   static const uint32_t kCanvasMaxInvalidateCount = 100;
@@ -804,17 +804,17 @@ protected:
     * State information for hit regions
     */
   struct RegionInfo
   {
     nsString          mId;
     // fallback element for a11y
     nsRefPtr<Element> mElement;
     // Path of the hit region in the 2d context coordinate space (not user space)
-    RefPtr<gfx::Path> mPath;
+    nsRefPtr<gfx::Path> mPath;
   };
 
   nsTArray<RegionInfo> mHitRegionsOptions;
 
   /**
     * Returns true if a shadow should be drawn along with a
     * drawing operation.
     */
@@ -979,17 +979,17 @@ protected:
       return (int32_t)floor(ShadowBlurSigma() * GAUSSIAN_SCALE_FACTOR + 0.5);
     }
 
     mozilla::gfx::Float ShadowBlurSigma() const
     {
       return std::min(SIGMA_MAX, shadowBlur / 2.0f);
     }
 
-    nsTArray<mozilla::RefPtr<mozilla::gfx::Path> > clipsPushed;
+    nsTArray<nsRefPtr<mozilla::gfx::Path> > clipsPushed;
 
     nsRefPtr<gfxFontGroup> fontGroup;
     nsCOMPtr<nsIAtom> fontLanguage;
     nsFont fontFont;
 
     EnumeratedArray<Style, Style::MAX, nsRefPtr<CanvasGradient>> gradientStyles;
     EnumeratedArray<Style, Style::MAX, nsRefPtr<CanvasPattern>> patternStyles;
     EnumeratedArray<Style, Style::MAX, nscolor> colorStyles;
@@ -1013,17 +1013,17 @@ protected:
     mozilla::gfx::FillRule fillRule;
     mozilla::gfx::CapStyle lineCap;
     mozilla::gfx::JoinStyle lineJoin;
 
     nsString filterString;
     nsTArray<nsStyleFilter> filterChain;
     nsRefPtr<nsSVGFilterChainObserver> filterChainObserver;
     mozilla::gfx::FilterDescription filter;
-    nsTArray<mozilla::RefPtr<mozilla::gfx::SourceSurface>> filterAdditionalImages;
+    nsTArray<nsRefPtr<mozilla::gfx::SourceSurface>> filterAdditionalImages;
 
     bool imageSmoothingEnabled;
     bool fontExplicitLanguage;
   };
 
   nsAutoTArray<ContextState, 3> mStyleStack;
 
   inline ContextState& CurrentState() {
--- a/dom/canvas/DocumentRendererChild.cpp
+++ b/dom/canvas/DocumentRendererChild.cpp
@@ -4,17 +4,17 @@
 
 #include "mozilla/ipc/DocumentRendererChild.h"
 
 #include "base/basictypes.h"
 
 #include "gfx2DGlue.h"
 #include "gfxPattern.h"
 #include "mozilla/gfx/2D.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
 #include "nsIDocShell.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCSSParser.h"
 #include "nsPresContext.h"
 #include "nsCOMPtr.h"
@@ -69,17 +69,17 @@ DocumentRendererChild::RenderDocument(ns
     nscolor bgColor;
     if (!nsRuleNode::ComputeColor(bgColorValue, presContext, nullptr, bgColor)) {
         return false;
     }
 
     // Draw directly into the output array.
     data.SetLength(renderSize.width * renderSize.height * 4);
 
-    RefPtr<DrawTarget> dt =
+    nsRefPtr<DrawTarget> dt =
         Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                          reinterpret_cast<uint8_t*>(data.BeginWriting()),
                                          IntSize(renderSize.width, renderSize.height),
                                          4 * renderSize.width,
                                          SurfaceFormat::B8G8R8A8);
     if (!dt) {
         gfxWarning() << "DocumentRendererChild::RenderDocument failed to Factory::CreateDrawTargetForData";
         return false;
--- a/dom/canvas/DocumentRendererParent.cpp
+++ b/dom/canvas/DocumentRendererParent.cpp
@@ -2,17 +2,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/. */
 
 #include "mozilla/ipc/DocumentRendererParent.h"
 
 #include "gfx2DGlue.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsICanvasRenderingContextInternal.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::ipc;
 
 DocumentRendererParent::DocumentRendererParent()
 {}
@@ -31,17 +31,17 @@ void DocumentRendererParent::DrawToCanva
                                           const nsCString& aData)
 {
     if (!mCanvas || !mCanvasContext)
         return;
 
     DrawTarget* drawTarget = mCanvasContext->GetDrawTarget();
     Rect rect(0, 0, aSize.width, aSize.height);
     MaybeSnapToDevicePixels(rect, *drawTarget, true);
-    RefPtr<DataSourceSurface> dataSurface =
+    nsRefPtr<DataSourceSurface> dataSurface =
         Factory::CreateWrappingDataSourceSurface(reinterpret_cast<uint8_t*>(const_cast<nsCString&>(aData).BeginWriting()),
                                                  aSize.width * 4,
                                                  IntSize(aSize.width, aSize.height),
                                                  SurfaceFormat::B8G8R8A8);
     SurfacePattern pattern(dataSurface, ExtendMode::CLAMP);
     drawTarget->FillRect(rect, pattern);
 
     gfxRect damageRect = mCanvasContext->UserToDevice(ThebesRect(rect));
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -100,17 +100,17 @@ CropAndCopyDataSourceSurface(DataSourceS
   // So, instead, we force the output format to be SurfaceFormat::B8G8R8A8.
   const SurfaceFormat format = SurfaceFormat::B8G8R8A8;
   const int bytesPerPixel = BytesPerPixel(format);
   const IntSize dstSize = IntSize(positiveCropRect.width,
                                   positiveCropRect.height);
   const uint32_t dstStride = dstSize.width * bytesPerPixel;
 
   // Create a new SourceSurface.
-  RefPtr<DataSourceSurface> dstDataSurface =
+  nsRefPtr<DataSourceSurface> dstDataSurface =
     Factory::CreateDataSourceSurfaceWithStride(dstSize, format, dstStride, true);
 
   if (NS_WARN_IF(!dstDataSurface)) {
     return nullptr;
   }
 
   // Only do copying and cropping when the positiveCropRect intersects with
   // the size of aSurface.
@@ -176,30 +176,30 @@ CreateSurfaceFromRawData(const gfx::IntS
                          uint32_t aBufferLength,
                          const Maybe<IntRect>& aCropRect,
                          ErrorResult& aRv)
 {
   MOZ_ASSERT(!aSize.IsEmpty());
   MOZ_ASSERT(aBuffer);
 
   // Wrap the source buffer into a SourceSurface.
-  RefPtr<DataSourceSurface> dataSurface =
+  nsRefPtr<DataSourceSurface> dataSurface =
     Factory::CreateWrappingDataSourceSurface(aBuffer, aStride, aSize, aFormat);
 
   if (NS_WARN_IF(!dataSurface)) {
     aRv.Throw(NS_ERROR_NOT_AVAILABLE);
     return nullptr;
   }
 
   // The temporary cropRect variable is equal to the size of source buffer if we
   // do not need to crop, or it equals to the given cropping size.
   const IntRect cropRect = aCropRect.valueOr(IntRect(0, 0, aSize.width, aSize.height));
 
   // Copy the source buffer in the _cropRect_ area into a new SourceSurface.
-  RefPtr<DataSourceSurface> result = CropAndCopyDataSourceSurface(dataSurface, cropRect);
+  nsRefPtr<DataSourceSurface> result = CropAndCopyDataSourceSurface(dataSurface, cropRect);
 
   if (NS_WARN_IF(!result)) {
     aRv.Throw(NS_ERROR_NOT_AVAILABLE);
     return nullptr;
   }
 
   return result.forget();
 }
@@ -211,28 +211,28 @@ CreateImageFromRawData(const gfx::IntSiz
                        uint8_t* aBuffer,
                        uint32_t aBufferLength,
                        const Maybe<IntRect>& aCropRect,
                        ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Copy and crop the source buffer into a SourceSurface.
-  RefPtr<SourceSurface> rgbaSurface =
+  nsRefPtr<SourceSurface> rgbaSurface =
     CreateSurfaceFromRawData(aSize, aStride, aFormat,
                              aBuffer, aBufferLength,
                              aCropRect, aRv);
 
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   // Convert RGBA to BGRA
-  RefPtr<DataSourceSurface> rgbaDataSurface = rgbaSurface->GetDataSurface();
-  RefPtr<DataSourceSurface> bgraDataSurface =
+  nsRefPtr<DataSourceSurface> rgbaDataSurface = rgbaSurface->GetDataSurface();
+  nsRefPtr<DataSourceSurface> bgraDataSurface =
     Factory::CreateDataSourceSurfaceWithStride(rgbaDataSurface->GetSize(),
                                                SurfaceFormat::B8G8R8A8,
                                                rgbaDataSurface->Stride());
 
   DataSourceSurface::MappedSurface rgbaMap;
   DataSourceSurface::MappedSurface bgraMap;
 
   if (NS_WARN_IF(!rgbaDataSurface->Map(DataSourceSurface::MapType::READ, &rgbaMap)) ||
@@ -363,17 +363,17 @@ GetSurfaceFromElement(nsIGlobalObject* a
     return nullptr;
   }
 
   if (NS_WARN_IF(!res.mSourceSurface)) {
     aRv.Throw(NS_ERROR_NOT_AVAILABLE);
     return nullptr;
   }
 
-  RefPtr<SourceSurface> surface(res.mSourceSurface);
+  nsRefPtr<SourceSurface> surface(res.mSourceSurface);
   return surface.forget();
 }
 
 /*
  * The specification doesn't allow to create an ImegeBitmap from a vector image.
  * This function is used to check if the given HTMLImageElement contains a
  * raster image.
  */
@@ -430,60 +430,60 @@ ImageBitmap::PrepareForDrawTarget(gfx::D
   if (!mSurface) {
     mSurface = mData->GetAsSourceSurface();
   }
 
   if (!mSurface) {
     return nullptr;
   }
 
-  RefPtr<DrawTarget> target = aTarget;
+  nsRefPtr<DrawTarget> target = aTarget;
   IntRect surfRect(0, 0, mSurface->GetSize().width, mSurface->GetSize().height);
 
   // Check if we still need to crop our surface
   if (!mPictureRect.IsEqualEdges(surfRect)) {
 
     IntRect surfPortion = surfRect.Intersect(mPictureRect);
 
     // the crop lies entirely outside the surface area, nothing to draw
     if (surfPortion.IsEmpty()) {
       mSurface = nullptr;
-      RefPtr<gfx::SourceSurface> surface(mSurface);
+      nsRefPtr<gfx::SourceSurface> surface(mSurface);
       return surface.forget();
     }
 
     IntPoint dest(std::max(0, surfPortion.X() - mPictureRect.X()),
                   std::max(0, surfPortion.Y() - mPictureRect.Y()));
 
     // We must initialize this target with mPictureRect.Size() because the
     // specification states that if the cropping area is given, then return an
     // ImageBitmap with the size equals to the cropping area.
     target = target->CreateSimilarDrawTarget(mPictureRect.Size(),
                                              target->GetFormat());
 
     if (!target) {
       mSurface = nullptr;
-      RefPtr<gfx::SourceSurface> surface(mSurface);
+      nsRefPtr<gfx::SourceSurface> surface(mSurface);
       return surface.forget();
     }
 
     // We need to fall back to generic copying and cropping for the Windows8.1,
     // D2D1 backend.
     // In the Windows8.1 D2D1 backend, it might trigger "partial upload" from a
     // non-SourceSurfaceD2D1 surface to a D2D1Image in the following
     // CopySurface() step. However, the "partial upload" only supports uploading
     // a rectangle starts from the upper-left point, which means it cannot
     // upload an arbitrary part of the source surface and this causes problems
     // if the mPictureRect is not starts from the upper-left point.
     if (target->GetBackendType() == BackendType::DIRECT2D1_1 &&
         mSurface->GetType() != SurfaceType::D2D1_1_IMAGE) {
-      RefPtr<DataSourceSurface> dataSurface = mSurface->GetDataSurface();
+      nsRefPtr<DataSourceSurface> dataSurface = mSurface->GetDataSurface();
       if (NS_WARN_IF(!dataSurface)) {
         mSurface = nullptr;
-        RefPtr<gfx::SourceSurface> surface(mSurface);
+        nsRefPtr<gfx::SourceSurface> surface(mSurface);
         return surface.forget();
       }
 
       mSurface = CropAndCopyDataSourceSurface(dataSurface, mPictureRect);
     } else {
       target->CopySurface(mSurface, surfPortion, dest);
       mSurface = target->Snapshot();
     }
@@ -492,17 +492,17 @@ ImageBitmap::PrepareForDrawTarget(gfx::D
     mPictureRect.MoveTo(0, 0);
   }
 
   // Replace our surface with one optimized for the target we're about to draw
   // to, under the assumption it'll likely be drawn again to that target.
   // This call should be a no-op for already-optimized surfaces
   mSurface = target->OptimizeSourceSurface(mSurface);
 
-  RefPtr<gfx::SourceSurface> surface(mSurface);
+  nsRefPtr<gfx::SourceSurface> surface(mSurface);
   return surface.forget();
 }
 
 /* static */ already_AddRefed<ImageBitmap>
 ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLImageElement& aImageEl,
                             const Maybe<IntRect>& aCropRect, ErrorResult& aRv)
 {
   // Check if the image element is completely available or not.
@@ -514,17 +514,17 @@ ImageBitmap::CreateInternal(nsIGlobalObj
   // Check if the image element is a bitmap (e.g. it's a vector graphic) or not.
   if (!HasRasterImage(aImageEl)) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
   // Get the SourceSurface out from the image element and then do security
   // checking.
-  RefPtr<SourceSurface> surface = GetSurfaceFromElement(aGlobal, aImageEl, aRv);
+  nsRefPtr<SourceSurface> surface = GetSurfaceFromElement(aGlobal, aImageEl, aRv);
 
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   // Create ImageBitmap.
   nsRefPtr<layers::Image> data = CreateImageFromSurface(surface, aRv);
 
@@ -591,37 +591,37 @@ ImageBitmap::CreateInternal(nsIGlobalObj
 ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLCanvasElement& aCanvasEl,
                             const Maybe<IntRect>& aCropRect, ErrorResult& aRv)
 {
   if (aCanvasEl.Width() == 0 || aCanvasEl.Height() == 0) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
-  RefPtr<SourceSurface> surface = GetSurfaceFromElement(aGlobal, aCanvasEl, aRv);
+  nsRefPtr<SourceSurface> surface = GetSurfaceFromElement(aGlobal, aCanvasEl, aRv);
 
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   // Crop the source surface if needed.
-  RefPtr<SourceSurface> croppedSurface;
+  nsRefPtr<SourceSurface> croppedSurface;
   IntRect cropRect = aCropRect.valueOr(IntRect());
 
   // If the HTMLCanvasElement's rendering context is WebGL, then the snapshot
   // we got from the HTMLCanvasElement is a DataSourceSurface which is a copy
   // of the rendering context. We handle cropping in this case.
   if ((aCanvasEl.GetCurrentContextType() == CanvasContextType::WebGL1 ||
        aCanvasEl.GetCurrentContextType() == CanvasContextType::WebGL2) &&
       aCropRect.isSome()) {
     // The _surface_ must be a DataSourceSurface.
     MOZ_ASSERT(surface->GetType() == SurfaceType::DATA,
                "The snapshot SourceSurface from WebGL rendering contest is not \
                DataSourceSurface.");
-    RefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();
+    nsRefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();
     croppedSurface = CropAndCopyDataSourceSurface(dataSurface, cropRect);
     cropRect.MoveTo(0, 0);
   }
   else {
     croppedSurface = surface;
   }
 
   if (NS_WARN_IF(!croppedSurface)) {
@@ -708,17 +708,17 @@ ImageBitmap::CreateInternal(nsIGlobalObj
                             const Maybe<IntRect>& aCropRect, ErrorResult& aRv)
 {
   // Check origin-clean.
   if (aCanvasCtx.GetCanvas()->IsWriteOnly()) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return nullptr;
   }
 
-  RefPtr<SourceSurface> surface = aCanvasCtx.GetSurfaceSnapshot();
+  nsRefPtr<SourceSurface> surface = aCanvasCtx.GetSurfaceSnapshot();
 
   if (NS_WARN_IF(!surface)) {
     aRv.Throw(NS_ERROR_NOT_AVAILABLE);
     return nullptr;
   }
 
   const IntSize surfaceSize = surface->GetSize();
   if (surfaceSize.width == 0 || surfaceSize.height == 0) {
@@ -858,53 +858,53 @@ DecodeBlob(Blob& aBlob, ErrorResult& aRv
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
   // Get the surface out.
   uint32_t frameFlags = imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_WANT_DATA_SURFACE;
   uint32_t whichFrame = imgIContainer::FRAME_FIRST;
-  RefPtr<SourceSurface> surface = imgContainer->GetFrame(whichFrame, frameFlags);
+  nsRefPtr<SourceSurface> surface = imgContainer->GetFrame(whichFrame, frameFlags);
 
   if (NS_WARN_IF(!surface)) {
     aRv.Throw(NS_ERROR_NOT_AVAILABLE);
     return nullptr;
   }
 
   return surface.forget();
 }
 
 static already_AddRefed<layers::Image>
 DecodeAndCropBlob(Blob& aBlob, Maybe<IntRect>& aCropRect, ErrorResult& aRv)
 {
   // Decode the blob into a SourceSurface.
-  RefPtr<SourceSurface> surface = DecodeBlob(aBlob, aRv);
+  nsRefPtr<SourceSurface> surface = DecodeBlob(aBlob, aRv);
 
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   // Crop the source surface if needed.
-  RefPtr<SourceSurface> croppedSurface = surface;
+  nsRefPtr<SourceSurface> croppedSurface = surface;
 
   if (aCropRect.isSome()) {
     // The blob is just decoded into a RasterImage and not optimized yet, so the
     // _surface_ we get is a DataSourceSurface which wraps the RasterImage's
     // raw buffer.
     //
     // The _surface_ might already be optimized so that its type is not
     // SurfaceType::DATA. However, we could keep using the generic cropping and
     // copying since the decoded buffer is only used in this ImageBitmap so we
     // should crop it to save memory usage.
     //
     // TODO: Bug1189632 is going to refactor this create-from-blob part to
     //       decode the blob off the main thread. Re-check if we should do
     //       cropping at this moment again there.
-    RefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();
+    nsRefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();
     croppedSurface = CropAndCopyDataSourceSurface(dataSurface, aCropRect.ref());
     aCropRect->MoveTo(0, 0);
   }
 
   if (NS_WARN_IF(!croppedSurface)) {
     aRv.Throw(NS_ERROR_NOT_AVAILABLE);
     return nullptr;
   }
@@ -959,17 +959,17 @@ protected:
     mPromise->MaybeResolve(imageBitmap);
     return;
   }
 
   virtual already_AddRefed<ImageBitmap> CreateImageBitmap(ErrorResult& aRv) = 0;
 
   nsRefPtr<Promise> mPromise;
   nsCOMPtr<nsIGlobalObject> mGlobalObject;
-  RefPtr<mozilla::dom::Blob> mBlob;
+  nsRefPtr<mozilla::dom::Blob> mBlob;
   Maybe<IntRect> mCropRect;
 };
 
 class CreateImageBitmapFromBlobTask final : public nsRunnable,
                                             public CreateImageBitmapFromBlob
 {
 public:
   CreateImageBitmapFromBlobTask(Promise* aPromise,
--- a/dom/canvas/ImageBitmap.h
+++ b/dom/canvas/ImageBitmap.h
@@ -154,17 +154,17 @@ protected:
    * called first time.
    *
    * The mSurface might just be a reference to the same data buffer of the mData
    * if the are of mPictureRect is just the same as the mData's size. Or, it is
    * a independent data buffer which is copied and cropped form the mData's data
    * buffer.
    */
   nsRefPtr<layers::Image> mData;
-  RefPtr<gfx::SourceSurface> mSurface;
+  nsRefPtr<gfx::SourceSurface> mSurface;
 
   /*
    * The mPictureRect is the size of the source image in default, however, if
    * users specify the cropping area while creating an ImageBitmap, then this
    * mPictureRect is the cropping area.
    *
    * Note that if the CreateInternal() copies and crops data from the source
    * image, then this mPictureRect is just the size of the final mData.
--- a/dom/canvas/OffscreenCanvas.h
+++ b/dom/canvas/OffscreenCanvas.h
@@ -4,17 +4,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_DOM_OFFSCREENCANVAS_H_
 #define MOZILLA_DOM_OFFSCREENCANVAS_H_
 
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/layers/LayersTypes.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "CanvasRenderingContextHelper.h"
 #include "nsCycleCollectionParticipant.h"
 
 struct JSContext;
 
 namespace mozilla {
 
 class ErrorResult;
@@ -33,17 +33,17 @@ namespace dom {
 struct OffscreenCanvasCloneData final
 {
   OffscreenCanvasCloneData(layers::AsyncCanvasRenderer* aRenderer,
                            uint32_t aWidth, uint32_t aHeight,
                            layers::LayersBackend aCompositorBackend,
                            bool aNeutered);
   ~OffscreenCanvasCloneData();
 
-  RefPtr<layers::AsyncCanvasRenderer> mRenderer;
+  nsRefPtr<layers::AsyncCanvasRenderer> mRenderer;
   uint32_t mWidth;
   uint32_t mHeight;
   layers::LayersBackend mCompositorBackendType;
   bool mNeutered;
 };
 
 class OffscreenCanvas final : public DOMEventTargetHelper
                             , public CanvasRenderingContextHelper
@@ -165,15 +165,15 @@ private:
   bool mNeutered;
 
   uint32_t mWidth;
   uint32_t mHeight;
 
   layers::LayersBackend mCompositorBackendType;
 
   layers::CanvasClient* mCanvasClient;
-  RefPtr<layers::AsyncCanvasRenderer> mCanvasRenderer;
+  nsRefPtr<layers::AsyncCanvasRenderer> mCanvasRenderer;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // MOZILLA_DOM_OFFSCREENCANVAS_H_
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -556,17 +556,17 @@ BaseCaps(const WebGLContextOptions& opti
 }
 
 ////////////////////////////////////////
 
 static already_AddRefed<gl::GLContext>
 CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
                 WebGLContext* webgl)
 {
-    RefPtr<GLContext> gl;
+    nsRefPtr<GLContext> gl;
 #ifndef XP_MACOSX // Mac doesn't have GLContextProviderEGL.
     gfx::IntSize dummySize(16, 16);
     gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
                                                                      flags);
     if (!gl) {
         webgl->GenerateWarning("Error during EGL OpenGL init.");
         return nullptr;
     }
@@ -576,17 +576,17 @@ CreateGLWithEGL(const gl::SurfaceCaps& c
 #endif // XP_MACOSX
     return gl.forget();
 }
 
 static already_AddRefed<GLContext>
 CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
                   WebGLContext* webgl)
 {
-    RefPtr<GLContext> gl;
+    nsRefPtr<GLContext> gl;
 
 #ifdef XP_WIN
     gfx::IntSize dummySize(16, 16);
     gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps, flags);
     if (!gl) {
         webgl->GenerateWarning("Error during ANGLE OpenGL init.");
         return nullptr;
     }
@@ -608,17 +608,17 @@ CreateGLWithDefault(const gl::SurfaceCap
         IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_OPENGL))
     {
         webgl->GenerateWarning("Refused to create native OpenGL context because of"
                                " blacklisting.");
         return nullptr;
     }
 
     gfx::IntSize dummySize(16, 16);
-    RefPtr<GLContext> gl = gl::GLContextProvider::CreateOffscreen(dummySize, caps, flags);
+    nsRefPtr<GLContext> gl = gl::GLContextProvider::CreateOffscreen(dummySize, caps, flags);
     if (!gl) {
         webgl->GenerateWarning("Error during native OpenGL init.");
         return nullptr;
     }
 
     if (gl->IsANGLE())
         return nullptr;
 
@@ -1050,48 +1050,48 @@ WebGLContext::LoseOldestWebGLContextIfLi
 void
 WebGLContext::GetImageBuffer(uint8_t** out_imageBuffer, int32_t* out_format)
 {
     *out_imageBuffer = nullptr;
     *out_format = 0;
 
     // Use GetSurfaceSnapshot() to make sure that appropriate y-flip gets applied
     bool premult;
-    RefPtr<SourceSurface> snapshot =
+    nsRefPtr<SourceSurface> snapshot =
       GetSurfaceSnapshot(mOptions.premultipliedAlpha ? nullptr : &premult);
     if (!snapshot)
         return;
 
     MOZ_ASSERT(mOptions.premultipliedAlpha || !premult, "We must get unpremult when we ask for it!");
 
-    RefPtr<DataSourceSurface> dataSurface = snapshot->GetDataSurface();
+    nsRefPtr<DataSourceSurface> dataSurface = snapshot->GetDataSurface();
 
     return gfxUtils::GetImageBuffer(dataSurface, mOptions.premultipliedAlpha,
                                     out_imageBuffer, out_format);
 }
 
 NS_IMETHODIMP
 WebGLContext::GetInputStream(const char* mimeType,
                              const char16_t* encoderOptions,
                              nsIInputStream** out_stream)
 {
     NS_ASSERTION(gl, "GetInputStream on invalid context?");
     if (!gl)
         return NS_ERROR_FAILURE;
 
     // Use GetSurfaceSnapshot() to make sure that appropriate y-flip gets applied
     bool premult;
-    RefPtr<SourceSurface> snapshot =
+    nsRefPtr<SourceSurface> snapshot =
       GetSurfaceSnapshot(mOptions.premultipliedAlpha ? nullptr : &premult);
     if (!snapshot)
         return NS_ERROR_FAILURE;
 
     MOZ_ASSERT(mOptions.premultipliedAlpha || !premult, "We must get unpremult when we ask for it!");
 
-    RefPtr<DataSourceSurface> dataSurface = snapshot->GetDataSurface();
+    nsRefPtr<DataSourceSurface> dataSurface = snapshot->GetDataSurface();
     return gfxUtils::GetInputStream(dataSurface, mOptions.premultipliedAlpha, mimeType,
                                     encoderOptions, out_stream);
 }
 
 void
 WebGLContext::UpdateLastUseIndex()
 {
     static CheckedInt<uint64_t> sIndex = 0;
@@ -1747,17 +1747,17 @@ already_AddRefed<mozilla::gfx::SourceSur
 WebGLContext::GetSurfaceSnapshot(bool* out_premultAlpha)
 {
     if (!gl)
         return nullptr;
 
     bool hasAlpha = mOptions.alpha;
     SurfaceFormat surfFormat = hasAlpha ? SurfaceFormat::B8G8R8A8
                                         : SurfaceFormat::B8G8R8X8;
-    RefPtr<DataSourceSurface> surf;
+    nsRefPtr<DataSourceSurface> surf;
     surf = Factory::CreateDataSourceSurfaceWithStride(IntSize(mWidth, mHeight),
                                                       surfFormat,
                                                       mWidth * 4);
     if (NS_WARN_IF(!surf)) {
         return nullptr;
     }
 
     gl->MakeCurrent();
@@ -1775,17 +1775,17 @@ WebGLContext::GetSurfaceSnapshot(bool* o
     if (!srcPremultAlpha) {
         if (out_premultAlpha) {
             *out_premultAlpha = false;
         } else if(hasAlpha) {
             gfxUtils::PremultiplyDataSurface(surf, surf);
         }
     }
 
-    RefPtr<DrawTarget> dt =
+    nsRefPtr<DrawTarget> dt =
         Factory::CreateDrawTarget(BackendType::CAIRO,
                                   IntSize(mWidth, mHeight),
                                   SurfaceFormat::B8G8R8A8);
 
     if (!dt) {
         return nullptr;
     }
 
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1285,17 +1285,17 @@ protected:
     template<class ElementType>
     nsLayoutUtils::SurfaceFromElementResult
     SurfaceFromElement(ElementType& element) {
        return SurfaceFromElement(&element);
     }
 
     nsresult
     SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromElementResult& res,
-                                           RefPtr<gfx::DataSourceSurface>& imageOut,
+                                           nsRefPtr<gfx::DataSourceSurface>& imageOut,
                                            WebGLTexelFormat* format);
 
     // Returns false if `object` is null or not valid.
     template<class ObjectType>
     bool ValidateObject(const char* info, ObjectType* object);
 
     // Returns false if `object` is not valid.  Considers null to be valid.
     template<class ObjectType>
@@ -1355,17 +1355,17 @@ protected:
     nsTArray<WebGLRefPtr<WebGLTexture> > mBound2DTextures;
     nsTArray<WebGLRefPtr<WebGLTexture> > mBoundCubeMapTextures;
     nsTArray<WebGLRefPtr<WebGLTexture> > mBound3DTextures;
     nsTArray<WebGLRefPtr<WebGLSampler> > mBoundSamplers;
 
     void ResolveTexturesForDraw() const;
 
     WebGLRefPtr<WebGLProgram> mCurrentProgram;
-    RefPtr<const webgl::LinkedProgramInfo> mActiveProgramLinkInfo;
+    nsRefPtr<const webgl::LinkedProgramInfo> mActiveProgramLinkInfo;
 
     GLenum LastColorAttachment() const {
         return LOCAL_GL_COLOR_ATTACHMENT0 + mGLMaxColorAttachments - 1;
     }
 
     bool ValidateFramebufferTarget(GLenum target, const char* const info);
 
     WebGLRefPtr<WebGLFramebuffer> mBoundDrawFramebuffer;
@@ -1448,17 +1448,17 @@ protected:
     GLfloat mDepthClearValue;
 
     GLint mViewportX;
     GLint mViewportY;
     GLsizei mViewportWidth;
     GLsizei mViewportHeight;
     bool mAlreadyWarnedAboutViewportLargerThanDest;
 
-    RefPtr<WebGLContextLossHandler> mContextLossHandler;
+    nsRefPtr<WebGLContextLossHandler> mContextLossHandler;
     bool mAllowContextRestore;
     bool mLastLossWasSimulated;
     ContextStatus mContextStatus;
     bool mContextLostErrorSet;
 
     // Used for some hardware (particularly Tegra 2 and 4) that likes to
     // be Flushed while doing hundreds of draw calls.
     int mDrawCallsSinceLastFlush;
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -1880,24 +1880,24 @@ WebGLContext::StencilOpSeparate(GLenum f
         return;
 
     MakeContextCurrent();
     gl->fStencilOpSeparate(face, sfail, dpfail, dppass);
 }
 
 nsresult
 WebGLContext::SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromElementResult& res,
-                                                     RefPtr<DataSourceSurface>& imageOut,
+                                                     nsRefPtr<DataSourceSurface>& imageOut,
                                                      WebGLTexelFormat* format)
 {
    *format = WebGLTexelFormat::None;
 
     if (!res.mSourceSurface)
         return NS_OK;
-    RefPtr<DataSourceSurface> data = res.mSourceSurface->GetDataSurface();
+    nsRefPtr<DataSourceSurface> data = res.mSourceSurface->GetDataSurface();
     if (!data) {
         // SurfaceFromElement lied!
         return NS_OK;
     }
 
     // We disallow loading cross-domain images and videos that have not been validated
     // with CORS as WebGL textures. The reason for doing that is that timing
     // attacks on WebGL shaders are able to retrieve approximations of the
--- a/dom/canvas/WebGLProgram.cpp
+++ b/dom/canvas/WebGLProgram.cpp
@@ -66,43 +66,43 @@ ParseName(const nsCString& name, nsCStri
     *out_isArray = true;
     *out_arrayIndex = indexNum;
     return true;
 }
 
 static void
 AddActiveInfo(WebGLContext* webgl, GLint elemCount, GLenum elemType, bool isArray,
               const nsACString& baseUserName, const nsACString& baseMappedName,
-              std::vector<RefPtr<WebGLActiveInfo>>* activeInfoList,
+              std::vector<nsRefPtr<WebGLActiveInfo>>* activeInfoList,
               std::map<nsCString, const WebGLActiveInfo*>* infoLocMap)
 {
-    RefPtr<WebGLActiveInfo> info = new WebGLActiveInfo(webgl, elemCount, elemType,
+    nsRefPtr<WebGLActiveInfo> info = new WebGLActiveInfo(webgl, elemCount, elemType,
                                                        isArray, baseUserName,
                                                        baseMappedName);
     activeInfoList->push_back(info);
 
     infoLocMap->insert(std::make_pair(info->mBaseUserName, info.get()));
 }
 
 static void
 AddActiveBlockInfo(const nsACString& baseUserName,
                    const nsACString& baseMappedName,
-                   std::vector<RefPtr<webgl::UniformBlockInfo>>* activeInfoList)
+                   std::vector<nsRefPtr<webgl::UniformBlockInfo>>* activeInfoList)
 {
-    RefPtr<webgl::UniformBlockInfo> info = new webgl::UniformBlockInfo(baseUserName, baseMappedName);
+    nsRefPtr<webgl::UniformBlockInfo> info = new webgl::UniformBlockInfo(baseUserName, baseMappedName);
 
     activeInfoList->push_back(info);
 }
 
 //#define DUMP_SHADERVAR_MAPPINGS
 
 static already_AddRefed<const webgl::LinkedProgramInfo>
 QueryProgramInfo(WebGLProgram* prog, gl::GLContext* gl)
 {
-    RefPtr<webgl::LinkedProgramInfo> info(new webgl::LinkedProgramInfo(prog));
+    nsRefPtr<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)
         maxAttribLenWithNull = 1;
 
     GLuint maxUniformLenWithNull = 0;
@@ -432,17 +432,17 @@ WebGLProgram::GetActiveAttrib(GLuint ind
     const auto& activeList = mMostRecentLinkInfo->activeAttribs;
 
     if (index >= activeList.size()) {
         mContext->ErrorInvalidValue("`index` (%i) must be less than %s (%i).",
                                     index, "ACTIVE_ATTRIBS", activeList.size());
         return nullptr;
     }
 
-    RefPtr<WebGLActiveInfo> ret = activeList[index];
+    nsRefPtr<WebGLActiveInfo> ret = activeList[index];
     return ret.forget();
 }
 
 already_AddRefed<WebGLActiveInfo>
 WebGLProgram::GetActiveUniform(GLuint index) const
 {
     if (!mMostRecentLinkInfo) {
         // According to the spec, this can return null.
@@ -453,17 +453,17 @@ WebGLProgram::GetActiveUniform(GLuint in
     const auto& activeList = mMostRecentLinkInfo->activeUniforms;
 
     if (index >= activeList.size()) {
         mContext->ErrorInvalidValue("`index` (%i) must be less than %s (%i).",
                                     index, "ACTIVE_UNIFORMS", activeList.size());
         return nullptr;
     }
 
-    RefPtr<WebGLActiveInfo> ret = activeList[index];
+    nsRefPtr<WebGLActiveInfo> ret = activeList[index];
     return ret.forget();
 }
 
 void
 WebGLProgram::GetAttachedShaders(nsTArray<nsRefPtr<WebGLShader>>* const out) const
 {
     out->TruncateLength(0);
 
@@ -593,17 +593,17 @@ WebGLProgram::GetUniformBlockIndex(const
     const NS_LossyConvertUTF16toASCII userName(userName_wide);
 
     nsDependentCString baseUserName;
     bool isArray;
     size_t arrayIndex;
     if (!ParseName(userName, &baseUserName, &isArray, &arrayIndex))
         return LOCAL_GL_INVALID_INDEX;
 
-    RefPtr<const webgl::UniformBlockInfo> info;
+    nsRefPtr<const webgl::UniformBlockInfo> info;
     if (!LinkInfo()->FindUniformBlock(baseUserName, &info)) {
         return LOCAL_GL_INVALID_INDEX;
     }
 
     const nsCString& baseMappedName = info->mBaseMappedName;
     nsAutoCString mappedName(baseMappedName);
     if (isArray) {
         mappedName.AppendLiteral("[");
@@ -1020,17 +1020,17 @@ WebGLProgram::GetTransformFeedbackVaryin
     }
 
     const nsCString& varyingUserName = mTransformFeedbackVaryings[index];
 
     WebGLActiveInfo* info;
     LinkInfo()->FindAttrib(varyingUserName, (const WebGLActiveInfo**) &info);
     MOZ_ASSERT(info);
 
-    RefPtr<WebGLActiveInfo> ret(info);
+    nsRefPtr<WebGLActiveInfo> ret(info);
     return ret.forget();
 }
 
 bool
 WebGLProgram::FindUniformBlockByMappedName(const nsACString& mappedName,
                                            nsCString* const out_userName,
                                            bool* const out_isArray) const
 {
--- a/dom/canvas/WebGLProgram.h
+++ b/dom/canvas/WebGLProgram.h
@@ -6,17 +6,17 @@
 #ifndef WEBGL_PROGRAM_H_
 #define WEBGL_PROGRAM_H_
 
 #include <map>
 #include <set>
 #include <vector>
 
 #include "mozilla/LinkedList.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/WeakPtr.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 
 #include "WebGLObjectModel.h"
 
 
 template<class> class nsRefPtr;
@@ -54,26 +54,26 @@ struct UniformBlockInfo final
 struct LinkedProgramInfo final
     : public RefCounted<LinkedProgramInfo>
     , public SupportsWeakPtr<LinkedProgramInfo>
 {
     MOZ_DECLARE_REFCOUNTED_TYPENAME(LinkedProgramInfo)
     MOZ_DECLARE_WEAKREFERENCE_TYPENAME(LinkedProgramInfo)
 
     WebGLProgram* const prog;
-    std::vector<RefPtr<WebGLActiveInfo>> activeAttribs;
-    std::vector<RefPtr<WebGLActiveInfo>> activeUniforms;
+    std::vector<nsRefPtr<WebGLActiveInfo>> activeAttribs;
+    std::vector<nsRefPtr<WebGLActiveInfo>> activeUniforms;
 
     // Needed for Get{Attrib,Uniform}Location. The keys for these are non-mapped
     // user-facing `GLActiveInfo::name`s, without any final "[0]".
     std::map<nsCString, const WebGLActiveInfo*> attribMap;
     std::map<nsCString, const WebGLActiveInfo*> uniformMap;
     std::map<nsCString, const nsCString>* fragDataMap;
 
-    std::vector<RefPtr<UniformBlockInfo>> uniformBlocks;
+    std::vector<nsRefPtr<UniformBlockInfo>> uniformBlocks;
 
     // Needed for draw call validation.
     std::set<GLuint> activeAttribLocs;
 
     explicit LinkedProgramInfo(WebGLProgram* prog);
 
     bool FindAttrib(const nsCString& baseUserName,
                     const WebGLActiveInfo** const out_activeInfo) const
@@ -93,17 +93,17 @@ struct LinkedProgramInfo final
         if (itr == uniformMap.end())
             return false;
 
         *out_activeInfo = itr->second;
         return true;
     }
 
     bool FindUniformBlock(const nsCString& baseUserName,
-                          RefPtr<const UniformBlockInfo>* const out_info) const
+                          nsRefPtr<const UniformBlockInfo>* const out_info) const
     {
         const size_t count = uniformBlocks.size();
         for (size_t i = 0; i < count; i++) {
             if (baseUserName == uniformBlocks[i]->mBaseUserName) {
                 *out_info = uniformBlocks[i].get();
                 return true;
             }
         }
@@ -206,17 +206,17 @@ public:
 
 private:
     WebGLRefPtr<WebGLShader> mVertShader;
     WebGLRefPtr<WebGLShader> mFragShader;
     std::map<nsCString, GLuint> mBoundAttribLocs;
     std::vector<nsCString> mTransformFeedbackVaryings;
     GLenum mTransformFeedbackBufferMode;
     nsCString mLinkLog;
-    RefPtr<const webgl::LinkedProgramInfo> mMostRecentLinkInfo;
+    nsRefPtr<const webgl::LinkedProgramInfo> mMostRecentLinkInfo;
     // Storage for transform feedback varyings before link.
     // (Work around for bug seen on nVidia drivers.)
     std::vector<std::string> mTempMappedVaryings;
 };
 
 } // namespace mozilla
 
 #endif // WEBGL_PROGRAM_H_
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -691,17 +691,17 @@ WebGLTexture::TexImage2D(TexImageTarget 
 
     // Trying to handle the video by GPU directly first
     if (TexImageFromVideoElement(texImageTarget, level, internalFormat,
                                  unpackFormat, unpackType, elem))
     {
         return;
     }
 
-    RefPtr<gfx::DataSourceSurface> data;
+    nsRefPtr<gfx::DataSourceSurface> data;
     WebGLTexelFormat srcFormat;
     nsLayoutUtils::SurfaceFromElementResult res = mContext->SurfaceFromElement(elem);
     *out_rv = mContext->SurfaceFromElementResultToImageSurface(res, data, &srcFormat);
     if (out_rv->Failed() || !data)
         return;
 
     gfx::IntSize size = data->GetSize();
     uint32_t byteLength = data->Stride() * size.height;
@@ -1009,17 +1009,17 @@ WebGLTexture::TexSubImage2D(TexImageTarg
     const TexInternalFormat internalFormat = imageInfo.EffectiveInternalFormat();
 
     // Trying to handle the video by GPU directly first
     if (TexImageFromVideoElement(texImageTarget, level, internalFormat.get(), unpackFormat, unpackType, elem))
     {
         return;
     }
 
-    RefPtr<gfx::DataSourceSurface> data;
+    nsRefPtr<gfx::DataSourceSurface> data;
     WebGLTexelFormat srcFormat;
     nsLayoutUtils::SurfaceFromElementResult res = mContext->SurfaceFromElement(elem);
     *out_rv = mContext->SurfaceFromElementResultToImageSurface(res, data, &srcFormat);
     if (out_rv->Failed() || !data)
         return;
 
     gfx::IntSize size = data->GetSize();
     uint32_t byteLength = data->Stride() * size.height;
--- a/dom/canvas/nsICanvasRenderingContextInternal.h
+++ b/dom/canvas/nsICanvasRenderingContextInternal.h
@@ -8,17 +8,17 @@
 
 #include "mozilla/gfx/2D.h"
 #include "nsISupports.h"
 #include "nsIInputStream.h"
 #include "nsIDocShell.h"
 #include "nsRefreshDriver.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "mozilla/dom/OffscreenCanvas.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #define NS_ICANVASRENDERINGCONTEXTINTERNAL_IID \
 { 0xb84f2fed, 0x9d4b, 0x430b, \
   { 0xbd, 0xfb, 0x85, 0x57, 0x8a, 0xc2, 0xb4, 0x4b } }
 
 class gfxASurface;
 class nsDisplayListBuilder;
 
--- a/dom/devicestorage/DeviceStorage.h
+++ b/dom/devicestorage/DeviceStorage.h
@@ -5,17 +5,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef DeviceStorage_h
 #define DeviceStorage_h
 
 #include "nsIFile.h"
 #include "nsIPrincipal.h"
 #include "mozilla/DOMEventTargetHelper.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/dom/DOMRequest.h"
 #include "nsWeakReference.h"
 
 #define DEVICESTORAGE_PICTURES   "pictures"
 #define DEVICESTORAGE_VIDEOS     "videos"
 #define DEVICESTORAGE_MUSIC      "music"
 #define DEVICESTORAGE_APPS       "apps"
--- a/dom/html/HTMLCanvasElement.cpp
+++ b/dom/html/HTMLCanvasElement.cpp
@@ -62,29 +62,29 @@ public:
     : mRegistered(false),
       mOwningElement(aOwningElement),
       mRefreshDriver(aRefreshDriver)
   {
     MOZ_ASSERT(mOwningElement);
   }
 
   static already_AddRefed<DataSourceSurface>
-  CopySurface(const RefPtr<SourceSurface>& aSurface)
+  CopySurface(const nsRefPtr<SourceSurface>& aSurface)
   {
-    RefPtr<DataSourceSurface> data = aSurface->GetDataSurface();
+    nsRefPtr<DataSourceSurface> data = aSurface->GetDataSurface();
     if (!data) {
       return nullptr;
     }
 
     DataSourceSurface::ScopedMap read(data, DataSourceSurface::READ);
     if (!read.IsMapped()) {
       return nullptr;
     }
 
-    RefPtr<DataSourceSurface> copy =
+    nsRefPtr<DataSourceSurface> copy =
       Factory::CreateDataSourceSurfaceWithStride(data->GetSize(),
                                                  data->GetFormat(),
                                                  read.GetStride());
     if (!copy) {
       return nullptr;
     }
 
     DataSourceSurface::ScopedMap write(copy, DataSourceSurface::WRITE);
@@ -117,22 +117,22 @@ public:
     if (mOwningElement->IsContextCleanForFrameCapture()) {
       return;
     }
 
     if (!mOwningElement->IsFrameCaptureRequested()) {
       return;
     }
 
-    RefPtr<SourceSurface> snapshot = mOwningElement->GetSurfaceSnapshot(nullptr);
+    nsRefPtr<SourceSurface> snapshot = mOwningElement->GetSurfaceSnapshot(nullptr);
     if (!snapshot) {
       return;
     }
 
-    RefPtr<DataSourceSurface> copy = CopySurface(snapshot);
+    nsRefPtr<DataSourceSurface> copy = CopySurface(snapshot);
 
     mOwningElement->SetFrameCapture(copy.forget());
     mOwningElement->MarkContextCleanForFrameCapture();
   }
 
   void DetachFromRefreshDriver()
   {
     MOZ_ASSERT(mOwningElement);
@@ -172,17 +172,17 @@ private:
   virtual ~RequestedFrameRefreshObserver()
   {
     MOZ_ASSERT(!mRefreshDriver);
     MOZ_ASSERT(!mRegistered);
   }
 
   bool mRegistered;
   HTMLCanvasElement* const mOwningElement;
-  RefPtr<nsRefreshDriver> mRefreshDriver;
+  nsRefPtr<nsRefreshDriver> mRefreshDriver;
 };
 
 // ---------------------------------------------------------------------------
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(HTMLCanvasPrintState, mCanvas,
                                       mContext, mCallback)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(HTMLCanvasPrintState, AddRef)
@@ -1164,17 +1164,17 @@ HTMLCanvasElement::IsFrameCaptureRequest
     }
   }
   return false;
 }
 
 void
 HTMLCanvasElement::SetFrameCapture(already_AddRefed<SourceSurface> aSurface)
 {
-  RefPtr<SourceSurface> surface = aSurface;
+  nsRefPtr<SourceSurface> surface = aSurface;
 
   CairoImage::Data imageData;
   imageData.mSize = surface->GetSize();
   imageData.mSourceSurface = surface;
 
   nsRefPtr<CairoImage> image = new CairoImage();
   image->SetData(imageData);
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2760,17 +2760,17 @@ ContentParent::RecvSetClipboard(const IP
             item.flavor().EqualsLiteral(kGIFImageMime)) {
           const IPCDataTransferImage& imageDetails = item.imageDetails();
           const gfx::IntSize size(imageDetails.width(), imageDetails.height());
           if (!size.width || !size.height) {
             return true;
           }
 
           nsCString text = item.data().get_nsCString();
-          mozilla::RefPtr<gfx::DataSourceSurface> image =
+          nsRefPtr<gfx::DataSourceSurface> image =
             new mozilla::gfx::SourceSurfaceRawData();
           mozilla::gfx::SourceSurfaceRawData* raw =
             static_cast<mozilla::gfx::SourceSurfaceRawData*>(image.get());
           raw->InitWrappingData(
             reinterpret_cast<uint8_t*>(const_cast<nsCString&>(text).BeginWriting()),
             size, imageDetails.stride(),
             static_cast<mozilla::gfx::SurfaceFormat>(imageDetails.format()), false);
           raw->GuaranteePersistance();
--- a/dom/ipc/StructuredCloneData.h
+++ b/dom/ipc/StructuredCloneData.h
@@ -3,17 +3,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_dom_ipc_StructuredCloneData_h
 #define mozilla_dom_ipc_StructuredCloneData_h
 
 #include <algorithm>
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/dom/StructuredCloneHolder.h"
 #include "nsISupportsImpl.h"
 
 namespace IPC {
 class Message;
 }
 
 namespace mozilla {
@@ -133,16 +133,16 @@ public:
   // For IPC serialization
   void WriteIPCParams(IPC::Message* aMessage) const;
   bool ReadIPCParams(const IPC::Message* aMessage, void** aIter);
 
 private:
   uint64_t* MOZ_NON_OWNING_REF mExternalData;
   size_t mExternalDataLength;
 
-  RefPtr<SharedJSAllocatedData> mSharedData;
+  nsRefPtr<SharedJSAllocatedData> mSharedData;
 };
 
 } // namespace ipc
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_ipc_StructuredCloneData_h
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -2109,17 +2109,17 @@ TabParent::RecvSetCustomCursor(const nsC
   if (widget) {
     if (aForce) {
       widget->ClearCachedCursor();
     }
 
     if (mTabSetsCursor) {
       const gfx::IntSize size(aWidth, aHeight);
 
-      mozilla::RefPtr<gfx::DataSourceSurface> customCursor = new mozilla::gfx::SourceSurfaceRawData();
+      nsRefPtr<gfx::DataSourceSurface> customCursor = new mozilla::gfx::SourceSurfaceRawData();
       mozilla::gfx::SourceSurfaceRawData* raw = static_cast<mozilla::gfx::SourceSurfaceRawData*>(customCursor.get());
       raw->InitWrappingData(
         reinterpret_cast<uint8_t*>(const_cast<nsCString&>(aCursorData).BeginWriting()),
         size, aStride, static_cast<mozilla::gfx::SurfaceFormat>(aFormat), false);
       raw->GuaranteePersistance();
 
       nsRefPtr<gfxDrawable> drawable = new gfxSurfaceDrawable(customCursor, size);
       nsCOMPtr<imgIContainer> cursorImage(image::ImageOps::CreateFromDrawable(drawable));
@@ -3596,17 +3596,17 @@ TabParent::AddInitialDnDDataTo(DataTrans
                                           variant, i,
                                           nsContentUtils::GetSystemPrincipal());
     }
   }
   mInitialDataTransferItems.Clear();
 }
 
 void
-TabParent::TakeDragVisualization(RefPtr<mozilla::gfx::SourceSurface>& aSurface,
+TabParent::TakeDragVisualization(nsRefPtr<mozilla::gfx::SourceSurface>& aSurface,
                                  int32_t& aDragAreaX, int32_t& aDragAreaY)
 {
   aSurface = mDnDVisualization.forget();
   aDragAreaX = mDragAreaX;
   aDragAreaY = mDragAreaY;
 }
 
 bool
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -10,17 +10,17 @@
 #include "js/TypeDecls.h"
 #include "mozilla/ContentCache.h"
 #include "mozilla/dom/ipc/IdType.h"
 #include "mozilla/dom/PBrowserParent.h"
 #include "mozilla/dom/PFilePickerParent.h"
 #include "mozilla/dom/TabContext.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/File.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsCOMPtr.h"
 #include "nsIAuthPromptProvider.h"
 #include "nsIBrowserDOMWindow.h"
 #include "nsIDOMEventListener.h"
 #include "nsISecureBrowserUI.h"
 #include "nsITabParent.h"
 #include "nsIWebBrowserPersistable.h"
 #include "nsIXULBrowserWindow.h"
@@ -445,17 +445,17 @@ public:
                           const uint32_t& aAction,
                           const nsCString& aVisualDnDData,
                           const uint32_t& aWidth, const uint32_t& aHeight,
                           const uint32_t& aStride, const uint8_t& aFormat,
                           const int32_t& aDragAreaX, const int32_t& aDragAreaY) override;
 
     void AddInitialDnDDataTo(DataTransfer* aDataTransfer);
 
-    void TakeDragVisualization(RefPtr<mozilla::gfx::SourceSurface>& aSurface,
+    void TakeDragVisualization(nsRefPtr<mozilla::gfx::SourceSurface>& aSurface,
                                int32_t& aDragAreaX, int32_t& aDragAreaY);
     layout::RenderFrameParent* GetRenderFrame();
 
     // Called by HttpChannelParent. The function may use a new process to
     // reload the URI associated with the given channel.
     void OnStartSignedPackageRequest(nsIChannel* aChannel);
 
 protected:
@@ -561,17 +561,17 @@ private:
       {
         eString,
         eBlob
       };
       DataType mType;
     };
     nsTArray<nsTArray<DataTransferItem>> mInitialDataTransferItems;
 
-    mozilla::RefPtr<gfx::DataSourceSurface> mDnDVisualization;
+    nsRefPtr<gfx::DataSourceSurface> mDnDVisualization;
     int32_t mDragAreaX;
     int32_t mDragAreaY;
 
     // When true, the TabParent is initialized without child side's request.
     // When false, the TabParent is initialized by window.open() from child side.
     bool mInitedByParent;
 
     nsCOMPtr<nsILoadContext> mLoadContext;
--- a/dom/media/AudioStream.h
+++ b/dom/media/AudioStream.h
@@ -7,17 +7,17 @@
 #define AudioStream_h_
 
 #include "AudioSampleFormat.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsThreadUtils.h"
 #include "mozilla/dom/AudioChannelBinding.h"
 #include "mozilla/Monitor.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/UniquePtr.h"
 #include "CubebUtils.h"
 #include "soundtouch/SoundTouchFactory.h"
 
 namespace mozilla {
 
 struct CubebDestroyPolicy
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -533,17 +533,17 @@ DOMMediaStream::GetTracks(nsTArray<nsRef
   }
 }
 
 void
 DOMMediaStream::AddTrack(MediaStreamTrack& aTrack)
 {
   MOZ_RELEASE_ASSERT(mPlaybackStream);
 
-  RefPtr<ProcessedMediaStream> dest = mPlaybackStream->AsProcessedStream();
+  nsRefPtr<ProcessedMediaStream> dest = mPlaybackStream->AsProcessedStream();
   MOZ_ASSERT(dest);
   if (!dest) {
     return;
   }
 
   LOG(LogLevel::Info, ("DOMMediaStream %p Adding track %p (from stream %p with ID %d)",
                        this, &aTrack, aTrack.GetStream(), aTrack.GetTrackID()));
 
@@ -568,20 +568,20 @@ DOMMediaStream::AddTrack(MediaStreamTrac
     return;
   }
 
   if (HasTrack(aTrack)) {
     LOG(LogLevel::Debug, ("DOMMediaStream %p already contains track %p", this, &aTrack));
     return;
   }
 
-  RefPtr<DOMMediaStream> addedDOMStream = aTrack.GetStream();
+  nsRefPtr<DOMMediaStream> addedDOMStream = aTrack.GetStream();
   MOZ_RELEASE_ASSERT(addedDOMStream);
 
-  RefPtr<MediaStream> owningStream = addedDOMStream->GetOwnedStream();
+  nsRefPtr<MediaStream> owningStream = addedDOMStream->GetOwnedStream();
   MOZ_RELEASE_ASSERT(owningStream);
 
   CombineWithPrincipal(addedDOMStream->mPrincipal);
 
   // Hook up the underlying track with our underlying playback stream.
   nsRefPtr<MediaInputPort> inputPort =
     GetPlaybackStream()->AllocateInputPort(owningStream, aTrack.GetTrackID());
   nsRefPtr<TrackPort> trackPort =
--- a/dom/media/MediaDecoderReader.cpp
+++ b/dom/media/MediaDecoderReader.cpp
@@ -333,17 +333,17 @@ MediaDecoderReader::RequestVideoData(boo
          !VideoQueue().IsFinished()) {
     if (!DecodeVideoFrame(skip, aTimeThreshold)) {
       VideoQueue().Finish();
     } else if (skip) {
       // We still need to decode more data in order to skip to the next
       // keyframe. Post another task to the decode task queue to decode
       // again. We don't just decode straight in a loop here, as that
       // would hog the decode task queue.
-      RefPtr<nsIRunnable> task(new ReRequestVideoWithSkipTask(this, aTimeThreshold));
+      nsRefPtr<nsIRunnable> task(new ReRequestVideoWithSkipTask(this, aTimeThreshold));
       mTaskQueue->Dispatch(task.forget());
       return p;
     }
   }
   if (VideoQueue().GetSize() > 0) {
     nsRefPtr<VideoData> v = VideoQueue().PopFront();
     if (v && mVideoDiscontinuity) {
       v->mDiscontinuity = true;
@@ -369,17 +369,17 @@ MediaDecoderReader::RequestAudioData()
       AudioQueue().Finish();
       break;
     }
     // AudioQueue size is still zero, post a task to try again. Don't spin
     // waiting in this while loop since it somehow prevents audio EOS from
     // coming in gstreamer 1.x when there is still video buffer waiting to be
     // consumed. (|mVideoSinkBufferCount| > 0)
     if (AudioQueue().GetSize() == 0) {
-      RefPtr<nsIRunnable> task(new ReRequestAudioTask(this));
+      nsRefPtr<nsIRunnable> task(new ReRequestAudioTask(this));
       mTaskQueue->Dispatch(task.forget());
       return p;
     }
   }
   if (AudioQueue().GetSize() > 0) {
     nsRefPtr<AudioData> a = AudioQueue().PopFront();
     if (mAudioDiscontinuity) {
       a->mDiscontinuity = true;
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -288,17 +288,17 @@ public:
   // In situations where these notifications come from stochastic network
   // activity, we can save significant recomputation by throttling the delivery
   // of these updates to the reader implementation. We don't want to do this
   // throttling when the update comes from MSE code, since that code needs the
   // updates to be observable immediately, and is generally less
   // trigger-happy with notifications anyway.
   void DispatchNotifyDataArrived(uint32_t aLength, int64_t aOffset, bool aThrottleUpdates)
   {
-    RefPtr<nsRunnable> r =
+    nsRefPtr<nsRunnable> r =
       NS_NewRunnableMethodWithArg<media::Interval<int64_t>>(this, aThrottleUpdates ? &MediaDecoderReader::ThrottledNotifyDataArrived
                                                                                    : &MediaDecoderReader::NotifyDataArrived,
                                                             media::Interval<int64_t>(aOffset, aOffset + aLength));
     OwnerThread()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess);
   }
 
   // Notify the reader that data from the resource was evicted (MediaSource only)
   virtual void NotifyDataRemoved() {}
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2225,17 +2225,17 @@ MediaDecoderStateMachine::FinishShutdown
   // state machine is destroyed on the main thread, and so the
   // event runner running this function (which holds a reference to the
   // state machine) needs to finish and be released in order to allow
   // that. So we dispatch an event to run after this event runner has
   // finished and released its monitor/references. That event then will
   // dispatch an event to the main thread to release the decoder and
   // state machine.
   DECODER_LOG("Shutting down state machine task queue");
-  RefPtr<DecoderDisposer> disposer = new DecoderDisposer(mDecoder, this);
+  nsRefPtr<DecoderDisposer> disposer = new DecoderDisposer(mDecoder, this);
   OwnerThread()->BeginShutdown()->Then(AbstractThread::MainThread(), __func__,
                                        disposer.get(),
                                        &DecoderDisposer::OnTaskQueueShutdown,
                                        &DecoderDisposer::OnTaskQueueShutdown);
 }
 
 nsresult MediaDecoderStateMachine::RunStateMachine()
 {
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -823,17 +823,17 @@ MediaFormatReader::ScheduleUpdate(TrackT
     return;
   }
   auto& decoder = GetDecoderData(aTrack);
   if (decoder.mUpdateScheduled) {
     return;
   }
   LOGV("SchedulingUpdate(%s)", TrackTypeToStr(aTrack));
   decoder.mUpdateScheduled = true;
-  RefPtr<nsIRunnable> task(
+  nsRefPtr<nsIRunnable> task(
     NS_NewRunnableMethodWithArg<TrackType>(this, &MediaFormatReader::Update, aTrack));
   OwnerThread()->Dispatch(task.forget());
 }
 
 bool
 MediaFormatReader::UpdateReceivedNewData(TrackType aTrack)
 {
   MOZ_ASSERT(OnTaskQueue());
@@ -1257,44 +1257,44 @@ MediaFormatReader::Output(TrackType aTra
        aSample->mKeyframe, aSample->mDuration);
 
   if (!aSample) {
     NS_WARNING("MediaFormatReader::Output() passed a null sample");
     Error(aTrack);
     return;
   }
 
-  RefPtr<nsIRunnable> task =
+  nsRefPtr<nsIRunnable> task =
     NS_NewRunnableMethodWithArgs<TrackType, MediaData*>(
       this, &MediaFormatReader::NotifyNewOutput, aTrack, aSample);
   OwnerThread()->Dispatch(task.forget());
 }
 
 void
 MediaFormatReader::DrainComplete(TrackType aTrack)
 {
-  RefPtr<nsIRunnable> task =
+  nsRefPtr<nsIRunnable> task =
     NS_NewRunnableMethodWithArg<TrackType>(
       this, &MediaFormatReader::NotifyDrainComplete, aTrack);
   OwnerThread()->Dispatch(task.forget());
 }
 
 void
 MediaFormatReader::InputExhausted(TrackType aTrack)
 {
-  RefPtr<nsIRunnable> task =
+  nsRefPtr<nsIRunnable> task =
     NS_NewRunnableMethodWithArg<TrackType>(
       this, &MediaFormatReader::NotifyInputExhausted, aTrack);
   OwnerThread()->Dispatch(task.forget());
 }
 
 void
 MediaFormatReader::Error(TrackType aTrack)
 {
-  RefPtr<nsIRunnable> task =
+  nsRefPtr<nsIRunnable> task =
     NS_NewRunnableMethodWithArg<TrackType>(
       this, &MediaFormatReader::NotifyError, aTrack);
   OwnerThread()->Dispatch(task.forget());
 }
 
 void
 MediaFormatReader::Flush(TrackType aTrack)
 {
@@ -1402,17 +1402,17 @@ MediaFormatReader::Seek(int64_t aTime, i
     return SeekPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   mOriginalSeekTime = Some(media::TimeUnit::FromMicroseconds(aTime));
   mPendingSeekTime = mOriginalSeekTime;
 
   nsRefPtr<SeekPromise> p = mSeekPromise.Ensure(__func__);
 
-  RefPtr<nsIRunnable> task(
+  nsRefPtr<nsIRunnable> task(
     NS_NewRunnableMethod(this, &MediaFormatReader::AttemptSeek));
   OwnerThread()->Dispatch(task.forget());
 
   return p;
 }
 
 void
 MediaFormatReader::AttemptSeek()
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -2597,30 +2597,30 @@ MediaManager::Observe(nsISupports* aSubj
         // must explicitly do this before dispatching the reply, since the reply may kill us with Stop()
         mBackend = nullptr; // last reference, will invoke Shutdown() again
 
         if (NS_FAILED(NS_DispatchToMainThread(mReply.forget()))) {
           LOG(("Will leak thread: DispatchToMainthread of reply runnable failed in MediaManager shutdown"));
         }
       }
       nsRefPtr<nsRunnable> mReply;
-      RefPtr<MediaEngine> mBackend;
+      nsRefPtr<MediaEngine> mBackend;
     };
 
     // Post ShutdownTask to execute on mMediaThread and pass in a lambda
     // callback to be executed back on this thread once it is done.
     //
     // The lambda callback "captures" the 'this' pointer for member access.
     // This is safe since this is guaranteed to be here since sSingleton isn't
     // cleared until the lambda function clears it.
 
     // note that this == sSingleton
     nsRefPtr<MediaManager> that(sSingleton);
     // Release the backend (and call Shutdown()) from within the MediaManager thread
-    RefPtr<MediaEngine> temp;
+    nsRefPtr<MediaEngine> temp;
     {
       MutexAutoLock lock(mMutex);
       temp = mBackend.forget();
     }
     // Don't use MediaManager::PostTask() because we're sInShutdown=true here!
     mMediaThread->message_loop()->PostTask(FROM_HERE, new ShutdownTask(
         temp.forget(),
         media::NewRunnableFrom([this, that]() mutable {
--- a/dom/media/MediaManager.h
+++ b/dom/media/MediaManager.h
@@ -528,17 +528,17 @@ private:
   nsClassHashtable<nsStringHashKey, GetUserMediaTask> mActiveCallbacks;
   nsClassHashtable<nsUint64HashKey, nsTArray<nsString>> mCallIds;
 
   // Always exists
   nsAutoPtr<base::Thread> mMediaThread;
 
   Mutex mMutex;
   // protected with mMutex:
-  RefPtr<MediaEngine> mBackend;
+  nsRefPtr<MediaEngine> mBackend;
 
   static StaticRefPtr<MediaManager> sSingleton;
 
   media::CoatCheck<PledgeSourceSet> mOutstandingPledges;
   media::CoatCheck<PledgeChar> mOutstandingCharPledges;
   media::CoatCheck<GetUserMediaCallbackMediaStreamListener::PledgeVoid> mOutstandingVoidPledges;
 #if defined(MOZ_B2G_CAMERA) && defined(MOZ_WIDGET_GONK)
   nsRefPtr<nsDOMCameraManager> mCameraManager;
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -1674,27 +1674,27 @@ public:
   NS_IMETHOD Run() {
     mDecoder->NotifyBytesConsumed(mNumBytes, mOffset);
     // Drop ref to decoder on main thread, just in case this reference
     // ends up being the last owning reference somehow.
     mDecoder = nullptr;
     return NS_OK;
   }
 
-  RefPtr<MediaDecoder> mDecoder;
+  nsRefPtr<MediaDecoder> mDecoder;
   int64_t mNumBytes;
   int64_t mOffset;
 };
 
 void BaseMediaResource::DispatchBytesConsumed(int64_t aNumBytes, int64_t aOffset)
 {
   if (aNumBytes <= 0) {
     return;
   }
-  RefPtr<nsIRunnable> event(new DispatchBytesConsumedEvent(mDecoder, aNumBytes, aOffset));
+  nsRefPtr<nsIRunnable> event(new DispatchBytesConsumedEvent(mDecoder, aNumBytes, aOffset));
   NS_DispatchToMainThread(event);
 }
 
 nsresult
 MediaResourceIndex::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
 {
   NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
 
--- a/dom/media/MediaShutdownManager.h
+++ b/dom/media/MediaShutdownManager.h
@@ -4,17 +4,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/. */
 
 #if !defined(MediaShutdownManager_h_)
 #define MediaShutdownManager_h_
 
 #include "nsIObserver.h"
 #include "mozilla/Monitor.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/StaticPtr.h"
 #include "nsIThread.h"
 #include "nsCOMPtr.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 
 namespace mozilla {
 
--- a/dom/media/MediaTimer.cpp
+++ b/dom/media/MediaTimer.cpp
@@ -6,17 +6,17 @@
 
 #include "MediaTimer.h"
 
 #include <math.h>
 
 #include "nsComponentManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/DebugOnly.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/SharedThreadPool.h"
 
 namespace mozilla {
 
 NS_IMPL_ADDREF(MediaTimer)
 NS_IMPL_RELEASE_WITH_DESTROY(MediaTimer, DispatchDestroy())
 
 MediaTimer::MediaTimer()
@@ -24,17 +24,17 @@ MediaTimer::MediaTimer()
   , mTimer(do_CreateInstance("@mozilla.org/timer;1"))
   , mCreationTimeStamp(TimeStamp::Now())
   , mUpdateScheduled(false)
 {
   TIMER_LOG("MediaTimer::MediaTimer");
 
   // Use the SharedThreadPool to create an nsIThreadPool with a maximum of one
   // thread, which is equivalent to an nsIThread for our purposes.
-  RefPtr<SharedThreadPool> threadPool(
+  nsRefPtr<SharedThreadPool> threadPool(
     SharedThreadPool::Get(NS_LITERAL_CSTRING("MediaTimer"), 1));
   mThread = threadPool.get();
   mTimer->SetTarget(mThread);
 }
 
 void
 MediaTimer::DispatchDestroy()
 {
--- a/dom/media/VideoUtils.h
+++ b/dom/media/VideoUtils.h
@@ -7,17 +7,17 @@
 #ifndef VideoUtils_h
 #define VideoUtils_h
 
 #include "FlushableTaskQueue.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/MozPromise.h"
 #include "mozilla/ReentrantMonitor.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #include "nsIThread.h"
 #include "nsSize.h"
 #include "nsRect.h"
 
 #include "nsThreadUtils.h"
 #include "prtime.h"
 #include "AudioSampleFormat.h"
--- a/dom/media/directshow/AudioSinkFilter.cpp
+++ b/dom/media/directshow/AudioSinkFilter.cpp
@@ -138,17 +138,17 @@ AudioSinkFilter::GetSampleSink()
 //
 // Calls to IMediaSeeking are forwarded to the output pin that the
 // AudioSinkInputPin is connected to, i.e. upstream towards the parser and
 // source filters, which actually implement seeking.
 #define ENSURE_CONNECTED_PIN_SEEKING \
   if (!mInputPin) { \
     return E_NOTIMPL; \
   } \
-  RefPtr<IMediaSeeking> pinSeeking = mInputPin->GetConnectedPinSeeking(); \
+  nsRefPtr<IMediaSeeking> pinSeeking = mInputPin->GetConnectedPinSeeking(); \
   if (!pinSeeking) { \
     return E_NOTIMPL; \
   }
 
 HRESULT
 AudioSinkFilter::GetCapabilities(DWORD* aCapabilities)
 {
   ENSURE_CONNECTED_PIN_SEEKING
--- a/dom/media/directshow/AudioSinkFilter.h
+++ b/dom/media/directshow/AudioSinkFilter.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #if !defined(AudioSinkFilter_h_)
 #define AudioSinkFilter_h_
 
 #include "BaseFilter.h"
 #include "DirectShowUtils.h"
 #include "nsAutoPtr.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 
 class AudioSinkInputPin;
 class SampleSink;
 
 // Filter that acts as the end of the graph. Audio samples input into
 // this filter block the calling thread, and the calling thread is
--- a/dom/media/directshow/AudioSinkInputPin.cpp
+++ b/dom/media/directshow/AudioSinkInputPin.cpp
@@ -129,21 +129,21 @@ AudioSinkInputPin::Receive(IMediaSample*
     NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
   }
   return S_OK;
 }
 
 already_AddRefed<IMediaSeeking>
 AudioSinkInputPin::GetConnectedPinSeeking()
 {
-  RefPtr<IPin> peer = GetConnected();
+  nsRefPtr<IPin> peer = GetConnected();
   if (!peer)
     return nullptr;
-  RefPtr<IMediaSeeking> seeking;
-  peer->QueryInterface(static_cast<IMediaSeeking**>(byRef(seeking)));
+  nsRefPtr<IMediaSeeking> seeking;
+  peer->QueryInterface(static_cast<IMediaSeeking**>(getter_AddRefs(seeking)));
   return seeking.forget();
 }
 
 HRESULT
 AudioSinkInputPin::BeginFlush()
 {
   HRESULT hr = media::BaseInputPin::BeginFlush();
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
--- a/dom/media/directshow/AudioSinkInputPin.h
+++ b/dom/media/directshow/AudioSinkInputPin.h
@@ -4,17 +4,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/. */
 
 #if !defined(AudioSinkInputPin_h_)
 #define AudioSinkInputPin_h_
 
 #include "BaseInputPin.h"
 #include "DirectShowUtils.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsAutoPtr.h"
 
 namespace mozilla {
 
 namespace media {
   class MediaType;
 }
 
--- a/dom/media/directshow/DirectShowReader.cpp
+++ b/dom/media/directshow/DirectShowReader.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DirectShowReader.h"
 #include "MediaDecoderReader.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "DirectShowUtils.h"
 #include "AudioSinkFilter.h"
 #include "SourceFilter.h"
 #include "SampleSink.h"
 #include "MediaResource.h"
 #include "VideoUtils.h"
 
 using namespace mozilla::media;
@@ -98,36 +98,36 @@ DirectShowReader::ReadMetadata(MediaInfo
   nsresult rv;
 
   // Create the filter graph, reference it by the GraphBuilder interface,
   // to make graph building more convenient.
   hr = CoCreateInstance(CLSID_FilterGraph,
                         nullptr,
                         CLSCTX_INPROC_SERVER,
                         IID_IGraphBuilder,
-                        reinterpret_cast<void**>(static_cast<IGraphBuilder**>(byRef(mGraph))));
+                        reinterpret_cast<void**>(static_cast<IGraphBuilder**>(getter_AddRefs(mGraph))));
   NS_ENSURE_TRUE(SUCCEEDED(hr) && mGraph, NS_ERROR_FAILURE);
 
   rv = ParseMP3Headers(&mMP3FrameParser, mDecoder->GetResource());
   NS_ENSURE_SUCCESS(rv, rv);
 
   #ifdef DEBUG
   // Add the graph to the Running Object Table so that we can connect
   // to this graph with GraphEdit/GraphStudio. Note: on Vista and up you must
   // also regsvr32 proppage.dll from the Windows SDK.
   // See: http://msdn.microsoft.com/en-us/library/ms787252(VS.85).aspx
   hr = AddGraphToRunningObjectTable(mGraph, &mRotRegister);
   NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
   #endif
 
   // Extract the interface pointers we'll need from the filter graph.
-  hr = mGraph->QueryInterface(static_cast<IMediaControl**>(byRef(mControl)));
+  hr = mGraph->QueryInterface(static_cast<IMediaControl**>(getter_AddRefs(mControl)));
   NS_ENSURE_TRUE(SUCCEEDED(hr) && mControl, NS_ERROR_FAILURE);
 
-  hr = mGraph->QueryInterface(static_cast<IMediaSeeking**>(byRef(mMediaSeeking)));
+  hr = mGraph->QueryInterface(static_cast<IMediaSeeking**>(getter_AddRefs(mMediaSeeking)));
   NS_ENSURE_TRUE(SUCCEEDED(hr) && mMediaSeeking, NS_ERROR_FAILURE);
 
   // Build the graph. Create the filters we need, and connect them. We
   // build the entire graph ourselves to prevent other decoders installed
   // on the system being created and used.
 
   // Our source filters, wraps the MediaResource.
   mSourceFilter = new SourceFilter(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1Audio);
@@ -135,36 +135,36 @@ DirectShowReader::ReadMetadata(MediaInfo
 
   rv = mSourceFilter->Init(mDecoder->GetResource(), mMP3FrameParser.GetMP3Offset());
   NS_ENSURE_SUCCESS(rv, rv);
 
   hr = mGraph->AddFilter(mSourceFilter, L"MozillaDirectShowSource");
   NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
 
   // The MPEG demuxer.
-  RefPtr<IBaseFilter> demuxer;
+  nsRefPtr<IBaseFilter> demuxer;
   hr = CreateAndAddFilter(mGraph,
                           CLSID_MPEG1Splitter,
                           L"MPEG1Splitter",
-                          byRef(demuxer));
+                          getter_AddRefs(demuxer));
   NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
 
   // Platform MP3 decoder.
-  RefPtr<IBaseFilter> decoder;
+  nsRefPtr<IBaseFilter> decoder;
   // Firstly try to create the MP3 decoder filter that ships with WinXP
   // directly. This filter doesn't normally exist on later versions of
   // Windows.
   hr = CreateAndAddFilter(mGraph,
                           CLSID_MPEG_LAYER_3_DECODER_FILTER,
                           L"MPEG Layer 3 Decoder",
-                          byRef(decoder));
+                          getter_AddRefs(decoder));
   if (FAILED(hr)) {
     // Failed to create MP3 decoder filter. Try to instantiate
     // the MP3 decoder DMO.
-    hr = AddMP3DMOWrapperFilter(mGraph, byRef(decoder));
+    hr = AddMP3DMOWrapperFilter(mGraph, getter_AddRefs(decoder));
     NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
   }
 
   // Sink, captures audio samples and inserts them into our pipeline.
   static const wchar_t* AudioSinkFilterName = L"MozAudioSinkFilter";
   mAudioSinkFilter = new AudioSinkFilter(AudioSinkFilterName, &hr);
   NS_ENSURE_TRUE(mAudioSinkFilter && SUCCEEDED(hr), NS_ERROR_FAILURE);
   hr = mGraph->AddFilter(mAudioSinkFilter, AudioSinkFilterName);
@@ -232,18 +232,18 @@ UnsignedByteToAudioSample(uint8_t aValue
 
 bool
 DirectShowReader::Finish(HRESULT aStatus)
 {
   MOZ_ASSERT(OnTaskQueue());
 
   LOG("DirectShowReader::Finish(0x%x)", aStatus);
   // Notify the filter graph of end of stream.
-  RefPtr<IMediaEventSink> eventSink;
-  HRESULT hr = mGraph->QueryInterface(static_cast<IMediaEventSink**>(byRef(eventSink)));
+  nsRefPtr<IMediaEventSink> eventSink;
+  HRESULT hr = mGraph->QueryInterface(static_cast<IMediaEventSink**>(getter_AddRefs(eventSink)));
   if (SUCCEEDED(hr) && eventSink) {
     eventSink->Notify(EC_COMPLETE, aStatus, 0);
   }
   return false;
 }
 
 class DirectShowCopy
 {
@@ -296,17 +296,17 @@ DirectShowReader::DecodeAudioData()
   SampleSink* sink = mAudioSinkFilter->GetSampleSink();
   if (sink->AtEOS()) {
     // End of stream.
     return Finish(S_OK);
   }
 
   // Get the next chunk of audio samples. This blocks until the sample
   // arrives, or an error occurs (like the stream is shutdown).
-  RefPtr<IMediaSample> sample;
+  nsRefPtr<IMediaSample> sample;
   hr = sink->Extract(sample);
   if (FAILED(hr) || hr == S_FALSE) {
     return Finish(hr);
   }
 
   int64_t start = 0, end = 0;
   sample->GetMediaTime(&start, &end);
   LOG("DirectShowReader::DecodeAudioData [%4.2lf-%4.2lf]",
--- a/dom/media/directshow/DirectShowReader.h
+++ b/dom/media/directshow/DirectShowReader.h
@@ -4,17 +4,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/. */
 
 #if !defined(DirectShowReader_h_)
 #define DirectShowReader_h_
 
 #include "windows.h" // HRESULT, DWORD
 #include "MediaDecoderReader.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "MP3FrameParser.h"
 
 struct IGraphBuilder;
 struct IMediaControl;
 struct IMediaSeeking;
 
 namespace mozilla {
 
@@ -69,26 +69,26 @@ private:
   // the code to send to the filter graph. Always returns false, so
   // that we can just "return Finish()" from DecodeAudioData().
   bool Finish(HRESULT aStatus);
 
   nsresult SeekInternal(int64_t aTime);
 
   // DirectShow filter graph, and associated playback and seeking
   // control interfaces.
-  RefPtr<IGraphBuilder> mGraph;
-  RefPtr<IMediaControl> mControl;
-  RefPtr<IMediaSeeking> mMediaSeeking;
+  nsRefPtr<IGraphBuilder> mGraph;
+  nsRefPtr<IMediaControl> mControl;
+  nsRefPtr<IMediaSeeking> mMediaSeeking;
 
   // Wraps the MediaResource, and feeds undecoded data into the filter graph.
-  RefPtr<SourceFilter> mSourceFilter;
+  nsRefPtr<SourceFilter> mSourceFilter;
 
   // Sits at the end of the graph, removing decoded samples from the graph.
   // The graph will block while this is blocked, i.e. it will pause decoding.
-  RefPtr<AudioSinkFilter> mAudioSinkFilter;
+  nsRefPtr<AudioSinkFilter> mAudioSinkFilter;
 
   // Some MP3s are variable bitrate, so DirectShow's duration estimation
   // can make its duration estimation based on the wrong bitrate. So we parse
   // the MP3 frames to get a more accuate estimate of the duration.
   MP3FrameParser mMP3FrameParser;
 
 #ifdef DEBUG
   // Used to add/remove the filter graph to the Running Object Table. You can
--- a/dom/media/directshow/DirectShowUtils.cpp
+++ b/dom/media/directshow/DirectShowUtils.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DirectShowUtils.h"
 #include "dmodshow.h"
 #include "wmcodecdsp.h"
 #include "dmoreg.h"
 #include "nsAutoPtr.h"
 #include "mozilla/ArrayUtils.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsPrintfCString.h"
 
 #define WARN(...) NS_WARNING(nsPrintfCString(__VA_ARGS__).get())
 
 namespace mozilla {
 
 // Create a table which maps GUIDs to a string representation of the GUID.
 // This is useful for debugging purposes, for logging the GUIDs of media types.
@@ -307,18 +307,18 @@ HRESULT
 MatchUnconnectedPin(IPin* aPin,
                     PIN_DIRECTION aPinDir,
                     bool *aOutMatches)
 {
   NS_ENSURE_TRUE(aPin, E_POINTER);
   NS_ENSURE_TRUE(aOutMatches, E_POINTER);
 
   // Ensure the pin is unconnected.
-  RefPtr<IPin> peer;
-  HRESULT hr = aPin->ConnectedTo(byRef(peer));
+  nsRefPtr<IPin> peer;
+  HRESULT hr = aPin->ConnectedTo(getter_AddRefs(peer));
   if (hr != VFW_E_NOT_CONNECTED) {
     *aOutMatches = false;
     return hr;
   }
 
   // Ensure the pin is of the specified direction.
   PIN_DIRECTION pinDir;
   hr = aPin->QueryDirection(&pinDir);
@@ -327,43 +327,43 @@ MatchUnconnectedPin(IPin* aPin,
   *aOutMatches = (pinDir == aPinDir);
   return S_OK;
 }
 
 // Return the first unconnected input pin or output pin.
 already_AddRefed<IPin>
 GetUnconnectedPin(IBaseFilter* aFilter, PIN_DIRECTION aPinDir)
 {
-  RefPtr<IEnumPins> enumPins;
+  nsRefPtr<IEnumPins> enumPins;
 
-  HRESULT hr = aFilter->EnumPins(byRef(enumPins));
+  HRESULT hr = aFilter->EnumPins(getter_AddRefs(enumPins));
   NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
 
   // Test each pin to see if it matches the direction we're looking for.
-  RefPtr<IPin> pin;
-  while (S_OK == enumPins->Next(1, byRef(pin), nullptr)) {
+  nsRefPtr<IPin> pin;
+  while (S_OK == enumPins->Next(1, getter_AddRefs(pin), nullptr)) {
     bool matches = FALSE;
     if (SUCCEEDED(MatchUnconnectedPin(pin, aPinDir, &matches)) &&
         matches) {
       return pin.forget();
     }
   }
 
   return nullptr;
 }
 
 HRESULT
 ConnectFilters(IGraphBuilder* aGraph,
                IBaseFilter* aOutputFilter,
                IBaseFilter* aInputFilter)
 {
-  RefPtr<IPin> output = GetUnconnectedPin(aOutputFilter, PINDIR_OUTPUT);
+  nsRefPtr<IPin> output = GetUnconnectedPin(aOutputFilter, PINDIR_OUTPUT);
   NS_ENSURE_TRUE(output, E_FAIL);
 
-  RefPtr<IPin> input = GetUnconnectedPin(aInputFilter, PINDIR_INPUT);
+  nsRefPtr<IPin> input = GetUnconnectedPin(aInputFilter, PINDIR_INPUT);
   NS_ENSURE_TRUE(output, E_FAIL);
 
   return aGraph->Connect(output, input);
 }
 
 } // namespace mozilla
 
 // avoid redefined macro in unified build
--- a/dom/media/directshow/SampleSink.cpp
+++ b/dom/media/directshow/SampleSink.cpp
@@ -76,17 +76,17 @@ SampleSink::Receive(IMediaSample* aSampl
   mSample = aSample;
   // Notify the signal, to awaken the consumer thread in WaitForSample()
   // if necessary.
   mon.NotifyAll();
   return S_OK;
 }
 
 HRESULT
-SampleSink::Extract(RefPtr<IMediaSample>& aOutSample)
+SampleSink::Extract(nsRefPtr<IMediaSample>& aOutSample)
 {
   ReentrantMonitorAutoEnter mon(mMonitor);
   // Loop until we have a sample, or we should abort.
   while (true) {
     if (mIsFlushing) {
       return S_FALSE;
     }
     if (mSample) {
--- a/dom/media/directshow/SampleSink.h
+++ b/dom/media/directshow/SampleSink.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #if !defined(SampleSink_h_)
 #define SampleSink_h_
 
 #include "BaseFilter.h"
 #include "DirectShowUtils.h"
 #include "nsAutoPtr.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/ReentrantMonitor.h"
 
 namespace mozilla {
 
 class SampleSink {
 public:
   SampleSink();
   virtual ~SampleSink();
@@ -30,17 +30,17 @@ public:
   // Called when a sample is delivered by the DirectShow graph to the sink.
   // The decode thread retrieves the sample by calling WaitForSample().
   // Blocks if there's already a sample waiting to be consumed by the decode
   // thread.
   HRESULT Receive(IMediaSample* aSample);
 
   // Retrieves a sample from the sample queue, blocking until one becomes
   // available, or until an error occurs. Returns S_FALSE on EOS.
-  HRESULT Extract(RefPtr<IMediaSample>& aOutSample);
+  HRESULT Extract(nsRefPtr<IMediaSample>& aOutSample);
 
   // Unblocks any threads waiting in GetSample().
   // Clears mSample, which unblocks upstream stream.
   void Flush();
 
   // Opens up the sink to receive more samples in PutSample().
   // Clears EOS flag.
   void Reset();
@@ -49,17 +49,17 @@ public:
   void SetEOS();
 
   // Returns whether we're at end of stream.
   bool AtEOS();
 
 private:
   // All data in this class is syncronized by mMonitor.
   ReentrantMonitor mMonitor;
-  RefPtr<IMediaSample> mSample;
+  nsRefPtr<IMediaSample> mSample;
 
   // Format of the audio stream we're receiving.
   WAVEFORMATEX mAudioFormat;
 
   bool mIsFlushing;
   bool mAtEOS;
 };
 
--- a/dom/media/directshow/SourceFilter.cpp
+++ b/dom/media/directshow/SourceFilter.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SourceFilter.h"
 #include "MediaResource.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "DirectShowUtils.h"
 #include "MP3FrameParser.h"
 #include "mozilla/Logging.h"
 #include <algorithm>
 
 using namespace mozilla::media;
 
 namespace mozilla {
@@ -51,17 +51,17 @@ public:
   {
     MOZ_COUNT_CTOR(ReadRequest);
   }
 
   ~ReadRequest() {
     MOZ_COUNT_DTOR(ReadRequest);
   }
 
-  RefPtr<IMediaSample> mSample;
+  nsRefPtr<IMediaSample> mSample;
   DWORD_PTR mDwUser;
   uint32_t mOffset;
   uint32_t mCount;
 };
 
 // A wrapper around media resource that presents only a partition of the
 // underlying resource to the caller to use. The partition returned is from
 // an offset to the end of stream, and this object deals with ensuring
--- a/dom/media/directshow/SourceFilter.h
+++ b/dom/media/directshow/SourceFilter.h
@@ -9,17 +9,17 @@
 
 #include "BaseFilter.h"
 #include "BasePin.h"
 #include "MediaType.h"
 
 #include "nsDeque.h"
 #include "nsAutoPtr.h"
 #include "DirectShowUtils.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 
 class MediaResource;
 class OutputPin;
 
 
 // SourceFilter is an asynchronous DirectShow source filter which
--- a/dom/media/eme/MediaKeySession.cpp
+++ b/dom/media/eme/MediaKeySession.cpp
@@ -394,17 +394,17 @@ MediaKeySession::DispatchKeyMessage(Medi
 }
 
 void
 MediaKeySession::DispatchKeyError(uint32_t aSystemCode)
 {
   EME_LOG("MediaKeySession[%p,'%s'] DispatchKeyError() systemCode=%u.",
           this, NS_ConvertUTF16toUTF8(mSessionId).get(), aSystemCode);
 
-  RefPtr<MediaKeyError> event(new MediaKeyError(this, aSystemCode));
+  nsRefPtr<MediaKeyError> event(new MediaKeyError(this, aSystemCode));
   nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(this, event);
   asyncDispatcher->PostDOMEvent();
 }
 
 void
 MediaKeySession::DispatchKeyStatusesChange()
 {
--- a/dom/media/eme/MediaKeys.h
+++ b/dom/media/eme/MediaKeys.h
@@ -6,17 +6,17 @@
 
 #ifndef mozilla_dom_mediakeys_h__
 #define mozilla_dom_mediakeys_h__
 
 #include "nsIDOMMediaError.h"
 #include "nsWrapperCache.h"
 #include "nsISupports.h"
 #include "mozilla/Attributes.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsRefPtrHashtable.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/MediaKeysBinding.h"
 #include "mozIGeckoMediaPluginService.h"
 #include "mozilla/DetailedPromise.h"
 
--- a/dom/media/encoder/VP8TrackEncoder.cpp
+++ b/dom/media/encoder/VP8TrackEncoder.cpp
@@ -365,23 +365,23 @@ nsresult VP8TrackEncoder::PrepareRawFram
       VP8LOG("Converting an %s frame to I420 failed\n", yuvFormat.c_str());
       return NS_ERROR_FAILURE;
     }
 
     VP8LOG("Converted an %s frame to I420\n");
   } else {
     // Not YCbCr at all. Try to get access to the raw data and convert.
 
-    RefPtr<SourceSurface> surf = img->GetAsSourceSurface();
+    nsRefPtr<SourceSurface> surf = img->GetAsSourceSurface();
     if (!surf) {
       VP8LOG("Getting surface from %s image failed\n", Stringify(format).c_str());
       return NS_ERROR_FAILURE;
     }
 
-    RefPtr<DataSourceSurface> data = surf->GetDataSurface();
+    nsRefPtr<DataSourceSurface> data = surf->GetDataSurface();
     if (!data) {
       VP8LOG("Getting data surface from %s image with %s (%s) surface failed\n",
              Stringify(format).c_str(), Stringify(surf->GetType()).c_str(),
              Stringify(surf->GetFormat()).c_str());
       return NS_ERROR_FAILURE;
     }
 
     DataSourceSurface::ScopedMap map(data, DataSourceSurface::READ);
--- a/dom/media/gmp/GMPAudioDecoderParent.h
+++ b/dom/media/gmp/GMPAudioDecoderParent.h
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GMPAudioDecoderParent_h_
 #define GMPAudioDecoderParent_h_
 
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "gmp-audio-decode.h"
 #include "gmp-audio-codec.h"
 #include "mozilla/gmp/PGMPAudioDecoderParent.h"
 #include "GMPMessageUtils.h"
 #include "GMPAudioDecoderProxy.h"
 
 namespace mozilla {
 namespace gmp {
--- a/dom/media/gmp/GMPDecryptorParent.h
+++ b/dom/media/gmp/GMPDecryptorParent.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 GMPDecryptorParent_h_
 #define GMPDecryptorParent_h_
 
 #include "mozilla/gmp/PGMPDecryptorParent.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "gmp-decryption.h"
 #include "GMPDecryptorProxy.h"
 
 namespace mozilla {
 
 class CryptoSample;
 
 namespace gmp {
--- a/dom/media/gmp/GMPVideoDecoderParent.h
+++ b/dom/media/gmp/GMPVideoDecoderParent.h
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GMPVideoDecoderParent_h_
 #define GMPVideoDecoderParent_h_
 
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "gmp-video-decode.h"
 #include "mozilla/gmp/PGMPVideoDecoderParent.h"
 #include "GMPMessageUtils.h"
 #include "GMPSharedMemManager.h"
 #include "GMPUtils.h"
 #include "GMPVideoHost.h"
 #include "GMPVideoDecoderProxy.h"
 #include "VideoUtils.h"
--- a/dom/media/gmp/GMPVideoEncoderParent.h
+++ b/dom/media/gmp/GMPVideoEncoderParent.h
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GMPVideoEncoderParent_h_
 #define GMPVideoEncoderParent_h_
 
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "gmp-video-encode.h"
 #include "mozilla/gmp/PGMPVideoEncoderParent.h"
 #include "GMPMessageUtils.h"
 #include "GMPSharedMemManager.h"
 #include "GMPUtils.h"
 #include "GMPVideoHost.h"
 #include "GMPVideoEncoderProxy.h"
 
--- a/dom/media/mediasink/DecodedAudioDataSink.cpp
+++ b/dom/media/mediasink/DecodedAudioDataSink.cpp
@@ -257,17 +257,17 @@ DecodedAudioDataSink::SetPlaying(bool aP
 }
 
 nsresult
 DecodedAudioDataSink::InitializeAudioStream()
 {
   // AudioStream initialization can block for extended periods in unusual
   // circumstances, so we take care to drop the decoder monitor while
   // initializing.
-  RefPtr<AudioStream> audioStream(new AudioStream());
+  nsRefPtr<AudioStream> audioStream(new AudioStream());
   nsresult rv = audioStream->Init(mInfo.mChannels, mInfo.mRate, mChannel);
   if (NS_FAILED(rv)) {
     audioStream->Shutdown();
     return rv;
   }
 
   ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
   mAudioStream = audioStream;
--- a/dom/media/mediasource/MediaSourceDemuxer.h
+++ b/dom/media/mediasource/MediaSourceDemuxer.h
@@ -65,17 +65,17 @@ private:
   TrackInfo* GetTrackInfo(TrackInfo::TrackType);
   void DoAttachSourceBuffer(TrackBuffersManager* aSourceBuffer);
   void DoDetachSourceBuffer(TrackBuffersManager* aSourceBuffer);
   bool OnTaskQueue()
   {
     return !GetTaskQueue() || GetTaskQueue()->IsCurrentThreadIn();
   }
 
-  RefPtr<TaskQueue> mTaskQueue;
+  nsRefPtr<TaskQueue> mTaskQueue;
   nsTArray<nsRefPtr<MediaSourceTrackDemuxer>> mDemuxers;
 
   nsTArray<nsRefPtr<TrackBuffersManager>> mSourceBuffers;
 
   MozPromiseHolder<InitPromise> mInitPromise;
 
   // Monitor to protect members below across multiple threads.
   mutable Monitor mMonitor;
--- a/dom/media/mediasource/TrackBuffersManager.h
+++ b/dom/media/mediasource/TrackBuffersManager.h
@@ -330,17 +330,17 @@ private:
   // TaskQueue methods and objects.
   AbstractThread* GetTaskQueue() {
     return mTaskQueue;
   }
   bool OnTaskQueue()
   {
     return !GetTaskQueue() || GetTaskQueue()->IsCurrentThreadIn();
   }
-  RefPtr<TaskQueue> mTaskQueue;
+  nsRefPtr<TaskQueue> mTaskQueue;
 
   media::TimeInterval mAppendWindow;
   media::TimeUnit mTimestampOffset;
   media::TimeUnit mLastTimestampOffset;
   void RestoreCachedVariables();
 
   // Strong references to external objects.
   nsRefPtr<dom::SourceBufferAttributes> mSourceBufferAttributes;
--- a/dom/media/omx/MPAPI.h
+++ b/dom/media/omx/MPAPI.h
@@ -36,17 +36,17 @@ struct VideoFrame {
   void *mData;
   size_t mSize;
   int32_t mStride;
   int32_t mSliceHeight;
   int32_t mRotation;
   VideoPlane Y;
   VideoPlane Cb;
   VideoPlane Cr;
-  mozilla::RefPtr<mozilla::layers::TextureClient> mGraphicBuffer;
+  nsRefPtr<mozilla::layers::TextureClient> mGraphicBuffer;
 
   VideoFrame() :
     mTimeUs(0),
     mKeyFrame(false),
     mShouldSkip(false),
     mData(nullptr),
     mSize(0),
     mStride(0),
--- a/dom/media/omx/MediaCodecReader.cpp
+++ b/dom/media/omx/MediaCodecReader.cpp
@@ -309,28 +309,28 @@ MediaCodecReader::Shutdown()
   ReleaseResources();
   return MediaDecoderReader::Shutdown();
 }
 
 void
 MediaCodecReader::DispatchAudioTask()
 {
   if (mAudioTrack.mTaskQueue) {
-    RefPtr<nsIRunnable> task =
+    nsRefPtr<nsIRunnable> task =
       NS_NewRunnableMethod(this,
                            &MediaCodecReader::DecodeAudioDataTask);
     mAudioTrack.mTaskQueue->Dispatch(task.forget());
   }
 }
 
 void
 MediaCodecReader::DispatchVideoTask(int64_t aTimeThreshold)
 {
   if (mVideoTrack.mTaskQueue) {
-    RefPtr<nsIRunnable> task =
+    nsRefPtr<nsIRunnable> task =
       NS_NewRunnableMethodWithArg<int64_t>(this,
                                            &MediaCodecReader::DecodeVideoFrameTask,
                                            aTimeThreshold);
     mVideoTrack.mTaskQueue->Dispatch(task.forget());
   }
 }
 
 nsRefPtr<MediaDecoderReader::AudioDataPromise>
@@ -808,17 +808,17 @@ MediaCodecReader::TextureClientRecycleCa
 
     FenceHandle handle = aClient->GetAndResetReleaseFenceHandle();
     mPendingReleaseItems.AppendElement(ReleaseItem(index, handle));
 
     mTextureClientIndexes.Remove(aClient);
   }
 
   if (mVideoTrack.mReleaseBufferTaskQueue->IsEmpty()) {
-    RefPtr<nsIRunnable> task =
+    nsRefPtr<nsIRunnable> task =
       NS_NewRunnableMethod(this,
                            &MediaCodecReader::WaitFenceAndReleaseOutputBuffer);
     mVideoTrack.mReleaseBufferTaskQueue->Dispatch(task.forget());
   }
 }
 
 void
 MediaCodecReader::WaitFenceAndReleaseOutputBuffer()
@@ -911,17 +911,17 @@ MediaCodecReader::DecodeVideoFrameSync(i
   if ((bufferInfo.mFlags & MediaCodec::BUFFER_FLAG_EOS) ||
       (status == ERROR_END_OF_STREAM)) {
     VideoQueue().Finish();
     mVideoTrack.mCodec->releaseOutputBuffer(bufferInfo.mIndex);
     return;
   }
 
   nsRefPtr<VideoData> v;
-  RefPtr<TextureClient> textureClient;
+  nsRefPtr<TextureClient> textureClient;
   sp<GraphicBuffer> graphicBuffer;
   if (bufferInfo.mBuffer != nullptr) {
     MOZ_ASSERT(mStreamSource);
     // This is the approximate byte position in the stream.
     int64_t pos = mStreamSource->Tell();
 
     if (mVideoTrack.mNativeWindow != nullptr &&
         mVideoTrack.mCodec->getOutputGraphicBufferFromIndex(bufferInfo.mIndex, &graphicBuffer) == OK &&
--- a/dom/media/omx/OMXCodecWrapper.cpp
+++ b/dom/media/omx/OMXCodecWrapper.cpp
@@ -397,17 +397,17 @@ ConvertSourceSurfaceToNV12(const nsRefPt
 
   SurfaceFormat format = aSurface->GetFormat();
 
   if (!aSurface) {
     CODEC_ERROR("Getting surface %s from image failed", Stringify(format).c_str());
     return NS_ERROR_FAILURE;
   }
 
-  RefPtr<DataSourceSurface> data = aSurface->GetDataSurface();
+  nsRefPtr<DataSourceSurface> data = aSurface->GetDataSurface();
   if (!data) {
     CODEC_ERROR("Getting data surface from %s image with %s (%s) surface failed",
                 Stringify(format).c_str(), Stringify(aSurface->GetType()).c_str(),
                 Stringify(aSurface->GetFormat()).c_str());
     return NS_ERROR_FAILURE;
   }
 
   DataSourceSurface::ScopedMap map(data, DataSourceSurface::READ);
--- a/dom/media/omx/OmxDecoder.cpp
+++ b/dom/media/omx/OmxDecoder.cpp
@@ -626,17 +626,17 @@ bool OmxDecoder::ReadVideo(VideoFrame *a
     if (!mVideoBuffer->meta_data()->findInt32(kKeyIsSyncFrame, &keyFrame)) {
       keyFrame = 0;
     }
 
     if (!mVideoBuffer->meta_data()->findInt32(kKeyIsUnreadable, &unreadable)) {
       unreadable = 0;
     }
 
-    RefPtr<mozilla::layers::TextureClient> textureClient;
+    nsRefPtr<mozilla::layers::TextureClient> textureClient;
     if ((mVideoBuffer->graphicBuffer().get())) {
       textureClient = mNativeWindow->getTextureClientFromBuffer(mVideoBuffer->graphicBuffer().get());
     }
 
     if (textureClient) {
       // Manually increment reference count to keep MediaBuffer alive
       // during TextureClient is in use.
       mVideoBuffer->add_ref();
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -7,17 +7,17 @@
 #if !defined(PlatformDecoderModule_h_)
 #define PlatformDecoderModule_h_
 
 #include "FlushableTaskQueue.h"
 #include "MediaDecoderReader.h"
 #include "mozilla/MozPromise.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "nsTArray.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include <queue>
 
 namespace mozilla {
 class TrackInfo;
 class AudioInfo;
 class VideoInfo;
 class MediaRawData;
 
--- a/dom/media/platforms/agnostic/BlankDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/BlankDecoderModule.cpp
@@ -2,17 +2,17 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaDecoderReader.h"
 #include "PlatformDecoderModule.h"
 #include "nsRect.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/CheckedInt.h"
 #include "VideoUtils.h"
 #include "ImageContainer.h"
 #include "MediaInfo.h"
 #include "mozilla/TaskQueue.h"
 #include "TimeUnits.h"
 
 namespace mozilla {
@@ -67,34 +67,34 @@ public:
     MediaDataDecoderCallback* mCallback;
   };
 
   nsresult Input(MediaRawData* aSample) override
   {
     // The MediaDataDecoder must delete the sample when we're finished
     // with it, so the OutputEvent stores it in an nsAutoPtr and deletes
     // it once it's run.
-    RefPtr<nsIRunnable> r(new OutputEvent(aSample, mCallback, mCreator));
+    nsRefPtr<nsIRunnable> r(new OutputEvent(aSample, mCallback, mCreator));
     mTaskQueue->Dispatch(r.forget());
     return NS_OK;
   }
 
   nsresult Flush() override {
     mTaskQueue->Flush();
     return NS_OK;
   }
 
   nsresult Drain() override {
     mCallback->DrainComplete();
     return NS_OK;
   }
 
 private:
   nsAutoPtr<BlankMediaDataCreator> mCreator;
-  RefPtr<FlushableTaskQueue> mTaskQueue;
+  nsRefPtr<FlushableTaskQueue> mTaskQueue;
   MediaDataDecoderCallback* mCallback;
   TrackInfo::TrackType mType;
 };
 
 class BlankVideoDataCreator {
 public:
   BlankVideoDataCreator(uint32_t aFrameWidth,
                         uint32_t aFrameHeight,
@@ -153,17 +153,17 @@ public:
                              aDTS.ToMicroseconds(),
                              mPicture);
   }
 private:
   VideoInfo mInfo;
   gfx::IntRect mPicture;
   uint32_t mFrameWidth;
   uint32_t mFrameHeight;
-  RefPtr<layers::ImageContainer> mImageContainer;
+  nsRefPtr<layers::ImageContainer> mImageContainer;
 };
 
 
 class BlankAudioDataCreator {
 public:
   BlankAudioDataCreator(uint32_t aChannelCount, uint32_t aSampleRate)
     : mFrameSum(0), mChannelCount(aChannelCount), mSampleRate(aSampleRate)
   {
--- a/dom/media/platforms/agnostic/OpusDecoder.cpp
+++ b/dom/media/platforms/agnostic/OpusDecoder.cpp
@@ -275,17 +275,17 @@ void
 OpusDataDecoder::DoDrain()
 {
   mCallback->DrainComplete();
 }
 
 nsresult
 OpusDataDecoder::Drain()
 {
-  RefPtr<nsIRunnable> runnable(
+  nsRefPtr<nsIRunnable> runnable(
     NS_NewRunnableMethod(this, &OpusDataDecoder::DoDrain));
   mTaskQueue->Dispatch(runnable.forget());
   return NS_OK;
 }
 
 nsresult
 OpusDataDecoder::Flush()
 {
--- a/dom/media/platforms/agnostic/OpusDecoder.h
+++ b/dom/media/platforms/agnostic/OpusDecoder.h
@@ -33,17 +33,17 @@ public:
 private:
   nsresult DecodeHeader(const unsigned char* aData, size_t aLength);
 
   void Decode (MediaRawData* aSample);
   int DoDecode (MediaRawData* aSample);
   void DoDrain ();
 
   const AudioInfo& mInfo;
-  RefPtr<FlushableTaskQueue> mTaskQueue;
+  nsRefPtr<FlushableTaskQueue> mTaskQueue;
   MediaDataDecoderCallback* mCallback;
 
   // Opus decoder state
   nsAutoPtr<OpusParser> mOpusParser;
   OpusMSDecoder* mOpusDecoder;
 
   uint16_t mSkip;        // Samples left to trim before playback.
   bool mDecodedHeader;
--- a/dom/media/platforms/agnostic/VPXDecoder.h
+++ b/dom/media/platforms/agnostic/VPXDecoder.h
@@ -44,17 +44,17 @@ public:
 
 private:
   void DecodeFrame (MediaRawData* aSample);
   int DoDecodeFrame (MediaRawData* aSample);
   void DoDrain ();
   void OutputDelayedFrames ();
 
   nsRefPtr<ImageContainer> mImageContainer;
-  RefPtr<FlushableTaskQueue> mTaskQueue;
+  nsRefPtr<FlushableTaskQueue> mTaskQueue;
   MediaDataDecoderCallback* mCallback;
 
   // VPx decoder state
   vpx_codec_ctx_t mVPX;
 
   const VideoInfo& mInfo;
 
   int mCodec;
--- a/dom/media/platforms/agnostic/VorbisDecoder.h
+++ b/dom/media/platforms/agnostic/VorbisDecoder.h
@@ -36,17 +36,17 @@ public:
 private:
   nsresult DecodeHeader(const unsigned char* aData, size_t aLength);
 
   void Decode (MediaRawData* aSample);
   int DoDecode (MediaRawData* aSample);
   void DoDrain ();
 
   const AudioInfo& mInfo;
-  RefPtr<FlushableTaskQueue> mTaskQueue;
+  nsRefPtr<FlushableTaskQueue> mTaskQueue;
   MediaDataDecoderCallback* mCallback;
 
   // Vorbis decoder state
   vorbis_info mVorbisInfo;
   vorbis_comment mVorbisComment;
   vorbis_dsp_state mVorbisDsp;
   vorbis_block mVorbisBlock;
 
--- a/dom/media/platforms/agnostic/eme/SamplesWaitingForKey.cpp
+++ b/dom/media/platforms/agnostic/eme/SamplesWaitingForKey.cpp
@@ -46,17 +46,17 @@ SamplesWaitingForKey::WaitIfKeyNotUsable
 
 void
 SamplesWaitingForKey::NotifyUsable(const CencKeyId& aKeyId)
 {
   MutexAutoLock lock(mMutex);
   size_t i = 0;
   while (i < mSamples.Length()) {
     if (aKeyId == mSamples[i]->mCrypto.mKeyId) {
-      RefPtr<nsIRunnable> task;
+      nsRefPtr<nsIRunnable> task;
       task = NS_NewRunnableMethodWithArg<nsRefPtr<MediaRawData>>(mDecoder,
                                                      &MediaDataDecoder::Input,
                                                      nsRefPtr<MediaRawData>(mSamples[i]));
       mSamples.RemoveElementAt(i);
       mTaskQueue->Dispatch(task.forget());
     } else {
       i++;
     }
--- a/dom/media/platforms/android/AndroidDecoderModule.cpp
+++ b/dom/media/platforms/android/AndroidDecoderModule.cpp
@@ -203,17 +203,17 @@ protected:
     }
 
     mGLContext = GLContextProvider::CreateHeadless(CreateContextFlags::NONE);
     return mGLContext;
   }
 
   layers::ImageContainer* mImageContainer;
   const VideoInfo& mConfig;
-  RefPtr<AndroidSurfaceTexture> mSurfaceTexture;
+  nsRefPtr<AndroidSurfaceTexture> mSurfaceTexture;
   nsRefPtr<GLContext> mGLContext;
 };
 
 class AudioDataDecoder : public MediaCodecDataDecoder {
 
 public:
   AudioDataDecoder(const AudioInfo& aConfig, MediaFormat::Param aFormat, MediaDataDecoderCallback* aCallback)
     : MediaCodecDataDecoder(MediaData::Type::AUDIO_DATA, aConfig.mMimeType, aFormat, aCallback)
--- a/dom/media/platforms/gonk/GonkAudioDecoderManager.h
+++ b/dom/media/platforms/gonk/GonkAudioDecoderManager.h
@@ -2,17 +2,17 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #if !defined(GonkAudioDecoderManager_h_)
 #define GonkAudioDecoderManager_h_
 
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "GonkMediaDataDecoder.h"
 
 using namespace android;
 
 namespace android {
 class MOZ_EXPORT MediaBuffer;
 } // namespace android
 
--- a/dom/media/platforms/gonk/GonkMediaDataDecoder.h
+++ b/dom/media/platforms/gonk/GonkMediaDataDecoder.h
@@ -140,16 +140,16 @@ public:
 
   nsresult Flush() override;
 
   nsresult Drain() override;
 
   nsresult Shutdown() override;
 
 private:
-  RefPtr<FlushableTaskQueue> mTaskQueue;
+  nsRefPtr<FlushableTaskQueue> mTaskQueue;
 
   android::sp<GonkDecoderManager> mManager;
 };
 
 } // namespace mozilla
 
 #endif // GonkMediaDataDecoder_h_
--- a/dom/media/platforms/gonk/GonkVideoDecoderManager.cpp
+++ b/dom/media/platforms/gonk/GonkVideoDecoderManager.cpp
@@ -180,17 +180,17 @@ GonkVideoDecoderManager::CreateVideoData
     // and we will preserve the ratio of the crop rectangle as it
     // was reported relative to the picture size reported by the container.
     picture.x = (mPicture.x * mFrameInfo.mWidth) / mInitialFrame.width;
     picture.y = (mPicture.y * mFrameInfo.mHeight) / mInitialFrame.height;
     picture.width = (mFrameInfo.mWidth * mPicture.width) / mInitialFrame.width;
     picture.height = (mFrameInfo.mHeight * mPicture.height) / mInitialFrame.height;
   }
 
-  RefPtr<mozilla::layers::TextureClient> textureClient;
+  nsRefPtr<mozilla::layers::TextureClient> textureClient;
 
   if ((mVideoBuffer->graphicBuffer().get())) {
     textureClient = mNativeWindow->getTextureClientFromBuffer(mVideoBuffer->graphicBuffer().get());
   }
 
   if (textureClient) {
     GrallocTextureClientOGL* grallocClient = static_cast<GrallocTextureClientOGL*>(textureClient.get());
     grallocClient->SetMediaBuffer(mVideoBuffer);
--- a/dom/media/platforms/gonk/GonkVideoDecoderManager.h
+++ b/dom/media/platforms/gonk/GonkVideoDecoderManager.h
@@ -4,17 +4,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/. */
 
 #if !defined(GonkVideoDecoderManager_h_)
 #define GonkVideoDecoderManager_h_
 
 #include "nsRect.h"
 #include "GonkMediaDataDecoder.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "I420ColorConverterHelper.h"
 #include "MediaCodecProxy.h"
 #include "GonkNativeWindow.h"
 #include "GonkNativeWindowClient.h"
 #include "mozilla/layers/FenceUtils.h"
 #include <ui/Fence.h>
 
 using namespace android;
--- a/dom/media/platforms/wmf/DXVA2Manager.cpp
+++ b/dom/media/platforms/wmf/DXVA2Manager.cpp
@@ -93,17 +93,17 @@ public:
                       Image** aOutImage) override;
 
   bool SupportsConfig(IMFMediaType* aType, float aFramerate) override;
 
 private:
   nsRefPtr<IDirect3D9Ex> mD3D9;
   nsRefPtr<IDirect3DDevice9Ex> mDevice;
   nsRefPtr<IDirect3DDeviceManager9> mDeviceManager;
-  RefPtr<D3D9RecycleAllocator> mTextureClientAllocator;
+  nsRefPtr<D3D9RecycleAllocator> mTextureClientAllocator;
   nsRefPtr<IDirectXVideoDecoderService> mDecoderService;
   GUID mDecoderGUID;
   UINT32 mResetToken;
   bool mFirstFrame;
   bool mIsAMDPreUVD4;
 };
 
 void GetDXVA2ExtendedFormatFromMFMediaType(IMFMediaType *pType,
@@ -485,36 +485,36 @@ public:
 
   bool IsD3D11() override { return true; }
 
   bool SupportsConfig(IMFMediaType* aType, float aFramerate) override;
 
 private:
   HRESULT CreateFormatConverter();
 
-  HRESULT CreateOutputSample(RefPtr<IMFSample>& aSample,
+  HRESULT CreateOutputSample(nsRefPtr<IMFSample>& aSample,
                              ID3D11Texture2D* aTexture);
 
-  RefPtr<ID3D11Device> mDevice;
-  RefPtr<ID3D11DeviceContext> mContext;
-  RefPtr<IMFDXGIDeviceManager> mDXGIDeviceManager;
-  RefPtr<MFTDecoder> mTransform;
-  RefPtr<D3D11RecycleAllocator> mTextureClientAllocator;
+  nsRefPtr<ID3D11Device> mDevice;
+  nsRefPtr<ID3D11DeviceContext> mContext;
+  nsRefPtr<IMFDXGIDeviceManager> mDXGIDeviceManager;
+  nsRefPtr<MFTDecoder> mTransform;
+  nsRefPtr<D3D11RecycleAllocator> mTextureClientAllocator;
   GUID mDecoderGUID;
   uint32_t mWidth;
   uint32_t mHeight;
   UINT mDeviceManagerToken;
   bool mIsAMDPreUVD4;
 };
 
 bool
 D3D11DXVA2Manager::SupportsConfig(IMFMediaType* aType, float aFramerate)
 {
-  RefPtr<ID3D11VideoDevice> videoDevice;
-  HRESULT hr = mDevice->QueryInterface(static_cast<ID3D11VideoDevice**>(byRef(videoDevice)));
+  nsRefPtr<ID3D11VideoDevice> videoDevice;
+  HRESULT hr = mDevice->QueryInterface(static_cast<ID3D11VideoDevice**>(getter_AddRefs(videoDevice)));
   NS_ENSURE_TRUE(SUCCEEDED(hr), false);
 
   D3D11_VIDEO_DECODER_DESC desc;
   desc.Guid = mDecoderGUID;
 
   UINT32 width = 0;
   UINT32 height = 0;
   hr = MFGetAttributeSize(aType, MF_MT_FRAME_SIZE, &width, &height);
@@ -576,23 +576,23 @@ D3D11DXVA2Manager::Init(nsACString& aFai
   HRESULT hr;
 
   mDevice = gfxWindowsPlatform::GetPlatform()->CreateD3D11DecoderDevice();
   if (!mDevice) {
     aFailureReason.AssignLiteral("Failed to create D3D11 device for decoder");
     return E_FAIL;
   }
 
-  mDevice->GetImmediateContext(byRef(mContext));
+  mDevice->GetImmediateContext(getter_AddRefs(mContext));
   if (!mContext) {
     aFailureReason.AssignLiteral("Failed to get immediate context for d3d11 device");
     return E_FAIL;
   }
 
-  hr = wmf::MFCreateDXGIDeviceManager(&mDeviceManagerToken, byRef(mDXGIDeviceManager));
+  hr = wmf::MFCreateDXGIDeviceManager(&mDeviceManagerToken, getter_AddRefs(mDXGIDeviceManager));
   if (!SUCCEEDED(hr)) {
     aFailureReason = nsPrintfCString("MFCreateDXGIDeviceManager failed with code %X", hr);
     return hr;
   }
 
   hr = mDXGIDeviceManager->ResetDevice(mDevice, mDeviceManagerToken);
   if (!SUCCEEDED(hr)) {
     aFailureReason = nsPrintfCString("IMFDXGIDeviceManager::ResetDevice failed with code %X", hr);
@@ -607,18 +607,18 @@ D3D11DXVA2Manager::Init(nsACString& aFai
   }
 
   hr = mTransform->SendMFTMessage(MFT_MESSAGE_SET_D3D_MANAGER, ULONG_PTR(mDXGIDeviceManager.get()));
   if (!SUCCEEDED(hr)) {
     aFailureReason = nsPrintfCString("MFTDecoder::SendMFTMessage(MFT_MESSAGE_SET_D3D_MANAGER) failed with code %X", hr);
     return hr;
   }
 
-  RefPtr<ID3D11VideoDevice> videoDevice;
-  hr = mDevice->QueryInterface(static_cast<ID3D11VideoDevice**>(byRef(videoDevice)));
+  nsRefPtr<ID3D11VideoDevice> videoDevice;
+  hr = mDevice->QueryInterface(static_cast<ID3D11VideoDevice**>(getter_AddRefs(videoDevice)));
   if (!SUCCEEDED(hr)) {
     aFailureReason = nsPrintfCString("QI to ID3D11VideoDevice failed with code %X", hr);
     return hr;
   }
 
   bool found = false;
   UINT profileCount = videoDevice->GetVideoDecoderProfileCount();
   for (UINT i = 0; i < profileCount; i++) {
@@ -641,18 +641,18 @@ D3D11DXVA2Manager::Init(nsACString& aFai
     aFailureReason = nsPrintfCString("CheckVideoDecoderFormat failed with code %X", hr);
     return hr;
   }
   if (!nv12Support) {
     aFailureReason.AssignLiteral("Decoder doesn't support NV12 surfaces");
     return E_FAIL;
   }
 
-  RefPtr<IDXGIDevice> dxgiDevice;
-  hr = mDevice->QueryInterface(static_cast<IDXGIDevice**>(byRef(dxgiDevice)));
+  nsRefPtr<IDXGIDevice> dxgiDevice;
+  hr = mDevice->QueryInterface(static_cast<IDXGIDevice**>(getter_AddRefs(dxgiDevice)));
   if (!SUCCEEDED(hr)) {
     aFailureReason = nsPrintfCString("QI to IDXGIDevice failed with code %X", hr);
     return hr;
   }
 
   nsRefPtr<IDXGIAdapter> adapter;
   hr = dxgiDevice->GetAdapter(adapter.StartAssignment());
   if (!SUCCEEDED(hr)) {
@@ -679,24 +679,24 @@ D3D11DXVA2Manager::Init(nsACString& aFai
   mTextureClientAllocator = new D3D11RecycleAllocator(layers::ImageBridgeChild::GetSingleton(),
                                                       mDevice);
   mTextureClientAllocator->SetMaxPoolSize(5);
 
   return S_OK;
 }
 
 HRESULT
-D3D11DXVA2Manager::CreateOutputSample(RefPtr<IMFSample>& aSample, ID3D11Texture2D* aTexture)
+D3D11DXVA2Manager::CreateOutputSample(nsRefPtr<IMFSample>& aSample, ID3D11Texture2D* aTexture)
 {
-  RefPtr<IMFSample> sample;
-  HRESULT hr = wmf::MFCreateSample(byRef(sample));
+  nsRefPtr<IMFSample> sample;
+  HRESULT hr = wmf::MFCreateSample(getter_AddRefs(sample));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  RefPtr<IMFMediaBuffer> buffer;
-  hr = wmf::MFCreateDXGISurfaceBuffer(__uuidof(ID3D11Texture2D), aTexture, 0, FALSE, byRef(buffer));
+  nsRefPtr<IMFMediaBuffer> buffer;
+  hr = wmf::MFCreateDXGISurfaceBuffer(__uuidof(ID3D11Texture2D), aTexture, 0, FALSE, getter_AddRefs(buffer));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   sample->AddBuffer(buffer);
 
   aSample = sample;
   return S_OK;
 }
 
@@ -724,23 +724,23 @@ D3D11DXVA2Manager::CopyToImage(IMFSample
   HRESULT hr = videoImage->SetData(D3D11ShareHandleImage::Data(mTextureClientAllocator,
                                                                gfx::IntSize(mWidth, mHeight),
                                                                aRegion));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = mTransform->Input(aVideoSample);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  RefPtr<IMFSample> sample;
-  RefPtr<ID3D11Texture2D> texture = videoImage->GetTexture();
+  nsRefPtr<IMFSample> sample;
+  nsRefPtr<ID3D11Texture2D> texture = videoImage->GetTexture();
   hr = CreateOutputSample(sample, texture);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  RefPtr<IDXGIKeyedMutex> keyedMutex;
-  hr = texture->QueryInterface(static_cast<IDXGIKeyedMutex**>(byRef(keyedMutex)));
+  nsRefPtr<IDXGIKeyedMutex> keyedMutex;
+  hr = texture->QueryInterface(static_cast<IDXGIKeyedMutex**>(getter_AddRefs(keyedMutex)));
   NS_ENSURE_TRUE(SUCCEEDED(hr) && keyedMutex, hr);
 
   hr = keyedMutex->AcquireSync(0, INFINITE);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = mTransform->Output(&sample);
 
   keyedMutex->ReleaseSync(0);
@@ -767,45 +767,45 @@ HRESULT ConfigureOutput(IMFMediaType* aO
 }
 
 HRESULT
 D3D11DXVA2Manager::ConfigureForSize(uint32_t aWidth, uint32_t aHeight)
 {
   mWidth = aWidth;
   mHeight = aHeight;
 
-  RefPtr<IMFMediaType> inputType;
-  HRESULT hr = wmf::MFCreateMediaType(byRef(inputType));
+  nsRefPtr<IMFMediaType> inputType;
+  HRESULT hr = wmf::MFCreateMediaType(getter_AddRefs(inputType));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = inputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = inputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_NV12);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = inputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = inputType->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  RefPtr<IMFAttributes> attr = mTransform->GetAttributes();
+  nsRefPtr<IMFAttributes> attr = mTransform->GetAttributes();
 
   hr = attr->SetUINT32(MF_XVP_PLAYBACK_MODE, TRUE);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = attr->SetUINT32(MF_LOW_LATENCY, FALSE);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = MFSetAttributeSize(inputType, MF_MT_FRAME_SIZE, aWidth, aHeight);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  RefPtr<IMFMediaType> outputType;
-  hr = wmf::MFCreateMediaType(byRef(outputType));
+  nsRefPtr<IMFMediaType> outputType;
+  hr = wmf::MFCreateMediaType(getter_AddRefs(outputType));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = outputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = outputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_ARGB32);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
--- a/dom/media/platforms/wmf/MFTDecoder.cpp
+++ b/dom/media/platforms/wmf/MFTDecoder.cpp
@@ -30,17 +30,17 @@ HRESULT
 MFTDecoder::Create(const GUID& aMFTClsID)
 {
   // Create the IMFTransform to do the decoding.
   HRESULT hr;
   hr = CoCreateInstance(aMFTClsID,
                         nullptr,
                         CLSCTX_INPROC_SERVER,
                         IID_IMFTransform,
-                        reinterpret_cast<void**>(static_cast<IMFTransform**>(byRef(mDecoder))));
+                        reinterpret_cast<void**>(static_cast<IMFTransform**>(getter_AddRefs(mDecoder))));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   return S_OK;
 }
 
 HRESULT
 MFTDecoder::SetMediaTypes(IMFMediaType* aInputType,
                           IMFMediaType* aOutputType,
@@ -66,33 +66,33 @@ MFTDecoder::SetMediaTypes(IMFMediaType* 
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   return S_OK;
 }
 
 already_AddRefed<IMFAttributes>
 MFTDecoder::GetAttributes()
 {
-  RefPtr<IMFAttributes> attr;
-  HRESULT hr = mDecoder->GetAttributes(byRef(attr));
+  nsRefPtr<IMFAttributes> attr;
+  HRESULT hr = mDecoder->GetAttributes(getter_AddRefs(attr));
   NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
   return attr.forget();
 }
 
 HRESULT
 MFTDecoder::SetDecoderOutputType(ConfigureOutputCallback aCallback, void* aData)
 {
   NS_ENSURE_TRUE(mDecoder != nullptr, E_POINTER);
 
   // Iterate the enumerate the output types, until we find one compatible
   // with what we need.
   HRESULT hr;
-  RefPtr<IMFMediaType> outputType;
+  nsRefPtr<IMFMediaType> outputType;
   UINT32 typeIndex = 0;
-  while (SUCCEEDED(mDecoder->GetOutputAvailableType(0, typeIndex++, byRef(outputType)))) {
+  while (SUCCEEDED(mDecoder->GetOutputAvailableType(0, typeIndex++, getter_AddRefs(outputType)))) {
     BOOL resultMatch;
     hr = mOutputType->Compare(outputType, MF_ATTRIBUTES_MATCH_OUR_ITEMS, &resultMatch);
     if (SUCCEEDED(hr) && resultMatch == TRUE) {
       if (aCallback) {
         hr = aCallback(outputType, aData);
         NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
       }
       hr = mDecoder->SetOutputType(0, outputType, 0);
@@ -118,29 +118,29 @@ MFTDecoder::SendMFTMessage(MFT_MESSAGE_T
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
   return S_OK;
 }
 
 HRESULT
 MFTDecoder::CreateInputSample(const uint8_t* aData,
                               uint32_t aDataSize,
                               int64_t aTimestamp,
-                              RefPtr<IMFSample>* aOutSample)
+                              nsRefPtr<IMFSample>* aOutSample)
 {
   NS_ENSURE_TRUE(mDecoder != nullptr, E_POINTER);
 
   HRESULT hr;
-  RefPtr<IMFSample> sample;
-  hr = wmf::MFCreateSample(byRef(sample));
+  nsRefPtr<IMFSample> sample;
+  hr = wmf::MFCreateSample(getter_AddRefs(sample));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  RefPtr<IMFMediaBuffer> buffer;
+  nsRefPtr<IMFMediaBuffer> buffer;
   int32_t bufferSize = std::max<uint32_t>(uint32_t(mInputStreamInfo.cbSize), aDataSize);
   UINT32 alignment = (mInputStreamInfo.cbAlignment > 1) ? mInputStreamInfo.cbAlignment - 1 : 0;
-  hr = wmf::MFCreateAlignedMemoryBuffer(bufferSize, alignment, byRef(buffer));
+  hr = wmf::MFCreateAlignedMemoryBuffer(bufferSize, alignment, getter_AddRefs(buffer));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   DWORD maxLength = 0;
   DWORD currentLength = 0;
   BYTE* dst = nullptr;
   hr = buffer->Lock(&dst, &maxLength, &currentLength);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
@@ -160,50 +160,50 @@ MFTDecoder::CreateInputSample(const uint
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   *aOutSample = sample.forget();
 
   return S_OK;
 }
 
 HRESULT
-MFTDecoder::CreateOutputSample(RefPtr<IMFSample>* aOutSample)
+MFTDecoder::CreateOutputSample(nsRefPtr<IMFSample>* aOutSample)
 {
   NS_ENSURE_TRUE(mDecoder != nullptr, E_POINTER);
 
   HRESULT hr;
-  RefPtr<IMFSample> sample;
-  hr = wmf::MFCreateSample(byRef(sample));
+  nsRefPtr<IMFSample> sample;
+  hr = wmf::MFCreateSample(getter_AddRefs(sample));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  RefPtr<IMFMediaBuffer> buffer;
+  nsRefPtr<IMFMediaBuffer> buffer;
   int32_t bufferSize = mOutputStreamInfo.cbSize;
   UINT32 alignment = (mOutputStreamInfo.cbAlignment > 1) ? mOutputStreamInfo.cbAlignment - 1 : 0;
-  hr = wmf::MFCreateAlignedMemoryBuffer(bufferSize, alignment, byRef(buffer));
+  hr = wmf::MFCreateAlignedMemoryBuffer(bufferSize, alignment, getter_AddRefs(buffer));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = sample->AddBuffer(buffer);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   *aOutSample = sample.forget();
 
   return S_OK;
 }
 
 HRESULT
-MFTDecoder::Output(RefPtr<IMFSample>* aOutput)
+MFTDecoder::Output(nsRefPtr<IMFSample>* aOutput)
 {
   NS_ENSURE_TRUE(mDecoder != nullptr, E_POINTER);
 
   HRESULT hr;
 
   MFT_OUTPUT_DATA_BUFFER output = {0};
 
   bool providedSample = false;
-  RefPtr<IMFSample> sample;
+  nsRefPtr<IMFSample> sample;
   if (*aOutput) {
     output.pSample = *aOutput;
     providedSample = true;
   } else if (!mMFTProvidesOutputSamples) {
     hr = CreateOutputSample(&sample);
     NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
     output.pSample = sample;
   }
@@ -258,17 +258,17 @@ MFTDecoder::Output(RefPtr<IMFSample>* aO
 
 HRESULT
 MFTDecoder::Input(const uint8_t* aData,
                   uint32_t aDataSize,
                   int64_t aTimestamp)
 {
   NS_ENSURE_TRUE(mDecoder != nullptr, E_POINTER);
 
-  RefPtr<IMFSample> input;
+  nsRefPtr<IMFSample> input;
   HRESULT hr = CreateInputSample(aData, aDataSize, aTimestamp, &input);
   NS_ENSURE_TRUE(SUCCEEDED(hr) && input != nullptr, hr);
 
   return Input(input);
 }
 
 HRESULT
 MFTDecoder::Input(IMFSample* aSample)
@@ -290,15 +290,15 @@ MFTDecoder::Flush()
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   mDiscontinuity = true;
 
   return S_OK;
 }
 
 HRESULT
-MFTDecoder::GetOutputMediaType(RefPtr<IMFMediaType>& aMediaType)
+MFTDecoder::GetOutputMediaType(nsRefPtr<IMFMediaType>& aMediaType)
 {
   NS_ENSURE_TRUE(mDecoder, E_POINTER);
-  return mDecoder->GetOutputCurrentType(0, byRef(aMediaType));
+  return mDecoder->GetOutputCurrentType(0, getter_AddRefs(aMediaType));
 }
 
 } // namespace mozilla
--- a/dom/media/platforms/wmf/MFTDecoder.h
+++ b/dom/media/platforms/wmf/MFTDecoder.h
@@ -3,17 +3,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/. */
 
 #if !defined(MFTDecoder_h_)
 #define MFTDecoder_h_
 
 #include "WMF.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "nsIThread.h"
 
 namespace mozilla {
 
 class MFTDecoder final {
   ~MFTDecoder();
 
@@ -42,67 +42,67 @@ public:
                         ConfigureOutputCallback aCallback = nullptr,
                         void* aData = nullptr);
 
   // Returns the MFT's IMFAttributes object.
   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);
+  HRESULT GetOutputMediaType(nsRefPtr<IMFMediaType>& aMediaType);
 
   // Submits data into the MFT for processing.
   //
   // Returns:
   //  - MF_E_NOTACCEPTING if the decoder can't accept input. The data
   //    must be resubmitted after Output() stops producing output.
   HRESULT Input(const uint8_t* aData,
                 uint32_t aDataSize,
                 int64_t aTimestampUsecs);
   HRESULT Input(IMFSample* aSample);
 
   HRESULT CreateInputSample(const uint8_t* aData,
                             uint32_t aDataSize,
                             int64_t aTimestampUsecs,
-                            RefPtr<IMFSample>* aOutSample);
+                            nsRefPtr<IMFSample>* aOutSample);
 
   // Retrieves output from the MFT. Call this once Input() returns
   // MF_E_NOTACCEPTING. Some MFTs with hardware acceleration (the H.264
   // decoder MFT in particular) can't handle it if clients hold onto
   // references to the output IMFSample, so don't do that.
   //
   // Returns:
   //  - MF_E_TRANSFORM_STREAM_CHANGE if the underlying stream output
   //    type changed. Retrieve the output media type and reconfig client,
   //    else you may misinterpret the MFT's output.
   //  - MF_E_TRANSFORM_NEED_MORE_INPUT if no output can be produced
   //    due to lack of input.
   //  - S_OK if an output frame is produced.
-  HRESULT Output(RefPtr<IMFSample>* aOutput);
+  HRESULT Output(nsRefPtr<IMFSample>* aOutput);
 
   // Sends a flush message to the MFT. This causes it to discard all
   // input data. Use before seeking.
   HRESULT Flush();
 
   // Sends a message to the MFT.
   HRESULT SendMFTMessage(MFT_MESSAGE_TYPE aMsg, ULONG_PTR aData);
 
 
   HRESULT SetDecoderOutputType(ConfigureOutputCallback aCallback, void* aData);
 private:
 
 
-  HRESULT CreateOutputSample(RefPtr<IMFSample>* aOutSample);
+  HRESULT CreateOutputSample(nsRefPtr<IMFSample>* aOutSample);
 
   MFT_INPUT_STREAM_INFO mInputStreamInfo;
   MFT_OUTPUT_STREAM_INFO mOutputStreamInfo;
 
-  RefPtr<IMFTransform> mDecoder;
+  nsRefPtr<IMFTransform> mDecoder;
 
-  RefPtr<IMFMediaType> mOutputType;
+  nsRefPtr<IMFMediaType> mOutputType;
 
   // True if the IMFTransform allocates the samples that it returns.
   bool mMFTProvidesOutputSamples;
 
   // True if we need to mark the next sample as a discontinuity.
   bool mDiscontinuity;
 };
 
--- a/dom/media/platforms/wmf/WMFAudioMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFAudioMFTManager.cpp
@@ -113,25 +113,25 @@ WMFAudioMFTManager::GetMediaSubtypeGUID(
   };
 }
 
 bool
 WMFAudioMFTManager::Init()
 {
   NS_ENSURE_TRUE(mStreamType != Unknown, false);
 
-  RefPtr<MFTDecoder> decoder(new MFTDecoder());
+  nsRefPtr<MFTDecoder> decoder(new MFTDecoder());
 
   HRESULT hr = decoder->Create(GetMFTGUID());
   NS_ENSURE_TRUE(SUCCEEDED(hr), false);
 
   // Setup input/output media types
-  RefPtr<IMFMediaType> inputType;
+  nsRefPtr<IMFMediaType> inputType;
 
-  hr = wmf::MFCreateMediaType(byRef(inputType));
+  hr = wmf::MFCreateMediaType(getter_AddRefs(inputType));
   NS_ENSURE_TRUE(SUCCEEDED(hr), false);
 
   hr = inputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio);
   NS_ENSURE_TRUE(SUCCEEDED(hr), false);
 
   hr = inputType->SetGUID(MF_MT_SUBTYPE, GetMediaSubtypeGUID());
   NS_ENSURE_TRUE(SUCCEEDED(hr), false);
 
@@ -146,18 +146,18 @@ WMFAudioMFTManager::Init()
     NS_ENSURE_TRUE(SUCCEEDED(hr), false);
 
     hr = inputType->SetBlob(MF_MT_USER_DATA,
                             mUserData.Elements(),
                             mUserData.Length());
     NS_ENSURE_TRUE(SUCCEEDED(hr), false);
   }
 
-  RefPtr<IMFMediaType> outputType;
-  hr = wmf::MFCreateMediaType(byRef(outputType));
+  nsRefPtr<IMFMediaType> outputType;
+  hr = wmf::MFCreateMediaType(getter_AddRefs(outputType));
   NS_ENSURE_TRUE(SUCCEEDED(hr), false);
 
   hr = outputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio);
   NS_ENSURE_TRUE(SUCCEEDED(hr), false);
 
   hr = outputType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM);
   NS_ENSURE_TRUE(SUCCEEDED(hr), false);
 
@@ -180,17 +180,17 @@ WMFAudioMFTManager::Input(MediaRawData* 
                          aSample->mTime);
 }
 
 HRESULT
 WMFAudioMFTManager::UpdateOutputType()
 {
   HRESULT hr;
 
-  RefPtr<IMFMediaType> type;
+  nsRefPtr<IMFMediaType> type;
   hr = mDecoder->GetOutputMediaType(type);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = type->GetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, &mAudioRate);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = type->GetUINT32(MF_MT_AUDIO_NUM_CHANNELS, &mAudioChannels);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
@@ -198,17 +198,17 @@ WMFAudioMFTManager::UpdateOutputType()
   return S_OK;
 }
 
 HRESULT
 WMFAudioMFTManager::Output(int64_t aStreamOffset,
                            nsRefPtr<MediaData>& aOutData)
 {
   aOutData = nullptr;
-  RefPtr<IMFSample> sample;
+  nsRefPtr<IMFSample> sample;
   HRESULT hr;
   int typeChangeCount = 0;
   while (true) {
     hr = mDecoder->Output(&sample);
     if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) {
       return hr;
     }
     if (hr == MF_E_TRANSFORM_STREAM_CHANGE) {
@@ -221,18 +221,18 @@ WMFAudioMFTManager::Output(int64_t aStre
       ++typeChangeCount;
       continue;
     }
     break;
   }
 
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  RefPtr<IMFMediaBuffer> buffer;
-  hr = sample->ConvertToContiguousBuffer(byRef(buffer));
+  nsRefPtr<IMFMediaBuffer> buffer;
+  hr = sample->ConvertToContiguousBuffer(getter_AddRefs(buffer));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   BYTE* data = nullptr; // Note: *data will be owned by the IMFMediaBuffer, we don't need to free it.
   DWORD maxLength = 0, currentLength = 0;
   hr = buffer->Lock(&data, &maxLength, &currentLength);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   // Sometimes when starting decoding, the AAC decoder gives us samples
--- a/dom/media/platforms/wmf/WMFAudioMFTManager.h
+++ b/dom/media/platforms/wmf/WMFAudioMFTManager.h
@@ -4,17 +4,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/. */
 
 #if !defined(WMFAudioOutputSource_h_)
 #define WMFAudioOutputSource_h_
 
 #include "WMF.h"
 #include "MFTDecoder.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "WMFMediaDataDecoder.h"
 
 extern const GUID CLSID_WebmMfVp8Dec;
 extern const GUID CLSID_WebmMfVp9Dec;
 
 namespace mozilla {
 
 class WMFAudioMFTManager : public MFTManager {
--- a/dom/media/platforms/wmf/WMFDecoderModule.cpp
+++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp
@@ -125,17 +125,17 @@ WMFDecoderModule::CreateAudioDecoder(con
 }
 
 static bool
 CanCreateMFTDecoder(const GUID& aGuid)
 {
   if (FAILED(wmf::MFStartup())) {
     return false;
   }
-  RefPtr<MFTDecoder> decoder(new MFTDecoder());
+  nsRefPtr<MFTDecoder> decoder(new MFTDecoder());
   bool hasH264 = SUCCEEDED(decoder->Create(aGuid));
   wmf::MFShutdown();
   return hasH264;
 }
 
 template<const GUID& aGuid>
 static bool
 CanCreateWMFDecoder()
--- a/dom/media/platforms/wmf/WMFMediaDataDecoder.h
+++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #if !defined(WMFMediaDataDecoder_h_)
 #define WMFMediaDataDecoder_h_
 
 
 #include "WMF.h"
 #include "MFTDecoder.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "PlatformDecoderModule.h"
 
 namespace mozilla {
 
 // Encapsulates the initialization of the MFTDecoder appropriate for decoding
 // a given stream, and the process of converting the IMFSample produced
 // by the MFT into a MediaData object.
 class MFTManager {
@@ -49,17 +49,17 @@ public:
   virtual void Shutdown() = 0;
 
   virtual bool IsHardwareAccelerated(nsACString& aFailureReason) const { return false; }
 
   virtual TrackInfo::TrackType GetType() = 0;
 
 protected:
   // IMFTransform wrapper that performs the decoding.
-  RefPtr<MFTDecoder> mDecoder;
+  nsRefPtr<MFTDecoder> mDecoder;
 };
 
 // Decodes audio and video using Windows Media Foundation. Samples are decoded
 // using the MFTDecoder created by the MFTManager. This class implements
 // the higher-level logic that drives mapping the MFT to the async
 // MediaDataDecoder interface. The specifics of decoding the exact stream
 // type are handled by MFTManager and the MFTDecoder it creates.
 class WMFMediaDataDecoder : public MediaDataDecoder {
@@ -96,17 +96,17 @@ private:
   void ProcessFlush();
 
   // Called on the task queue. Orders the MFT to drain, and then extracts
   // all available output.
   void ProcessDrain();
 
   void ProcessShutdown();
 
-  RefPtr<FlushableTaskQueue> mTaskQueue;
+  nsRefPtr<FlushableTaskQueue> mTaskQueue;
   MediaDataDecoderCallback* mCallback;
 
   nsAutoPtr<MFTManager> mMFTManager;
 
   // The last offset into the media resource that was passed into Input().
   // This is used to approximate the decoder's position in the media resource.
   int64_t mLastStreamOffset;
 
--- a/dom/media/platforms/wmf/WMFUtils.cpp
+++ b/dom/media/platforms/wmf/WMFUtils.cpp
@@ -2,17 +2,17 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WMFUtils.h"
 #include <stdint.h>
 #include "mozilla/ArrayUtils.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/WindowsVersion.h"
 #include "mozilla/Logging.h"
 #include "nsThreadUtils.h"
 #include "nsWindowsHelpers.h"
 #include "mozilla/CheckedInt.h"
 #include "VideoUtils.h"
 #include <initguid.h>
 #include "nsTArray.h"
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -200,22 +200,22 @@ WMFVideoMFTManager::Init()
 }
 
 bool
 WMFVideoMFTManager::InitInternal(bool aForceD3D9)
 {
   mUseHwAccel = false; // default value; changed if D3D setup succeeds.
   bool useDxva = InitializeDXVA(aForceD3D9);
 
-  RefPtr<MFTDecoder> decoder(new MFTDecoder());
+  nsRefPtr<MFTDecoder> decoder(new MFTDecoder());
 
   HRESULT hr = decoder->Create(GetMFTGUID());
   NS_ENSURE_TRUE(SUCCEEDED(hr), false);
 
-  RefPtr<IMFAttributes> attr(decoder->GetAttributes());
+  nsRefPtr<IMFAttributes> attr(decoder->GetAttributes());
   UINT32 aware = 0;
   if (attr) {
     attr->GetUINT32(MF_SA_D3D_AWARE, &aware);
     attr->SetUINT32(CODECAPI_AVDecNumWorkerThreads,
       WMFDecoderModule::GetNumDecoderThreads());
     hr = attr->SetUINT32(CODECAPI_AVLowLatencyMode, TRUE);
     if (SUCCEEDED(hr)) {
       LOG("Enabling Low Latency Mode");
@@ -260,31 +260,31 @@ WMFVideoMFTManager::InitInternal(bool aF
 
   return true;
 }
 
 HRESULT
 WMFVideoMFTManager::SetDecoderMediaTypes()
 {
   // Setup the input/output media types.
-  RefPtr<IMFMediaType> inputType;
-  HRESULT hr = wmf::MFCreateMediaType(byRef(inputType));
+  nsRefPtr<IMFMediaType> inputType;
+  HRESULT hr = wmf::MFCreateMediaType(getter_AddRefs(inputType));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = inputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = inputType->SetGUID(MF_MT_SUBTYPE, GetMediaSubtypeGUID());
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = inputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_MixedInterlaceOrProgressive);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  RefPtr<IMFMediaType> outputType;
-  hr = wmf::MFCreateMediaType(byRef(outputType));
+  nsRefPtr<IMFMediaType> outputType;
+  hr = wmf::MFCreateMediaType(getter_AddRefs(outputType));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = outputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   GUID outputSubType = mUseHwAccel ? MFVideoFormat_NV12 : MFVideoFormat_YV12;
   hr = outputType->SetGUID(MF_MT_SUBTYPE, outputSubType);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
@@ -337,17 +337,17 @@ WMFVideoMFTManager::CanUseDXVA(IMFMediaT
   float framerate = 1000000.0 / mLastDuration;
 
   return mDXVA2Manager->SupportsConfig(aType, framerate);
 }
 
 HRESULT
 WMFVideoMFTManager::ConfigureVideoFrameGeometry()
 {
-  RefPtr<IMFMediaType> mediaType;
+  nsRefPtr<IMFMediaType> mediaType;
   HRESULT hr = mDecoder->GetOutputMediaType(mediaType);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   // If we enabled/disabled DXVA in response to a resolution
   // change then we need to renegotiate our media types,
   // and resubmit our previous frame (since the MFT appears
   // to lose it otherwise).
   if (mUseHwAccel && !CanUseDXVA(mediaType)) {
@@ -424,29 +424,29 @@ WMFVideoMFTManager::CreateBasicVideoFram
                                           VideoData** aOutVideoData)
 {
   NS_ENSURE_TRUE(aSample, E_POINTER);
   NS_ENSURE_TRUE(aOutVideoData, E_POINTER);
 
   *aOutVideoData = nullptr;
 
   HRESULT hr;
-  RefPtr<IMFMediaBuffer> buffer;
+  nsRefPtr<IMFMediaBuffer> buffer;
 
   // Must convert to contiguous buffer to use IMD2DBuffer interface.
-  hr = aSample->ConvertToContiguousBuffer(byRef(buffer));
+  hr = aSample->ConvertToContiguousBuffer(getter_AddRefs(buffer));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   // Try and use the IMF2DBuffer interface if available, otherwise fallback
   // to the IMFMediaBuffer interface. Apparently IMF2DBuffer is more efficient,
   // but only some systems (Windows 8?) support it.
   BYTE* data = nullptr;
   LONG stride = 0;
-  RefPtr<IMF2DBuffer> twoDBuffer;
-  hr = buffer->QueryInterface(static_cast<IMF2DBuffer**>(byRef(twoDBuffer)));
+  nsRefPtr<IMF2DBuffer> twoDBuffer;
+  hr = buffer->QueryInterface(static_cast<IMF2DBuffer**>(getter_AddRefs(twoDBuffer)));
   if (SUCCEEDED(hr)) {
     hr = twoDBuffer->Lock2D(&data, &stride);
     NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
   } else {
     hr = buffer->Lock(&data, nullptr, nullptr);
     NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
     stride = mVideoStride;
   }
@@ -561,17 +561,17 @@ WMFVideoMFTManager::CreateD3DVideoFrame(
   return S_OK;
 }
 
 // Blocks until decoded sample is produced by the deoder.
 HRESULT
 WMFVideoMFTManager::Output(int64_t aStreamOffset,
                            nsRefPtr<MediaData>& aOutData)
 {
-  RefPtr<IMFSample> sample;
+  nsRefPtr<IMFSample> sample;
   HRESULT hr;
   aOutData = nullptr;
   int typeChangeCount = 0;
 
   // Loop until we decode a sample, or an unexpected error that we can't
   // handle occurs.
   while (true) {
     hr = mDecoder->Output(&sample);
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -6,17 +6,17 @@
 
 #if !defined(WMFVideoMFTManager_h_)
 #define WMFVideoMFTManager_h_
 
 #include "WMF.h"
 #include "MFTDecoder.h"
 #include "nsRect.h"
 #include "WMFMediaDataDecoder.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 
 class DXVA2Manager;
 
 class WMFVideoMFTManager : public MFTManager {
 public:
   WMFVideoMFTManager(const VideoInfo& aConfig,
@@ -61,20 +61,20 @@ private:
 
   // Video frame geometry.
   VideoInfo mVideoInfo;
   uint32_t mVideoStride;
   uint32_t mVideoWidth;
   uint32_t mVideoHeight;
   nsIntRect mPictureRegion;
 
-  RefPtr<layers::ImageContainer> mImageContainer;
+  nsRefPtr<layers::ImageContainer> mImageContainer;
   nsAutoPtr<DXVA2Manager> mDXVA2Manager;
 
-  RefPtr<IMFSample> mLastInput;
+  nsRefPtr<IMFSample> mLastInput;
   float mLastDuration;
 
   bool mDXVAEnabled;
   const layers::LayersBackend mLayersBackend;
   bool mUseHwAccel;
 
   nsCString mDXVAFailureReason;
 
--- a/dom/media/systemservices/LoadMonitor.cpp
+++ b/dom/media/systemservices/LoadMonitor.cpp
@@ -531,17 +531,17 @@ nsresult RTCLoadInfo::UpdateProcessLoad(
 }
 
 // Note: This class can't be in the anonymous namespace, because then we can't
 // declare it as a friend of LoadMonitor.
 class LoadInfoCollectRunner : public nsRunnable
 {
 public:
   LoadInfoCollectRunner(nsRefPtr<LoadMonitor> loadMonitor,
-                        RefPtr<RTCLoadInfo> loadInfo,
+                        nsRefPtr<RTCLoadInfo> loadInfo,
                         nsIThread *loadInfoThread)
     : mThread(loadInfoThread),
       mLoadUpdateInterval(loadMonitor->mLoadUpdateInterval),
       mLoadNoiseCounter(0)
   {
     mLoadMonitor = loadMonitor;
     mLoadInfo = loadInfo;
   }
@@ -580,17 +580,17 @@ public:
     }
     // ok, we need to exit safely and can't shut ourselves down (DARN)
     NS_DispatchToMainThread(this);
     return NS_OK;
   }
 
 private:
   nsCOMPtr<nsIThread> mThread;
-  RefPtr<RTCLoadInfo> mLoadInfo;
+  nsRefPtr<RTCLoadInfo> mLoadInfo;
   nsRefPtr<LoadMonitor> mLoadMonitor;
   int mLoadUpdateInterval;
   int mLoadNoiseCounter;
 };
 
 void
 LoadMonitor::SetProcessLoad(float load) {
   mLock.AssertCurrentThreadOwns();
@@ -624,17 +624,17 @@ LoadMonitor::GetSystemLoad() {
   return load;
 }
 
 nsresult
 LoadMonitor::Init(nsRefPtr<LoadMonitor> &self)
 {
   LOG(("Initializing LoadMonitor"));
 
-  RefPtr<RTCLoadInfo> load_info = new RTCLoadInfo();
+  nsRefPtr<RTCLoadInfo> load_info = new RTCLoadInfo();
   nsresult rv = load_info->Init(mLoadUpdateInterval);
 
   if (NS_FAILED(rv)) {
     LOG(("RTCLoadInfo::Init error"));
     return rv;
   }
 
   nsRefPtr<LoadMonitorAddObserver> addObsRunner = new LoadMonitorAddObserver(self);
--- a/dom/media/systemservices/LoadMonitor.h
+++ b/dom/media/systemservices/LoadMonitor.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 _LOADMONITOR_H_
 #define _LOADMONITOR_H_
 
 #include "mozilla/Mutex.h"
 #include "mozilla/CondVar.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/Atomics.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsIThread.h"
 #include "nsIObserver.h"
 
 namespace mozilla {
 class LoadInfoCollectRunner;
--- a/dom/media/webaudio/MediaBufferDecoder.cpp
+++ b/dom/media/webaudio/MediaBufferDecoder.cpp
@@ -475,17 +475,17 @@ AsyncDecodeWebAudio(const char* aContent
       new ReportResultTask(aDecodeJob,
                            &WebAudioDecodeJob::OnFailure,
                            WebAudioDecodeJob::UnknownContent);
     JS_free(nullptr, aBuffer);
     NS_DispatchToMainThread(event);
     return;
   }
 
-  RefPtr<MediaDecodeTask> task =
+  nsRefPtr<MediaDecodeTask> task =
     new MediaDecodeTask(aContentType, aBuffer, aLength, aDecodeJob);
   if (!task->CreateReader()) {
     nsCOMPtr<nsIRunnable> event =
       new ReportResultTask(aDecodeJob,
                            &WebAudioDecodeJob::OnFailure,
                            WebAudioDecodeJob::UnknownError);
     NS_DispatchToMainThread(event);
   } else {
--- a/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp
+++ b/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp
@@ -41,17 +41,17 @@ size_t HRTFDatabaseLoader::sizeOfLoaders
 {
     return s_loaderMap ? s_loaderMap->SizeOfIncludingThis(aMallocSizeOf) : 0;
 }
 
 already_AddRefed<HRTFDatabaseLoader> HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(float sampleRate)
 {
     MOZ_ASSERT(NS_IsMainThread());
 
-    RefPtr<HRTFDatabaseLoader> loader;
+    nsRefPtr<HRTFDatabaseLoader> loader;
     
     if (!s_loaderMap) {
         s_loaderMap = new nsTHashtable<LoaderByRateEntry>();
     }
 
     LoaderByRateEntry* entry = s_loaderMap->PutEntry(sampleRate);
     loader = entry->mLoader;
     if (loader) { // existing entry
--- a/dom/media/webaudio/blink/HRTFDatabaseLoader.h
+++ b/dom/media/webaudio/blink/HRTFDatabaseLoader.h
@@ -25,17 +25,17 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef HRTFDatabaseLoader_h
 #define HRTFDatabaseLoader_h
 
 #include "nsHashKeys.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Mutex.h"
 #include "HRTFDatabase.h"
 
 template <class EntryType> class nsTHashtable;
 template <class T> class nsAutoRef;
 
 namespace WebCore {
--- a/dom/media/webaudio/blink/HRTFPanner.h
+++ b/dom/media/webaudio/blink/HRTFPanner.h
@@ -58,17 +58,17 @@ public:
 
     size_t sizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
 private:
     // Given an azimuth angle in the range -180 -> +180, returns the corresponding azimuth index for the database,
     // and azimuthBlend which is an interpolation value from 0 -> 1.
     int calculateDesiredAzimuthIndexAndBlend(double azimuth, double& azimuthBlend);
 
-    mozilla::RefPtr<HRTFDatabaseLoader> m_databaseLoader;
+    nsRefPtr<HRTFDatabaseLoader> m_databaseLoader;
 
     float m_sampleRate;
 
     // We maintain two sets of convolvers for smooth cross-faded interpolations when
     // then azimuth and elevation are dynamically changing.
     // When the azimuth and elevation are not changing, we simply process with one of the two sets.
     // Initially we use CrossfadeSelection1 corresponding to m_convolverL1 and m_convolverR1.
     // Whenever the azimuth or elevation changes, a crossfade is initiated to transition
--- a/dom/media/webrtc/MediaEngine.h
+++ b/dom/media/webrtc/MediaEngine.h
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MEDIAENGINE_H_
 #define MEDIAENGINE_H_
 
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "DOMMediaStream.h"
 #include "MediaStreamGraph.h"
 #include "mozilla/dom/MediaStreamTrackBinding.h"
 #include "mozilla/dom/VideoStreamTrack.h"
 
 namespace mozilla {
 
 namespace dom {
--- a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
@@ -752,24 +752,24 @@ MediaEngineGonkVideoSource::RotateImage(
     dstWidth = aWidth;
     dstHeight = aHeight;
   }
 
   uint32_t half_width = dstWidth / 2;
 
   layers::GrallocImage* videoImage = static_cast<layers::GrallocImage*>(image.get());
   MOZ_ASSERT(mTextureClientAllocator);
-  RefPtr<layers::TextureClient> textureClient
+  nsRefPtr<layers::TextureClient> textureClient
     = mTextureClientAllocator->CreateOrRecycle(gfx::SurfaceFormat::YUV,
                                                gfx::IntSize(dstWidth, dstHeight),
                                                layers::BackendSelector::Content,
                                                layers::TextureFlags::DEFAULT,
                                                layers::ALLOC_DISALLOW_BUFFERTEXTURECLIENT);
   if (textureClient) {
-    RefPtr<layers::GrallocTextureClientOGL> grallocTextureClient =
+    nsRefPtr<layers::GrallocTextureClientOGL> grallocTextureClient =
       static_cast<layers::GrallocTextureClientOGL*>(textureClient.get());
 
     android::sp<android::GraphicBuffer> destBuffer = grallocTextureClient->GetGraphicBuffer();
 
     void* destMem = nullptr;
     destBuffer->lock(android::GraphicBuffer::USAGE_SW_WRITE_OFTEN, &destMem);
     uint8_t* dstPtr = static_cast<uint8_t*>(destMem);
 
--- a/dom/media/webrtc/MediaEngineGonkVideoSource.h
+++ b/dom/media/webrtc/MediaEngineGonkVideoSource.h
@@ -125,14 +125,14 @@ protected:
 
   // These are protected by mMonitor in parent class
   nsTArray<nsRefPtr<PhotoCallback>> mPhotoCallbacks;
   int mRotation;
   int mCameraAngle; // See dom/base/ScreenOrientation.h
   bool mBackCamera;
   bool mOrientationChanged; // True when screen rotates.
 
-  RefPtr<layers::TextureClientRecycleAllocator> mTextureClientAllocator;
+  nsRefPtr<layers::TextureClientRecycleAllocator> mTextureClientAllocator;
 };
 
 } // namespace mozilla
 
 #endif // MediaEngineGonkVideoSource_h_
--- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaEngineRemoteVideoSource.h"
 
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "VideoUtils.h"
 #include "nsIPrefService.h"
 #include "MediaTrackConstraints.h"
 #include "CamerasChild.h"
 
 extern PRLogModuleInfo* GetMediaManagerLog();
 #define LOG(msg) MOZ_LOG(GetMediaManagerLog(), mozilla::LogLevel::Debug, msg)
 #define LOGFRAME(msg) MOZ_LOG(GetMediaManagerLog(), mozilla::LogLevel::Verbose, msg)
--- a/dom/media/webrtc/MediaEngineTabVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineTabVideoSource.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaEngineTabVideoSource.h"
 
 #include "mozilla/gfx/2D.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsGlobalWindow.h"
 #include "nsIDOMClientRect.h"
 #include "nsIDocShell.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "gfxContext.h"
 #include "gfx2DGlue.h"
 #include "ImageContainer.h"
@@ -244,32 +244,32 @@ MediaEngineTabVideoSource::Draw() {
   uint32_t renderDocFlags = 0;
   if (!mScrollWithPage) {
     renderDocFlags |= nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING;
   }
   nsRect r(0, 0, nsPresContext::CSSPixelsToAppUnits((float)innerWidth),
            nsPresContext::CSSPixelsToAppUnits((float)innerHeight));
 
   nsRefPtr<layers::ImageContainer> container = layers::LayerManager::CreateImageContainer();
-  RefPtr<DrawTarget> dt =
+  nsRefPtr<DrawTarget> dt =
     Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                      mData.rwget(),
                                      size,
                                      stride,
                                      SurfaceFormat::B8G8R8X8);
   if (!dt) {
     return;
   }
   nsRefPtr<gfxContext> context = new gfxContext(dt);
   context->SetMatrix(context->CurrentMatrix().Scale((((float) size.width)/innerWidth),
                                                     (((float) size.height)/innerHeight)));
 
   NS_ENSURE_SUCCESS_VOID(presShell->RenderDocument(r, renderDocFlags, bgColor, context));
 
-  RefPtr<SourceSurface> surface = dt->Snapshot();
+  nsRefPtr<SourceSurface> surface = dt->Snapshot();
   if (!surface) {
     return;
   }
 
   layers::CairoImage::Data cairoData;
   cairoData.mSize = size;
   cairoData.mSourceSurface = surface;
 
--- a/dom/media/webrtc/RTCCertificate.cpp
+++ b/dom/media/webrtc/RTCCertificate.cpp
@@ -306,26 +306,26 @@ RTCCertificate::~RTCCertificate()
 // Unfortunately, the code that uses DtlsIdentity cannot always use that lock
 // due to external linkage requirements.  Therefore, the lock is held on this
 // object instead.  Consequently, the DtlsIdentity that this method returns must
 // have a lifetime that is strictly shorter than the RTCCertificate.
 //
 // RTCPeerConnection provides this guarantee by holding a strong reference to
 // the RTCCertificate.  It will cleanup any DtlsIdentity instances that it
 // creates before the RTCCertificate reference is released.
-RefPtr<DtlsIdentity>
+nsRefPtr<DtlsIdentity>
 RTCCertificate::CreateDtlsIdentity() const
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown() || !mPrivateKey || !mCertificate) {
     return nullptr;
   }
   SECKEYPrivateKey* key = SECKEY_CopyPrivateKey(mPrivateKey);
   CERTCertificate* cert = CERT_DupCertificate(mCertificate);
-  RefPtr<DtlsIdentity> id = new DtlsIdentity(key, cert, mAuthType);
+  nsRefPtr<DtlsIdentity> id = new DtlsIdentity(key, cert, mAuthType);
   return id;
 }
 
 JSObject*
 RTCCertificate::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return RTCCertificateBinding::Wrap(aCx, this, aGivenProto);
 }
--- a/dom/media/webrtc/RTCCertificate.h
+++ b/dom/media/webrtc/RTCCertificate.h
@@ -12,17 +12,17 @@
 #include "nsIGlobalObject.h"
 #include "nsNSSShutDown.h"
 #include "prtime.h"
 #include "sslt.h"
 #include "ScopedNSSTypes.h"
 
 #include "mozilla/ErrorResult.h"
 #include "mozilla/UniquePtr.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/dom/Date.h"
 #include "mozilla/dom/CryptoKey.h"
 #include "mtransport/dtlsidentity.h"
 #include "js/Date.h"
 #include "js/StructuredClone.h"
 #include "js/TypeDecls.h"
 
 namespace mozilla {
@@ -56,17 +56,17 @@ public:
   // WebIDL expires attribute.  Note: JS dates are milliseconds since epoch;
   // NSPR PRTime is in microseconds since the same epoch.
   JS::ClippedTime Expires() const
   {
     return JS::TimeClip(mExpires / PR_USEC_PER_MSEC);
   }
 
   // Accessors for use by PeerConnectionImpl.
-  RefPtr<DtlsIdentity> CreateDtlsIdentity() const;
+  nsRefPtr<DtlsIdentity> CreateDtlsIdentity() const;
   CERTCertificate* Certificate() const { return mCertificate; }
 
   // For nsNSSShutDownObject
   virtual void virtualDestroyNSSReference() override;
   void destructorSafeDestroyNSSReference();
 
   // Structured clone methods
   bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const;
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -960,17 +960,17 @@ already_AddRefed<AndroidSurfaceTexture> 
 {
   if (!EnsureGLContext())
     return nullptr;
 
   GLuint texture = TexturePoolOGL::AcquireTexture();
   if (!texture)
     return nullptr;
 
-  RefPtr<AndroidSurfaceTexture> surface = AndroidSurfaceTexture::Create(TexturePoolOGL::GetGLContext(),
+  nsRefPtr<AndroidSurfaceTexture> surface = AndroidSurfaceTexture::Create(TexturePoolOGL::GetGLContext(),
                                                                         texture);
   if (!surface) {
     return nullptr;
   }
 
   nsCOMPtr<nsIRunnable> frameCallback = NS_NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable);
   surface->SetFrameAvailableCallback(frameCallback);
   return surface.forget();
@@ -1009,17 +1009,17 @@ nsNPAPIPluginInstance::AsSurfaceTexture(
   if (!mContentSurface)
     return nullptr;
 
   return mContentSurface;
 }
 
 void* nsNPAPIPluginInstance::AcquireVideoWindow()
 {
-  RefPtr<AndroidSurfaceTexture> surface = CreateSurfaceTexture();
+  nsRefPtr<AndroidSurfaceTexture> surface = CreateSurfaceTexture();
   if (!surface) {
     return nullptr;
   }
 
   VideoInfo* info = new VideoInfo(surface);
 
   void* window = info->mSurfaceTexture->NativeWindow()->Handle();
   mVideos.insert(std::pair<void*, VideoInfo*>(window, info));
--- a/dom/plugins/base/nsNPAPIPluginInstance.h
+++ b/dom/plugins/base/nsNPAPIPluginInstance.h
@@ -216,17 +216,17 @@ public:
     {
     }
 
     ~VideoInfo()
     {
       mSurfaceTexture = nullptr;
     }
 
-    mozilla::RefPtr<mozilla::gl::AndroidSurfaceTexture> mSurfaceTexture;
+    nsRefPtr<mozilla::gl::AndroidSurfaceTexture> mSurfaceTexture;
     gfxRect mDimensions;
   };
 
   void* AcquireVideoWindow();
   void ReleaseVideoWindow(void* aWindow);
   void SetVideoDimensions(void* aWindow, gfxRect aDimensions);
 
   void GetVideos(nsTArray<VideoInfo*>& aVideos);
@@ -340,18 +340,18 @@ protected:
   void PopPostedEvent(PluginEventRunnable* r);
   void OnSurfaceTextureFrameAvailable();
 
   uint32_t mFullScreenOrientation;
   bool mWakeLocked;
   bool mFullScreen;
   mozilla::gl::OriginPos mOriginPos;
 
-  mozilla::RefPtr<SharedPluginTexture> mContentTexture;
-  mozilla::RefPtr<mozilla::gl::AndroidSurfaceTexture> mContentSurface;
+  nsRefPtr<SharedPluginTexture> mContentTexture;
+  nsRefPtr<mozilla::gl::AndroidSurfaceTexture> mContentSurface;
 #endif
 
   enum {
     NOT_STARTED,
     RUNNING,
     DESTROYING,
     DESTROYED
   } mRunning;
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -1228,17 +1228,17 @@ void nsPluginInstanceOwner::RenderCoreAn
       (mIOSurface->GetWidth() != (size_t)aWidth ||
        mIOSurface->GetHeight() != (size_t)aHeight ||
        mIOSurface->GetContentsScaleFactor() != scaleFactor)) {
     mIOSurface = nullptr;
 
     // If the renderer is backed by an IOSurface, resize it as required.
     mIOSurface = MacIOSurface::CreateIOSurface(aWidth, aHeight, scaleFactor);
     if (mIOSurface) {
-      RefPtr<MacIOSurface> attachSurface = MacIOSurface::LookupSurface(
+      nsRefPtr<MacIOSurface> attachSurface = MacIOSurface::LookupSurface(
                                               mIOSurface->GetIOSurfaceID(),
                                               scaleFactor);
       if (attachSurface) {
         mCARenderer->AttachIOSurface(attachSurface);
       } else {
         NS_ERROR("IOSurface attachment failed");
         mIOSurface = nullptr;
       }
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -290,18 +290,18 @@ private:
   nsCString                   mDocumentBase;
   bool                        mWidgetCreationComplete;
   nsCOMPtr<nsIWidget>         mWidget;
   nsRefPtr<nsPluginHost>      mPluginHost;
   
 #ifdef XP_MACOSX
   NP_CGContext                              mCGPluginPortCopy;
   int32_t                                   mInCGPaintLevel;
-  mozilla::RefPtr<MacIOSurface>             mIOSurface;
-  mozilla::RefPtr<nsCARenderer>             mCARenderer;
+  nsRefPtr<MacIOSurface>             mIOSurface;
+  nsRefPtr<nsCARenderer>             mCARenderer;
   CGColorSpaceRef                           mColorProfile;
   static nsCOMPtr<nsITimer>                *sCATimer;
   static nsTArray<nsPluginInstanceOwner*>  *sCARefreshListeners;
   bool                                      mSentInitialTopLevelWindowEvent;
   bool                                      mLastWindowIsActive;
   bool                                      mLastContentFocused;
   double                                    mLastScaleFactor;
   // True if, the next time the window is activated, we should blur ourselves.
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -96,21 +96,21 @@ struct RunnableMethodTraits<PluginInstan
 };
 
 /**
  * We can't use gfxPlatform::CreateDrawTargetForSurface() because calling
  * gfxPlatform::GetPlatform() instantiates the prefs service, and that's not
  * allowed from processes other than the main process. So we have our own
  * version here.
  */
-static RefPtr<DrawTarget>
+static nsRefPtr<DrawTarget>
 CreateDrawTargetForSurface(gfxASurface *aSurface)
 {
   SurfaceFormat format = aSurface->GetSurfaceFormat();
-  RefPtr<DrawTarget> drawTarget =
+  nsRefPtr<DrawTarget> drawTarget =
     Factory::CreateDrawTargetForCairoSurface(aSurface->CairoSurface(),
                                              aSurface->GetSize(),
                                              &format);
   if (!drawTarget) {
     NS_RUNTIMEABORT("CreateDrawTargetForSurface failed in plugin");
   }
   aSurface->SetData(&kDrawTarget, drawTarget, nullptr);
   return drawTarget;
@@ -990,17 +990,17 @@ PluginInstanceChild::AnswerNPP_HandleEve
 {
     PLUGIN_LOG_DEBUG_FUNCTION;
     AssertPluginThread();
 
     PaintTracker pt;
 
     NPCocoaEvent evcopy = event.event;
     mContentsScaleFactor = event.contentsScaleFactor;
-    RefPtr<MacIOSurface> surf = MacIOSurface::LookupSurface(surfaceid,
+    nsRefPtr<MacIOSurface> surf = MacIOSurface::LookupSurface(surfaceid,
                                                             mContentsScaleFactor);
     if (!surf) {
         NS_ERROR("Invalid IOSurface.");
         *handled = false;
         return false;
     }
 
     if (!mCARenderer) {
@@ -3231,32 +3231,32 @@ PluginInstanceChild::PaintRectToSurface(
     }
     if (mHelperSurface) {
         // On X11 we can paint to non Xlib surface only with HelperSurface
         renderSurface = mHelperSurface;
     }
 #endif
 
     if (mIsTransparent && !CanPaintOnBackground()) {
-        RefPtr<DrawTarget> dt = CreateDrawTargetForSurface(renderSurface);
+        nsRefPtr<DrawTarget> dt = CreateDrawTargetForSurface(renderSurface);
         gfx::Rect rect(plPaintRect.x, plPaintRect.y,
                        plPaintRect.width, plPaintRect.height);
         // Moz2D treats OP_SOURCE operations as unbounded, so we need to
         // clip to the rect that we want to fill:
         dt->PushClipRect(rect);
         dt->FillRect(rect, ColorPattern(aColor), // aColor is already a device color
                      DrawOptions(1.f, CompositionOp::OP_SOURCE));
         dt->PopClip();
         dt->Flush();
     }
 
     PaintRectToPlatformSurface(plPaintRect, renderSurface);
 
     if (renderSurface != aSurface) {
-      RefPtr<DrawTarget> dt;
+      nsRefPtr<DrawTarget> dt;
       if (aSurface == mCurrentSurface &&
           aSurface->GetType() == gfxSurfaceType::Image &&
           aSurface->GetSurfaceFormat() == SurfaceFormat::B8G8R8X8) {
         gfxImageSurface* imageSurface = static_cast<gfxImageSurface*>(aSurface);
         // Bug 1196927 - Reinterpret target surface as BGRA to fill alpha with opaque.
         // Certain backends (i.e. Skia) may not truly support BGRX formats, so they must
         // be emulated by filling the alpha channel opaque as if it was BGRA data. Cairo
         // leaves the alpha zeroed out for BGRX, so we cause Cairo to fill it as opaque
@@ -3265,17 +3265,17 @@ PluginInstanceChild::PaintRectToSurface(
                                               imageSurface->Data(),
                                               imageSurface->GetSize(),
                                               imageSurface->Stride(),
                                               SurfaceFormat::B8G8R8A8);
       } else {
         // Copy helper surface content to target
         dt = CreateDrawTargetForSurface(aSurface);
       }
-      RefPtr<SourceSurface> surface =
+      nsRefPtr<SourceSurface> surface =
         gfxPlatform::GetSourceSurfaceForSurface(dt, renderSurface);
       dt->CopySurface(surface, aRect, aRect.TopLeft());
     }
 }
 
 void
 PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
                                                   gfxASurface* aSurface)
@@ -3322,18 +3322,18 @@ PluginInstanceChild::PaintRectWithAlphaE
     // we don't accidentally attempt that.
     if (!SharedDIBSurface::IsSharedDIBSurface(aSurface))
         NS_RUNTIMEABORT("Expected SharedDIBSurface!");
 
     // Paint the plugin directly onto the target, with a white
     // background and copy the result
     PaintRectToSurface(rect, aSurface, Color(1.f, 1.f, 1.f));
     {
-        RefPtr<DrawTarget> dt = CreateDrawTargetForSurface(whiteImage);
-        RefPtr<SourceSurface> surface =
+        nsRefPtr<DrawTarget> dt = CreateDrawTargetForSurface(whiteImage);
+        nsRefPtr<SourceSurface> surface =
             gfxPlatform::GetSourceSurfaceForSurface(dt, aSurface);
         dt->CopySurface(surface, rect, IntPoint());
     }
 
     // Paint the plugin directly onto the target, with a black
     // background
     PaintRectToSurface(rect, aSurface, Color(0.f, 0.f, 0.f));
 
@@ -3366,18 +3366,18 @@ PluginInstanceChild::PaintRectWithAlphaE
     // image
     if (!gfxAlphaRecovery::RecoverAlpha(blackImage, whiteImage)) {
         return;
     }
 
     // If we had to use a temporary black surface, copy the pixels
     // with alpha back to the target
     if (!useSurfaceSubimageForBlack) {
-        RefPtr<DrawTarget> dt = CreateDrawTargetForSurface(aSurface);
-        RefPtr<SourceSurface> surface =
+        nsRefPtr<DrawTarget> dt = CreateDrawTargetForSurface(aSurface);
+        nsRefPtr<SourceSurface> surface =
             gfxPlatform::GetSourceSurfaceForSurface(dt, blackImage);
         dt->CopySurface(surface,
                         IntRect(0, 0, rect.width, rect.height),
                         rect.TopLeft());
     }
 }
 
 bool
@@ -3505,18 +3505,18 @@ PluginInstanceChild::ShowPluginFrame()
          mCurrentSurface->GetSize().width, mCurrentSurface->GetSize().height));
 
     if (CanPaintOnBackground()) {
         PLUGIN_LOG_DEBUG(("  (on background)"));
         // Source the background pixels ...
         {
             nsRefPtr<gfxASurface> surface =
                 mHelperSurface ? mHelperSurface : mCurrentSurface;
-            RefPtr<DrawTarget> dt = CreateDrawTargetForSurface(surface);
-            RefPtr<SourceSurface> backgroundSurface =
+            nsRefPtr<DrawTarget> dt = CreateDrawTargetForSurface(surface);
+            nsRefPtr<SourceSurface> backgroundSurface =
                 gfxPlatform::GetSourceSurfaceForSurface(dt, mBackground);
             dt->CopySurface(backgroundSurface, rect, rect.TopLeft());
         }
         // ... and hand off to the plugin
         // BEWARE: mBackground may die during this call
         PaintRectToSurface(rect, mCurrentSurface, Color());
     } else if (!temporarilyMakeVisible && mDoAlphaExtraction) {
         // We don't want to pay the expense of alpha extraction for
@@ -3631,18 +3631,18 @@ PluginInstanceChild::ReadbackDifferenceR
         return true;
 
     PLUGIN_LOG_DEBUG(
         ("[InstanceChild][%p] Reading back part of <x=%d,y=%d, w=%d,h=%d>",
          this, mSurfaceDifferenceRect.x, mSurfaceDifferenceRect.y,
          mSurfaceDifferenceRect.width, mSurfaceDifferenceRect.height));
 
     // Read back previous content
-    RefPtr<DrawTarget> dt = CreateDrawTargetForSurface(mCurrentSurface);
-    RefPtr<SourceSurface> source =
+    nsRefPtr<DrawTarget> dt = CreateDrawTargetForSurface(mCurrentSurface);
+    nsRefPtr<SourceSurface> source =
         gfxPlatform::GetSourceSurfaceForSurface(dt, mBackSurface);
     // Subtract from mSurfaceDifferenceRect area which is overlapping with rect
     nsIntRegion result;
     result.Sub(mSurfaceDifferenceRect, nsIntRegion(rect));
     nsIntRegionRectIterator iter(result);
     const nsIntRect* r;
     while ((r = iter.Next()) != nullptr) {
         dt->CopySurface(source, *r, r->TopLeft());
--- a/dom/plugins/ipc/PluginInstanceChild.h
+++ b/dom/plugins/ipc/PluginInstanceChild.h
@@ -452,17 +452,17 @@ private:
 #endif // defined(OS_WIN)
 #if defined(MOZ_WIDGET_COCOA)
 private:
 #if defined(__i386__)
     NPEventModel                  mEventModel;
 #endif
     CGColorSpaceRef               mShColorSpace;
     CGContextRef                  mShContext;
-    mozilla::RefPtr<nsCARenderer> mCARenderer;
+    nsRefPtr<nsCARenderer> mCARenderer;
     void                         *mCGLayer;
 
     // Core Animation drawing model requires a refresh timer.
     uint32_t                      mCARefreshTimer;
 
 public:
     const NPCocoaEvent* getCurrentEvent() {
         return mCurrentEvent;
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -542,17 +542,17 @@ PluginInstanceParent::RecvShow(const NPR
             return false;
         }
         surface = gfxSharedImageSurface::Open(newSurface.get_Shmem());
     }
 #ifdef XP_MACOSX
     else if (newSurface.type() == SurfaceDescriptor::TIOSurfaceDescriptor) {
         IOSurfaceDescriptor iodesc = newSurface.get_IOSurfaceDescriptor();
 
-        RefPtr<MacIOSurface> newIOSurface =
+        nsRefPtr<MacIOSurface> newIOSurface =
           MacIOSurface::LookupSurface(iodesc.surfaceId(),
                                       iodesc.contentsScaleFactor());
 
         if (!newIOSurface) {
             NS_WARNING("Got bad IOSurfaceDescriptor in RecvShow");
             return false;
         }
 
@@ -795,17 +795,17 @@ PluginInstanceParent::BeginUpdateBackgro
     }
 
     mozilla::gfx::IntSize sz = mBackground->GetSize();
 #ifdef DEBUG
     MOZ_ASSERT(nsIntRect(0, 0, sz.width, sz.height).Contains(aRect),
                "Update outside of background area");
 #endif
 
-    RefPtr<gfx::DrawTarget> dt = gfxPlatform::GetPlatform()->
+    nsRefPtr<gfx::DrawTarget> dt = gfxPlatform::GetPlatform()->
       CreateDrawTargetForSurface(mBackground, gfx::IntSize(sz.width, sz.height));
     nsRefPtr<gfxContext> ctx = new gfxContext(dt);
     ctx.forget(aCtx);
 
     return NS_OK;
 }
 
 nsresult
--- a/dom/plugins/ipc/PluginInstanceParent.h
+++ b/dom/plugins/ipc/PluginInstanceParent.h
@@ -383,18 +383,18 @@ private:
     nsRefPtrHashtable<nsPtrHashKey<void>, ID3D10Texture2D> mTextureMap;
 #endif // defined(XP_WIN)
 #if defined(MOZ_WIDGET_COCOA)
 private:
     Shmem                  mShSurface; 
     uint16_t               mShWidth;
     uint16_t               mShHeight;
     CGColorSpaceRef        mShColorSpace;
-    RefPtr<MacIOSurface> mIOSurface;
-    RefPtr<MacIOSurface> mFrontIOSurface;
+    nsRefPtr<MacIOSurface> mIOSurface;
+    nsRefPtr<MacIOSurface> mFrontIOSurface;
 #endif // definied(MOZ_WIDGET_COCOA)
 
     // ObjectFrame layer wrapper
     nsRefPtr<gfxASurface>    mFrontSurface;
     // For windowless+transparent instances, this surface contains a
     // "pretty recent" copy of the pixels under its <object> frame.
     // On the plugin side, we use this surface to avoid doing alpha
     // recovery when possible.  This surface is created and owned by
--- a/dom/plugins/ipc/PluginUtilsOSX.h
+++ b/dom/plugins/ipc/PluginUtilsOSX.h
@@ -75,19 +75,19 @@ public:
   void SwapSurfaces();
   void ClearFrontSurface();
   void ClearBackSurface();
 
   double GetContentsScaleFactor() { return mContentsScaleFactor; }
 
 private:
   void *mCALayer;
-  RefPtr<nsCARenderer> mCARenderer;
-  RefPtr<MacIOSurface> mFrontSurface;
-  RefPtr<MacIOSurface> mBackSurface;
+  nsRefPtr<nsCARenderer> mCARenderer;
+  nsRefPtr<MacIOSurface> mFrontSurface;
+  nsRefPtr<MacIOSurface> mBackSurface;
   double mContentsScaleFactor;
 };
 
 } // namespace PluginUtilsOSX
 } // namespace plugins
 } // namespace mozilla
 
 #endif //dom_plugins_PluginUtilsOSX_h
--- a/dom/plugins/ipc/PluginUtilsOSX.mm
+++ b/dom/plugins/ipc/PluginUtilsOSX.mm
@@ -483,17 +483,17 @@ void nsDoubleBufferCARenderer::Render() 
     return;
   }
 
   mCARenderer->Render(GetFrontSurfaceWidth(), GetFrontSurfaceHeight(),
                       mContentsScaleFactor, nullptr);
 }
 
 void nsDoubleBufferCARenderer::SwapSurfaces() {
-  RefPtr<MacIOSurface> prevFrontSurface = mFrontSurface;
+  nsRefPtr<MacIOSurface> prevFrontSurface = mFrontSurface;
   mFrontSurface = mBackSurface;
   mBackSurface = prevFrontSurface;
 
   if (mFrontSurface) {
     mCARenderer->AttachIOSurface(mFrontSurface);
   }
 }
 
--- a/dom/svg/SVGContentUtils.cpp
+++ b/dom/svg/SVGContentUtils.cpp
@@ -10,17 +10,17 @@
 
 // Keep others in (case-insensitive) order:
 #include "gfx2DGlue.h"
 #include "gfxMatrix.h"
 #include "gfxPlatform.h"
 #include "gfxSVGGlyphs.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/dom/SVGSVGElement.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsComputedDOMStyle.h"
 #include "nsFontMetrics.h"
 #include "nsIFrame.h"
 #include "nsIScriptError.h"
 #include "nsLayoutUtils.h"
 #include "SVGAnimationElement.h"
 #include "SVGAnimatedPreserveAspectRatio.h"
 #include "nsContentUtils.h"
@@ -840,19 +840,19 @@ already_AddRefed<gfx::Path>
 SVGContentUtils::GetPath(const nsAString& aPathString)
 {
   SVGPathData pathData;
   nsSVGPathDataParser parser(aPathString, &pathData);
   if (!parser.Parse()) {
     return NULL;
   }
 
-  RefPtr<DrawTarget> drawTarget =
+  nsRefPtr<DrawTarget> drawTarget =
     gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
-  RefPtr<PathBuilder> builder =
+  nsRefPtr<PathBuilder> builder =
     drawTarget->CreatePathBuilder(FillRule::FILL_WINDING);
 
   return pathData.BuildPath(builder, NS_STYLE_STROKE_LINECAP_BUTT, 1);
 }
 
 bool
 SVGContentUtils::ShapeTypeHasNoCorners(const nsIContent* aContent) {
   return aContent && aContent->IsAnyOfSVGElements(nsGkAtoms::circle,
--- a/dom/svg/SVGEllipseElement.cpp
+++ b/dom/svg/SVGEllipseElement.cpp
@@ -3,17 +3,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/. */
 
 #include "mozilla/dom/SVGEllipseElement.h"
 #include "mozilla/dom/SVGEllipseElementBinding.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Ellipse)
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace dom {
 
--- a/dom/svg/SVGFEBlendElement.cpp
+++ b/dom/svg/SVGFEBlendElement.cpp
@@ -81,17 +81,17 @@ SVGFEBlendElement::Mode()
 {
   return mEnumAttributes[MODE].ToDOMAnimatedEnum(this);
 }
 
 FilterPrimitiveDescription
 SVGFEBlendElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                                            const IntRect& aFilterSubregion,
                                            const nsTArray<bool>& aInputsAreTainted,
-                                           nsTArray<RefPtr<SourceSurface>>& aInputImages)
+                                           nsTArray<nsRefPtr<SourceSurface>>& aInputImages)
 {
   uint32_t mode = mEnumAttributes[MODE].GetAnimValue();
   FilterPrimitiveDescription descr(PrimitiveType::Blend);
   descr.Attributes().Set(eBlendBlendmode, mode);
   return descr;
 }
 
 bool
--- a/dom/svg/SVGFEBlendElement.h
+++ b/dom/svg/SVGFEBlendElement.h
@@ -28,17 +28,17 @@ protected:
   }
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
                             const nsTArray<bool>& aInputsAreTainted,
-                            nsTArray<mozilla::RefPtr<SourceSurface>>& aInputImages) override;
+                            nsTArray<nsRefPtr<SourceSurface>>& aInputImages) override;
   virtual bool AttributeAffectsRendering(
           int32_t aNameSpaceID, nsIAtom* aAttribute) const override;
   virtual nsSVGString& GetResultImageName() override { return mStringAttributes[RESULT]; }
   virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) override;
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
   // WebIDL
--- a/dom/svg/SVGFEColorMatrixElement.cpp
+++ b/dom/svg/SVGFEColorMatrixElement.cpp
@@ -84,17 +84,17 @@ SVGFEColorMatrixElement::GetSourceImageN
 {
   aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
 }
 
 FilterPrimitiveDescription
 SVGFEColorMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                                                  const IntRect& aFilterSubregion,
                                                  const nsTArray<bool>& aInputsAreTainted,
-                                                 nsTArray<RefPtr<SourceSurface>>& aInputImages)
+                                                 nsTArray<nsRefPtr<SourceSurface>>& aInputImages)
 {
   uint32_t type = mEnumAttributes[TYPE].GetAnimValue();
   const SVGNumberList &values = mNumberListAttributes[VALUES].GetAnimValue();
 
   FilterPrimitiveDescription descr(PrimitiveType::ColorMatrix);
   if (!mNumberListAttributes[VALUES].IsExplicitlySet() &&
       (type == SVG_FECOLORMATRIX_TYPE_MATRIX ||
        type == SVG_FECOLORMATRIX_TYPE_SATURATE ||
--- a/dom/svg/SVGFEColorMatrixElement.h
+++ b/dom/svg/SVGFEColorMatrixElement.h
@@ -30,17 +30,17 @@ protected:
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
                             const nsTArray<bool>& aInputsAreTainted,
-                            nsTArray<mozilla::RefPtr<SourceSurface>>& aInputImages) override;
+                            nsTArray<nsRefPtr<SourceSurface>>& aInputImages) override;
   virtual bool AttributeAffectsRendering(
           int32_t aNameSpaceID, nsIAtom* aAttribute) const override;
   virtual nsSVGString& GetResultImageName() override { return mStringAttributes[RESULT]; }
   virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) override;
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
   // WebIDL
--- a/dom/svg/SVGFEComponentTransferElement.cpp
+++ b/dom/svg/SVGFEComponentTransferElement.cpp
@@ -51,17 +51,17 @@ SVGFEComponentTransferElement::GetString
 }
 
 //--------------------------------------------
 
 FilterPrimitiveDescription
 SVGFEComponentTransferElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                                                        const IntRect& aFilterSubregion,
                                                        const nsTArray<bool>& aInputsAreTainted,
-                                                       nsTArray<RefPtr<SourceSurface>>& aInputImages)
+                                                       nsTArray<nsRefPtr<SourceSurface>>& aInputImages)
 {
   nsRefPtr<SVGComponentTransferFunctionElement> childForChannel[4];
 
   for (nsIContent* childContent = nsINode::GetFirstChild();
        childContent;
        childContent = childContent->GetNextSibling()) {
 
     nsRefPtr<SVGComponentTransferFunctionElement> child;
--- a/dom/svg/SVGFEComponentTransferElement.h
+++ b/dom/svg/SVGFEComponentTransferElement.h
@@ -28,17 +28,17 @@ protected:
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
                             const nsTArray<bool>& aInputsAreTainted,
-                            nsTArray<mozilla::RefPtr<SourceSurface>>& aInputImages) override;
+                            nsTArray<nsRefPtr<SourceSurface>>& aInputImages) override;
   virtual bool AttributeAffectsRendering(
           int32_t aNameSpaceID, nsIAtom* aAttribute) const override;
   virtual nsSVGString& GetResultImageName() override { return mStringAttributes[RESULT]; }
   virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) override;
 
   // nsIContent
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
--- a/dom/svg/SVGFECompositeElement.cpp
+++ b/dom/svg/SVGFECompositeElement.cpp
@@ -108,17 +108,17 @@ SVGFECompositeElement::SetK(float k1, fl
   mNumberAttributes[ATTR_K3].SetBaseValue(k3, this);
   mNumberAttributes[ATTR_K4].SetBaseValue(k4, this);
 }
 
 FilterPrimitiveDescription
 SVGFECompositeElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                                                const IntRect& aFilterSubregion,
                                                const nsTArray<bool>& aInputsAreTainted,
-                                               nsTArray<RefPtr<SourceSurface>>& aInputImages)
+                                               nsTArray<nsRefPtr<SourceSurface>>& aInputImages)
 {
   FilterPrimitiveDescription descr(PrimitiveType::Composite);
   uint32_t op = mEnumAttributes[OPERATOR].GetAnimValue();
   descr.Attributes().Set(eCompositeOperator, op);
 
   if (op == SVG_FECOMPOSITE_OPERATOR_ARITHMETIC) {
     float k[4];
     GetAnimatedNumberValues(k, k+1, k+2, k+3, nullptr);
--- a/dom/svg/SVGFECompositeElement.h
+++ b/dom/svg/SVGFECompositeElement.h
@@ -30,17 +30,17 @@ protected:
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
                             const nsTArray<bool>& aInputsAreTainted,
-                            nsTArray<mozilla::RefPtr<SourceSurface>>& aInputImages) override;
+                            nsTArray<nsRefPtr<SourceSurface>>& aInputImages) override;
   virtual bool AttributeAffectsRendering(
           int32_t aNameSpaceID, nsIAtom* aAttribute) const override;
   virtual nsSVGString& GetResultImageName() override { return mStringAttributes[RESULT]; }
   virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) override;
 
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
--- a/dom/svg/SVGFEConvolveMatrixElement.cpp
+++ b/dom/svg/SVGFEConvolveMatrixElement.cpp
@@ -163,17 +163,17 @@ SVGFEConvolveMatrixElement::GetSourceIma
 {
   aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
 }
 
 FilterPrimitiveDescription
 SVGFEConvolveMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                                                     const IntRect& aFilterSubregion,
                                                     const nsTArray<bool>& aInputsAreTainted,
-                                                    nsTArray<RefPtr<SourceSurface>>& aInputImages)
+                                                    nsTArray<nsRefPtr<SourceSurface>>& aInputImages)
 {
   const FilterPrimitiveDescription failureDescription(PrimitiveType::Empty);
 
   const SVGNumberList &kernelMatrix =
     mNumberListAttributes[KERNELMATRIX].GetAnimValue();
   uint32_t kmLength = kernelMatrix.Length();
 
   int32_t orderX = mIntegerPairAttributes[ORDER].GetAnimValue(nsSVGIntegerPair::eFirst);
--- a/dom/svg/SVGFEConvolveMatrixElement.h
+++ b/dom/svg/SVGFEConvolveMatrixElement.h
@@ -38,17 +38,17 @@ protected:
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
                             const nsTArray<bool>& aInputsAreTainted,
-                            nsTArray<mozilla::RefPtr<SourceSurface>>& aInputImages) override;
+                            nsTArray<nsRefPtr<SourceSurface>>& aInputImages) override;
   virtual bool AttributeAffectsRendering(
           int32_t aNameSpaceID, nsIAtom* aAttribute) const override;
   virtual nsSVGString& GetResultImageName() override { return mStringAttributes[RESULT]; }
   virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) override;
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
   // WebIDL
--- a/dom/svg/SVGFEDiffuseLightingElement.cpp
+++ b/dom/svg/SVGFEDiffuseLightingElement.cpp
@@ -60,17 +60,17 @@ SVGFEDiffuseLightingElement::KernelUnitL
   return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(
     nsSVGNumberPair::eSecond, this);
 }