Bug 782416 - Switch from NULL to nullptr in gfx::2d. r=Bas
authorJoe Drew <joe@drew.ca>
Tue, 14 Aug 2012 14:06:12 -0400
changeset 104443 8f6b4e0bcef0922e09b722a6b52285918ca88c63
parent 104442 e00f4d16eeed04c089402d805a2453a7406d8bc4
child 104444 5c8fcc4cc760241487f9d24c68419630cbacf8a7
push id43
push usershu@rfrn.org
push dateMon, 20 Aug 2012 21:21:55 +0000
reviewersBas
bugs782416
milestone17.0a1
Bug 782416 - Switch from NULL to nullptr in gfx::2d. r=Bas
gfx/2d/Blur.cpp
gfx/2d/Blur.h
gfx/2d/DrawTargetCG.cpp
gfx/2d/DrawTargetCG.h
gfx/2d/DrawTargetCairo.cpp
gfx/2d/DrawTargetCairo.h
gfx/2d/DrawTargetD2D.cpp
gfx/2d/DrawTargetD2D.h
gfx/2d/DrawTargetDual.h
gfx/2d/DrawTargetSkia.cpp
gfx/2d/DrawTargetSkia.h
gfx/2d/Factory.cpp
gfx/2d/ImageScaling.h
gfx/2d/PathCG.cpp
gfx/2d/PathCairo.cpp
gfx/2d/PathD2D.cpp
gfx/2d/QuartzSupport.mm
gfx/2d/ScaledFontBase.cpp
gfx/2d/ScaledFontDWrite.cpp
gfx/2d/ScaledFontMac.cpp
gfx/2d/SourceSurfaceCG.cpp
gfx/2d/SourceSurfaceCairo.cpp
gfx/2d/SourceSurfaceCairo.h
gfx/2d/SourceSurfaceD2D.cpp
gfx/2d/SourceSurfaceD2DTarget.cpp
gfx/2d/SourceSurfaceDual.h
gfx/2d/SourceSurfaceSkia.cpp
gfx/2d/SourceSurfaceSkia.h
gfx/2d/UserData.h
gfx/2d/unittest/TestDrawTargetD2D.cpp
gfx/2d/unittest/TestDrawTargetD2D.h
--- a/gfx/2d/Blur.cpp
+++ b/gfx/2d/Blur.cpp
@@ -325,17 +325,17 @@ RoundUpToMultipleOf4(int32_t aVal)
 
 AlphaBoxBlur::AlphaBoxBlur(const Rect& aRect,
                            const IntSize& aSpreadRadius,
                            const IntSize& aBlurRadius,
                            const Rect* aDirtyRect,
                            const Rect* aSkipRect)
  : mSpreadRadius(aSpreadRadius),
    mBlurRadius(aBlurRadius),
-   mData(NULL)
+   mData(nullptr)
 {
   Rect rect(aRect);
   rect.Inflate(Size(aBlurRadius + aSpreadRadius));
   rect.RoundOut();
 
   if (aDirtyRect) {
     // If we get passed a dirty rect from layout, we can minimize the
     // shadow size and make painting faster.
@@ -419,17 +419,17 @@ AlphaBoxBlur::GetRect()
 
 Rect*
 AlphaBoxBlur::GetDirtyRect()
 {
   if (mHasDirtyRect) {
     return &mDirtyRect;
   }
 
-  return NULL;
+  return nullptr;
 }
 
 void
 AlphaBoxBlur::Blur()
 {
   if (!mData) {
     return;
   }
--- a/gfx/2d/Blur.h
+++ b/gfx/2d/Blur.h
@@ -40,21 +40,21 @@ public:
    * @param aBlurRadius The blur radius in pixels.  This is the radius of the
    *   entire (triple) kernel function.  Each individual box blur has radius
    *   approximately 1/3 this value, or diameter approximately 2/3 this value.
    *   This parameter should nearly always be computed using CalculateBlurRadius,
    *   below.
    *
    * @param aDirtyRect A pointer to a dirty rect, measured in device units, if
    *   available.  This will be used for optimizing the blur operation. It is
-   *   safe to pass NULL here.
+   *   safe to pass nullptr here.
    *
    * @param aSkipRect A pointer to a rect, measured in device units, that
    *   represents an area where blurring is unnecessary and shouldn't be done for
-   *   speed reasons. It is safe to pass NULL here.
+   *   speed reasons. It is safe to pass nullptr here.
    */
   AlphaBoxBlur(const Rect& aRect,
                const IntSize& aSpreadRadius,
                const IntSize& aBlurRadius,
                const Rect* aDirtyRect,
                const Rect* aSkipRect);
 
   ~AlphaBoxBlur();
@@ -79,17 +79,17 @@ public:
   int32_t GetStride();
 
   /**
    * Returns the device-space rectangle the 8-bit alpha surface covers.
    */
   IntRect GetRect();
 
   /**
-   * Return a pointer to a dirty rect, as passed in to the constructor, or NULL
+   * Return a pointer to a dirty rect, as passed in to the constructor, or nullptr
    * if none was passed in.
    */
   Rect* GetDirtyRect();
 
   /**
    * Perform the blur in-place on the surface backed by the pointer returned by
    * GetData().
    */
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -72,17 +72,17 @@ CGBlendMode ToBlendMode(CompositionOp op
     default:
       mode = kCGBlendModeNormal;
   }
   return mode;
 }
 
 
 
-DrawTargetCG::DrawTargetCG() : mSnapshot(NULL)
+DrawTargetCG::DrawTargetCG() : mSnapshot(nullptr)
 {
 }
 
 DrawTargetCG::~DrawTargetCG()
 {
   MarkChanged();
 
   // We need to conditionally release these because Init can fail without initializing these.
@@ -123,30 +123,30 @@ TemporaryRef<DrawTarget>
 DrawTargetCG::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   // XXX: in thebes we use CGLayers to do this kind of thing. It probably makes sense
   // to add that in somehow, but at a higher level
   RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
   if (newTarget->Init(GetType(), aSize, aFormat)) {
     return newTarget;
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetCG::CreateSourceSurfaceFromData(unsigned char *aData,
                                            const IntSize &aSize,
                                            int32_t aStride,
                                            SurfaceFormat aFormat) const
 {
   RefPtr<SourceSurfaceCG> newSurf = new SourceSurfaceCG();
 
  if (!newSurf->InitFromData(aData, aSize, aStride, aFormat)) {
-    return NULL;
+    return nullptr;
   }
 
   return newSurf;
 }
 
 static CGImageRef
 GetImageFromSourceSurface(SourceSurface *aSurface)
 {
@@ -157,38 +157,38 @@ GetImageFromSourceSurface(SourceSurface 
   else if (aSurface->GetType() == SURFACE_DATA)
     return static_cast<DataSourceSurfaceCG*>(aSurface)->GetImage();
   abort();
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetCG::OptimizeSourceSurface(SourceSurface *aSurface) const
 {
-  return NULL;
+  return nullptr;
 }
 
 class UnboundnessFixer
 {
     CGRect mClipBounds;
     CGLayerRef mLayer;
     CGContextRef mCg;
   public:
-    UnboundnessFixer() : mCg(NULL) {}
+    UnboundnessFixer() : mCg(nullptr) {}
 
     CGContextRef Check(CGContextRef baseCg, CompositionOp blend)
     {
       if (!IsOperatorBoundByMask(blend)) {
         mClipBounds = CGContextGetClipBoundingBox(baseCg);
         // TransparencyLayers aren't blended using the blend mode so
         // we are forced to use CGLayers
 
         //XXX: The size here is in default user space units, of the layer relative to the graphics context.
         // is the clip bounds still correct if, for example, we have a scale applied to the context?
-        mLayer = CGLayerCreateWithContext(baseCg, mClipBounds.size, NULL);
-        //XXX: if the size is 0x0 we get a NULL CGContext back from GetContext
+        mLayer = CGLayerCreateWithContext(baseCg, mClipBounds.size, nullptr);
+        //XXX: if the size is 0x0 we get a nullptr CGContext back from GetContext
         mCg = CGLayerGetContext(mLayer);
         // CGContext's default to have the origin at the bottom left
         // so flip it to the top left and adjust for the origin
         // of the layer
         CGContextTranslateCTM(mCg, -mClipBounds.origin.x, mClipBounds.origin.y + mClipBounds.size.height);
         CGContextScaleCTM(mCg, 1, -1);
 
         return mCg;
@@ -214,17 +214,17 @@ DrawTargetCG::DrawSurface(SourceSurface 
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions,
                            const DrawOptions &aDrawOptions)
 {
   MarkChanged();
 
   CGImageRef image;
-  CGImageRef subimage = NULL;
+  CGImageRef subimage = nullptr;
   CGContextSaveGState(mCg);
 
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(cg, aDrawOptions.mAlpha);
 
   CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform));
@@ -424,17 +424,17 @@ SetFillFromPattern(CGContextRef cg, CGCo
     const Color& color = static_cast<const ColorPattern&>(aPattern).mColor;
     //XXX: we should cache colors
     CGColorRef cgcolor = ColorToCGColor(aColorSpace, color);
     CGContextSetFillColorWithColor(cg, cgcolor);
     CGColorRelease(cgcolor);
   } else if (aPattern.GetType() == PATTERN_SURFACE) {
 
     CGColorSpaceRef patternSpace;
-    patternSpace = CGColorSpaceCreatePattern (NULL);
+    patternSpace = CGColorSpaceCreatePattern (nullptr);
     CGContextSetFillColorSpace(cg, patternSpace);
     CGColorSpaceRelease(patternSpace);
 
     CGPatternRef pattern = CreateCGPattern(aPattern, CGContextGetCTM(cg));
     CGFloat alpha = 1.;
     CGContextSetFillPattern(cg, pattern, &alpha);
     CGPatternRelease(pattern);
   }
@@ -447,17 +447,17 @@ SetStrokeFromPattern(CGContextRef cg, CG
   if (aPattern.GetType() == PATTERN_COLOR) {
     const Color& color = static_cast<const ColorPattern&>(aPattern).mColor;
     //XXX: we should cache colors
     CGColorRef cgcolor = ColorToCGColor(aColorSpace, color);
     CGContextSetStrokeColorWithColor(cg, cgcolor);
     CGColorRelease(cgcolor);
   } else if (aPattern.GetType() == PATTERN_SURFACE) {
     CGColorSpaceRef patternSpace;
-    patternSpace = CGColorSpaceCreatePattern (NULL);
+    patternSpace = CGColorSpaceCreatePattern (nullptr);
     CGContextSetStrokeColorSpace(cg, patternSpace);
     CGColorSpaceRelease(patternSpace);
 
     CGPatternRef pattern = CreateCGPattern(aPattern, CGContextGetCTM(cg));
     CGFloat alpha = 1.;
     CGContextSetStrokePattern(cg, pattern, &alpha);
     CGPatternRelease(pattern);
   }
@@ -751,17 +751,17 @@ CGContextResetClip(CGContextRef);
 void
 DrawTargetCG::CopySurface(SourceSurface *aSurface,
                           const IntRect& aSourceRect,
                           const IntPoint &aDestination)
 {
   MarkChanged();
 
   CGImageRef image;
-  CGImageRef subimage = NULL;
+  CGImageRef subimage = nullptr;
   if (aSurface->GetType() == SURFACE_COREGRAPHICS_IMAGE) {
     image = GetImageFromSourceSurface(aSurface);
     /* we have two options here:
      *  - create a subimage -- this is slower
      *  - fancy things with clip and different dest rects */
     {
       subimage = CGImageCreateWithImageInRect(image, IntRectToCGRect(aSourceRect));
       image = subimage;
@@ -825,45 +825,45 @@ DrawTargetCG::Init(BackendType aType,
                    SurfaceFormat aFormat)
 {
   // XXX: we should come up with some consistent semantics for dealing
   // with zero area drawtargets
   if (aSize.width <= 0 || aSize.height <= 0 ||
       // 32767 is the maximum size supported by cairo
       // we clamp to that to make it easier to interoperate
       aSize.width > 32767 || aSize.height > 32767) {
-    mColorSpace = NULL;
-    mCg = NULL;
-    mData = NULL;
+    mColorSpace = nullptr;
+    mCg = nullptr;
+    mData = nullptr;
     return false;
   }
 
   //XXX: handle SurfaceFormat
 
   //XXX: we'd be better off reusing the Colorspace across draw targets
   mColorSpace = CGColorSpaceCreateDeviceRGB();
 
-  if (aData == NULL && aType != BACKEND_COREGRAPHICS_ACCELERATED) {
+  if (aData == nullptr && aType != BACKEND_COREGRAPHICS_ACCELERATED) {
     // XXX: Currently, Init implicitly clears, that can often be a waste of time
     mData = calloc(aSize.height * aStride, 1);
     aData = static_cast<unsigned char*>(mData);  
   } else {
-    // mData == NULL means DrawTargetCG doesn't own the image data and will not
+    // mData == nullptr means DrawTargetCG doesn't own the image data and will not
     // delete it in the destructor
-    mData = NULL;
+    mData = nullptr;
   }
 
   mSize = aSize;
 
   if (aType == BACKEND_COREGRAPHICS_ACCELERATED) {
     RefPtr<MacIOSurface> ioSurface = MacIOSurface::CreateIOSurface(aSize.width, aSize.height);
     mCg = ioSurface->CreateIOSurfaceContext();
     // If we don't have the symbol for 'CreateIOSurfaceContext' mCg will be null
     // and we will fallback to software below
-    mData = NULL;
+    mData = nullptr;
   }
 
   if (!mCg || aType == BACKEND_COREGRAPHICS) {
     int bitsPerComponent = 8;
 
     CGBitmapInfo bitinfo;
     bitinfo = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst;
 
@@ -911,32 +911,32 @@ DrawTargetCG::Flush()
 }
 
 bool
 DrawTargetCG::Init(CGContextRef cgContext, const IntSize &aSize)
 {
   // XXX: we should come up with some consistent semantics for dealing
   // with zero area drawtargets
   if (aSize.width == 0 || aSize.height == 0) {
-    mColorSpace = NULL;
-    mCg = NULL;
-    mData = NULL;
+    mColorSpace = nullptr;
+    mCg = nullptr;
+    mData = nullptr;
     return false;
   }
 
   //XXX: handle SurfaceFormat
 
   //XXX: we'd be better off reusing the Colorspace across draw targets
   mColorSpace = CGColorSpaceCreateDeviceRGB();
 
   mSize = aSize;
 
   mCg = cgContext;
 
-  mData = NULL;
+  mData = nullptr;
 
   assert(mCg);
   // CGContext's default to have the origin at the bottom left
   // so flip it to the top left
   CGContextTranslateCTM(mCg, 0, mSize.height);
   CGContextScaleCTM(mCg, 1, -1);
 
   //XXX: set correct format
@@ -945,35 +945,35 @@ DrawTargetCG::Init(CGContextRef cgContex
   return true;
 }
 
 bool
 DrawTargetCG::Init(BackendType aType, const IntSize &aSize, SurfaceFormat &aFormat)
 {
   int stride = aSize.width*4;
   
-  // Calling Init with aData == NULL will allocate.
-  return Init(aType, NULL, aSize, stride, aFormat);
+  // Calling Init with aData == nullptr will allocate.
+  return Init(aType, nullptr, aSize, stride, aFormat);
 }
 
 TemporaryRef<PathBuilder>
 DrawTargetCG::CreatePathBuilder(FillRule aFillRule) const
 {
   RefPtr<PathBuilderCG> pb = new PathBuilderCG(aFillRule);
   return pb;
 }
 
 void*
 DrawTargetCG::GetNativeSurface(NativeSurfaceType aType)
 {
   if (aType == NATIVE_SURFACE_CGCONTEXT && GetContextType(mCg) == CG_CONTEXT_TYPE_BITMAP ||
       aType == NATIVE_SURFACE_CGCONTEXT_ACCELERATED && GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE) {
     return mCg;
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
 void
 DrawTargetCG::Mask(const Pattern &aSource,
                    const Pattern &aMask,
                    const DrawOptions &aDrawOptions)
 {
@@ -1061,16 +1061,16 @@ DrawTargetCG::PopClip()
 void
 DrawTargetCG::MarkChanged()
 {
   if (mSnapshot) {
     if (mSnapshot->refCount() > 1) {
       // We only need to worry about snapshots that someone else knows about
       mSnapshot->DrawTargetWillChange();
     }
-    mSnapshot = NULL;
+    mSnapshot = nullptr;
   }
 }
 
 
 
 }
 }
--- a/gfx/2d/DrawTargetCG.h
+++ b/gfx/2d/DrawTargetCG.h
@@ -119,17 +119,17 @@ public:
   virtual void Fill(const Path *, const Pattern &, const DrawOptions &);
   virtual void FillGlyphs(ScaledFont *, const GlyphBuffer&, const Pattern &, const DrawOptions &, const GlyphRenderingOptions *);
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void PushClip(const Path *);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
-  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromNativeSurface(const NativeSurface&) const { return NULL;}
+  virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromNativeSurface(const NativeSurface&) const { return nullptr;}
   virtual TemporaryRef<DrawTarget> CreateSimilarDrawTarget(const IntSize &, SurfaceFormat) const;
   virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule) const;
   virtual TemporaryRef<GradientStops> CreateGradientStops(GradientStop *, uint32_t,
                                                           ExtendMode aExtendMode = EXTEND_CLAMP) const;
 
   virtual void *GetNativeSurface(NativeSurfaceType);
 
   virtual IntSize GetSize() { return mSize; }
@@ -150,17 +150,17 @@ private:
   IntSize mSize;
   CGColorSpaceRef mColorSpace;
   CGContextRef mCg;
 
   GLuint mIOSurfaceTexture;
 
   /**
    * A pointer to the image buffer if the buffer is owned by this class (set to
-   * NULL otherwise).
+   * nullptr otherwise).
    * The data is not considered owned by DrawTargetCG if the DrawTarget was 
    * created for a pre-existing buffer or if the buffer's lifetime is managed
    * by CoreGraphics.
    * Data owned by DrawTargetCG will be deallocated in the destructor. 
    */
   void *mData;
 
   RefPtr<SourceSurfaceCGContext> mSnapshot;
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -159,17 +159,17 @@ GetCairoSurfaceForSourceSurface(SourceSu
                                         data->Stride());
   cairo_surface_set_user_data(surf,
  				                      &surfaceDataKey,
  				                      data.forget().drop(),
  				                      ReleaseData);
   return surf;
 }
 
-// Never returns NULL. As such, you must always pass in Cairo-compatible
+// Never returns nullptr. As such, you must always pass in Cairo-compatible
 // patterns, most notably gradients with a GradientStopCairo.
 // The pattern returned must have cairo_pattern_destroy() called on it by the
 // caller.
 // As the cairo_pattern_t returned may depend on the Pattern passed in, the
 // lifetime of the cairo_pattern_t returned must not exceed the lifetime of the
 // Pattern passed in.
 static cairo_pattern_t*
 GfxPatternToCairoPattern(const Pattern& aPattern, Float aAlpha)
@@ -270,17 +270,17 @@ NeedIntermediateSurface(const Pattern& a
 
   if (aOptions.mAlpha == 1.0)
     return false;
 
   return true;
 }
 
 DrawTargetCairo::DrawTargetCairo()
-  : mContext(NULL)
+  : mContext(nullptr)
 {
 }
 
 DrawTargetCairo::~DrawTargetCairo()
 {
   MarkSnapshotsIndependent();
   if (mPathObserver) {
     mPathObserver->ForgetDrawTarget();
@@ -313,17 +313,17 @@ DrawTargetCairo::Snapshot()
 void
 DrawTargetCairo::Flush()
 {
   cairo_surface_t* surf = cairo_get_target(mContext);
   cairo_surface_flush(surf);
 }
 
 void
-DrawTargetCairo::PrepareForDrawing(cairo_t* aContext, const Path* aPath /* = NULL */)
+DrawTargetCairo::PrepareForDrawing(cairo_t* aContext, const Path* aPath /* = nullptr */)
 {
   WillChange(aPath);
 }
 
 void
 DrawTargetCairo::DrawSurface(SourceSurface *aSurface,
                              const Rect &aDest,
                              const Rect &aSource,
@@ -386,17 +386,17 @@ DrawTargetCairo::DrawSurfaceWithShadow(S
   WillChange();
 
   Float width = aSurface->GetSize().width;
   Float height = aSurface->GetSize().height;
   Rect extents(0, 0, width, height);
 
   AlphaBoxBlur blur(extents, IntSize(0, 0),
                     AlphaBoxBlur::CalculateBlurRadius(Point(aSigma, aSigma)),
-                    NULL, NULL);
+                    nullptr, nullptr);
   if (!blur.GetData()) {
     return;
   }
 
   IntSize blursize = blur.GetSize();
   cairo_surface_t* blursurf = cairo_image_surface_create_for_data(blur.GetData(),
                                                                   CAIRO_FORMAT_A8,
                                                                   blursize.width,
@@ -781,33 +781,33 @@ DrawTargetCairo::CreateSourceSurfaceFrom
     cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface);
     if (GetCairoSurfaceSize(surf, size)) {
       RefPtr<SourceSurfaceCairo> source =
         new SourceSurfaceCairo(surf, size, aSurface.mFormat);
       return source;
     }
   }
 
-  return NULL;
+  return nullptr;
 }
 
 TemporaryRef<DrawTarget>
 DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   cairo_surface_t* similar = cairo_surface_create_similar(cairo_get_target(mContext),
                                                           GfxFormatToCairoContent(aFormat),
                                                           aSize.width, aSize.height);
 
   if (!cairo_surface_status(similar)) {
     RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
     target->Init(similar, aSize);
     return target;
   }
 
-  return NULL;
+  return nullptr;
 }
 
 bool
 DrawTargetCairo::Init(cairo_surface_t* aSurface, const IntSize& aSize)
 {
   mContext = cairo_create(aSurface);
   mSurface = aSurface;
   cairo_surface_reference(mSurface);
@@ -819,17 +819,17 @@ DrawTargetCairo::Init(cairo_surface_t* a
 
 void *
 DrawTargetCairo::GetNativeSurface(NativeSurfaceType aType)
 {
   if (aType == NATIVE_SURFACE_CAIRO_SURFACE) {
     return cairo_get_target(mContext);
   }
 
-  return NULL;
+  return nullptr;
 }
 
 void
 DrawTargetCairo::MarkSnapshotsIndependent()
 {
   // Make a copy of the vector, since MarkIndependent implicitly modifies mSnapshots.
   std::vector<SourceSurfaceCairo*> snapshots = mSnapshots;
   for (std::vector<SourceSurfaceCairo*>::iterator iter = snapshots.begin();
@@ -852,31 +852,31 @@ DrawTargetCairo::RemoveSnapshot(SourceSu
                                                               mSnapshots.end(),
                                                               aSnapshot);
   if (iter != mSnapshots.end()) {
     mSnapshots.erase(iter);
   }
 }
 
 void
-DrawTargetCairo::WillChange(const Path* aPath /* = NULL */)
+DrawTargetCairo::WillChange(const Path* aPath /* = nullptr */)
 {
   if (!mSnapshots.empty()) {
     for (std::vector<SourceSurfaceCairo*>::iterator iter = mSnapshots.begin();
          iter != mSnapshots.end(); ++iter) {
       (*iter)->DrawTargetWillChange();
     }
     // All snapshots will now have copied data.
     mSnapshots.clear();
   }
 
   if (mPathObserver &&
       (!aPath || !mPathObserver->ContainsPath(aPath))) {
     mPathObserver->PathWillChange();
-    mPathObserver = NULL;
+    mPathObserver = nullptr;
   }
 }
 
 void
 DrawTargetCairo::SetPathObserver(CairoPathContext* aPathObserver)
 {
   if (mPathObserver && mPathObserver != aPathObserver) {
     mPathObserver->PathWillChange();
--- a/gfx/2d/DrawTargetCairo.h
+++ b/gfx/2d/DrawTargetCairo.h
@@ -90,17 +90,17 @@ public:
   virtual void Fill(const Path *aPath,
                     const Pattern &aPattern,
                     const DrawOptions &aOptions = DrawOptions());
 
   virtual void FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
                           const DrawOptions &aOptions,
-                          const GlyphRenderingOptions *aRenderingOptions = NULL);
+                          const GlyphRenderingOptions *aRenderingOptions = nullptr);
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
 
   virtual void PushClip(const Path *aPath);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
 
@@ -127,34 +127,34 @@ public:
 
   void SetPathObserver(CairoPathContext* aPathObserver);
 
   virtual void SetTransform(const Matrix& aTransform);
 
   // Call to set up aContext for drawing (with the current transform, etc).
   // Pass the path you're going to be using if you have one.
   // Implicitly calls WillChange(aPath).
-  void PrepareForDrawing(cairo_t* aContext, const Path* aPath = NULL);
+  void PrepareForDrawing(cairo_t* aContext, const Path* aPath = nullptr);
 
 private: // methods
   enum DrawPatternType { DRAW_FILL, DRAW_STROKE };
   void DrawPattern(const Pattern& aPattern,
                    const StrokeOptions& aStrokeOptions,
                    const DrawOptions& aOptions,
                    DrawPatternType aDrawType);
 
   // Copy-on-write support for snapshot surfaces.
   friend class SourceSurfaceCairo;
   void AppendSnapshot(SourceSurfaceCairo* aSnapshot);
   void RemoveSnapshot(SourceSurfaceCairo* aSnapshot);
 
   // Call before you make any changes to the backing surface with which this
   // context is associated. Pass the path you're going to be using if you have
   // one.
-  void WillChange(const Path* aPath = NULL);
+  void WillChange(const Path* aPath = nullptr);
 
   // Call if there is any reason to disassociate all snapshots from this draw
   // target; for example, because we're going to be destroyed.
   void MarkSnapshotsIndependent();
 
   // If the current operator is "source" then clear the destination before we
   // draw into it, to simulate the effect of an unbounded source operator.
   void ClearSurfaceForUnboundedSource(const CompositionOp &aOperator);
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -74,17 +74,17 @@ public:
     RefPtr<ID3D10Texture2D> tmpTexture;
     IntSize size = mDT->mSize;
     SurfaceFormat format = mDT->mFormat;
 
     CD3D10_TEXTURE2D_DESC desc(DXGIFormat(format), size.width, size.height,
                                1, 1);
     desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
 
-    HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, NULL, byRef(tmpTexture));
+    HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture));
     if (FAILED(hr)) {
       gfxWarning() << "Failed to create temporary texture to hold surface data.";
     }
     mDT->mDevice->CopyResource(tmpTexture, mDT->mTexture);
 
     D2D1_BITMAP_PROPERTIES props =
       D2D1::BitmapProperties(D2D1::PixelFormat(DXGIFormat(format),
                              AlphaMode(format)));
@@ -123,17 +123,17 @@ public:
       D2D1::RectF(0, 0, float(mDT->mSize.width), float(mDT->mSize.height)),
       byRef(rectGeom));
 
     RefPtr<ID2D1PathGeometry> invClippedArea;
     factory()->CreatePathGeometry(byRef(invClippedArea));
     RefPtr<ID2D1GeometrySink> sink;
     invClippedArea->Open(byRef(sink));
 
-    rectGeom->CombineWithGeometry(mClippedArea, D2D1_COMBINE_MODE_EXCLUDE, NULL, sink);
+    rectGeom->CombineWithGeometry(mClippedArea, D2D1_COMBINE_MODE_EXCLUDE, nullptr, sink);
     sink->Close();
 
     RefPtr<ID2D1BitmapBrush> brush;
     rt->CreateBitmapBrush(mOldSurfBitmap, D2D1::BitmapBrushProperties(), D2D1::BrushProperties(), byRef(brush));                   
 
     rt->FillGeometry(invClippedArea, brush);
   }
 
@@ -146,17 +146,17 @@ private:
   RefPtr<ID2D1Bitmap> mOldSurfBitmap;
   // This contains the area drawing is clipped to.
   RefPtr<ID2D1Geometry> mClippedArea;
 };
 
 DrawTargetD2D::DrawTargetD2D()
   : mCurrentCachedLayer(0)
   , mClipsArePushed(false)
-  , mPrivateData(NULL)
+  , mPrivateData(nullptr)
 {
 }
 
 DrawTargetD2D::~DrawTargetD2D()
 {
   if (mRT) {  
     PopAllClips();
 
@@ -178,17 +178,17 @@ DrawTargetD2D::~DrawTargetD2D()
     // mSnapshot can be treated as independent of this DrawTarget since we know
     // this DrawTarget won't change again.
     deathGrip->MarkIndependent();
     // mSnapshot will be cleared now.
   }
 
   for (int i = 0; i < kLayerCacheSize; i++) {
     if (mCachedLayers[i]) {
-      mCachedLayers[i] = NULL;
+      mCachedLayers[i] = nullptr;
       mVRAMUsageDT -= GetByteSize();
     }
   }
 
   // Targets depending on us can break that dependency, since we're obviously not going to
   // be modified in the future.
   for (TargetSet::iterator iter = mDependentTargets.begin();
        iter != mDependentTargets.end(); iter++) {
@@ -315,17 +315,17 @@ DrawTargetD2D::DrawSurface(SourceSurface
 void
 DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
                                      const Point &aDest,
                                      const Color &aColor,
                                      const Point &aOffset,
                                      Float aSigma,
                                      CompositionOp aOperator)
 {
-  RefPtr<ID3D10ShaderResourceView> srView = NULL;
+  RefPtr<ID3D10ShaderResourceView> srView = nullptr;
   if (aSurface->GetType() != SURFACE_D2D1_DRAWTARGET) {
     return;
   }
 
   // XXX - This function is way too long, it should be split up soon to make
   // it more graspable!
 
   Flush();
@@ -337,17 +337,17 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
   }
 
   srView = static_cast<SourceSurfaceD2DTarget*>(aSurface)->GetSRView();
 
   EnsureViews();
 
   if (!mTempRTView) {
     // This view is only needed in this path.
-    HRESULT hr = mDevice->CreateRenderTargetView(mTempTexture, NULL, byRef(mTempRTView));
+    HRESULT hr = mDevice->CreateRenderTargetView(mTempTexture, nullptr, byRef(mTempRTView));
 
     if (FAILED(hr)) {
       gfxWarning() << "Failure to create RenderTargetView. Code: " << hr;
       return;
     }
   }
 
 
@@ -355,17 +355,17 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
   RefPtr<ID3D10Texture2D> destTexture;
   HRESULT hr;
 
   RefPtr<ID3D10Texture2D> maskTexture;
   RefPtr<ID3D10ShaderResourceView> maskSRView;
   if (mPushedClips.size()) {
     EnsureClipMaskTexture();
 
-    mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, NULL, byRef(maskSRView));
+    mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, nullptr, byRef(maskSRView));
   }
 
   IntSize srcSurfSize;
   ID3D10RenderTargetView *rtViews;
   D3D10_VIEWPORT viewport;
 
   UINT stride = sizeof(Vertex);
   UINT offset = 0;
@@ -397,17 +397,17 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
     
     CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM,
                                aSurface->GetSize().width,
                                aSurface->GetSize().height);
     desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
     desc.MiscFlags = D3D10_RESOURCE_MISC_GENERATE_MIPS;
 
     RefPtr<ID3D10Texture2D> mipTexture;
-    hr = mDevice->CreateTexture2D(&desc, NULL, byRef(mipTexture));
+    hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mipTexture));
 
     if (FAILED(hr)) {
       gfxWarning() << "Failure to create temporary texture. Size: " <<
         aSurface->GetSize() << " Code: " << hr;
       return;
     }
 
     IntSize dsSize = IntSize(int32_t(aSurface->GetSize().width * (1.7f / aSigma)),
@@ -425,59 +425,59 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
     correctedOffset.x *= dsFactorX;
     correctedOffset.y *= dsFactorY;
 
     desc = CD3D10_TEXTURE2D_DESC(DXGI_FORMAT_B8G8R8A8_UNORM,
                                  dsSize.width,
                                  dsSize.height, 1, 1);
     desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
     RefPtr<ID3D10Texture2D> tmpDSTexture;
-    hr = mDevice->CreateTexture2D(&desc, NULL, byRef(tmpDSTexture));
+    hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpDSTexture));
 
     if (FAILED(hr)) {
       gfxWarning() << "Failure to create temporary texture. Size: " << dsSize << " Code: " << hr;
       return;
     }
 
     D3D10_BOX box;
     box.left = box.top = box.front = 0;
     box.back = 1;
     box.right = aSurface->GetSize().width;
     box.bottom = aSurface->GetSize().height;
     mDevice->CopySubresourceRegion(mipTexture, 0, 0, 0, 0, static_cast<SourceSurfaceD2DTarget*>(aSurface)->mTexture, 0, &box);
 
-    mDevice->CreateShaderResourceView(mipTexture, NULL,  byRef(srView));
+    mDevice->CreateShaderResourceView(mipTexture, nullptr,  byRef(srView));
     mDevice->GenerateMips(srView);
 
     RefPtr<ID3D10RenderTargetView> dsRTView;
     RefPtr<ID3D10ShaderResourceView> dsSRView;
-    mDevice->CreateRenderTargetView(tmpDSTexture, NULL,  byRef(dsRTView));
-    mDevice->CreateShaderResourceView(tmpDSTexture, NULL,  byRef(dsSRView));
+    mDevice->CreateRenderTargetView(tmpDSTexture, nullptr,  byRef(dsRTView));
+    mDevice->CreateShaderResourceView(tmpDSTexture, nullptr,  byRef(dsSRView));
 
     // We're not guaranteed the texture we created will be empty, we've
     // seen old content at least on NVidia drivers.
     float color[4] = { 0, 0, 0, 0 };
     mDevice->ClearRenderTargetView(dsRTView, color);
 
     rtViews = dsRTView;
-    mDevice->OMSetRenderTargets(1, &rtViews, NULL);
+    mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
 
     viewport.MaxDepth = 1;
     viewport.MinDepth = 0;
     viewport.Height = dsSize.height;
     viewport.Width = dsSize.width;
     viewport.TopLeftX = 0;
     viewport.TopLeftY = 0;
 
     mDevice->RSSetViewports(1, &viewport);
     mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(srView);
     mPrivateData->mEffect->GetTechniqueByName("SampleTexture")->
       GetPassByIndex(0)->Apply(0);
 
-    mDevice->OMSetBlendState(GetBlendStateForOperator(OP_OVER), NULL, 0xffffffff);
+    mDevice->OMSetBlendState(GetBlendStateForOperator(OP_OVER), nullptr, 0xffffffff);
 
     mDevice->Draw(4, 0);
     
     srcSurfSize = dsSize;
 
     srView = dsSRView;
   } else {
     // In this case generate a kernel to draw the blur directly to the temp
@@ -536,25 +536,25 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
     mDevice->ClearRenderTargetView(tmpRTView, color);
   } else {
     CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM,
                                srcSurfSize.width,
                                srcSurfSize.height,
                                1, 1);
     desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
 
-    mDevice->CreateTexture2D(&desc, NULL,  byRef(tmpTexture));
-    mDevice->CreateRenderTargetView(tmpTexture, NULL,  byRef(tmpRTView));
-    mDevice->CreateShaderResourceView(tmpTexture, NULL,  byRef(tmpSRView));
+    mDevice->CreateTexture2D(&desc, nullptr,  byRef(tmpTexture));
+    mDevice->CreateRenderTargetView(tmpTexture, nullptr,  byRef(tmpRTView));
+    mDevice->CreateShaderResourceView(tmpTexture, nullptr,  byRef(tmpSRView));
 
     tmpSurfSize = srcSurfSize;
   }
 
   rtViews = tmpRTView;
-  mDevice->OMSetRenderTargets(1, &rtViews, NULL);
+  mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
 
   mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(srView);
 
   // Premultiplied!
   float shadowColor[4] = { aColor.r * aColor.a, aColor.g * aColor.a,
                            aColor.b * aColor.a, aColor.a };
   mPrivateData->mEffect->GetVariableByName("ShadowColor")->AsVector()->
     SetFloatVector(shadowColor);
@@ -588,17 +588,17 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
   viewport.TopLeftX = 0;
   viewport.TopLeftY = 0;
 
   mDevice->RSSetViewports(1, &viewport);
 
   mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(tmpSRView);
 
   rtViews = destRTView;
-  mDevice->OMSetRenderTargets(1, &rtViews, NULL);
+  mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
 
   Point shadowDest = aDest + aOffset;
 
   mPrivateData->mEffect->GetVariableByName("QuadDesc")->AsVector()->
     SetFloatVector(ShaderConstantRectD3D10(-1.0f + ((shadowDest.x / mSize.width) * 2.0f),
                                            1.0f - (shadowDest.y / mSize.height * 2.0f),
                                            (Float(aSurface->GetSize().width) / mSize.width) * 2.0f,
                                            (-Float(aSurface->GetSize().height) / mSize.height) * 2.0f));
@@ -614,17 +614,17 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
                                              Float(aSurface->GetSize().height) / mSize.height));
     mPrivateData->mEffect->GetTechniqueByName("SampleTextureWithShadow")->
       GetPassByIndex(2)->Apply(0);
   } else {
     mPrivateData->mEffect->GetTechniqueByName("SampleTextureWithShadow")->
       GetPassByIndex(1)->Apply(0);
   }
 
-  mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), NULL, 0xffffffff);
+  mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), nullptr, 0xffffffff);
 
   mDevice->Draw(4, 0);
 
   mPrivateData->mEffect->GetVariableByName("QuadDesc")->AsVector()->
     SetFloatVector(ShaderConstantRectD3D10(-1.0f + ((aDest.x / mSize.width) * 2.0f),
                                            1.0f - (aDest.y / mSize.height * 2.0f),
                                            (Float(aSurface->GetSize().width) / mSize.width) * 2.0f,
                                            (-Float(aSurface->GetSize().height) / mSize.height) * 2.0f));
@@ -639,17 +639,17 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
                                              Float(aSurface->GetSize().height) / mSize.height));
     mPrivateData->mEffect->GetTechniqueByName("SampleMaskedTexture")->
       GetPassByIndex(0)->Apply(0);
   } else {
     mPrivateData->mEffect->GetTechniqueByName("SampleTexture")->
       GetPassByIndex(0)->Apply(0);
   }
 
-  mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), NULL, 0xffffffff);
+  mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), nullptr, 0xffffffff);
 
   mDevice->Draw(4, 0);
 }
 
 void
 DrawTargetD2D::ClearRect(const Rect &aRect)
 {
   MarkChanged();
@@ -863,17 +863,17 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aF
 {
   if (aFont->GetType() != FONT_DWRITE) {
     gfxDebug() << *this << ": Ignoring drawing call for incompatible font.";
     return;
   }
 
   ScaledFontDWrite *font = static_cast<ScaledFontDWrite*>(aFont);
 
-  IDWriteRenderingParams *params = NULL;
+  IDWriteRenderingParams *params = nullptr;
   if (aRenderOptions) {
     if (aRenderOptions->GetType() != FONT_DWRITE) {
       gfxDebug() << *this << ": Ignoring incompatible GlyphRenderingOptions.";
       // This should never happen.
       MOZ_ASSERT(false);
     } else {
       params = static_cast<const GlyphRenderingOptionsDWrite*>(aRenderOptions)->mParams;
     }
@@ -922,17 +922,17 @@ DrawTargetD2D::Mask(const Pattern &aSour
 
   RefPtr<ID2D1Brush> brush = CreateBrushForPattern(aSource, aOptions.mAlpha);
   RefPtr<ID2D1Brush> maskBrush = CreateBrushForPattern(aMask, 1.0f);
 
   RefPtr<ID2D1Layer> layer;
 
   layer = GetCachedLayer();
 
-  rt->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), NULL,
+  rt->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), nullptr,
                                       D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,
                                       D2D1::IdentityMatrix(),
                                       1.0f, maskBrush),
                 layer);
 
   Rect rect(0, 0, mSize.width, mSize.height);
   Matrix mat = mTransform;
   mat.Invert();
@@ -946,18 +946,18 @@ DrawTargetD2D::Mask(const Pattern &aSour
 void
 DrawTargetD2D::PushClip(const Path *aPath)
 {
   if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
     gfxDebug() << *this << ": Ignoring clipping call for incompatible path.";
     return;
   }
 
-  mCurrentClipMaskTexture = NULL;
-  mCurrentClippedGeometry = NULL;
+  mCurrentClipMaskTexture = nullptr;
+  mCurrentClippedGeometry = nullptr;
 
   RefPtr<PathD2D> pathD2D = static_cast<PathD2D*>(const_cast<Path*>(aPath));
 
   PushedClip clip;
   clip.mTransform = D2DMatrix(mTransform);
   clip.mPath = pathD2D;
   
   pathD2D->mGeometry->GetBounds(clip.mTransform, &clip.mBounds);
@@ -975,26 +975,26 @@ DrawTargetD2D::PushClip(const Path *aPat
     D2D1_LAYER_OPTIONS options = D2D1_LAYER_OPTIONS_NONE;
 
     if (mFormat == FORMAT_B8G8R8X8) {
       options = D2D1_LAYER_OPTIONS_INITIALIZE_FOR_CLEARTYPE;
     }
 
     mRT->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), pathD2D->mGeometry,
                                          D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,
-                                         clip.mTransform, 1.0f, NULL,
+                                         clip.mTransform, 1.0f, nullptr,
                                          options), clip.mLayer);
   }
 }
 
 void
 DrawTargetD2D::PushClipRect(const Rect &aRect)
 {
-  mCurrentClipMaskTexture = NULL;
-  mCurrentClippedGeometry = NULL;
+  mCurrentClipMaskTexture = nullptr;
+  mCurrentClippedGeometry = nullptr;
   if (!mTransform.IsRectilinear()) {
     // Whoops, this isn't a rectangle in device space, Direct2D will not deal
     // with this transform the way we want it to.
     // See remarks: http://msdn.microsoft.com/en-us/library/dd316860%28VS.85%29.aspx
 
     RefPtr<PathBuilder> pathBuilder = CreatePathBuilder();
     pathBuilder->MoveTo(aRect.TopLeft());
     pathBuilder->LineTo(aRect.TopRight());
@@ -1016,18 +1016,18 @@ DrawTargetD2D::PushClipRect(const Rect &
   if (mClipsArePushed) {
     mRT->PushAxisAlignedClip(clip.mBounds, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
   }
 }
 
 void
 DrawTargetD2D::PopClip()
 {
-  mCurrentClipMaskTexture = NULL;
-  mCurrentClippedGeometry = NULL;
+  mCurrentClipMaskTexture = nullptr;
+  mCurrentClippedGeometry = nullptr;
   if (mClipsArePushed) {
     if (mPushedClips.back().mLayer) {
       PopCachedLayer(mRT);
     } else {
       mRT->PopAxisAlignedClip();
     }
   }
   mPushedClips.pop_back();
@@ -1037,79 +1037,79 @@ TemporaryRef<SourceSurface>
 DrawTargetD2D::CreateSourceSurfaceFromData(unsigned char *aData,
                                            const IntSize &aSize,
                                            int32_t aStride,
                                            SurfaceFormat aFormat) const
 {
   RefPtr<SourceSurfaceD2D> newSurf = new SourceSurfaceD2D();
 
   if (!newSurf->InitFromData(aData, aSize, aStride, aFormat, mRT)) {
-    return NULL;
+    return nullptr;
   }
 
   return newSurf;
 }
 
 TemporaryRef<SourceSurface> 
 DrawTargetD2D::OptimizeSourceSurface(SourceSurface *aSurface) const
 {
   // Unsupported!
-  return NULL;
+  return nullptr;
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetD2D::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
 {
   if (aSurface.mType != NATIVE_SURFACE_D3D10_TEXTURE) {
     gfxDebug() << *this << ": Failure to create source surface from non-D3D10 texture native surface.";
-    return NULL;
+    return nullptr;
   }
   RefPtr<SourceSurfaceD2D> newSurf = new SourceSurfaceD2D();
 
   if (!newSurf->InitFromTexture(static_cast<ID3D10Texture2D*>(aSurface.mSurface),
                                 aSurface.mFormat,
                                 mRT))
   {
     gfxWarning() << *this << ": Failed to create SourceSurface from texture.";
-    return NULL;
+    return nullptr;
   }
 
   return newSurf;
 }
 
 TemporaryRef<DrawTarget>
 DrawTargetD2D::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   RefPtr<DrawTargetD2D> newTarget =
     new DrawTargetD2D();
 
   if (!newTarget->Init(aSize, aFormat)) {
     gfxDebug() << *this << ": Failed to create optimal draw target. Size: " << aSize;
-    return NULL;
+    return nullptr;
   }
 
   return newTarget;
 }
 
 TemporaryRef<PathBuilder>
 DrawTargetD2D::CreatePathBuilder(FillRule aFillRule) const
 {
   RefPtr<ID2D1PathGeometry> path;
   HRESULT hr = factory()->CreatePathGeometry(byRef(path));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create Direct2D Path Geometry. Code: " << hr;
-    return NULL;
+    return nullptr;
   }
 
   RefPtr<ID2D1GeometrySink> sink;
   hr = path->Open(byRef(sink));
   if (FAILED(hr)) {
     gfxWarning() << "Failed to access Direct2D Path Geometry. Code: " << hr;
-    return NULL;
+    return nullptr;
   }
 
   if (aFillRule == FILL_WINDING) {
     sink->SetFillMode(D2D1_FILL_MODE_WINDING);
   }
 
   return new PathBuilderD2D(sink, path, aFillRule);
 }
@@ -1129,27 +1129,27 @@ DrawTargetD2D::CreateGradientStops(Gradi
   HRESULT hr =
     mRT->CreateGradientStopCollection(stops, aNumStops,
                                       D2D1_GAMMA_2_2, D2DExtend(aExtendMode),
                                       byRef(stopCollection));
   delete [] stops;
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create GradientStopCollection. Code: " << hr;
-    return NULL;
+    return nullptr;
   }
 
   return new GradientStopsD2D(stopCollection);
 }
 
 void*
 DrawTargetD2D::GetNativeSurface(NativeSurfaceType aType)
 {
   if (aType != NATIVE_SURFACE_D3D10_TEXTURE) {
-    return NULL;
+    return nullptr;
   }
 
   return mTexture;
 }
 
 /*
  * Public functions
  */
@@ -1168,17 +1168,17 @@ DrawTargetD2D::Init(const IntSize &aSize
   mDevice = Factory::GetDirect3D10Device();
 
   CD3D10_TEXTURE2D_DESC desc(DXGIFormat(aFormat),
                              mSize.width,
                              mSize.height,
                              1, 1);
   desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
 
-  hr = mDevice->CreateTexture2D(&desc, NULL, byRef(mTexture));
+  hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mTexture));
 
   if (FAILED(hr)) {
     gfxDebug() << "Failed to init Direct2D DrawTarget. Size: " << mSize << " Code: " << hr;
     return false;
   }
 
   if (!InitD2DRenderTarget()) {
     return false;
@@ -1238,17 +1238,17 @@ DrawTargetD2D::InitD3D10Data()
 
   mPrivateData = new PrivateD3D10DataD2D;
 
   D3D10CreateEffectFromMemoryFunc createD3DEffect;
   HMODULE d3dModule = LoadLibraryW(L"d3d10_1.dll");
   createD3DEffect = (D3D10CreateEffectFromMemoryFunc)
       GetProcAddress(d3dModule, "D3D10CreateEffectFromMemory");
 
-  hr = createD3DEffect((void*)d2deffect, sizeof(d2deffect), 0, mDevice, NULL, byRef(mPrivateData->mEffect));
+  hr = createD3DEffect((void*)d2deffect, sizeof(d2deffect), 0, mDevice, nullptr, byRef(mPrivateData->mEffect));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to initialize Direct2D required effects. Code: " << hr;
     return false;
   }
 
   privateDataSize = sizeof(mPrivateData);
   mDevice->SetPrivateData(sPrivateDataD2D, privateDataSize, &mPrivateData);
@@ -1370,17 +1370,17 @@ DrawTargetD2D::PrepareForDrawing(ID2D1Re
 }
 
 void
 DrawTargetD2D::MarkChanged()
 {
   if (mSnapshot) {
     if (mSnapshot->hasOneRef()) {
       // Just destroy it, since no-one else knows about it.
-      mSnapshot = NULL;
+      mSnapshot = nullptr;
     } else {
       mSnapshot->DrawTargetWillChange();
       // The snapshot will no longer depend on this target.
       MOZ_ASSERT(!mSnapshot);
     }
   }
   if (mDependentTargets.size()) {
     // Copy mDependentTargets since the Flush()es below will modify it.
@@ -1528,17 +1528,17 @@ DrawTargetD2D::FinalizeRTForOperation(Co
   bool needsWriteBack =
     !IsOperatorBoundByMask(aOperator) && mPushedClips.size();
 
   if (needsWriteBack) {
     restoreClippedOut.Save();
   }
 
   ID3D10RenderTargetView *rtViews = mRTView;
-  mDevice->OMSetRenderTargets(1, &rtViews, NULL);
+  mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
 
   UINT stride = sizeof(Vertex);
   UINT offset = 0;
   ID3D10Buffer *buff = mPrivateData->mVB;
 
   mDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
   mDevice->IASetVertexBuffers(0, 1, &buff, &stride, &offset);
   mDevice->IASetInputLayout(mPrivateData->mInputLayout);
@@ -1568,17 +1568,17 @@ DrawTargetD2D::FinalizeRTForOperation(Co
       return;
     }
 
     mPrivateData->mEffect->GetVariableByName("mask")->AsShaderResource()->SetResource(mSRView);
 
     SetupEffectForRadialGradient(pat);
   }
 
-  mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), NULL, 0xffffffff);
+  mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), nullptr, 0xffffffff);
   
   mDevice->Draw(4, 0);
 }
 
 TemporaryRef<ID2D1Geometry>
 DrawTargetD2D::ConvertRectToGeometry(const D2D1_RECT_F& aRect)
 {
   RefPtr<ID2D1RectangleGeometry> rectGeom;
@@ -1666,17 +1666,17 @@ DrawTargetD2D::CreateRTForTexture(ID3D10
 
   RefPtr<IDXGISurface> surface;
   RefPtr<ID2D1RenderTarget> rt;
 
   hr = aTexture->QueryInterface((IDXGISurface**)byRef(surface));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to QI texture to surface.";
-    return NULL;
+    return nullptr;
   }
 
   D3D10_TEXTURE2D_DESC desc;
   aTexture->GetDesc(&desc);
 
   D2D1_ALPHA_MODE alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
 
   if (aFormat == FORMAT_B8G8R8X8 && aTexture == mTexture) {
@@ -1684,17 +1684,17 @@ DrawTargetD2D::CreateRTForTexture(ID3D10
   }
 
   D2D1_RENDER_TARGET_PROPERTIES props =
     D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(desc.Format, alphaMode));
   hr = factory()->CreateDxgiSurfaceRenderTarget(surface, props, byRef(rt));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create D2D render target for texture.";
-    return NULL;
+    return nullptr;
   }
 
   return rt;
 }
 
 void
 DrawTargetD2D::EnsureViews()
 {
@@ -1705,32 +1705,32 @@ DrawTargetD2D::EnsureViews()
   HRESULT hr;
 
   CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM,
                              mSize.width,
                              mSize.height,
                              1, 1);
   desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
 
-  hr = mDevice->CreateTexture2D(&desc, NULL, byRef(mTempTexture));
+  hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mTempTexture));
 
   if (FAILED(hr)) {
     gfxWarning() << *this << "Failed to create temporary texture for rendertarget. Size: "
       << mSize << " Code: " << hr;
     return;
   }
 
-  hr = mDevice->CreateShaderResourceView(mTempTexture, NULL, byRef(mSRView));
+  hr = mDevice->CreateShaderResourceView(mTempTexture, nullptr, byRef(mSRView));
 
   if (FAILED(hr)) {
     gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hr;
     return;
   }
 
-  hr = mDevice->CreateRenderTargetView(mTexture, NULL, byRef(mRTView));
+  hr = mDevice->CreateRenderTargetView(mTexture, nullptr, byRef(mRTView));
 
   if (FAILED(hr)) {
     gfxWarning() << *this << "Failed to create rendertarget view for temp texture. Code: " << hr;
   }
 }
 
 void
 DrawTargetD2D::PopAllClips()
@@ -1751,17 +1751,17 @@ DrawTargetD2D::PushClipsToRT(ID2D1Render
       D2D1_LAYER_OPTIONS options = D2D1_LAYER_OPTIONS_NONE;
 
       if (mFormat == FORMAT_B8G8R8X8) {
         options = D2D1_LAYER_OPTIONS_INITIALIZE_FOR_CLEARTYPE;
       }
 
       aRT->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), iter->mPath->mGeometry,
                                             D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,
-                                            iter->mTransform, 1.0f, NULL,
+                                            iter->mTransform, 1.0f, nullptr,
                                             options), iter->mLayer);
     } else {
       aRT->PushAxisAlignedClip(iter->mBounds, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
     }
   }
 }
 
 void
@@ -1784,17 +1784,17 @@ DrawTargetD2D::EnsureClipMaskTexture()
   }
   
   CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_A8_UNORM,
                              mSize.width,
                              mSize.height,
                              1, 1);
   desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
 
-  HRESULT hr = mDevice->CreateTexture2D(&desc, NULL, byRef(mCurrentClipMaskTexture));
+  HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mCurrentClipMaskTexture));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create texture for ClipMask!";
     return;
   }
 
   RefPtr<ID2D1RenderTarget> rt = CreateRTForTexture(mCurrentClipMaskTexture, FORMAT_A8);
 
@@ -1904,17 +1904,17 @@ DrawTargetD2D::FillGlyphsManual(ScaledFo
 
   RefPtr<ID3D10Texture2D> tex = CreateTextureForAnalysis(analysis, rectBounds);
 
   if (!tex) {
     return false;
   }
 
   RefPtr<ID3D10ShaderResourceView> srView;
-  hr = mDevice->CreateShaderResourceView(tex, NULL, byRef(srView));
+  hr = mDevice->CreateShaderResourceView(tex, nullptr, byRef(srView));
 
   if (FAILED(hr)) {
     return false;
   }
 
   MarkChanged();
 
   // Prepare our background texture for drawing.
@@ -1955,17 +1955,17 @@ DrawTargetD2D::FillGlyphsManual(ScaledFo
       isMasking = true;
     }        
   }
   
   if (isMasking) {
     EnsureClipMaskTexture();
 
     RefPtr<ID3D10ShaderResourceView> srViewMask;
-    hr = mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, NULL, byRef(srViewMask));
+    hr = mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, nullptr, byRef(srViewMask));
 
     if (FAILED(hr)) {
       return false;
     }
 
     mPrivateData->mEffect->GetVariableByName("mask")->AsShaderResource()->SetResource(srViewMask);
 
     mPrivateData->mEffect->GetVariableByName("MaskTexCoords")->AsVector()->
@@ -1974,20 +1974,20 @@ DrawTargetD2D::FillGlyphsManual(ScaledFo
 
     technique->GetPassByIndex(1)->Apply(0);
   } else {
     technique->GetPassByIndex(0)->Apply(0);
   }  
 
   RefPtr<ID3D10RenderTargetView> rtView;
   ID3D10RenderTargetView *rtViews;
-  mDevice->CreateRenderTargetView(mTexture, NULL, byRef(rtView));
+  mDevice->CreateRenderTargetView(mTexture, nullptr, byRef(rtView));
 
   rtViews = rtView;
-  mDevice->OMSetRenderTargets(1, &rtViews, NULL);
+  mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
 
   mDevice->Draw(4, 0);
   return true;
 }
 
 TemporaryRef<ID2D1Brush>
 DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
 {
@@ -2009,17 +2009,17 @@ DrawTargetD2D::CreateBrushForPattern(con
     RefPtr<ID2D1LinearGradientBrush> gradBrush;
     const LinearGradientPattern *pat =
       static_cast<const LinearGradientPattern*>(&aPattern);
 
     GradientStopsD2D *stops = static_cast<GradientStopsD2D*>(pat->mStops.get());
 
     if (!stops) {
       gfxDebug() << "No stops specified for gradient pattern.";
-      return NULL;
+      return nullptr;
     }
 
     if (pat->mBegin == pat->mEnd) {
       RefPtr<ID2D1SolidColorBrush> colBrush;
       uint32_t stopCount = stops->mStopCollection->GetGradientStopCount();
       vector<D2D1_GRADIENT_STOP> d2dStops(stopCount);
       stops->mStopCollection->GetGradientStops(&d2dStops.front(), stopCount);
       mRT->CreateSolidColorBrush(d2dStops.back().color,
@@ -2038,17 +2038,17 @@ DrawTargetD2D::CreateBrushForPattern(con
     RefPtr<ID2D1RadialGradientBrush> gradBrush;
     const RadialGradientPattern *pat =
       static_cast<const RadialGradientPattern*>(&aPattern);
 
     GradientStopsD2D *stops = static_cast<GradientStopsD2D*>(pat->mStops.get());
 
     if (!stops) {
       gfxDebug() << "No stops specified for gradient pattern.";
-      return NULL;
+      return nullptr;
     }
 
     // This will not be a complex radial gradient brush.
     mRT->CreateRadialGradientBrush(
       D2D1::RadialGradientBrushProperties(D2DPoint(pat->mCenter1),
                                           D2D1::Point2F(),
                                           pat->mRadius2, pat->mRadius2),
       D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)),
@@ -2058,32 +2058,32 @@ DrawTargetD2D::CreateBrushForPattern(con
     return gradBrush;
   } else if (aPattern.GetType() == PATTERN_SURFACE) {
     RefPtr<ID2D1BitmapBrush> bmBrush;
     const SurfacePattern *pat =
       static_cast<const SurfacePattern*>(&aPattern);
 
     if (!pat->mSurface) {
       gfxDebug() << "No source surface specified for surface pattern";
-      return NULL;
+      return nullptr;
     }
 
     RefPtr<ID2D1Bitmap> bitmap;
 
     Matrix mat = pat->mMatrix;
     
     switch (pat->mSurface->GetType()) {
     case SURFACE_D2D1_BITMAP:
       {
         SourceSurfaceD2D *surf = static_cast<SourceSurfaceD2D*>(pat->mSurface.get());
 
         bitmap = surf->mBitmap;
 
         if (!bitmap) {
-          return NULL;
+          return nullptr;
         }
       }
       break;
     case SURFACE_D2D1_DRAWTARGET:
       {
         SourceSurfaceD2DTarget *surf =
           static_cast<SourceSurfaceD2DTarget*>(pat->mSurface.get());
         bitmap = surf->GetBitmap(mRT);
@@ -2092,17 +2092,17 @@ DrawTargetD2D::CreateBrushForPattern(con
       break;
     case SURFACE_DATA:
       {
         DataSourceSurface *dataSurf =
           static_cast<DataSourceSurface*>(pat->mSurface.get());
         bitmap = CreatePartialBitmapForSurface(dataSurf, mat, pat->mExtendMode);
         
         if (!bitmap) {
-          return NULL;
+          return nullptr;
         }
       }
       break;
     default:
       break;
     }
     
     mRT->CreateBitmapBrush(bitmap,
@@ -2111,17 +2111,17 @@ DrawTargetD2D::CreateBrushForPattern(con
                                                        D2DFilter(pat->mFilter)),
                            D2D1::BrushProperties(aAlpha, D2DMatrix(mat)),
                            byRef(bmBrush));
 
     return bmBrush;
   }
 
   gfxWarning() << "Invalid pattern type detected.";
-  return NULL;
+  return nullptr;
 }
 
 TemporaryRef<ID2D1StrokeStyle>
 DrawTargetD2D::CreateStrokeStyleForOptions(const StrokeOptions &aStrokeOptions)
 {
   RefPtr<ID2D1StrokeStyle> style;
 
   D2D1_CAP_STYLE capStyle;
@@ -2178,17 +2178,17 @@ DrawTargetD2D::CreateStrokeStyleForOptio
                 // and VC10's STL
       dash.size(),
       byRef(style));
   } else {
     hr = factory()->CreateStrokeStyle(
       D2D1::StrokeStyleProperties(capStyle, capStyle,
                                   capStyle, joinStyle,
                                   aStrokeOptions.mMiterLimit),
-      NULL, 0, byRef(style));
+      nullptr, 0, byRef(style));
   }
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create Direct2D stroke style.";
   }
 
   return style;
 }
@@ -2280,17 +2280,17 @@ DrawTargetD2D::CreateTextureForAnalysis(
 
   // Add one byte so we can safely read a 32-bit int when copying the last
   // 3 bytes.
   BYTE *texture = new BYTE[bufferSize + 1];
   hr = aAnalysis->CreateAlphaTexture(DWRITE_TEXTURE_CLEARTYPE_3x1, &bounds, texture, bufferSize);
 
   if (FAILED(hr)) {
     delete [] texture;
-    return NULL;
+    return nullptr;
   }
 
   int alignedBufferSize = aBounds.width * aBounds.height * 4;
 
   // Create a one-off immutable texture from system memory.
   BYTE *alignedTextureData = new BYTE[alignedBufferSize];
   for (int y = 0; y < aBounds.height; y++) {
     for (int x = 0; x < aBounds.width; x++) {
@@ -2319,17 +2319,17 @@ DrawTargetD2D::CreateTextureForAnalysis(
 
   RefPtr<ID3D10Texture2D> tex;
   hr = mDevice->CreateTexture2D(&desc, &data, byRef(tex));
 	
   delete [] alignedTextureData;
   delete [] texture;
 
   if (FAILED(hr)) {
-    return NULL;
+    return nullptr;
   }
 
   return tex;
 }
 
 TemporaryRef<ID2D1Bitmap>
 DrawTargetD2D::CreatePartialBitmapForSurface(DataSourceSurface *aSurface, Matrix &aMatrix, ExtendMode aExtendMode)
 {
@@ -2339,17 +2339,17 @@ DrawTargetD2D::CreatePartialBitmapForSur
   // created for a surface that was too large to fit in a texture.
   // We'll need to figure out if we can work with a partial upload
   // or downsample in software.
 
   Matrix transform = mTransform;
   Matrix invTransform = transform = aMatrix * transform;
   if (!invTransform.Invert()) {
     // Singular transform, nothing to be drawn.
-    return NULL;
+    return nullptr;
   }
 
   Rect rect(0, 0, mSize.width, mSize.height);
 
   // Calculate the rectangle of the source mapped to our surface.
   rect = invTransform.TransformBounds(rect);
   rect.RoundOut();
 
@@ -2407,17 +2407,17 @@ DrawTargetD2D::CreatePartialBitmapForSur
 
     return bitmap;
   } else {
     int Bpp = BytesPerPixel(aSurface->GetFormat());
 
     if (Bpp != 4) {
       // This shouldn't actually happen in practice!
       MOZ_ASSERT(false);
-      return NULL;
+      return nullptr;
     }
 
     ImageHalfScaler scaler(aSurface->GetData(), stride, size);
 
     // Calculate the maximum width/height of the image post transform.
     Point topRight = transform * Point(size.width, 0);
     Point topLeft = transform * Point(0, 0);
     Point bottomRight = transform * Point(size.width, size.height);
@@ -2464,17 +2464,17 @@ DrawTargetD2D::SetupEffectForRadialGradi
     SetFloatVector(dimensions);
 
   const GradientStopsD2D *stops =
     static_cast<const GradientStopsD2D*>(aPattern->mStops.get());
 
   RefPtr<ID3D10Texture2D> tex = CreateGradientTexture(stops);
 
   RefPtr<ID3D10ShaderResourceView> srView;
-  mDevice->CreateShaderResourceView(tex, NULL, byRef(srView));
+  mDevice->CreateShaderResourceView(tex, nullptr, byRef(srView));
 
   mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(srView);
 
   Point dc = aPattern->mCenter2 - aPattern->mCenter1;
   float dr = aPattern->mRadius2 - aPattern->mRadius1;
 
   float diffv[] = { dc.x, dc.y, dr, 0 };
   mPrivateData->mEffect->GetVariableByName("diff")->AsVector()->
@@ -2558,17 +2558,17 @@ DrawTargetD2D::factory()
 
   D2D1CreateFactoryFunc createD2DFactory;
   HMODULE d2dModule = LoadLibraryW(L"d2d1.dll");
   createD2DFactory = (D2D1CreateFactoryFunc)
       GetProcAddress(d2dModule, "D2D1CreateFactory");
 
   if (!createD2DFactory) {
     gfxWarning() << "Failed to locate D2D1CreateFactory function.";
-    return NULL;
+    return nullptr;
   }
 
   D2D1_FACTORY_OPTIONS options;
 #ifdef _DEBUG
   options.debugLevel = D2D1_DEBUG_LEVEL_WARNING;
 #else
   options.debugLevel = D2D1_DEBUG_LEVEL_NONE;
 #endif
@@ -2594,17 +2594,17 @@ DrawTargetD2D::GetDWriteFactory()
 
   DWriteCreateFactoryFunc createDWriteFactory;
   HMODULE dwriteModule = LoadLibraryW(L"dwrite.dll");
   createDWriteFactory = (DWriteCreateFactoryFunc)
     GetProcAddress(dwriteModule, "DWriteCreateFactory");
 
   if (!createDWriteFactory) {
     gfxWarning() << "Failed to locate DWriteCreateFactory function.";
-    return NULL;
+    return nullptr;
   }
 
   HRESULT hr = createDWriteFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
                                    reinterpret_cast<IUnknown**>(&mDWriteFactory));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create DWrite Factory.";
   }
--- a/gfx/2d/DrawTargetD2D.h
+++ b/gfx/2d/DrawTargetD2D.h
@@ -86,17 +86,17 @@ public:
                       const DrawOptions &aOptions = DrawOptions());
   virtual void Fill(const Path *aPath,
                     const Pattern &aPattern,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
                           const DrawOptions &aOptions = DrawOptions(),
-                          const GlyphRenderingOptions *aRenderingOptions = NULL);
+                          const GlyphRenderingOptions *aRenderingOptions = nullptr);
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void PushClip(const Path *aPath);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
 
   virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
--- a/gfx/2d/DrawTargetDual.h
+++ b/gfx/2d/DrawTargetDual.h
@@ -119,20 +119,20 @@ public:
                         uint32_t aNumStops,
                         ExtendMode aExtendMode = EXTEND_CLAMP) const
   {
     return mA->CreateGradientStops(aStops, aNumStops, aExtendMode);
   }
      
   virtual void *GetNativeSurface(NativeSurfaceType aType)
   {
-    return NULL;
+    return nullptr;
   }
      
 private:
   RefPtr<DrawTarget> mA;
   RefPtr<DrawTarget> mB;
 };
      
 }
 }
      
-#endif /* MOZILLA_GFX_DRAWTARGETDUAL_H_ */ 
\ No newline at end of file
+#endif /* MOZILLA_GFX_DRAWTARGETDUAL_H_ */ 
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -157,17 +157,17 @@ DrawTargetSkia::~DrawTargetSkia()
   }
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetSkia::Snapshot()
 {
   RefPtr<SourceSurfaceSkia> source = new SourceSurfaceSkia();
   if (!source->InitWithBitmap(mBitmap, mFormat, this)) {
-    return NULL;
+    return nullptr;
   }
   AppendSnapshot(source);
   return source;
 }
 
 SkShader::TileMode
 ExtendModeToTileMode(ExtendMode aMode)
 {
@@ -306,17 +306,17 @@ struct AutoPaintSetup {
     // clear the clip rect. The other operators would be harder
     // but could be worth it to skip pushing a group.
     if (!IsOperatorBoundByMask(aOptions.mCompositionOp)) {
       mPaint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
       SkPaint temp;
       temp.setXfermodeMode(GfxOpToSkiaOp(aOptions.mCompositionOp));
       temp.setAlpha(aOptions.mAlpha*255);
       //TODO: Get a rect here
-      mCanvas->saveLayer(NULL, &temp);
+      mCanvas->saveLayer(nullptr, &temp);
       mNeedsRestore = true;
     } else {
       mPaint.setAlpha(aOptions.mAlpha*255.0);
       mAlpha = aOptions.mAlpha;
     }
     mPaint.setFilterBitmap(true);
   }
 
@@ -586,42 +586,42 @@ DrawTargetSkia::CreateSourceSurfaceFromD
                                              const IntSize &aSize,
                                              int32_t aStride,
                                              SurfaceFormat aFormat) const
 {
   RefPtr<SourceSurfaceSkia> newSurf = new SourceSurfaceSkia();
 
   if (!newSurf->InitFromData(aData, aSize, aStride, aFormat)) {
     gfxDebug() << *this << ": Failure to create source surface from data. Size: " << aSize;
-    return NULL;
+    return nullptr;
   }
     
   return newSurf;
 }
 
 TemporaryRef<DrawTarget>
 DrawTargetSkia::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   RefPtr<DrawTargetSkia> target = new DrawTargetSkia();
   if (!target->Init(aSize, aFormat)) {
-    return NULL;
+    return nullptr;
   }
   return target;
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetSkia::OptimizeSourceSurface(SourceSurface *aSurface) const
 {
-  return NULL;
+  return nullptr;
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetSkia::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
 {
-  return NULL;
+  return nullptr;
 }
 
 void
 DrawTargetSkia::CopySurface(SourceSurface *aSurface,
                             const IntRect& aSourceRect,
                             const IntPoint &aDestination)
 {
   //TODO: We could just use writePixels() here if the sourceRect is the entire source
--- a/gfx/2d/DrawTargetSkia.h
+++ b/gfx/2d/DrawTargetSkia.h
@@ -61,17 +61,17 @@ public:
                       const DrawOptions &aOptions = DrawOptions());
   virtual void Fill(const Path *aPath,
                     const Pattern &aPattern,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
                           const DrawOptions &aOptions = DrawOptions(),
-                          const GlyphRenderingOptions *aRenderingOptions = NULL);
+                          const GlyphRenderingOptions *aRenderingOptions = nullptr);
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void PushClip(const Path *aPath);
   virtual void PushClipRect(const Rect& aRect);
   virtual void PopClip();
   virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                             const IntSize &aSize,
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -191,22 +191,22 @@ Factory::CreateDrawTarget(BackendType aB
       if (newTarget->Init(aSize, aFormat)) {
         return newTarget;
       }
       break;
     }
 #endif
   default:
     gfxDebug() << "Invalid draw target type specified.";
-    return NULL;
+    return nullptr;
   }
 
   gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize;
   // Failed
-  return NULL;
+  return nullptr;
 }
 
 TemporaryRef<DrawTarget>
 Factory::CreateDrawTargetForData(BackendType aBackend, 
                                  unsigned char *aData, 
                                  const IntSize &aSize, 
                                  int32_t aStride, 
                                  SurfaceFormat aFormat)
@@ -227,22 +227,22 @@ Factory::CreateDrawTargetForData(Backend
       RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
       if (newTarget->Init(aBackend, aData, aSize, aStride, aFormat))
         return newTarget;
       break;
     }
 #endif
   default:
     gfxDebug() << "Invalid draw target type specified.";
-    return NULL;
+    return nullptr;
   }
 
   gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize;
   // Failed
-  return NULL;
+  return nullptr;
 }
 
 TemporaryRef<ScaledFont>
 Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSize)
 {
   switch (aNativeFont.mType) {
 #ifdef WIN32
   case NATIVE_FONT_DWRITE_FONT_FACE:
@@ -273,33 +273,33 @@ Factory::CreateScaledFontForNativeFont(c
     {
       ScaledFontBase* fontBase = new ScaledFontBase(aSize);
       fontBase->SetCairoScaledFont(static_cast<cairo_scaled_font_t*>(aNativeFont.mFont));
       return fontBase;
     }
 #endif
   default:
     gfxWarning() << "Invalid native font type specified.";
-    return NULL;
+    return nullptr;
   }
 }
 
 TemporaryRef<ScaledFont>
 Factory::CreateScaledFontWithCairo(const NativeFont& aNativeFont, Float aSize, cairo_scaled_font_t* aScaledFont)
 {
 #ifdef USE_CAIRO
   // In theory, we could pull the NativeFont out of the cairo_scaled_font_t*,
   // but that would require a lot of code that would be otherwise repeated in
   // various backends.
   // Therefore, we just reuse CreateScaledFontForNativeFont's implementation.
   RefPtr<ScaledFont> font = CreateScaledFontForNativeFont(aNativeFont, aSize);
   static_cast<ScaledFontBase*>(font.get())->SetCairoScaledFont(aScaledFont);
   return font;
 #else
-  return NULL;
+  return nullptr;
 #endif
 }
 
 #ifdef WIN32
 TemporaryRef<DrawTarget>
 Factory::CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat)
 {
   RefPtr<DrawTargetD2D> newTarget;
@@ -307,37 +307,37 @@ Factory::CreateDrawTargetForD3D10Texture
   newTarget = new DrawTargetD2D();
   if (newTarget->Init(aTexture, aFormat)) {
     return newTarget;
   }
 
   gfxWarning() << "Failed to create draw target for D3D10 texture.";
 
   // Failed
-  return NULL;
+  return nullptr;
 }
 
 TemporaryRef<DrawTarget>
 Factory::CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA,
                                               ID3D10Texture2D *aTextureB,
                                               SurfaceFormat aFormat)
 {
   RefPtr<DrawTargetD2D> newTargetA;
   RefPtr<DrawTargetD2D> newTargetB;
 
   newTargetA = new DrawTargetD2D();
   if (!newTargetA->Init(aTextureA, aFormat)) {
     gfxWarning() << "Failed to create draw target for D3D10 texture.";
-    return NULL;
+    return nullptr;
   }
 
   newTargetB = new DrawTargetD2D();
   if (!newTargetB->Init(aTextureB, aFormat)) {
     gfxWarning() << "Failed to create draw target for D3D10 texture.";
-    return NULL;
+    return nullptr;
   }
 
   RefPtr<DrawTarget> newTarget =
     new DrawTargetDual(newTargetA, newTargetB);
 
   return newTarget;
 }
 
@@ -381,27 +381,27 @@ Factory::CreateDrawTargetForCairoSurface
 {
 #ifdef USE_CAIRO
   RefPtr<DrawTargetCairo> newTarget = new DrawTargetCairo();
   if (newTarget->Init(aSurface, aSize)) {
     return newTarget;
   }
 
 #endif
-  return NULL;
+  return nullptr;
 }
 
 TemporaryRef<DataSourceSurface>
 Factory::CreateWrappingDataSourceSurface(uint8_t *aData, int32_t aStride,
                                          const IntSize &aSize,
                                          SurfaceFormat aFormat)
 {
   RefPtr<SourceSurfaceRawData> newSurf = new SourceSurfaceRawData();
 
   if (newSurf->InitWrappingData(aData, aSize, aStride, aFormat, false)) {
     return newSurf;
   }
 
-  return NULL;
+  return nullptr;
 }
 
 }
 }
--- a/gfx/2d/ImageScaling.h
+++ b/gfx/2d/ImageScaling.h
@@ -14,17 +14,17 @@
 namespace mozilla {
 namespace gfx {
 
 class ImageHalfScaler
 {
 public:
   ImageHalfScaler(uint8_t *aData, int32_t aStride, const IntSize &aSize)
     : mOrigData(aData), mOrigStride(aStride), mOrigSize(aSize)
-    , mDataStorage(NULL)
+    , mDataStorage(nullptr)
   {
   }
 
   ~ImageHalfScaler()
   {
     delete [] mDataStorage;
   }
 
--- a/gfx/2d/PathCG.cpp
+++ b/gfx/2d/PathCG.cpp
@@ -14,50 +14,50 @@ namespace gfx {
 PathBuilderCG::~PathBuilderCG()
 {
   CGPathRelease(mCGPath);
 }
 
 void
 PathBuilderCG::MoveTo(const Point &aPoint)
 {
-  CGPathMoveToPoint(mCGPath, NULL, aPoint.x, aPoint.y);
+  CGPathMoveToPoint(mCGPath, nullptr, aPoint.x, aPoint.y);
 }
 
 void
 PathBuilderCG::LineTo(const Point &aPoint)
 {
   if (CGPathIsEmpty(mCGPath))
     MoveTo(aPoint);
   else
-    CGPathAddLineToPoint(mCGPath, NULL, aPoint.x, aPoint.y);
+    CGPathAddLineToPoint(mCGPath, nullptr, aPoint.x, aPoint.y);
 }
 
 void
 PathBuilderCG::BezierTo(const Point &aCP1,
                          const Point &aCP2,
                          const Point &aCP3)
 {
 
   if (CGPathIsEmpty(mCGPath))
     MoveTo(aCP1);
-  CGPathAddCurveToPoint(mCGPath, NULL,
+  CGPathAddCurveToPoint(mCGPath, nullptr,
                           aCP1.x, aCP1.y,
                           aCP2.x, aCP2.y,
                           aCP3.x, aCP3.y);
 
 }
 
 void
 PathBuilderCG::QuadraticBezierTo(const Point &aCP1,
                                   const Point &aCP2)
 {
   if (CGPathIsEmpty(mCGPath))
     MoveTo(aCP1);
-  CGPathAddQuadCurveToPoint(mCGPath, NULL,
+  CGPathAddQuadCurveToPoint(mCGPath, nullptr,
                               aCP1.x, aCP1.y,
                               aCP2.x, aCP2.y);
 }
 
 void
 PathBuilderCG::Close()
 {
   if (!CGPathIsEmpty(mCGPath))
@@ -166,32 +166,32 @@ PathCG::ContainsPoint(const Point &aPoin
   Matrix inverse = aTransform;
   inverse.Invert();
   Point transformedPoint = inverse*aPoint;
   // We could probably drop the input transform and just transform the point at the caller?
   CGPoint point = {transformedPoint.x, transformedPoint.y};
 
   // The transform parameter of CGPathContainsPoint doesn't seem to work properly on OS X 10.5
   // so we transform aPoint ourselves.
-  return CGPathContainsPoint(mPath, NULL, point, mFillRule == FILL_EVEN_ODD);
+  return CGPathContainsPoint(mPath, nullptr, point, mFillRule == FILL_EVEN_ODD);
 }
 
 static size_t
 PutBytesNull(void *info, const void *buffer, size_t count)
 {
   return count;
 }
 
 /* The idea of a scratch context comes from WebKit */
 static CGContextRef
 CreateScratchContext()
 {
-  CGDataConsumerCallbacks callbacks = {PutBytesNull, NULL};
-  CGDataConsumerRef consumer = CGDataConsumerCreate(NULL, &callbacks);
-  CGContextRef cg = CGPDFContextCreate(consumer, NULL, NULL);
+  CGDataConsumerCallbacks callbacks = {PutBytesNull, nullptr};
+  CGDataConsumerRef consumer = CGDataConsumerCreate(nullptr, &callbacks);
+  CGContextRef cg = CGPDFContextCreate(consumer, nullptr, nullptr);
   CGDataConsumerRelease(consumer);
   return cg;
 }
 
 static CGContextRef
 ScratchContext()
 {
   static CGContextRef cg = CreateScratchContext();
--- a/gfx/2d/PathCairo.cpp
+++ b/gfx/2d/PathCairo.cpp
@@ -34,30 +34,30 @@ CairoPathContext::CairoPathContext(cairo
   } else if (mDrawTarget) {
     mDrawTarget->SetPathObserver(this);
   }
 }
 
 CairoPathContext::~CairoPathContext()
 {
   if (mDrawTarget) {
-    mDrawTarget->SetPathObserver(NULL);
+    mDrawTarget->SetPathObserver(nullptr);
   }
   cairo_destroy(mContext);
 }
 
 void
 CairoPathContext::ObserveTarget(DrawTargetCairo* aDrawTarget)
 {
   if (!aDrawTarget) {
     return;
   }
 
   if (mDrawTarget) {
-    mDrawTarget->SetPathObserver(NULL);
+    mDrawTarget->SetPathObserver(nullptr);
   }
   mDrawTarget = aDrawTarget;
 
   // If there is a transform on the path, then we must have a separate context
   // from the draw target, so we cannot be its observer
   if (!mTransform.IsIdentity()) {
     ForgetDrawTarget();
     return;
@@ -154,17 +154,17 @@ CairoPathContext::CopyPathTo(cairo_t* aT
 
     cairo_set_matrix(aToContext, &origMat);
   }
 }
 
 void
 CairoPathContext::ForgetDrawTarget()
 {
-  mDrawTarget = NULL;
+  mDrawTarget = nullptr;
 }
 
 bool
 CairoPathContext::ContainsPath(const Path* aPath)
 {
   if (aPath->GetBackendType() != BACKEND_CAIRO) {
     return false;
   }
--- a/gfx/2d/PathD2D.cpp
+++ b/gfx/2d/PathD2D.cpp
@@ -231,17 +231,17 @@ PathBuilderD2D::Finish()
 {
   if (mFigureActive) {
     mSink->EndFigure(D2D1_FIGURE_END_OPEN);
   }
 
   HRESULT hr = mSink->Close();
   if (FAILED(hr)) {
     gfxDebug() << "Failed to close PathSink. Code: " << hr;
-    return NULL;
+    return nullptr;
   }
 
   return new PathD2D(mGeometry, mFigureActive, mCurrentPoint, mFillRule);
 }
 
 TemporaryRef<PathBuilder>
 PathD2D::CopyToBuilder(FillRule aFillRule) const
 {
@@ -251,24 +251,24 @@ PathD2D::CopyToBuilder(FillRule aFillRul
 TemporaryRef<PathBuilder>
 PathD2D::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) const
 {
   RefPtr<ID2D1PathGeometry> path;
   HRESULT hr = DrawTargetD2D::factory()->CreatePathGeometry(byRef(path));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create PathGeometry. Code: " << hr;
-    return NULL;
+    return nullptr;
   }
 
   RefPtr<ID2D1GeometrySink> sink;
   hr = path->Open(byRef(sink));
   if (FAILED(hr)) {
     gfxWarning() << "Failed to open Geometry for writing. Code: " << hr;
-    return NULL;
+    return nullptr;
   }
 
   if (aFillRule == FILL_WINDING) {
     sink->SetFillMode(D2D1_FILL_MODE_WINDING);
   }
 
   if (mEndedActive) {
     OpeningGeometrySink wrapSink(sink);
--- a/gfx/2d/QuartzSupport.mm
+++ b/gfx/2d/QuartzSupport.mm
@@ -132,17 +132,17 @@ IOSurfaceGetHeightFunc        MacIOSurfa
 IOSurfaceGetWidthFunc         MacIOSurfaceLib::sHeight;
 IOSurfaceGetBytesPerRowFunc   MacIOSurfaceLib::sBytesPerRow;
 IOSurfaceLockFunc             MacIOSurfaceLib::sLock;
 IOSurfaceUnlockFunc           MacIOSurfaceLib::sUnlock;
 CGLTexImageIOSurface2DFunc    MacIOSurfaceLib::sTexImage;
 IOSurfaceContextCreateFunc    MacIOSurfaceLib::sIOSurfaceContextCreate;
 IOSurfaceContextCreateImageFunc   MacIOSurfaceLib::sIOSurfaceContextCreateImage;
 IOSurfaceContextGetSurfaceFunc    MacIOSurfaceLib::sIOSurfaceContextGetSurface;
-unsigned int                  (*MacIOSurfaceLib::sCGContextGetTypePtr) (CGContextRef) = NULL;
+unsigned int                  (*MacIOSurfaceLib::sCGContextGetTypePtr) (CGContextRef) = nullptr;
 
 CFStringRef                   MacIOSurfaceLib::kPropWidth;
 CFStringRef                   MacIOSurfaceLib::kPropHeight;
 CFStringRef                   MacIOSurfaceLib::kPropBytesPerElem;
 CFStringRef                   MacIOSurfaceLib::kPropBytesPerRow;
 CFStringRef                   MacIOSurfaceLib::kPropIsGlobal;
 
 bool MacIOSurfaceLib::isInit() {
@@ -203,29 +203,29 @@ CGLError MacIOSurfaceLib::CGLTexImageIOS
                    format, type, ioSurface, plane);
 }
 
 CGContextRef MacIOSurfaceLib::IOSurfaceContextCreate(IOSurfacePtr aIOSurfacePtr,
                              unsigned aWidth, unsigned aHeight,
                              unsigned aBitsPerComponent, unsigned aBytes,
                              CGColorSpaceRef aColorSpace, CGBitmapInfo bitmapInfo) {
   if (!sIOSurfaceContextCreate)
-    return NULL;
+    return nullptr;
   return sIOSurfaceContextCreate(aIOSurfacePtr, aWidth, aHeight, aBitsPerComponent, aBytes, aColorSpace, bitmapInfo);
 }
 
 CGImageRef MacIOSurfaceLib::IOSurfaceContextCreateImage(CGContextRef aContext) {
   if (!sIOSurfaceContextCreateImage)
-    return NULL;
+    return nullptr;
   return sIOSurfaceContextCreateImage(aContext);
 }
 
 IOSurfacePtr MacIOSurfaceLib::IOSurfaceContextGetSurface(CGContextRef aContext) {
   if (!sIOSurfaceContextGetSurface)
-    return NULL;
+    return nullptr;
   return sIOSurfaceContextGetSurface(aContext);
 }
 
 CFStringRef MacIOSurfaceLib::GetIOConst(const char* symbole) {
   CFStringRef *address = (CFStringRef*)dlsym(sIOSurfaceFramework, symbole);
   if (!address)
     return nullptr;
 
@@ -309,19 +309,19 @@ TemporaryRef<MacIOSurface> MacIOSurface:
   CFMutableDictionaryRef props = ::CFDictionaryCreateMutable(
                       kCFAllocatorDefault, 4,
                       &kCFTypeDictionaryKeyCallBacks,
                       &kCFTypeDictionaryValueCallBacks);
   if (!props)
     return nullptr;
 
   int32_t bytesPerElem = 4;
-  CFNumberRef cfWidth = ::CFNumberCreate(NULL, kCFNumberSInt32Type, &aWidth);
-  CFNumberRef cfHeight = ::CFNumberCreate(NULL, kCFNumberSInt32Type, &aHeight);
-  CFNumberRef cfBytesPerElem = ::CFNumberCreate(NULL, kCFNumberSInt32Type, &bytesPerElem);
+  CFNumberRef cfWidth = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &aWidth);
+  CFNumberRef cfHeight = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &aHeight);
+  CFNumberRef cfBytesPerElem = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &bytesPerElem);
   ::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropWidth,
                                 cfWidth);
   ::CFRelease(cfWidth);
   ::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropHeight,
                                 cfHeight);
   ::CFRelease(cfHeight);
   ::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropBytesPerElem, 
                                 cfBytesPerElem);
@@ -377,21 +377,21 @@ size_t MacIOSurface::GetHeight() {
 }
 
 size_t MacIOSurface::GetBytesPerRow() { 
   return MacIOSurfaceLib::IOSurfaceGetBytesPerRow(mIOSurfacePtr);
 }
 
 #define READ_ONLY 0x1
 void MacIOSurface::Lock() {
-  MacIOSurfaceLib::IOSurfaceLock(mIOSurfacePtr, READ_ONLY, NULL);
+  MacIOSurfaceLib::IOSurfaceLock(mIOSurfacePtr, READ_ONLY, nullptr);
 }
 
 void MacIOSurface::Unlock() {
-  MacIOSurfaceLib::IOSurfaceUnlock(mIOSurfacePtr, READ_ONLY, NULL);
+  MacIOSurfaceLib::IOSurfaceUnlock(mIOSurfacePtr, READ_ONLY, nullptr);
 }
 
 #include "SourceSurfaceRawData.h"
 using mozilla::gfx::SourceSurface;
 using mozilla::gfx::SourceSurfaceRawData;
 using mozilla::gfx::IntSize;
 
 TemporaryRef<SourceSurface>
@@ -585,17 +585,17 @@ nsresult nsCARenderer::SetupRenderer(voi
       Destroy();
       return NS_ERROR_FAILURE;
     }
 
     CGColorSpaceRef colorSpace = CreateSystemColorSpace();
 
     mCGImage = ::CGImageCreate(aWidth, aHeight, 8, 32, aWidth * 4, colorSpace,
                 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
-                dataProvider, NULL, true, kCGRenderingIntentDefault);
+                dataProvider, nullptr, true, kCGRenderingIntentDefault);
 
     ::CGDataProviderRelease(dataProvider);
     if (colorSpace) {
       ::CGColorSpaceRelease(colorSpace);
     }
     if (!mCGImage) {
       mUnsupportedWidth = aWidth;
       mUnsupportedHeight = aHeight;
@@ -758,18 +758,18 @@ IOSurfaceID nsCARenderer::GetIOSurfaceID
 }
 
 nsresult nsCARenderer::Render(int aWidth, int aHeight, 
                               CGImageRef *aOutCGImage) {
   if (!aOutCGImage && !mIOSurface) {
     NS_ERROR("No target destination for rendering");
   } else if (aOutCGImage) {
     // We are expected to return a CGImageRef, we will set
-    // it to NULL in case we fail before the image is ready.
-    *aOutCGImage = NULL;
+    // it to nullptr in case we fail before the image is ready.
+    *aOutCGImage = nullptr;
   }
 
   if (aWidth == 0 || aHeight == 0)
     return NS_OK;
 
   if (!mCARenderer) {
     return NS_ERROR_FAILURE;
   }
@@ -808,17 +808,17 @@ nsresult nsCARenderer::Render(int aWidth
     return NS_ERROR_FAILURE;
   }
 
   ::glClearColor(0.0, 0.0, 0.0, 0.0);
   ::glClear(GL_COLOR_BUFFER_BIT);
 
   [CATransaction commit];
   double caTime = ::CACurrentMediaTime();
-  [caRenderer beginFrameAtTime:caTime timeStamp:NULL];
+  [caRenderer beginFrameAtTime:caTime timeStamp:nullptr];
   [caRenderer addUpdateRect:CGRectMake(0,0, aWidth, aHeight)];
   [caRenderer render];
   [caRenderer endFrame];
 
   // Read the data back either to the IOSurface or mCGImage.
   if (mIOSurface) {
     ::glFlush();
   } else {
@@ -862,25 +862,25 @@ nsresult nsCARenderer::DrawSurfaceToCGCo
       aY < 0 || aY >= ioHeight) {
     surf->Unlock();
     return NS_ERROR_FAILURE;
   }
 
   void* ioData = surf->GetBaseAddress();
   CGDataProviderRef dataProvider = ::CGDataProviderCreateWithData(ioData,
                                       ioData, ioHeight*(bytesPerRow)*4, 
-                                      NULL); //No release callback 
+                                      nullptr); //No release callback 
   if (!dataProvider) {
     surf->Unlock();
     return NS_ERROR_FAILURE;
   }
 
   CGImageRef cgImage = ::CGImageCreate(ioWidth, ioHeight, 8, 32, bytesPerRow,
               aColorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
-              dataProvider, NULL, true, kCGRenderingIntentDefault);
+              dataProvider, nullptr, true, kCGRenderingIntentDefault);
   ::CGDataProviderRelease(dataProvider);
   if (!cgImage) {
     surf->Unlock();
     return NS_ERROR_FAILURE;
   }
   CGImageRef subImage = ::CGImageCreateWithImageInRect(cgImage,
                                        ::CGRectMake(aX, aY, aWidth, aHeight));
   if (!subImage) {
@@ -920,50 +920,50 @@ int sSaveToDiskSequence = 0;
 void nsCARenderer::SaveToDisk(MacIOSurface *surf) {
   surf->Lock();
   size_t bytesPerRow = surf->GetBytesPerRow();
   size_t ioWidth = surf->GetWidth();
   size_t ioHeight = surf->GetHeight();
   void* ioData = surf->GetBaseAddress();
   CGDataProviderRef dataProvider = ::CGDataProviderCreateWithData(ioData,
                                       ioData, ioHeight*(bytesPerRow)*4, 
-                                      NULL); //No release callback 
+                                      nullptr); //No release callback 
   if (!dataProvider) {
     surf->Unlock();
     return;
   }
 
   CGColorSpaceRef colorSpace = CreateSystemColorSpace();
   CGImageRef cgImage = ::CGImageCreate(ioWidth, ioHeight, 8, 32, bytesPerRow,
               colorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
-              dataProvider, NULL, true, kCGRenderingIntentDefault);
+              dataProvider, nullptr, true, kCGRenderingIntentDefault);
   ::CGDataProviderRelease(dataProvider);
   ::CGColorSpaceRelease(colorSpace);
   if (!cgImage) {
     surf->Unlock();
     return;
   }
 
   char cstr[1000];
 
   sprintf(cstr, "file:///Users/benoitgirard/debug/iosurface_%i.png", ++sSaveToDiskSequence);
 
   CFStringRef cfStr = ::CFStringCreateWithCString(kCFAllocatorDefault, cstr, kCFStringEncodingMacRoman);
 
   printf("Exporting: %s\n", cstr);
-  CFURLRef url = ::CFURLCreateWithString( NULL, cfStr, NULL);
+  CFURLRef url = ::CFURLCreateWithString( nullptr, cfStr, nullptr);
   ::CFRelease(cfStr);
 
   CFStringRef type = kUTTypePNG;
   size_t count = 1;
-  CFDictionaryRef options = NULL;
+  CFDictionaryRef options = nullptr;
   CGImageDestinationRef dest = ::CGImageDestinationCreateWithURL(url, type, count, options);
   ::CFRelease(url);
 
-  ::CGImageDestinationAddImage(dest, cgImage, NULL);
+  ::CGImageDestinationAddImage(dest, cgImage, nullptr);
 
   ::CGImageDestinationFinalize(dest);
   ::CFRelease(dest);
   ::CGImageRelease(cgImage);
 
   surf->Unlock();
 
   return;
--- a/gfx/2d/ScaledFontBase.cpp
+++ b/gfx/2d/ScaledFontBase.cpp
@@ -32,20 +32,20 @@ ScaledFontBase::~ScaledFontBase()
   cairo_scaled_font_destroy(mScaledFont);
 #endif
 }
 
 ScaledFontBase::ScaledFontBase(Float aSize)
   : mSize(aSize)
 {
 #ifdef USE_SKIA
-  mTypeface = NULL;
+  mTypeface = nullptr;
 #endif
 #ifdef USE_CAIRO
-  mScaledFont = NULL;
+  mScaledFont = nullptr;
 #endif
 }
 
 TemporaryRef<Path>
 ScaledFontBase::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
 {
 #ifdef USE_SKIA
   if (aTarget->GetType() == BACKEND_SKIA) {
@@ -90,17 +90,17 @@ ScaledFontBase::GetPathForGlyphs(const G
       glyphs[i].y = aBuffer.mGlyphs[i].mPosition.y;
     }
 
     cairo_glyph_path(*context, &glyphs[0], aBuffer.mNumGlyphs);
 
     return builder->Finish();
   }
 #endif
-  return NULL;
+  return nullptr;
 }
 
 void
 ScaledFontBase::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder)
 {
   // XXX - implement me
   MOZ_ASSERT(false);
   return;
--- a/gfx/2d/ScaledFontDWrite.cpp
+++ b/gfx/2d/ScaledFontDWrite.cpp
@@ -13,17 +13,17 @@ namespace mozilla {
 namespace gfx {
 
 TemporaryRef<Path>
 ScaledFontDWrite::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
 {
   if (aTarget->GetType() != BACKEND_DIRECT2D) {
     // For now we only support Direct2D.
     gfxWarning() << "Attempt to use Direct Write font with non-Direct2D backend";
-    return NULL;
+    return nullptr;
   }
 
   RefPtr<PathBuilder> pathBuilder = aTarget->CreatePathBuilder();
 
   PathBuilderD2D *pathBuilderD2D =
     static_cast<PathBuilderD2D*>(pathBuilder.get());
 
   CopyGlyphsToSink(aBuffer, pathBuilderD2D->GetSink());
--- a/gfx/2d/ScaledFontMac.cpp
+++ b/gfx/2d/ScaledFontMac.cpp
@@ -33,17 +33,17 @@ ScaledFontMac::~ScaledFontMac()
 {
   CGFontRelease(mFont);
 }
 
 #ifdef USE_SKIA
 SkTypeface* ScaledFontMac::GetSkTypeface()
 {
   if (!mTypeface) {
-    CTFontRef fontFace = CTFontCreateWithGraphicsFont(mFont, mSize, NULL, NULL);
+    CTFontRef fontFace = CTFontCreateWithGraphicsFont(mFont, mSize, nullptr, nullptr);
     mTypeface = SkCreateTypefaceFromCTFont(fontFace);
     CFRelease(fontFace);
   }
   return mTypeface;
 }
 #endif
 
 // private API here are the public options on OS X
--- a/gfx/2d/SourceSurfaceCG.cpp
+++ b/gfx/2d/SourceSurfaceCG.cpp
@@ -48,19 +48,19 @@ static void releaseCallback(void *info, 
 
 bool
 SourceSurfaceCG::InitFromData(unsigned char *aData,
                                const IntSize &aSize,
                                int32_t aStride,
                                SurfaceFormat aFormat)
 {
   //XXX: we should avoid creating this colorspace everytime
-  CGColorSpaceRef colorSpace = NULL;
+  CGColorSpaceRef colorSpace = nullptr;
   CGBitmapInfo bitinfo = 0;
-  CGDataProviderRef dataProvider = NULL;
+  CGDataProviderRef dataProvider = nullptr;
   int bitsPerComponent = 0;
   int bitsPerPixel = 0;
 
   assert(aSize.width >= 0 && aSize.height >= 0);
 
   switch (aFormat) {
     case FORMAT_B8G8R8A8:
       colorSpace = CGColorSpaceCreateDeviceRGB();
@@ -105,25 +105,25 @@ SourceSurfaceCG::InitFromData(unsigned c
   } else {
     mImage = CGImageCreate (aSize.width, aSize.height,
 			    bitsPerComponent,
 			    bitsPerPixel,
 			    aStride,
 			    colorSpace,
 			    bitinfo,
 			    dataProvider,
-			    NULL,
+			    nullptr,
 			    true,
 			    kCGRenderingIntentDefault);
   }
 
   CGDataProviderRelease(dataProvider);
   CGColorSpaceRelease (colorSpace);
 
-  return mImage != NULL;
+  return mImage != nullptr;
 }
 
 DataSourceSurfaceCG::~DataSourceSurfaceCG()
 {
   CGImageRelease(mImage);
   free(CGBitmapContextGetData(mCg));
   CGContextRelease(mCg);
 }
@@ -139,19 +139,19 @@ DataSourceSurfaceCG::GetSize() const
 
 bool
 DataSourceSurfaceCG::InitFromData(unsigned char *aData,
                                const IntSize &aSize,
                                int32_t aStride,
                                SurfaceFormat aFormat)
 {
   //XXX: we should avoid creating this colorspace everytime
-  CGColorSpaceRef colorSpace = NULL;
+  CGColorSpaceRef colorSpace = nullptr;
   CGBitmapInfo bitinfo = 0;
-  CGDataProviderRef dataProvider = NULL;
+  CGDataProviderRef dataProvider = nullptr;
   int bitsPerComponent = 0;
   int bitsPerPixel = 0;
 
   switch (aFormat) {
     case FORMAT_B8G8R8A8:
       colorSpace = CGColorSpaceCreateDeviceRGB();
       bitinfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
       bitsPerComponent = 8;
@@ -194,17 +194,17 @@ DataSourceSurfaceCG::InitFromData(unsign
   } else {
     mImage = CGImageCreate (aSize.width, aSize.height,
 			    bitsPerComponent,
 			    bitsPerPixel,
 			    aStride,
 			    colorSpace,
 			    bitinfo,
 			    dataProvider,
-			    NULL,
+			    nullptr,
 			    true,
 			    kCGRenderingIntentDefault);
   }
 
   CGDataProviderRelease(dataProvider);
   CGColorSpaceRelease (colorSpace);
 
   return mImage;
@@ -220,20 +220,20 @@ CGContextRef CreateBitmapContextForImage
   int bitmapBytesPerRow = (width * 4);
   int bitmapByteCount   = (bitmapBytesPerRow * height);
 
   void *data = calloc(bitmapByteCount, 1);
   //XXX: which color space should we be using here?
   colorSpace = CGColorSpaceCreateDeviceRGB();
   assert(colorSpace);
 
-  // we'd like to pass NULL as the first parameter
+  // we'd like to pass nullptr as the first parameter
   // to let Quartz manage this memory for us. However,
   // on 10.5 and older CGBitmapContextGetData will return
-  // NULL instead of the associated buffer so we need
+  // nullptr instead of the associated buffer so we need
   // to manage it ourselves.
   CGContextRef cg = CGBitmapContextCreate(data,
                                           width,
                                           height,
                                           8,
                                           bitmapBytesPerRow,
                                           colorSpace,
                                           kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);
@@ -243,17 +243,17 @@ CGContextRef CreateBitmapContextForImage
 
   return cg;
 }
 
 DataSourceSurfaceCG::DataSourceSurfaceCG(CGImageRef aImage)
 {
   mImage = aImage;
   mCg = CreateBitmapContextForImage(aImage);
-  if (mCg == NULL) {
+  if (mCg == nullptr) {
     // error creating context
     return;
   }
 
   // Get image width, height. We'll use the entire image.
   CGFloat w = CGImageGetWidth(aImage);
   CGFloat h = CGImageGetHeight(aImage);
   CGRect rect = {{0,0},{w,h}};
@@ -290,45 +290,45 @@ SourceSurfaceCGBitmapContext::SourceSurf
   if (!mCg)
     abort();
 
   mSize.width = CGBitmapContextGetWidth(mCg);
   mSize.height = CGBitmapContextGetHeight(mCg);
   mStride = CGBitmapContextGetBytesPerRow(mCg);
   mData = CGBitmapContextGetData(mCg);
 
-  mImage = NULL;
+  mImage = nullptr;
 }
 
 void SourceSurfaceCGBitmapContext::EnsureImage() const
 {
   // Instead of using CGBitmapContextCreateImage we create
   // a CGImage around the data associated with the CGBitmapContext
   // we do this to avoid the vm_copy that CGBitmapContextCreateImage.
   // vm_copy tends to cause all sorts of unexpected performance problems
   // because of the mm tricks that vm_copy does. Using a regular
   // memcpy when the bitmap context is modified gives us more predictable
   // performance characteristics.
   if (!mImage) {
       //XXX: we should avoid creating this colorspace everytime
-      CGColorSpaceRef colorSpace = NULL;
+      CGColorSpaceRef colorSpace = nullptr;
       CGBitmapInfo bitinfo = 0;
-      CGDataProviderRef dataProvider = NULL;
+      CGDataProviderRef dataProvider = nullptr;
       int bitsPerComponent = 8;
       int bitsPerPixel = 32;
 
       colorSpace = CGColorSpaceCreateDeviceRGB();
       bitinfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
 
       void *info;
       if (mCg) {
           // if we have an mCg than it owns the data
           // and we don't want to tranfer ownership
           // to the CGDataProviderCreateWithData
-          info = NULL;
+          info = nullptr;
       } else {
           // otherwise we transfer ownership to
           // the dataProvider
           info = mData;
       }
 
       if (!mData) abort();
 
@@ -339,17 +339,17 @@ void SourceSurfaceCGBitmapContext::Ensur
 
       mImage = CGImageCreate (mSize.width, mSize.height,
                               bitsPerComponent,
                               bitsPerPixel,
                               mStride,
                               colorSpace,
                               bitinfo,
                               dataProvider,
-                              NULL,
+                              nullptr,
                               true,
                               kCGRenderingIntentDefault);
 
       CGDataProviderRelease(dataProvider);
       CGColorSpaceRelease (colorSpace);
   }
 }
 
@@ -373,20 +373,20 @@ SourceSurfaceCGBitmapContext::DrawTarget
     // copy out the data from the CGBitmapContext
     // we'll maintain ownership of mData until
     // we transfer it to mImage
     memcpy(mData, CGBitmapContextGetData(mCg), stride*height);
 
     // drop the current image for the data associated with the CGBitmapContext
     if (mImage)
       CGImageRelease(mImage);
-    mImage = NULL;
+    mImage = nullptr;
 
-    mCg = NULL;
-    mDrawTarget = NULL;
+    mCg = nullptr;
+    mDrawTarget = nullptr;
   }
 }
 
 SourceSurfaceCGBitmapContext::~SourceSurfaceCGBitmapContext()
 {
   if (!mImage && !mCg) {
     // neither mImage or mCg owns the data
     free(mData);
@@ -401,17 +401,17 @@ SourceSurfaceCGIOSurfaceContext::SourceS
 
   RefPtr<MacIOSurface> surf = MacIOSurface::IOSurfaceContextGetSurface(cg);
 
   mSize.width = surf->GetWidth();
   mSize.height = surf->GetHeight();
 
   // TODO use CreateImageFromIOSurfaceContext instead of reading back the surface
   //mImage = MacIOSurface::CreateImageFromIOSurfaceContext(cg);
-  mImage = NULL;
+  mImage = nullptr;
 
   aDrawTarget->Flush();
   surf->Lock();
   size_t bytesPerRow = surf->GetBytesPerRow();
   size_t ioHeight = surf->GetHeight();
   void* ioData = surf->GetBaseAddress();
   // XXX If the width is much less then the stride maybe
   //     we should repack the image?
@@ -429,19 +429,19 @@ void SourceSurfaceCGIOSurfaceContext::En
   // a CGImage around the data associated with the CGBitmapContext
   // we do this to avoid the vm_copy that CGBitmapContextCreateImage.
   // vm_copy tends to cause all sorts of unexpected performance problems
   // because of the mm tricks that vm_copy does. Using a regular
   // memcpy when the bitmap context is modified gives us more predictable
   // performance characteristics.
   if (!mImage) {
       //XXX: we should avoid creating this colorspace everytime
-      CGColorSpaceRef colorSpace = NULL;
+      CGColorSpaceRef colorSpace = nullptr;
       CGBitmapInfo bitinfo = 0;
-      CGDataProviderRef dataProvider = NULL;
+      CGDataProviderRef dataProvider = nullptr;
       int bitsPerComponent = 8;
       int bitsPerPixel = 32;
 
       colorSpace = CGColorSpaceCreateDeviceRGB();
       bitinfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
 
       void *info = mData;
 
@@ -452,17 +452,17 @@ void SourceSurfaceCGIOSurfaceContext::En
 
       mImage = CGImageCreate (mSize.width, mSize.height,
                               bitsPerComponent,
                               bitsPerPixel,
                               mStride,
                               colorSpace,
                               bitinfo,
                               dataProvider,
-                              NULL,
+                              nullptr,
                               true,
                               kCGRenderingIntentDefault);
 
       CGDataProviderRelease(dataProvider);
       CGColorSpaceRelease (colorSpace);
   }
 
 }
--- a/gfx/2d/SourceSurfaceCairo.cpp
+++ b/gfx/2d/SourceSurfaceCairo.cpp
@@ -26,17 +26,17 @@ CairoFormatToSurfaceFormat(cairo_format_
     default:
       return FORMAT_B8G8R8A8;
   }
 }
 
 SourceSurfaceCairo::SourceSurfaceCairo(cairo_surface_t* aSurface,
                                        const IntSize& aSize,
                                        const SurfaceFormat& aFormat,
-                                       DrawTargetCairo* aDrawTarget /* = NULL */)
+                                       DrawTargetCairo* aDrawTarget /* = nullptr */)
  : mSize(aSize)
  , mFormat(aFormat)
  , mSurface(aSurface)
  , mDrawTarget(aDrawTarget)
 {
   cairo_surface_reference(mSurface);
 }
 
@@ -87,17 +87,17 @@ SourceSurfaceCairo::GetSurface() const
 {
   return mSurface;
 }
 
 void
 SourceSurfaceCairo::DrawTargetWillChange()
 {
   if (mDrawTarget) {
-    mDrawTarget = NULL;
+    mDrawTarget = nullptr;
 
     // We're about to lose our version of the surface, so make a copy of it.
     cairo_surface_t* surface = cairo_surface_create_similar(mSurface,
                                                             GfxFormatToCairoContent(mFormat),
                                                             mSize.width, mSize.height);
     cairo_t* ctx = cairo_create(surface);
     cairo_pattern_t* pat = cairo_pattern_create_for_surface(mSurface);
     cairo_set_source(ctx, pat);
@@ -111,17 +111,17 @@ SourceSurfaceCairo::DrawTargetWillChange
   }
 }
 
 void
 SourceSurfaceCairo::MarkIndependent()
 {
   if (mDrawTarget) {
     mDrawTarget->RemoveSnapshot(this);
-    mDrawTarget = NULL;
+    mDrawTarget = nullptr;
   }
 }
 
 DataSourceSurfaceCairo::DataSourceSurfaceCairo(cairo_surface_t* imageSurf)
  : mImageSurface(imageSurf)
 {
   cairo_surface_reference(mImageSurface);
 }
--- a/gfx/2d/SourceSurfaceCairo.h
+++ b/gfx/2d/SourceSurfaceCairo.h
@@ -13,22 +13,22 @@ namespace gfx {
 
 class DrawTargetCairo;
 
 class SourceSurfaceCairo : public SourceSurface
 {
 public:
   // Create a SourceSurfaceCairo. The surface will not be copied, but simply
   // referenced.
-  // If aDrawTarget is non-NULL, it is assumed that this is a snapshot source
+  // If aDrawTarget is non-nullptr, it is assumed that this is a snapshot source
   // surface, and we'll call DrawTargetCairo::RemoveSnapshot(this) on it when
   // we're destroyed.
   SourceSurfaceCairo(cairo_surface_t* aSurface, const IntSize& aSize,
                      const SurfaceFormat& aFormat,
-                     DrawTargetCairo* aDrawTarget = NULL);
+                     DrawTargetCairo* aDrawTarget = nullptr);
   virtual ~SourceSurfaceCairo();
 
   virtual SurfaceType GetType() const { return SURFACE_CAIRO; }
   virtual IntSize GetSize() const;
   virtual SurfaceFormat GetFormat() const;
   virtual TemporaryRef<DataSourceSurface> GetDataSurface();
 
   cairo_surface_t* GetSurface() const;
--- a/gfx/2d/SourceSurfaceD2D.cpp
+++ b/gfx/2d/SourceSurfaceD2D.cpp
@@ -38,17 +38,17 @@ bool
 SourceSurfaceD2D::IsValid() const
 {
   return mDevice == Factory::GetDirect3D10Device();
 }
 
 TemporaryRef<DataSourceSurface>
 SourceSurfaceD2D::GetDataSurface()
 {
-  return NULL;
+  return nullptr;
 }
 
 bool
 SourceSurfaceD2D::InitFromData(unsigned char *aData,
                                const IntSize &aSize,
                                int32_t aStride,
                                SurfaceFormat aFormat,
                                ID2D1RenderTarget *aRT)
--- a/gfx/2d/SourceSurfaceD2DTarget.cpp
+++ b/gfx/2d/SourceSurfaceD2DTarget.cpp
@@ -59,35 +59,35 @@ SourceSurfaceD2DTarget::GetDataSurface()
   D3D10_TEXTURE2D_DESC desc;
   mTexture->GetDesc(&desc);
 
   desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
   desc.Usage = D3D10_USAGE_STAGING;
   desc.BindFlags = 0;
   desc.MiscFlags = 0;
 
-  HRESULT hr = Factory::GetDirect3D10Device()->CreateTexture2D(&desc, NULL, byRef(dataSurf->mTexture));
+  HRESULT hr = Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, byRef(dataSurf->mTexture));
 
   if (FAILED(hr)) {
     gfxDebug() << "Failed to create staging texture for SourceSurface. Code: " << hr;
-    return NULL;
+    return nullptr;
   }
   Factory::GetDirect3D10Device()->CopyResource(dataSurf->mTexture, mTexture);
 
   return dataSurf;
 }
 
 ID3D10ShaderResourceView*
 SourceSurfaceD2DTarget::GetSRView()
 {
   if (mSRView) {
     return mSRView;
   }
 
-  HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, NULL, byRef(mSRView));
+  HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, nullptr, byRef(mSRView));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create ShaderResourceView. Code: " << hr;
   }
 
   return mSRView;
 }
 
@@ -95,20 +95,20 @@ void
 SourceSurfaceD2DTarget::DrawTargetWillChange()
 {
   RefPtr<ID3D10Texture2D> oldTexture = mTexture;
 
   D3D10_TEXTURE2D_DESC desc;
   mTexture->GetDesc(&desc);
 
   // Get a copy of the surface data so the content at snapshot time was saved.
-  Factory::GetDirect3D10Device()->CreateTexture2D(&desc, NULL, byRef(mTexture));
+  Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, byRef(mTexture));
   Factory::GetDirect3D10Device()->CopyResource(mTexture, oldTexture);
 
-  mBitmap = NULL;
+  mBitmap = nullptr;
 
   DrawTargetD2D::mVRAMUsageSS += desc.Width * desc.Height * BytesPerPixel(mFormat);
   mOwnsCopy = true;
 
   // We now no longer depend on the source surface content remaining the same.
   MarkIndependent();
 }
 
@@ -125,17 +125,17 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1R
 
   IntSize size(desc.Width, desc.Height);
   
   RefPtr<IDXGISurface> surf;
   hr = mTexture->QueryInterface((IDXGISurface**)byRef(surf));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to query interface texture to DXGISurface. Code: " << hr;
-    return NULL;
+    return nullptr;
   }
 
   D2D1_BITMAP_PROPERTIES props =
     D2D1::BitmapProperties(D2D1::PixelFormat(DXGIFormat(mFormat), AlphaMode(mFormat)));
   hr = aRT->CreateSharedBitmap(IID_IDXGISurface, surf, &props, byRef(mBitmap));
 
   if (FAILED(hr)) {
     // This seems to happen for FORMAT_A8 sometimes...
@@ -155,43 +155,43 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1R
       // surface the only way we can get to a bitmap is by creating a
       // a rendertarget and from there copying to a bitmap! Terrible!
       RefPtr<IDXGISurface> surface;
 
       hr = mTexture->QueryInterface((IDXGISurface**)byRef(surface));
 
       if (FAILED(hr)) {
         gfxWarning() << "Failed to QI texture to surface.";
-        return NULL;
+        return nullptr;
       }
 
       D2D1_RENDER_TARGET_PROPERTIES props =
         D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(DXGIFormat(mFormat), AlphaMode(mFormat)));
       hr = DrawTargetD2D::factory()->CreateDxgiSurfaceRenderTarget(surface, props, byRef(rt));
 
       if (FAILED(hr)) {
         gfxWarning() << "Failed to create D2D render target for texture.";
-        return NULL;
+        return nullptr;
       }
     }
 
-    mBitmap->CopyFromRenderTarget(NULL, rt, NULL);
+    mBitmap->CopyFromRenderTarget(nullptr, rt, nullptr);
     return mBitmap;
   }
 
   return mBitmap;
 }
 
 void
 SourceSurfaceD2DTarget::MarkIndependent()
 {
   if (mDrawTarget) {
     MOZ_ASSERT(mDrawTarget->mSnapshot == this);
-    mDrawTarget->mSnapshot = NULL;
-    mDrawTarget = NULL;
+    mDrawTarget->mSnapshot = nullptr;
+    mDrawTarget = nullptr;
   }
 }
 
 DataSourceSurfaceD2DTarget::DataSourceSurfaceD2DTarget()
   : mFormat(FORMAT_B8G8R8A8)
   , mMapped(false)
 {
 }
--- a/gfx/2d/SourceSurfaceDual.h
+++ b/gfx/2d/SourceSurfaceDual.h
@@ -22,17 +22,17 @@ public:
     , mB(aDTB->Snapshot())
   { }
 
   virtual SurfaceType GetType() const { return SURFACE_DUAL_DT; }
   virtual IntSize GetSize() const { return mA->GetSize(); }
   virtual SurfaceFormat GetFormat() const { return mA->GetFormat(); }
 
   /* Readback from this surface type is not supported! */
-  virtual TemporaryRef<DataSourceSurface> GetDataSurface() { return NULL; }
+  virtual TemporaryRef<DataSourceSurface> GetDataSurface() { return nullptr; }
 private:
   friend class DualSurface;
   friend class DualPattern;
 
   RefPtr<SourceSurface> mA;
   RefPtr<SourceSurface> mB;
 };
 
--- a/gfx/2d/SourceSurfaceSkia.cpp
+++ b/gfx/2d/SourceSurfaceSkia.cpp
@@ -10,17 +10,17 @@
 #include "skia/SkDevice.h"
 #include "HelpersSkia.h"
 #include "DrawTargetSkia.h"
 
 namespace mozilla {
 namespace gfx {
 
 SourceSurfaceSkia::SourceSurfaceSkia()
-  : mDrawTarget(NULL)
+  : mDrawTarget(nullptr)
 {
 }
 
 SourceSurfaceSkia::~SourceSurfaceSkia()
 {
   MarkIndependent();
 }
 
@@ -85,32 +85,32 @@ SourceSurfaceSkia::GetData()
   return pixels;
 
 }
 
 void
 SourceSurfaceSkia::DrawTargetWillChange()
 {
   if (mDrawTarget) {
-    mDrawTarget = NULL;
+    mDrawTarget = nullptr;
     SkBitmap temp = mBitmap;
     mBitmap.reset();
     temp.copyTo(&mBitmap, temp.getConfig());
   }
 }
 
 void
 SourceSurfaceSkia::DrawTargetDestroyed()
 {
-  mDrawTarget = NULL;
+  mDrawTarget = nullptr;
 }
 
 void
 SourceSurfaceSkia::MarkIndependent()
 {
   if (mDrawTarget) {
     mDrawTarget->RemoveSnapshot(this);
-    mDrawTarget = NULL;
+    mDrawTarget = nullptr;
   }
 }
 
 }
 }
--- a/gfx/2d/SourceSurfaceSkia.h
+++ b/gfx/2d/SourceSurfaceSkia.h
@@ -29,17 +29,17 @@ public:
   SkBitmap& GetBitmap() { return mBitmap; }
 
   bool InitFromData(unsigned char* aData,
                     const IntSize &aSize,
                     int32_t aStride,
                     SurfaceFormat aFormat);
 
   /**
-   * If aOwner is NULL, we make a copy of the pixel data in the bitmap, 
+   * If aOwner is nullptr, we make a copy of the pixel data in the bitmap, 
    * otherwise we just reference this data until DrawTargetWillChange is called.
    */
   bool InitWithBitmap(const SkBitmap& aBitmap,
                       SurfaceFormat aFormat,
                       DrawTargetSkia* aOwner);
 
 
   virtual unsigned char *GetData();
--- a/gfx/2d/UserData.h
+++ b/gfx/2d/UserData.h
@@ -17,17 +17,17 @@ struct UserDataKey {
   int unused;
 };
 
 /* this class is basically a clone of the user data concept from cairo */
 class UserData
 {
   typedef void (*destroyFunc)(void *data);
 public:
-  UserData() : count(0), entries(NULL) {}
+  UserData() : count(0), entries(nullptr) {}
 
   /* Attaches untyped userData associated with key. destroy is called on destruction */
   void Add(UserDataKey *key, void *userData, destroyFunc destroy)
   {
     for (int i=0; i<count; i++) {
       if (key == entries[i].key) {
         if (entries[i].destroy) {
           entries[i].destroy(entries[i].userData);
@@ -64,28 +64,28 @@ public:
         // decrement before looping so entries[i+1] doesn't read past the end:
         --count;
         for (;i<count; i++) {
           entries[i] = entries[i+1];
         }
         return userData;
       }
     }
-    return NULL;
+    return nullptr;
   }
 
   /* Retrives the userData for the associated key */
   void *Get(UserDataKey *key)
   {
     for (int i=0; i<count; i++) {
       if (key == entries[i].key) {
         return entries[i].userData;
       }
     }
-    return NULL;
+    return nullptr;
   }
 
   bool Has(UserDataKey *key)
   {
     for (int i=0; i<count; i++) {
       if (key == entries[i].key) {
         return true;
       }
@@ -96,17 +96,17 @@ public:
   void Destroy()
   {
     for (int i=0; i<count; i++) {
       if (entries[i].destroy) {
         entries[i].destroy(entries[i].userData);
       }
     }
     free(entries);
-    entries = NULL;
+    entries = nullptr;
     count = 0;
   }
 
   ~UserData()
   {
     Destroy();
   }
 
--- a/gfx/2d/unittest/TestDrawTargetD2D.cpp
+++ b/gfx/2d/unittest/TestDrawTargetD2D.cpp
@@ -3,19 +3,19 @@
  * 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 "TestDrawTargetD2D.h"
 
 using namespace mozilla::gfx;
 TestDrawTargetD2D::TestDrawTargetD2D()
 {
-  ::D3D10CreateDevice1(NULL,
+  ::D3D10CreateDevice1(nullptr,
                        D3D10_DRIVER_TYPE_HARDWARE,
-                       NULL,
+                       nullptr,
                        D3D10_CREATE_DEVICE_BGRA_SUPPORT |
                        D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
                        D3D10_FEATURE_LEVEL_10_0,
                        D3D10_1_SDK_VERSION,
                        byRef(mDevice));
 
   Factory::SetDirect3D10Device(mDevice);
 
--- a/gfx/2d/unittest/TestDrawTargetD2D.h
+++ b/gfx/2d/unittest/TestDrawTargetD2D.h
@@ -11,9 +11,9 @@
 
 class TestDrawTargetD2D : public TestDrawTargetBase
 {
 public:
   TestDrawTargetD2D();
 
 private:
   mozilla::RefPtr<ID3D10Device1> mDevice;
-};
\ No newline at end of file
+};