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 291643 ca86c21a96b4ec676afc55d3b714c22c547884b2
parent 291642 e2ee8f447aa139ac476058c1f8d657bcc0ade30f
child 291644 12d944fcb09d145ad9de48c38e2e8ae9de7e844c
push idunknown
push userunknown
push dateunknown
reviewersehsan
bugs1207245
milestone44.0a1
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;