Bug 784739 - Switch from NULL to nullptr in gfx/thebes/; r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Wed, 31 Jul 2013 11:44:31 -0400
changeset 153068 ac758cadd0341af4ea6a8e9763cf6b668a677734
parent 153067 5172d6907d409cc1c95b4a20a3c9b875284a7482
child 153069 417f4d51eba24f710542bdb1f540dc656e57710b
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs784739
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 784739 - Switch from NULL to nullptr in gfx/thebes/; r=ehsan
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxAndroidPlatform.cpp
gfx/thebes/gfxBlur.h
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxContext.h
gfx/thebes/gfxCoreTextShaper.cpp
gfx/thebes/gfxCoreTextShaper.h
gfx/thebes/gfxD2DSurface.cpp
gfx/thebes/gfxDWriteCommon.cpp
gfx/thebes/gfxDWriteFontList.cpp
gfx/thebes/gfxDWriteFontList.h
gfx/thebes/gfxDWriteFonts.cpp
gfx/thebes/gfxDWriteShaper.cpp
gfx/thebes/gfxDWriteTextAnalysis.cpp
gfx/thebes/gfxFT2FontBase.cpp
gfx/thebes/gfxFT2FontList.cpp
gfx/thebes/gfxFT2FontList.h
gfx/thebes/gfxFT2Fonts.cpp
gfx/thebes/gfxFT2Utils.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxFontconfigUtils.cpp
gfx/thebes/gfxFontconfigUtils.h
gfx/thebes/gfxGDIFont.cpp
gfx/thebes/gfxGDIFontList.cpp
gfx/thebes/gfxGDIFontList.h
gfx/thebes/gfxGDIShaper.cpp
gfx/thebes/gfxGdkNativeRenderer.cpp
gfx/thebes/gfxImageSurface.cpp
gfx/thebes/gfxMacFont.cpp
gfx/thebes/gfxOS2Fonts.cpp
gfx/thebes/gfxOS2Surface.cpp
gfx/thebes/gfxPangoFonts.cpp
gfx/thebes/gfxPangoFonts.h
gfx/thebes/gfxPattern.cpp
gfx/thebes/gfxPattern.h
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformMac.cpp
gfx/thebes/gfxQtNativeRenderer.cpp
gfx/thebes/gfxQtPlatform.cpp
gfx/thebes/gfxQuartzImageSurface.cpp
gfx/thebes/gfxQuartzSurface.cpp
gfx/thebes/gfxUniscribeShaper.cpp
gfx/thebes/gfxUniscribeShaper.h
gfx/thebes/gfxUserFontSet.cpp
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxWindowsNativeDrawing.cpp
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
gfx/thebes/gfxWindowsSurface.cpp
gfx/thebes/gfxWindowsSurface.h
gfx/thebes/gfxXlibNativeRenderer.cpp
gfx/thebes/gfxXlibSurface.cpp
gfx/thebes/nsSurfaceTexture.cpp
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -108,17 +108,17 @@ gfxASurface::SurfaceDestroyFunc(void *da
     // fprintf (stderr, "Deleting wrapper for %p (wrapper: %p)\n", surf->mSurface, data);
     delete surf;
 }
 
 gfxASurface*
 gfxASurface::GetSurfaceWrapper(cairo_surface_t *csurf)
 {
     if (!csurf)
-        return NULL;
+        return nullptr;
     return (gfxASurface*) cairo_surface_get_user_data(csurf, &gfxasurface_pointer_key);
 }
 
 void
 gfxASurface::SetSurfaceWrapper(cairo_surface_t *csurf, gfxASurface *asurf)
 {
     if (!csurf)
         return;
@@ -276,17 +276,17 @@ gfxASurface::SetData(const cairo_user_da
         return;
     cairo_surface_set_user_data(mSurface, key, user_data, destroy);
 }
 
 void *
 gfxASurface::GetData(const cairo_user_data_key_t *key)
 {
     if (!mSurfaceValid)
-        return NULL;
+        return nullptr;
     return cairo_surface_get_user_data(mSurface, key);
 }
 
 void
 gfxASurface::Finish()
 {
     // null surfaces are allowed here
     cairo_surface_finish(mSurface);
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -22,17 +22,17 @@
 #include "ft2build.h"
 #include FT_FREETYPE_H
 #include FT_MODULE_H
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
-static FT_Library gPlatformFTLibrary = NULL;
+static FT_Library gPlatformFTLibrary = nullptr;
 
 static int64_t sFreetypeMemoryUsed;
 static FT_MemoryRec_ sFreetypeMemoryRecord;
 
 static int64_t
 GetFreetypeSize()
 {
     return sFreetypeMemoryUsed;
@@ -109,17 +109,17 @@ gfxAndroidPlatform::gfxAndroidPlatform()
 
 }
 
 gfxAndroidPlatform::~gfxAndroidPlatform()
 {
     cairo_debug_reset_static_data();
 
     FT_Done_Library(gPlatformFTLibrary);
-    gPlatformFTLibrary = NULL;
+    gPlatformFTLibrary = nullptr;
 }
 
 already_AddRefed<gfxASurface>
 gfxAndroidPlatform::CreateOffscreenSurface(const gfxIntSize& size,
                                       gfxASurface::gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> newSurface;
     newSurface = new gfxImageSurface(size, OptimalFormatForContent(contentType));
--- a/gfx/thebes/gfxBlur.h
+++ b/gfx/thebes/gfxBlur.h
@@ -47,22 +47,23 @@ public:
      * @param aRect The coordinates of the surface to create in device units.
      *
      * @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.
+     * @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 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.
+     * @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 nullptr here.
      */
     gfxContext* Init(const gfxRect& aRect,
                      const gfxIntSize& aSpreadRadius,
                      const gfxIntSize& aBlurRadius,
                      const gfxRect* aDirtyRect,
                      const gfxRect* aSkipRect);
 
     /**
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -31,17 +31,17 @@ using namespace mozilla;
 using namespace mozilla::gfx;
 
 /* This class lives on the stack and allows gfxContext users to easily, and
  * performantly get a gfx::Pattern to use for drawing in their current context.
  */
 class GeneralPattern
 {
 public:    
-  GeneralPattern(gfxContext *aContext) : mContext(aContext), mPattern(NULL) {}
+  GeneralPattern(gfxContext *aContext) : mContext(aContext), mPattern(nullptr) {}
   ~GeneralPattern() { if (mPattern) { mPattern->~Pattern(); } }
 
   operator mozilla::gfx::Pattern&()
   {
     gfxContext::AzureState &state = mContext->CurrentState();
 
     if (state.pattern) {
       return *state.pattern->GetPattern(mContext->mDT, state.patternTransformChanged ? &state.patternTransform : nullptr);
@@ -71,17 +71,17 @@ private:
     mozilla::AlignedStorage2<mozilla::gfx::SurfacePattern> mSurfacePattern;
   };
 
   gfxContext *mContext;
   Pattern *mPattern;
 };
 
 gfxContext::gfxContext(gfxASurface *surface)
-  : mRefCairo(NULL)
+  : mRefCairo(nullptr)
   , mSurface(surface)
 {
   MOZ_COUNT_CTOR(gfxContext);
 
   mCairo = cairo_create(surface->CairoSurface());
   mFlags = surface->GetDefaultContextFlags();
   if (mSurface->GetRotateForLandscape()) {
     // Rotate page 90 degrees to draw landscape page on portrait paper
@@ -92,19 +92,19 @@ gfxContext::gfxContext(gfxASurface *surf
                       0,  0);
     Multiply(matrix);
   }
 }
 
 gfxContext::gfxContext(DrawTarget *aTarget)
   : mPathIsRect(false)
   , mTransformChanged(false)
-  , mCairo(NULL)
-  , mRefCairo(NULL)
-  , mSurface(NULL)
+  , mCairo(nullptr)
+  , mRefCairo(nullptr)
+  , mSurface(nullptr)
   , mFlags(0)
   , mDT(aTarget)
   , mOriginalDT(aTarget)
 {
   MOZ_COUNT_CTOR(gfxContext);
 
   mStateStack.SetLength(1);
   CurrentState().drawTarget = mDT;
@@ -219,18 +219,18 @@ gfxContext::Restore()
 
 // drawing
 void
 gfxContext::NewPath()
 {
   if (mCairo) {
     cairo_new_path(mCairo);
   } else {
-    mPath = NULL;
-    mPathBuilder = NULL;
+    mPath = nullptr;
+    mPathBuilder = nullptr;
     mPathIsRect = false;
     mTransformChanged = false;
   }
 }
 
 void
 gfxContext::ClosePath()
 {
@@ -929,17 +929,18 @@ gfxContext::SetDash(gfxFloat *dashes, in
     AzureState &state = CurrentState();
 
     state.dashPattern.SetLength(ndash);
     for (int i = 0; i < ndash; i++) {
       state.dashPattern[i] = Float(dashes[i]);
     }
     state.strokeOptions.mDashLength = ndash;
     state.strokeOptions.mDashOffset = Float(offset);
-    state.strokeOptions.mDashPattern = ndash ? state.dashPattern.Elements() : NULL;
+    state.strokeOptions.mDashPattern = ndash ? state.dashPattern.Elements()
+                                             : nullptr;
   }
 }
 
 bool
 gfxContext::CurrentDash(FallibleTArray<gfxFloat>& dashes, gfxFloat* offset) const
 {
   if (mCairo) {
     int count = cairo_get_dash_count(mCairo);
@@ -969,17 +970,17 @@ gfxContext::CurrentDash(FallibleTArray<g
 gfxFloat
 gfxContext::CurrentDashOffset() const
 {
   if (mCairo) {
     if (cairo_get_dash_count(mCairo) <= 0) {
         return 0.0;
     }
     gfxFloat offset;
-    cairo_get_dash(mCairo, NULL, &offset);
+    cairo_get_dash(mCairo, nullptr, &offset);
     return offset;
   } else {
     return CurrentState().strokeOptions.mDashOffset;
   }
 }
 
 void
 gfxContext::SetLineWidth(gfxFloat width)
@@ -1117,33 +1118,33 @@ gfxContext::CurrentFillRule() const
 void
 gfxContext::Clip(const gfxRect& rect)
 {
   if (mCairo) {
     cairo_new_path(mCairo);
     cairo_rectangle(mCairo, rect.X(), rect.Y(), rect.Width(), rect.Height());
     cairo_clip(mCairo);
   } else {
-    AzureState::PushedClip clip = { NULL, ToRect(rect), mTransform };
+    AzureState::PushedClip clip = { nullptr, ToRect(rect), mTransform };
     CurrentState().pushedClips.AppendElement(clip);
     mDT->PushClipRect(ToRect(rect));
     NewPath();
   }
 }
 
 void
 gfxContext::Clip()
 {
   if (mCairo) {
     cairo_clip_preserve(mCairo);
   } else {
     if (mPathIsRect) {
       MOZ_ASSERT(!mTransformChanged);
 
-      AzureState::PushedClip clip = { NULL, mRect, mTransform };
+      AzureState::PushedClip clip = { nullptr, mRect, mTransform };
       CurrentState().pushedClips.AppendElement(clip);
       mDT->PushClipRect(mRect);
     } else {
       EnsurePath();
       mDT->PushClip(mPath);
       AzureState::PushedClip clip = { mPath, Rect(), mTransform };
       CurrentState().pushedClips.AppendElement(clip);
     }
@@ -1274,19 +1275,19 @@ gfxContext::SetColor(const gfxRGBA& c)
 
         // Use the original alpha to avoid unnecessary float->byte->float
         // conversion errors
         cairo_set_source_rgba(mCairo, cms.r, cms.g, cms.b, c.a);
     }
     else
         cairo_set_source_rgba(mCairo, c.r, c.g, c.b, c.a);
   } else {
-    CurrentState().pattern = NULL;
-    CurrentState().sourceSurfCairo = NULL;
-    CurrentState().sourceSurface = NULL;
+    CurrentState().pattern = nullptr;
+    CurrentState().sourceSurfCairo = nullptr;
+    CurrentState().sourceSurface = nullptr;
 
     if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
 
         gfxRGBA cms;
         qcms_transform *transform = gfxPlatform::GetCMSRGBTransform();
         if (transform)
           gfxPlatform::TransformPixel(c, cms, transform);
 
@@ -1300,19 +1301,19 @@ gfxContext::SetColor(const gfxRGBA& c)
 }
 
 void
 gfxContext::SetDeviceColor(const gfxRGBA& c)
 {
   if (mCairo) {
     cairo_set_source_rgba(mCairo, c.r, c.g, c.b, c.a);
   } else {
-    CurrentState().pattern = NULL;
-    CurrentState().sourceSurfCairo = NULL;
-    CurrentState().sourceSurface = NULL;
+    CurrentState().pattern = nullptr;
+    CurrentState().sourceSurfCairo = nullptr;
+    CurrentState().sourceSurface = nullptr;
     CurrentState().color = ToColor(c);
   }
 }
 
 bool
 gfxContext::GetDeviceColor(gfxRGBA& c)
 {
   if (mCairo) {
@@ -1338,34 +1339,34 @@ gfxContext::GetDeviceColor(gfxRGBA& c)
 void
 gfxContext::SetSource(gfxASurface *surface, const gfxPoint& offset)
 {
   if (mCairo) {
     NS_ASSERTION(surface->GetAllowUseAsSource(), "Surface not allowed to be used as source!");
     cairo_set_source_surface(mCairo, surface->CairoSurface(), offset.x, offset.y);
   } else {
     CurrentState().surfTransform = Matrix(1.0f, 0, 0, 1.0f, Float(offset.x), Float(offset.y));
-    CurrentState().pattern = NULL;
+    CurrentState().pattern = nullptr;
     CurrentState().patternTransformChanged = false;
     // Keep the underlying cairo surface around while we keep the
     // sourceSurface.
     CurrentState().sourceSurfCairo = surface;
     CurrentState().sourceSurface =
       gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mDT, surface);
   }
 }
 
 void
 gfxContext::SetPattern(gfxPattern *pattern)
 {
   if (mCairo) {
     cairo_set_source(mCairo, pattern->CairoPattern());
   } else {
-    CurrentState().sourceSurfCairo = NULL;
-    CurrentState().sourceSurface = NULL;
+    CurrentState().sourceSurfCairo = nullptr;
+    CurrentState().sourceSurface = nullptr;
     CurrentState().patternTransformChanged = false;
     CurrentState().pattern = pattern;
   }
 }
 
 already_AddRefed<gfxPattern>
 gfxContext::GetPattern()
 {
@@ -1616,19 +1617,19 @@ void
 gfxContext::PopGroupToSource()
 {
   if (mCairo) {
     cairo_pop_group_to_source(mCairo);
   } else {
     RefPtr<SourceSurface> src = mDT->Snapshot();
     Point deviceOffset = CurrentState().deviceOffset;
     Restore();
-    CurrentState().sourceSurfCairo = NULL;
+    CurrentState().sourceSurfCairo = nullptr;
     CurrentState().sourceSurface = src;
-    CurrentState().pattern = NULL;
+    CurrentState().pattern = nullptr;
     CurrentState().patternTransformChanged = false;
 
     Matrix mat = mTransform;
     mat.Invert();
 
     Matrix deviceOffsetTranslation;
     deviceOffsetTranslation.Translate(deviceOffset.x, deviceOffset.y);
     CurrentState().surfTransform = deviceOffsetTranslation * mat;
@@ -1947,58 +1948,58 @@ gfxContext::CopyAsDataURL()
 }
 #endif
 
 void
 gfxContext::EnsurePath()
 {
   if (mPathBuilder) {
     mPath = mPathBuilder->Finish();
-    mPathBuilder = NULL;
+    mPathBuilder = nullptr;
   }
 
   if (mPath) {
     if (mTransformChanged) {
       Matrix mat = mTransform;
       mat.Invert();
       mat = mPathTransform * mat;
       mPathBuilder = mPath->TransformedCopyToBuilder(mat, CurrentState().fillRule);
       mPath = mPathBuilder->Finish();
-      mPathBuilder = NULL;
+      mPathBuilder = nullptr;
 
       mTransformChanged = false;
     }
 
     if (CurrentState().fillRule == mPath->GetFillRule()) {
       return;
     }
 
     mPathBuilder = mPath->CopyToBuilder(CurrentState().fillRule);
 
     mPath = mPathBuilder->Finish();
-    mPathBuilder = NULL;
+    mPathBuilder = nullptr;
     return;
   }
 
   EnsurePathBuilder();
   mPath = mPathBuilder->Finish();
-  mPathBuilder = NULL;
+  mPathBuilder = nullptr;
 }
 
 void
 gfxContext::EnsurePathBuilder()
 {
   if (mPathBuilder && !mTransformChanged) {
     return;
   }
 
   if (mPath) {
     if (!mTransformChanged) {
       mPathBuilder = mPath->CopyToBuilder(CurrentState().fillRule);
-      mPath = NULL;
+      mPath = nullptr;
     } else {
       Matrix invTransform = mTransform;
       invTransform.Invert();
       Matrix toNewUS = mPathTransform * invTransform;
       mPathBuilder = mPath->TransformedCopyToBuilder(toNewUS, CurrentState().fillRule);
     }
     return;
   }
@@ -2014,18 +2015,18 @@ gfxContext::EnsurePathBuilder()
       mPathBuilder->LineTo(mRect.BottomRight());
       mPathBuilder->LineTo(mRect.BottomLeft());
       mPathBuilder->Close();
     }
   }
 
   if (mTransformChanged) {
     // This could be an else if since this should never happen when
-    // mPathBuilder is NULL and mPath is NULL. But this way we can assert
-    // if all the state is as expected.
+    // mPathBuilder is nullptr and mPath is nullptr. But this way we can
+    // assert if all the state is as expected.
     MOZ_ASSERT(oldPath);
     MOZ_ASSERT(!mPathIsRect);
 
     Matrix invTransform = mTransform;
     invTransform.Invert();
     Matrix toNewUS = mPathTransform * invTransform;
 
     RefPtr<Path> path = mPathBuilder->Finish();
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -62,17 +62,17 @@ public:
     /**
      * Return the current transparency group target, if any, along
      * with its device offsets from the top.  If no group is
      * active, returns the surface the gfxContext was created with,
      * and 0,0 in dx,dy.
      */
     already_AddRefed<gfxASurface> CurrentSurface(gfxFloat *dx, gfxFloat *dy);
     already_AddRefed<gfxASurface> CurrentSurface() {
-        return CurrentSurface(NULL, NULL);
+        return CurrentSurface(nullptr, nullptr);
     }
 
     /**
      * Return the raw cairo_t object.
      * XXX this should go away at some point.
      */
     cairo_t *GetCairo();
 
@@ -448,17 +448,17 @@ public:
         gfxLineSolid,
         gfxLineDashed,
         gfxLineDotted
     } gfxLineType;
 
     void SetDash(gfxLineType ltype);
     void SetDash(gfxFloat *dashes, int ndash, gfxFloat offset);
     // Return true if dashing is set, false if it's not enabled or the
-    // context is in an error state.  |offset| can be NULL to mean
+    // context is in an error state.  |offset| can be nullptr to mean
     // "don't care".
     bool CurrentDash(FallibleTArray<gfxFloat>& dashes, gfxFloat* offset) const;
     // Returns 0.0 if dashing isn't enabled.
     gfxFloat CurrentDashOffset() const;
 
     /**
      * Sets the line width that's used for line drawing.
      */
--- a/gfx/thebes/gfxCoreTextShaper.cpp
+++ b/gfx/thebes/gfxCoreTextShaper.cpp
@@ -27,26 +27,26 @@
 #include "gfxUserFontSet.h"
 
 #include "nsUnicodeRange.h"
 #include <algorithm>
 
 using namespace mozilla;
 
 // standard font descriptors that we construct the first time they're needed
-CTFontDescriptorRef gfxCoreTextShaper::sDefaultFeaturesDescriptor = NULL;
-CTFontDescriptorRef gfxCoreTextShaper::sDisableLigaturesDescriptor = NULL;
+CTFontDescriptorRef gfxCoreTextShaper::sDefaultFeaturesDescriptor = nullptr;
+CTFontDescriptorRef gfxCoreTextShaper::sDisableLigaturesDescriptor = nullptr;
 
 gfxCoreTextShaper::gfxCoreTextShaper(gfxMacFont *aFont)
     : gfxFontShaper(aFont)
 {
     // Create our CTFontRef
     mCTFont = ::CTFontCreateWithGraphicsFont(aFont->GetCGFontRef(),
                                              aFont->GetAdjustedSize(),
-                                             NULL,
+                                             nullptr,
                                              GetDefaultFeaturesDescriptor());
 
     // Set up the default attribute dictionary that we will need each time we create a CFAttributedString
     mAttributesDict = ::CFDictionaryCreate(kCFAllocatorDefault,
                                            (const void**) &kCTFontAttributeName,
                                            (const void**) &mCTFont,
                                            1, // count of attributes
                                            &kCFTypeDictionaryKeyCallBacks,
@@ -209,19 +209,19 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxS
         stringRange.location - aStringOffset >= wordLength) {
         return NS_OK;
     }
 
     // retrieve the laid-out glyph data from the CTRun
     nsAutoArrayPtr<CGGlyph> glyphsArray;
     nsAutoArrayPtr<CGPoint> positionsArray;
     nsAutoArrayPtr<CFIndex> glyphToCharArray;
-    const CGGlyph* glyphs = NULL;
-    const CGPoint* positions = NULL;
-    const CFIndex* glyphToChar = NULL;
+    const CGGlyph* glyphs = nullptr;
+    const CGPoint* positions = nullptr;
+    const CFIndex* glyphToChar = nullptr;
 
     // Testing indicates that CTRunGetGlyphsPtr (almost?) always succeeds,
     // and so allocating a new array and copying data with CTRunGetGlyphs
     // will be extremely rare.
     // If this were not the case, we could use an nsAutoTArray<> to
     // try and avoid the heap allocation for small runs.
     // It's possible that some future change to CoreText will mean that
     // CTRunGetGlyphsPtr fails more often; if this happens, nsAutoTArray<>
@@ -255,17 +255,17 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxS
         if (!glyphToCharArray) {
             return NS_ERROR_OUT_OF_MEMORY;
         }
         ::CTRunGetStringIndices(aCTRun, ::CFRangeMake(0, 0), glyphToCharArray.get());
         glyphToChar = glyphToCharArray.get();
     }
 
     double runWidth = ::CTRunGetTypographicBounds(aCTRun, ::CFRangeMake(0, 0),
-                                                  NULL, NULL, NULL);
+                                                  nullptr, nullptr, nullptr);
 
     nsAutoTArray<gfxShapedText::DetailedGlyph,1> detailedGlyphs;
     gfxShapedText::CompressedGlyph g;
     gfxShapedText::CompressedGlyph *charGlyphs =
         aShapedText->GetCharacterGlyphs() + aOffset;
 
     // CoreText gives us the glyphindex-to-charindex mapping, which relates each glyph
     // to a source text character; we also need the charindex-to-glyphindex mapping to
@@ -508,17 +508,17 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxS
 }
 
 // Construct the font attribute descriptor that we'll apply by default when creating a CTFontRef.
 // This will turn off line-edge swashes by default, because we don't know the actual line breaks
 // when doing glyph shaping.
 void
 gfxCoreTextShaper::CreateDefaultFeaturesDescriptor()
 {
-    if (sDefaultFeaturesDescriptor != NULL) {
+    if (sDefaultFeaturesDescriptor != nullptr) {
         return;
     }
 
     SInt16 val = kSmartSwashType;
     CFNumberRef swashesType =
         ::CFNumberCreate(kCFAllocatorDefault,
                          kCFNumberSInt16Type,
                          &val);
@@ -581,17 +581,17 @@ gfxCoreTextShaper::CreateDefaultFeatures
         ::CTFontDescriptorCreateWithAttributes(attributesDict);
     ::CFRelease(attributesDict);
 }
 
 // Create a CTFontRef, with the Common Ligatures feature disabled
 CTFontRef
 gfxCoreTextShaper::CreateCTFontWithDisabledLigatures(CGFloat aSize)
 {
-    if (sDisableLigaturesDescriptor == NULL) {
+    if (sDisableLigaturesDescriptor == nullptr) {
         // initialize cached descriptor to turn off the Common Ligatures feature
         SInt16 val = kLigaturesType;
         CFNumberRef ligaturesType =
             ::CFNumberCreate(kCFAllocatorDefault,
                              kCFNumberSInt16Type,
                              &val);
         val = kCommonLigaturesOffSelector;
         CFNumberRef commonLigaturesOffSelector =
@@ -631,24 +631,24 @@ gfxCoreTextShaper::CreateCTFontWithDisab
 
         sDisableLigaturesDescriptor =
             ::CTFontDescriptorCreateCopyWithAttributes(GetDefaultFeaturesDescriptor(),
                                                        attributesDict);
         ::CFRelease(attributesDict);
     }
 
     gfxMacFont *f = static_cast<gfxMacFont*>(mFont);
-    return ::CTFontCreateWithGraphicsFont(f->GetCGFontRef(), aSize, NULL,
+    return ::CTFontCreateWithGraphicsFont(f->GetCGFontRef(), aSize, nullptr,
                                           sDisableLigaturesDescriptor);
 }
 
 void
 gfxCoreTextShaper::Shutdown() // [static]
 {
-    if (sDisableLigaturesDescriptor != NULL) {
+    if (sDisableLigaturesDescriptor != nullptr) {
         ::CFRelease(sDisableLigaturesDescriptor);
-        sDisableLigaturesDescriptor = NULL;
+        sDisableLigaturesDescriptor = nullptr;
     }        
-    if (sDefaultFeaturesDescriptor != NULL) {
+    if (sDefaultFeaturesDescriptor != nullptr) {
         ::CFRelease(sDefaultFeaturesDescriptor);
-        sDefaultFeaturesDescriptor = NULL;
+        sDefaultFeaturesDescriptor = nullptr;
     }
 }
--- a/gfx/thebes/gfxCoreTextShaper.h
+++ b/gfx/thebes/gfxCoreTextShaper.h
@@ -42,17 +42,17 @@ protected:
                               CTRunRef       aCTRun,
                               int32_t        aStringOffset);
 
     CTFontRef CreateCTFontWithDisabledLigatures(CGFloat aSize);
 
     static void CreateDefaultFeaturesDescriptor();
 
     static CTFontDescriptorRef GetDefaultFeaturesDescriptor() {
-        if (sDefaultFeaturesDescriptor == NULL) {
+        if (sDefaultFeaturesDescriptor == nullptr) {
             CreateDefaultFeaturesDescriptor();
         }
         return sDefaultFeaturesDescriptor;
     }
 
     // cached font descriptor, created the first time it's needed
     static CTFontDescriptorRef    sDefaultFeaturesDescriptor;
 
--- a/gfx/thebes/gfxD2DSurface.cpp
+++ b/gfx/thebes/gfxD2DSurface.cpp
@@ -78,17 +78,17 @@ gfxD2DSurface::GetDC(bool aRetainContent
 {
     return cairo_d2d_get_dc(CairoSurface(), aRetainContents);
 }
 
 void
 gfxD2DSurface::ReleaseDC(const nsIntRect *aUpdatedRect)
 {
     if (!aUpdatedRect) {
-        return cairo_d2d_release_dc(CairoSurface(), NULL);
+        return cairo_d2d_release_dc(CairoSurface(), nullptr);
     }
 
     cairo_rectangle_int_t rect;
     rect.x = aUpdatedRect->x;
     rect.y = aUpdatedRect->y;
     rect.width = aUpdatedRect->width;
     rect.height = aUpdatedRect->height;
     cairo_d2d_release_dc(CairoSurface(), &rect);
--- a/gfx/thebes/gfxDWriteCommon.cpp
+++ b/gfx/thebes/gfxDWriteCommon.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gfxDWriteCommon.h"
 
-IDWriteFontFileLoader* gfxDWriteFontFileLoader::mInstance = NULL;
+IDWriteFontFileLoader* gfxDWriteFontFileLoader::mInstance = nullptr;
 
 HRESULT STDMETHODCALLTYPE
 gfxDWriteFontFileLoader::CreateStreamFromKey(const void *fontFileReferenceKey, 
                                              UINT32 fontFileReferenceKeySize, 
                                              IDWriteFontFileStream **fontFileStream)
 {
     if (!fontFileReferenceKey || !fontFileStream) {
         return E_POINTER;
@@ -56,16 +56,16 @@ gfxDWriteFontFileStream::ReadFileFragmen
                                           void **fragmentContext)
 {
     // We are required to do bounds checking.
     if (fileOffset + fragmentSize > (UINT64)mData.Length()) {
         return E_FAIL;
     }
     // We should be alive for the duration of this.
     *fragmentStart = &mData[fileOffset];
-    *fragmentContext = NULL;
+    *fragmentContext = nullptr;
     return S_OK;
 }
 
 void STDMETHODCALLTYPE
 gfxDWriteFontFileStream::ReleaseFileFragment(void *fragmentContext)
 {
 }
--- a/gfx/thebes/gfxDWriteFontList.cpp
+++ b/gfx/thebes/gfxDWriteFontList.cpp
@@ -285,17 +285,17 @@ gfxDWriteFontEntry::CopyFontTable(uint32
             return NS_ERROR_FAILURE;
 
         AutoDC dc;
         AutoSelectFont font(dc.GetDC(), &logfont);
         if (font.IsValid()) {
             uint32_t tableSize =
                 ::GetFontData(dc.GetDC(),
                               NativeEndian::swapToBigEndian(aTableTag), 0,
-                              NULL, 0);
+                              nullptr, 0);
             if (tableSize != GDI_ERROR) {
                 if (aBuffer.SetLength(tableSize)) {
                     ::GetFontData(dc.GetDC(),
                                   NativeEndian::swapToBigEndian(aTableTag), 0,
                                   aBuffer.Elements(), aBuffer.Length());
                     return NS_OK;
                 }
                 return NS_ERROR_OUT_OF_MEMORY;
@@ -307,17 +307,17 @@ gfxDWriteFontEntry::CopyFontTable(uint32
     nsRefPtr<IDWriteFontFace> fontFace;
     nsresult rv = CreateFontFace(getter_AddRefs(fontFace));
     if (NS_FAILED(rv)) {
         return rv;
     }
 
     uint8_t *tableData;
     uint32_t len;
-    void *tableContext = NULL;
+    void *tableContext = nullptr;
     BOOL exists;
     HRESULT hr =
         fontFace->TryGetFontTable(NativeEndian::swapToBigEndian(aTableTag),
                                   (const void**)&tableData, &len,
                                   &tableContext, &exists);
     if (FAILED(hr) || !exists) {
         return NS_ERROR_FAILURE;
     }
@@ -476,17 +476,17 @@ gfxDWriteFontEntry::CreateFontFace(IDWri
 
     // check whether we need to add a DWrite simulated style
     if ((aSimulations & DWRITE_FONT_SIMULATIONS_BOLD) &&
         !(mFontFace->GetSimulations() & DWRITE_FONT_SIMULATIONS_BOLD)) {
         // if so, we need to return not mFontFace itself but a version that
         // has the Bold simulation - unfortunately, DWrite doesn't provide
         // a simple API for this
         UINT32 numberOfFiles = 0;
-        if (FAILED(mFontFace->GetFiles(&numberOfFiles, NULL))) {
+        if (FAILED(mFontFace->GetFiles(&numberOfFiles, nullptr))) {
             return NS_ERROR_FAILURE;
         }
         nsAutoTArray<IDWriteFontFile*,1> files;
         files.AppendElements(numberOfFiles);
         if (FAILED(mFontFace->GetFiles(&numberOfFiles, files.Elements()))) {
             return NS_ERROR_FAILURE;
         }
         HRESULT hr = gfxWindowsPlatform::GetPlatform()->GetDWriteFactory()->
@@ -748,18 +748,18 @@ gfxDWriteFontList::InitFontList()
 
     LARGE_INTEGER frequency;        // ticks per second
     LARGE_INTEGER t1, t2, t3;           // ticks
     double elapsedTime, upTime;
     char nowTime[256], nowDate[256];
 
     if (LOG_FONTINIT_ENABLED()) {    
         GetTimeFormat(LOCALE_INVARIANT, TIME_FORCE24HOURFORMAT, 
-                      NULL, NULL, nowTime, 256);
-        GetDateFormat(LOCALE_INVARIANT, 0, NULL, NULL, nowDate, 256);
+                      nullptr, nullptr, nowTime, 256);
+        GetDateFormat(LOCALE_INVARIANT, 0, nullptr, nullptr, nowDate, 256);
     }
     upTime = (double) GetTickCount();
     QueryPerformanceFrequency(&frequency);
     QueryPerformanceCounter(&t1);
 
     HRESULT hr;
     gfxFontCache *fc = gfxFontCache::GetCache();
     if (fc) {
@@ -816,18 +816,18 @@ gfxDWriteFontList::DelayedInitFontList()
 
     LARGE_INTEGER frequency;        // ticks per second
     LARGE_INTEGER t1, t2, t3;           // ticks
     double elapsedTime, upTime;
     char nowTime[256], nowDate[256];
 
     if (LOG_FONTINIT_ENABLED()) {    
         GetTimeFormat(LOCALE_INVARIANT, TIME_FORCE24HOURFORMAT, 
-                      NULL, NULL, nowTime, 256);
-        GetDateFormat(LOCALE_INVARIANT, 0, NULL, NULL, nowDate, 256);
+                      nullptr, nullptr, nowTime, 256);
+        GetDateFormat(LOCALE_INVARIANT, 0, nullptr, nullptr, nowDate, 256);
     }
 
     upTime = (double) GetTickCount();
     QueryPerformanceFrequency(&frequency);
     QueryPerformanceCounter(&t1);
 
     HRESULT hr;
 
@@ -1089,17 +1089,17 @@ gfxDWriteFontList::GetFontSubstitutes()
         return NS_ERROR_FAILURE;
     }
 
     for (i = 0, rv = ERROR_SUCCESS; rv != ERROR_NO_MORE_ITEMS; i++) {
         aliasName[0] = 0;
         lenAlias = ArrayLength(aliasName);
         actualName[0] = 0;
         lenActual = sizeof(actualName);
-        rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, NULL, &valueType, 
+        rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, nullptr, &valueType,
                 (LPBYTE)actualName, &lenActual);
 
         if (rv != ERROR_SUCCESS || valueType != REG_SZ || lenAlias == 0) {
             continue;
         }
 
         if (aliasName[0] == WCHAR('@')) {
             continue;
@@ -1366,17 +1366,17 @@ gfxDWriteFontList::GlobalFontFallback(co
 
     // initialize fallback renderer
     if (!mFallbackRenderer) {
         mFallbackRenderer = new FontFallbackRenderer(dwFactory);
     }
 
     // initialize text format
     if (!mFallbackFormat) {
-        hr = dwFactory->CreateTextFormat(L"Arial", NULL,
+        hr = dwFactory->CreateTextFormat(L"Arial", nullptr,
                                          DWRITE_FONT_WEIGHT_REGULAR,
                                          DWRITE_FONT_STYLE_NORMAL,
                                          DWRITE_FONT_STRETCH_NORMAL,
                                          72.0f, L"en-us",
                                          getter_AddRefs(mFallbackFormat));
         if (FAILED(hr)) {
             return nullptr;
         }
@@ -1404,17 +1404,17 @@ gfxDWriteFontList::GlobalFontFallback(co
                                      200.0f, 200.0f,
                                      getter_AddRefs(fallbackLayout));
     if (FAILED(hr)) {
         return nullptr;
     }
 
     // call the draw method to invoke the DirectWrite layout functions
     // which determine the fallback font
-    hr = fallbackLayout->Draw(NULL, mFallbackRenderer, 50.0f, 50.0f);
+    hr = fallbackLayout->Draw(nullptr, mFallbackRenderer, 50.0f, 50.0f);
     if (FAILED(hr)) {
         return nullptr;
     }
 
     gfxFontFamily *family = FindFamily(mFallbackRenderer->FallbackFamilyName());
     if (family) {
         gfxFontEntry *fontEntry;
         bool needsBold;  // ignored in the system fallback case
--- a/gfx/thebes/gfxDWriteFontList.h
+++ b/gfx/thebes/gfxDWriteFontList.h
@@ -308,17 +308,17 @@ public:
     {
         if (__uuidof(IDWriteTextRenderer) == riid) {
             *ppvObject = this;
         } else if (__uuidof(IDWritePixelSnapping) == riid) {
             *ppvObject = this;
         } else if (__uuidof(IUnknown) == riid) {
             *ppvObject = this;
         } else {
-            *ppvObject = NULL;
+            *ppvObject = nullptr;
             return E_FAIL;
         }
 
         this->AddRef();
         return S_OK;
     }
 
     const nsString& FallbackFamilyName() { return mFamilyName; }
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -486,17 +486,17 @@ gfxDWriteFont::SetupCairoFont(gfxContext
     }
     cairo_set_scaled_font(aContext->GetCairo(), scaledFont);
     return true;
 }
 
 bool
 gfxDWriteFont::IsValid()
 {
-    return mFontFace != NULL;
+    return mFontFace != nullptr;
 }
 
 IDWriteFontFace*
 gfxDWriteFont::GetFontFace()
 {
     return  mFontFace.get();
 }
 
--- a/gfx/thebes/gfxDWriteShaper.cpp
+++ b/gfx/thebes/gfxDWriteShaper.cpp
@@ -40,17 +40,17 @@ gfxDWriteShaper::ShapeText(gfxContext   
 
     /**
      * There's an internal 16-bit limit on some things inside the analyzer,
      * but we never attempt to shape a word longer than 32K characters
      * in a single call, so we cannot exceed that limit.
      */
     UINT32 length = aLength;
 
-    TextAnalysis analysis(aText, length, NULL, readingDirection);
+    TextAnalysis analysis(aText, length, nullptr, readingDirection);
     TextAnalysis::Run *runHead;
     hr = analysis.GenerateResults(analyzer, &runHead);
 
     if (FAILED(hr)) {
         NS_WARNING("Analyzer failed to generate results.");
         return false;
     }
 
@@ -78,17 +78,17 @@ trymoreglyphs:
         return false;
     }
 
     UINT32 actualGlyphs;
 
     hr = analyzer->GetGlyphs(aText, length,
             font->GetFontFace(), FALSE, 
             readingDirection == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT,
-            &runHead->mScript, NULL, NULL, NULL, NULL, 0,
+            &runHead->mScript, nullptr, nullptr, nullptr, nullptr, 0,
             maxGlyphs, clusters.Elements(), textProperties.Elements(),
             indices.Elements(), glyphProperties.Elements(), &actualGlyphs);
 
     if (hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)) {
         // We increase the amount of glyphs and try again.
         goto trymoreglyphs;
     }
     if (FAILED(hr)) {
@@ -117,38 +117,38 @@ trymoreglyphs:
                                           font->GetFontFace(),
                                           font->GetAdjustedSize(),
                                           1.0,
                                           nullptr,
                                           FALSE,
                                           FALSE,
                                           FALSE,
                                           &runHead->mScript,
-                                          NULL,
-                                          NULL,
-                                          NULL,
+                                          nullptr,
+                                          nullptr,
+                                          nullptr,
                                           0,
                                           advances.Elements(),
                                           glyphOffsets.Elements());
     } else {
         hr = analyzer->GetGlyphPlacements(aText,
                                           clusters.Elements(),
                                           textProperties.Elements(),
                                           length,
                                           indices.Elements(),
                                           glyphProperties.Elements(),
                                           actualGlyphs,
                                           font->GetFontFace(),
                                           font->GetAdjustedSize(),
                                           FALSE,
                                           FALSE,
                                           &runHead->mScript,
-                                          NULL,
-                                          NULL,
-                                          NULL,
+                                          nullptr,
+                                          nullptr,
+                                          nullptr,
                                           0,
                                           advances.Elements(),
                                           glyphOffsets.Elements());
     }
     if (FAILED(hr)) {
         NS_WARNING("Analyzer failed to get glyph placements.");
         return false;
     }
--- a/gfx/thebes/gfxDWriteTextAnalysis.cpp
+++ b/gfx/thebes/gfxDWriteTextAnalysis.cpp
@@ -8,17 +8,17 @@
 TextAnalysis::TextAnalysis(const wchar_t* text,
                            UINT32 textLength,
                            const wchar_t* localeName,
                            DWRITE_READING_DIRECTION readingDirection)
   : mText(text)
   , mTextLength(textLength)
   , mLocaleName(localeName)
   , mReadingDirection(readingDirection)
-  , mCurrentRun(NULL)
+  , mCurrentRun(nullptr)
 {
 }
 
 TextAnalysis::~TextAnalysis()
 {
     // delete runs, except mRunHead which is part of the TextAnalysis object
     for (Run *run = mRunHead.nextRun; run;) {
         Run *origRun = run;
@@ -37,17 +37,17 @@ TextAnalysis::GenerateResults(IDWriteTex
     HRESULT hr = S_OK;
 
     // Initially start out with one result that covers the entire range.
     // This result will be subdivided by the analysis processes.
     mRunHead.mTextStart = 0;
     mRunHead.mTextLength = mTextLength;
     mRunHead.mBidiLevel = 
         (mReadingDirection == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT);
-    mRunHead.nextRun = NULL;
+    mRunHead.nextRun = nullptr;
     mCurrentRun = &mRunHead;
 
     // Call each of the analyzers in sequence, recording their results.
     if (SUCCEEDED(hr = textAnalyzer->AnalyzeScript(this,
                                                    0,
                                                    mTextLength,
                                                    this))) {
         *runHead = &mRunHead;
@@ -62,17 +62,17 @@ TextAnalysis::GenerateResults(IDWriteTex
 
 IFACEMETHODIMP 
 TextAnalysis::GetTextAtPosition(UINT32 textPosition,
                                 OUT WCHAR const** textString,
                                 OUT UINT32* textLength)
 {
     if (textPosition >= mTextLength) {
         // No text at this position, valid query though.
-        *textString = NULL;
+        *textString = nullptr;
         *textLength = 0;
     } else {
         *textString = mText + textPosition;
         *textLength = mTextLength - textPosition;
     }
     return S_OK;
 }
 
@@ -80,17 +80,17 @@ TextAnalysis::GetTextAtPosition(UINT32 t
 IFACEMETHODIMP 
 TextAnalysis::GetTextBeforePosition(UINT32 textPosition,
                                     OUT WCHAR const** textString,
                                     OUT UINT32* textLength)
 {
     if (textPosition == 0 || textPosition > mTextLength) {
         // Either there is no text before here (== 0), or this
         // is an invalid position. The query is considered valid thouh.
-        *textString = NULL;
+        *textString = nullptr;
         *textLength = 0;
     } else {
         *textString = mText;
         *textLength = textPosition;
     }
     return S_OK;
 }
 
@@ -117,17 +117,17 @@ TextAnalysis::GetLocaleName(UINT32 textP
 
 
 IFACEMETHODIMP 
 TextAnalysis::GetNumberSubstitution(UINT32 textPosition,
                                     OUT UINT32* textLength,
                                     OUT IDWriteNumberSubstitution** numberSubstitution)
 {
     // We do not support number substitution.
-    *numberSubstitution = NULL;
+    *numberSubstitution = nullptr;
     *textLength = mTextLength - textPosition;
 
     return S_OK;
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // IDWriteTextAnalysisSink implementation
--- a/gfx/thebes/gfxFT2FontBase.cpp
+++ b/gfx/thebes/gfxFT2FontBase.cpp
@@ -86,17 +86,17 @@ gfxFT2FontBase::GetGlyph(uint32_t aCharC
     }
 
     return slot->mGlyphIndex;
 }
 
 void
 gfxFT2FontBase::GetGlyphExtents(uint32_t aGlyph, cairo_text_extents_t* aExtents)
 {
-    NS_PRECONDITION(aExtents != NULL, "aExtents must not be NULL");
+    NS_PRECONDITION(aExtents != nullptr, "aExtents must not be NULL");
 
     cairo_glyph_t glyphs[1];
     glyphs[0].index = aGlyph;
     glyphs[0].x = 0.0;
     glyphs[0].y = 0.0;
     // cairo does some caching for us here but perhaps a small gain could be
     // made by caching more.  It is usually only the advance that is needed,
     // so caching only the advance could allow many requests to be cached with
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -595,17 +595,17 @@ public:
         mOps = (PLDHashTableOps) {
             PL_DHashAllocTable,
             PL_DHashFreeTable,
             StringHash,
             HashMatchEntry,
             MoveEntry,
             PL_DHashClearEntryStub,
             PL_DHashFinalizeStub,
-            NULL
+            nullptr
         };
 
         if (!PL_DHashTableInit(&mMap, &mOps, nullptr,
                                sizeof(FNCMapEntry), 0))
         {
             mMap.ops = nullptr;
             LOG(("initializing the map failed"));
         }
@@ -654,22 +654,22 @@ public:
             if (!(end = strchr(beginning, ';'))) {
                 break;
             }
             nsCString faceList(beginning, end - beginning);
             beginning = end + 1;
             if (!(end = strchr(beginning, ';'))) {
                 break;
             }
-            uint32_t timestamp = strtoul(beginning, NULL, 10);
+            uint32_t timestamp = strtoul(beginning, nullptr, 10);
             beginning = end + 1;
             if (!(end = strchr(beginning, ';'))) {
                 break;
             }
-            uint32_t filesize = strtoul(beginning, NULL, 10);
+            uint32_t filesize = strtoul(beginning, nullptr, 10);
 
             FNCMapEntry* mapEntry =
                 static_cast<FNCMapEntry*>
                 (PL_DHashTableOperate(&mMap, filename.get(), PL_DHASH_ADD));
             if (mapEntry) {
                 mapEntry->mFilename.Assign(filename);
                 mapEntry->mTimestamp = timestamp;
                 mapEntry->mFilesize = filesize;
@@ -824,32 +824,32 @@ gfxFT2FontList::AppendFacesFromCachedFac
             break;
         }
         nsString faceName =
             NS_ConvertUTF8toUTF16(beginning, end - beginning);
         beginning = end + 1;
         if (!(end = strchr(beginning, ','))) {
             break;
         }
-        uint32_t index = strtoul(beginning, NULL, 10);
+        uint32_t index = strtoul(beginning, nullptr, 10);
         beginning = end + 1;
         if (!(end = strchr(beginning, ','))) {
             break;
         }
         bool italic = (*beginning != '0');
         beginning = end + 1;
         if (!(end = strchr(beginning, ','))) {
             break;
         }
-        uint32_t weight = strtoul(beginning, NULL, 10);
+        uint32_t weight = strtoul(beginning, nullptr, 10);
         beginning = end + 1;
         if (!(end = strchr(beginning, ','))) {
             break;
         }
-        int32_t stretch = strtol(beginning, NULL, 10);
+        int32_t stretch = strtol(beginning, nullptr, 10);
 
         FontListEntry fle(familyName, faceName, aFileName,
                           weight, stretch, italic, index);
         AppendFaceFromFontListEntry(fle, aStdFile);
 
         beginning = end + 1;
         end = strchr(beginning, ',');
     }
@@ -1152,17 +1152,17 @@ gfxFT2FontList::FindFonts()
         const nsString& path(searchPaths[i]);
         for (uint32_t j = 0; j < fontPatterns.Length(); j++) { 
             nsAutoString pattern(path);
             pattern.Append(fontPatterns[j]);
             HANDLE handle = FindFirstFileExW(pattern.get(),
                                              FindExInfoStandard,
                                              &results,
                                              FindExSearchNameMatch,
-                                             NULL,
+                                             nullptr,
                                              0);
             bool moreFiles = handle != INVALID_HANDLE_VALUE;
             while (moreFiles) {
                 nsAutoString filePath(path);
                 filePath.AppendLiteral("\\");
                 filePath.Append(results.cFileName);
                 AppendFacesFromFontFile(NS_ConvertUTF16toUTF8(filePath));
                 moreFiles = FindNextFile(handle, &results);
@@ -1271,18 +1271,18 @@ gfxFT2FontList::FindFontsInDir(const nsC
         "DroidSansFallback.ttf"
     };
 
     DIR *d = opendir(aDir.get());
     if (!d) {
         return;
     }
 
-    struct dirent *ent = NULL;
-    while ((ent = readdir(d)) != NULL) {
+    struct dirent *ent = nullptr;
+    while ((ent = readdir(d)) != nullptr) {
         int namelen = strlen(ent->d_name);
         if (namelen <= 4) {
             // cannot be a usable font filename
             continue;
         }
         const char *ext = ent->d_name + namelen - 4;
         if (strcasecmp(ext, ".ttf") == 0 ||
             strcasecmp(ext, ".otf") == 0 ||
--- a/gfx/thebes/gfxFT2FontList.h
+++ b/gfx/thebes/gfxFT2FontList.h
@@ -50,17 +50,17 @@ public:
     // create a font entry representing an installed font, identified by
     // a FontListEntry; the freetype and cairo faces will not be instantiated
     // until actually needed
     static FT2FontEntry*
     CreateFontEntry(const FontListEntry& aFLE);
 
     // Create a font entry for a given freetype face; if it is an installed font,
     // also record the filename and index.
-    // aFontData (if non-NULL) is NS_Malloc'ed data that aFace depends on,
+    // aFontData (if non-nullptr) is NS_Malloc'ed data that aFace depends on,
     // to be freed after the face is destroyed
     static FT2FontEntry* 
     CreateFontEntry(FT_Face aFace,
                     const char *aFilename, uint8_t aIndex,
                     const nsAString& aName,
                     const uint8_t *aFontData = nullptr);
 
     virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle,
--- a/gfx/thebes/gfxFT2Fonts.cpp
+++ b/gfx/thebes/gfxFT2Fonts.cpp
@@ -281,17 +281,17 @@ void gfxFT2FontGroup::GetCJKPrefFonts(ns
         switch (::GetACP()) {
             case 932: GetPrefFonts(nsGkAtoms::Japanese, aFontEntryList); break;
             case 936: GetPrefFonts(nsGkAtoms::zh_cn, aFontEntryList); break;
             case 949: GetPrefFonts(nsGkAtoms::ko, aFontEntryList); break;
             // XXX Don't we need to append nsGkAtoms::zh_hk if the codepage is 950?
             case 950: GetPrefFonts(nsGkAtoms::zh_tw, aFontEntryList); break;
         }
 #else
-        const char *ctype = setlocale(LC_CTYPE, NULL);
+        const char *ctype = setlocale(LC_CTYPE, nullptr);
         if (ctype) {
             if (!PL_strncasecmp(ctype, "ja", 2)) {
                 GetPrefFonts(nsGkAtoms::Japanese, aFontEntryList);
             } else if (!PL_strncasecmp(ctype, "zh_cn", 5)) {
                 GetPrefFonts(nsGkAtoms::zh_cn, aFontEntryList);
             } else if (!PL_strncasecmp(ctype, "zh_hk", 5)) {
                 GetPrefFonts(nsGkAtoms::zh_hk, aFontEntryList);
             } else if (!PL_strncasecmp(ctype, "zh_tw", 5)) {
--- a/gfx/thebes/gfxFT2Utils.cpp
+++ b/gfx/thebes/gfxFT2Utils.cpp
@@ -42,18 +42,18 @@ SnapLineToPixels(gfxFloat& aOffset, gfxF
     aOffset = floor(offset + 0.5);
     aSize = snappedSize;
 }
 
 void
 gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics,
                              uint32_t* aSpaceGlyph)
 {
-    NS_PRECONDITION(aMetrics != NULL, "aMetrics must not be NULL");
-    NS_PRECONDITION(aSpaceGlyph != NULL, "aSpaceGlyph must not be NULL");
+    NS_PRECONDITION(aMetrics != nullptr, "aMetrics must not be NULL");
+    NS_PRECONDITION(aSpaceGlyph != nullptr, "aSpaceGlyph must not be NULL");
 
     if (MOZ_UNLIKELY(!mFace)) {
         // No face.  This unfortunate situation might happen if the font
         // file is (re)moved at the wrong time.
         aMetrics->emHeight = mGfxFont->GetStyle()->size;
         aMetrics->emAscent = 0.8 * aMetrics->emHeight;
         aMetrics->emDescent = 0.2 * aMetrics->emHeight;
         aMetrics->maxAscent = aMetrics->emAscent;
@@ -318,17 +318,17 @@ gfxFT2LockedFace::GetUVSGlyph(uint32_t a
 #endif
 
     return (*sGetCharVariantPtr)(mFace, aCharCode, aVariantSelector);
 }
 
 uint32_t
 gfxFT2LockedFace::GetCharExtents(char aChar, cairo_text_extents_t* aExtents)
 {
-    NS_PRECONDITION(aExtents != NULL, "aExtents must not be NULL");
+    NS_PRECONDITION(aExtents != nullptr, "aExtents must not be NULL");
 
     if (!mFace)
         return 0;
 
     FT_UInt gid = mGfxFont->GetGlyph(aChar);
     if (gid) {
         mGfxFont->GetGlyphExtents(gid, aExtents);
     }
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -701,17 +701,17 @@ gfxFontFamily::FindFontForStyle(const gf
         return fe;
     }
 
     bool wantItalic = (aFontStyle.style &
                        (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0;
 
     // Most families are "simple", having just Regular/Bold/Italic/BoldItalic,
     // or some subset of these. In this case, we have exactly 4 entries in mAvailableFonts,
-    // stored in the above order; note that some of the entries may be NULL.
+    // stored in the above order; note that some of the entries may be nullptr.
     // We can then pick the required entry based on whether the request is for
     // bold or non-bold, italic or non-italic, without running the more complex
     // matching algorithm used for larger families with many weights and/or widths.
 
     if (mIsSimpleFamily) {
         // Family has no more than the "standard" 4 faces, at fixed indexes;
         // calculate which one we want.
         // Note that we cannot simply return it as not all 4 faces are necessarily present.
@@ -880,17 +880,17 @@ gfxFontFamily::FindWeightsForStyle(gfxFo
                                    bool anItalic, int16_t aStretch)
 {
     uint32_t foundWeights = 0;
     uint32_t bestMatchDistance = 0xffffffff;
 
     uint32_t count = mAvailableFonts.Length();
     for (uint32_t i = 0; i < count; i++) {
         // this is not called for "simple" families, and therefore it does not
-        // need to check the mAvailableFonts entries for NULL
+        // need to check the mAvailableFonts entries for nullptr.
         gfxFontEntry *fe = mAvailableFonts[i];
         uint32_t distance = StyleDistance(fe, anItalic, aStretch);
         if (distance <= bestMatchDistance) {
             int8_t wt = fe->mWeight / 100;
             NS_ASSERTION(wt >= 1 && wt < 10, "invalid weight in fontEntry");
             if (!aFontsForWeights[wt]) {
                 // record this as a possible candidate for weight matching
                 aFontsForWeights[wt] = fe;
@@ -2521,18 +2521,18 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint
       }
 
       GlyphBufferAzure glyphs;
       Glyph *glyph;
 
       Matrix mat, matInv;
       Matrix oldMat = dt->GetTransform();
 
-      // This is NULL when we have inverse-transformed glyphs and we need to
-      // transform the Brush inside flush.
+      // This is nullptr when we have inverse-transformed glyphs and we need
+      // to transform the Brush inside flush.
       Matrix *passedInvMatrix = nullptr;
 
       RefPtr<GlyphRenderingOptions> renderingOptions =
         GetGlyphRenderingOptions();
 
       DrawOptions drawOptions;
       drawOptions.mAntialiasMode = Get2DAAMode(mAntialiasOption);
 
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -345,22 +345,22 @@ public:
     // reference to a shared system font cache.
     //
     // The default implementation uses CopyFontTable to get the data
     // into a byte array, and maintains a cache of loaded tables.
     //
     // Subclasses should override this if they can provide more efficient
     // access than copying table data into our own buffers.
     //
-    // Get blob that encapsulates a specific font table, or NULL if
+    // Get blob that encapsulates a specific font table, or nullptr if
     // the table doesn't exist in the font.
     //
     // Caller is responsible to call hb_blob_destroy() on the returned blob
-    // (if non-NULL) when no longer required. For transient access to a table,
-    // use of AutoTable (below) is generally preferred.
+    // (if non-nullptr) when no longer required. For transient access to a
+    // table, use of AutoTable (below) is generally preferred.
     virtual hb_blob_t *GetFontTable(uint32_t aTag);
 
     // Stack-based utility to return a specified table, automatically releasing
     // the blob when the AutoTable goes out of scope.
     class AutoTable {
     public:
         AutoTable(gfxFontEntry* aFontEntry, uint32_t aTag)
         {
@@ -390,18 +390,18 @@ public:
     // if it is more efficient to get the table from the OS at that level.
     bool GetExistingFontTable(uint32_t aTag, hb_blob_t** aBlob);
 
     // Elements of aTable are transferred (not copied) to and returned in a
     // new hb_blob_t which is registered on the gfxFontEntry, but the initial
     // reference is owned by the caller.  Removing the last reference
     // unregisters the table from the font entry.
     //
-    // Pass NULL for aBuffer to indicate that the table is not present and
-    // NULL will be returned.  Also returns NULL on OOM.
+    // Pass nullptr for aBuffer to indicate that the table is not present and
+    // nullptr will be returned.  Also returns nullptr on OOM.
     hb_blob_t *ShareFontTableAndGetBlob(uint32_t aTag,
                                         FallibleTArray<uint8_t>* aTable);
 
     // Shaper face accessors:
     // NOTE that harfbuzz and graphite handle ownership/lifetime of the face
     // object in completely different ways.
 
     // Get HarfBuzz face corresponding to this font file.
@@ -1543,17 +1543,17 @@ public:
      * units, really!
      * @param aSpacing spacing to insert before and after characters (for RTL
      * glyphs, before-spacing is inserted to the right of characters). There
      * are aEnd - aStart elements in this array, unless it's null to indicate
      * that there is no spacing.
      * @param aDrawMode specifies whether the fill or stroke of the glyph should be
      * drawn, or if it should be drawn into the current path
      * @param aObjectPaint information about how to construct the fill and
-     * stroke pattern. Can be NULL if we are not stroking the text, which
+     * stroke pattern. Can be nullptr if we are not stroking the text, which
      * indicates that the current source from aContext should be used for filling
      * 
      * Callers guarantee:
      * -- aStart and aEnd are aligned to cluster and ligature boundaries
      * -- all glyphs use this font
      * 
      * The default implementation builds a cairo glyph array and
      * calls cairo_show_glyphs or cairo_glyph_path.
--- a/gfx/thebes/gfxFontconfigUtils.cpp
+++ b/gfx/thebes/gfxFontconfigUtils.cpp
@@ -303,17 +303,17 @@ gfxFontconfigUtils::NewPattern(const nsT
             AddWeakString(pattern, FC_FAMILY, family.get());
         }
     }
 
     return pattern.out();
 }
 
 gfxFontconfigUtils::gfxFontconfigUtils()
-    : mLastConfig(NULL)
+    : mLastConfig(nullptr)
 {
     mFontsByFamily.Init(50);
     mFontsByFullname.Init(50);
     mLangSupportTable.Init(20);
     UpdateFontListInternal();
 }
 
 nsresult
@@ -472,54 +472,54 @@ gfxFontconfigUtils::GetSampleLangForGrou
 
                     if (*pos == '\0')
                         break;
 
                     languages = pos + 1;
                 }
             }
         }
-        const char *ctype = setlocale(LC_CTYPE, NULL);
+        const char *ctype = setlocale(LC_CTYPE, nullptr);
         if (ctype &&
             TryLangForGroup(nsDependentCString(ctype), aLangGroup, aFcLang))
             return;
     }
 
     if (langGroup->defaultLang) {
         aFcLang->Assign(langGroup->defaultLang);
     } else {
         aFcLang->Truncate();
     }
 }
 
 nsresult
 gfxFontconfigUtils::GetFontListInternal(nsTArray<nsCString>& aListOfFonts,
                                         nsIAtom *aLangGroup)
 {
-    FcPattern *pat = NULL;
-    FcObjectSet *os = NULL;
-    FcFontSet *fs = NULL;
+    FcPattern *pat = nullptr;
+    FcObjectSet *os = nullptr;
+    FcFontSet *fs = nullptr;
     nsresult rv = NS_ERROR_FAILURE;
 
     aListOfFonts.Clear();
 
     pat = FcPatternCreate();
     if (!pat)
         goto end;
 
-    os = FcObjectSetBuild(FC_FAMILY, NULL);
+    os = FcObjectSetBuild(FC_FAMILY, nullptr);
     if (!os)
         goto end;
 
     // take the pattern and add the lang group to it
     if (aLangGroup) {
         AddLangGroup(pat, aLangGroup);
     }
 
-    fs = FcFontList(NULL, pat, os);
+    fs = FcFontList(nullptr, pat, os);
     if (!fs)
         goto end;
 
     for (int i = 0; i < fs->nfont; i++) {
         char *family;
 
         if (FcPatternGetString(fs->fonts[i], FC_FAMILY, 0,
                                (FcChar8 **) &family) != FcResultMatch)
@@ -559,18 +559,18 @@ gfxFontconfigUtils::UpdateFontList()
 
 nsresult
 gfxFontconfigUtils::UpdateFontListInternal(bool aForce)
 {
     if (!aForce) {
         // This checks periodically according to fontconfig's configured
         // <rescan> interval.
         FcInitBringUptoDate();
-    } else if (!FcConfigUptoDate(NULL)) { // check now with aForce
-        mLastConfig = NULL;
+    } else if (!FcConfigUptoDate(nullptr)) { // check now with aForce
+        mLastConfig = nullptr;
         FcInitReinitialize();
     }
 
     // FcInitReinitialize() (used by FcInitBringUptoDate) creates a new config
     // before destroying the old config, so the only way that we'd miss an
     // update is if fontconfig did more than one update and the memory for the
     // most recent config happened to be at the same location as the original
     // config.
@@ -664,34 +664,34 @@ gfxFontconfigUtils::GetStandardFamilyNam
         return rv;
 
     NS_ConvertUTF16toUTF8 fontname(aFontName);
 
     // return empty string if no such family exists
     if (!IsExistingFamily(fontname))
         return NS_OK;
 
-    FcPattern *pat = NULL;
-    FcObjectSet *os = NULL;
-    FcFontSet *givenFS = NULL;
+    FcPattern *pat = nullptr;
+    FcObjectSet *os = nullptr;
+    FcFontSet *givenFS = nullptr;
     nsTArray<nsCString> candidates;
-    FcFontSet *candidateFS = NULL;
+    FcFontSet *candidateFS = nullptr;
     rv = NS_ERROR_FAILURE;
 
     pat = FcPatternCreate();
     if (!pat)
         goto end;
 
     FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)fontname.get());
 
-    os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, NULL);
+    os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, nullptr);
     if (!os)
         goto end;
 
-    givenFS = FcFontList(NULL, pat, os);
+    givenFS = FcFontList(nullptr, pat, os);
     if (!givenFS)
         goto end;
 
     // The first value associated with a FC_FAMILY property is the family
     // returned by GetFontList(), so use this value if appropriate.
 
     // See if there is a font face with first family equal to the given family.
     for (int i = 0; i < givenFS->nfont; ++i) {
@@ -713,17 +713,17 @@ gfxFontconfigUtils::GetStandardFamilyNam
     }
 
     // See if any of the first family names represent the same set of font
     // faces as the given family.
     for (uint32_t j = 0; j < candidates.Length(); ++j) {
         FcPatternDel(pat, FC_FAMILY);
         FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)candidates[j].get());
 
-        candidateFS = FcFontList(NULL, pat, os);
+        candidateFS = FcFontList(nullptr, pat, os);
         if (!candidateFS)
             goto end;
 
         if (candidateFS->nfont != givenFS->nfont)
             continue;
 
         bool equal = true;
         for (int i = 0; i < givenFS->nfont; ++i) {
@@ -829,50 +829,51 @@ gfxFontconfigUtils::GetFullnameFromFamil
 
     return true;
 }
 
 bool
 gfxFontconfigUtils::FontsByFullnameEntry::KeyEquals(KeyTypePointer aKey) const
 {
     const FcChar8 *key = mKey;
-    // If mKey is NULL, key comes from the style and family of the first font.
+    // If mKey is nullptr, key comes from the style and family of the first
+    // font.
     nsAutoCString fullname;
     if (!key) {
         NS_ASSERTION(mFonts.Length(), "No font in FontsByFullnameEntry!");
         GetFullnameFromFamilyAndStyle(mFonts[0], &fullname);
 
         key = ToFcChar8(fullname);
     }
 
     return FcStrCmpIgnoreCase(aKey, key) == 0;
 }
 
 void
 gfxFontconfigUtils::AddFullnameEntries()
 {
     // This FcFontSet is owned by fontconfig
-    FcFontSet *fontSet = FcConfigGetFonts(NULL, FcSetSystem);
+    FcFontSet *fontSet = FcConfigGetFonts(nullptr, FcSetSystem);
 
     // Record the existing font families
     for (int f = 0; f < fontSet->nfont; ++f) {
         FcPattern *font = fontSet->fonts[f];
 
         int v = 0;
         FcChar8 *fullname;
         while (FcPatternGetString(font,
                                   FC_FULLNAME, v, &fullname) == FcResultMatch) {
             FontsByFullnameEntry *entry = mFontsByFullname.PutEntry(fullname);
             if (entry) {
                 // entry always has space for one font, so the first AddFont
                 // will always succeed, and so the entry will always have a
                 // font from which to obtain the key.
                 bool added = entry->AddFont(font);
-                // The key may be NULL either if this is the first font, or if
-                // the first font does not have a fullname property, and so
+                // The key may be nullptr either if this is the first font, or
+                // if the first font does not have a fullname property, and so
                 // the key is obtained from the font.  Set the key in both
                 // cases.  The check that AddFont succeeded is required for
                 // the second case.
                 if (!entry->mKey && added) {
                     entry->mKey = fullname;
                 }
             }
 
@@ -885,18 +886,18 @@ gfxFontconfigUtils::AddFullnameEntries()
             if (!GetFullnameFromFamilyAndStyle(font, &name))
                 continue;
 
             FontsByFullnameEntry *entry =
                 mFontsByFullname.PutEntry(ToFcChar8(name));
             if (entry) {
                 entry->AddFont(font);
                 // Either entry->mKey has been set for a previous font or it
-                // remains NULL to indicate that the key is obtained from the
-                // first font.
+                // remains nullptr to indicate that the key is obtained from
+                // the first font.
             }
         }
     }
 }
 
 const nsTArray< nsCountedRef<FcPattern> >&
 gfxFontconfigUtils::GetFontsForFullname(const FcChar8 *aFullname)
 {
@@ -1003,17 +1004,17 @@ gfxFontconfigUtils::GetLangSupportEntry(
         best = entry->mSupport;
         // If there is support for this language, an empty font list indicates
         // that the list hasn't been initialized yet.
         if (best == FcLangDifferentLang || entry->mFonts.Length() > 0)
             return entry;
     }
 
     // This FcFontSet is owned by fontconfig
-    FcFontSet *fontSet = FcConfigGetFonts(NULL, FcSetSystem);
+    FcFontSet *fontSet = FcConfigGetFonts(nullptr, FcSetSystem);
 
     nsAutoTArray<FcPattern*,100> fonts;
 
     for (int f = 0; f < fontSet->nfont; ++f) {
         FcPattern *font = fontSet->fonts[f];
 
         FcLangResult support = GetLangSupport(font, aLang);
 
@@ -1041,17 +1042,17 @@ gfxFontconfigUtils::GetLangSupportEntry(
         if (fonts.Length() != 0) {
             entry->mFonts.AppendElements(fonts.Elements(), fonts.Length());
         } else if (best != FcLangDifferentLang) {
             // Previously there was a font that supported this language at the
             // level of entry->mSupport, but it has now disappeared.  At least
             // entry->mSupport needs to be recalculated, but this is an
             // indication that the set of installed fonts has changed, so
             // update all caches.
-            mLastConfig = NULL; // invalidates caches
+            mLastConfig = nullptr; // invalidates caches
             UpdateFontListInternal(true);
             return GetLangSupportEntry(aLang, aWithFonts);
         }
     }
 
     return entry;
 }
 
--- a/gfx/thebes/gfxFontconfigUtils.h
+++ b/gfx/thebes/gfxFontconfigUtils.h
@@ -176,21 +176,21 @@ public:
     // Hash entry with a dependent const FcChar8* pointer to an external
     // string for a key (and no data).  The user must ensure that the string
     // associated with the pointer is not destroyed.  This entry type is
     // useful for family name keys as the family name string is held in the
     // font pattern.
     class DepFcStrEntry : public FcStrEntryBase {
     public:
         // When constructing a new entry in the hashtable, the key is left
-        // NULL.  The caller of PutEntry() must fill in mKey when NULL.  This
-        // provides a mechanism for the caller of PutEntry() to determine
+        // nullptr.  The caller of PutEntry() must fill in mKey when nullptr.
+        // This provides a mechanism for the caller of PutEntry() to determine
         // whether the entry has been initialized.
         DepFcStrEntry(KeyTypePointer aName)
-            : mKey(NULL) { }
+            : mKey(nullptr) { }
 
         DepFcStrEntry(const DepFcStrEntry& toCopy)
             : mKey(toCopy.mKey) { }
 
         bool KeyEquals(KeyTypePointer aKey) const {
             return FcStrCmpIgnoreCase(aKey, mKey) == 0;
         }
 
@@ -248,17 +248,17 @@ protected:
     //
     // * The font does not always contain a single string for the fullname, so
     //   the key is sometimes a combination of family and style.
     //
     // * There is usually only one font.
     class FontsByFullnameEntry : public DepFcStrEntry {
     public:
         // When constructing a new entry in the hashtable, the key is left
-        // NULL.  The caller of PutEntry() is must fill in mKey when adding
+        // nullptr.  The caller of PutEntry() is must fill in mKey when adding
         // the first font if the key is not derived from the family and style.
         // If the key is derived from family and style, a font must be added.
         FontsByFullnameEntry(KeyTypePointer aName)
             : DepFcStrEntry(aName) { }
 
         FontsByFullnameEntry(const FontsByFullnameEntry& toCopy)
             : DepFcStrEntry(toCopy), mFonts(toCopy.mFonts) { }
 
--- a/gfx/thebes/gfxGDIFont.cpp
+++ b/gfx/thebes/gfxGDIFont.cpp
@@ -35,17 +35,17 @@ GetCairoAntialiasOption(gfxFont::Antiali
     }
 }
 
 gfxGDIFont::gfxGDIFont(GDIFontEntry *aFontEntry,
                        const gfxFontStyle *aFontStyle,
                        bool aNeedsBold,
                        AntialiasOption anAAOption)
     : gfxFont(aFontEntry, aFontStyle, anAAOption),
-      mFont(NULL),
+      mFont(nullptr),
       mFontFace(nullptr),
       mMetrics(nullptr),
       mSpaceGlyph(0),
       mNeedsBold(aNeedsBold)
 {
     if (FontCanSupportGraphite()) {
         mGraphiteShaper = new gfxGraphiteShaper(this);
     }
@@ -538,17 +538,17 @@ gfxGDIFont::GetGlyphWidth(gfxContext *aC
     if (mGlyphWidths.Get(aGID, &width)) {
         return width;
     }
 
     DCFromContext dc(aCtx);
     AutoSelectFont fs(dc, GetHFONT());
 
     int devWidth;
-    if (GetCharWidthI(dc, aGID, 1, NULL, &devWidth)) {
+    if (GetCharWidthI(dc, aGID, 1, nullptr, &devWidth)) {
         // ensure width is positive, 16.16 fixed-point value
         width = (devWidth & 0x7fff) << 16;
         mGlyphWidths.Put(aGID, width);
         return width;
     }
 
     return -1;
 }
--- a/gfx/thebes/gfxGDIFontList.cpp
+++ b/gfx/thebes/gfxGDIFontList.cpp
@@ -238,17 +238,18 @@ GDIFontEntry::CopyFontTable(uint32_t aTa
         return NS_ERROR_FAILURE;
     }
 
     AutoDC dc;
     AutoSelectFont font(dc.GetDC(), &mLogFont);
     if (font.IsValid()) {
         uint32_t tableSize =
             ::GetFontData(dc.GetDC(),
-                          NativeEndian::swapToBigEndian(aTableTag), 0, NULL, 0);
+                          NativeEndian::swapToBigEndian(aTableTag),
+                          0, nullptr, 0);
         if (tableSize != GDI_ERROR) {
             if (aBuffer.SetLength(tableSize)) {
                 ::GetFontData(dc.GetDC(),
                               NativeEndian::swapToBigEndian(aTableTag), 0,
                               aBuffer.Elements(), tableSize);
                 return NS_OK;
             }
             return NS_ERROR_OUT_OF_MEMORY;
@@ -338,24 +339,24 @@ GDIFontEntry::TestCharacterMap(uint32_t 
                 && glyph[0] != 0xFFFF
                 && (IsType1() || glyph[0] != MISSING_GLYPH))
             {
                 hasGlyph = true;
             }
         } else {
             // ScriptGetCMap works better than GetGlyphIndicesW 
             // for things like bitmap/vector fonts
-            SCRIPT_CACHE sc = NULL;
+            SCRIPT_CACHE sc = nullptr;
             HRESULT rv = ScriptGetCMap(dc, &sc, str, 1, 0, glyph);
             if (rv == S_OK)
                 hasGlyph = true;
         }
 
         SelectObject(dc, oldFont);
-        ReleaseDC(NULL, dc);
+        ReleaseDC(nullptr, dc);
 
         if (hasGlyph) {
             mCharacterMap->set(aCh);
             return true;
         }
     } else {
         // font had a cmap so simply check that
         return mCharacterMap->test(aCh);
@@ -594,17 +595,17 @@ gfxGDIFontList::GetFontSubstitutes()
         return NS_ERROR_FAILURE;
     }
 
     for (i = 0, rv = ERROR_SUCCESS; rv != ERROR_NO_MORE_ITEMS; i++) {
         aliasName[0] = 0;
         lenAlias = ArrayLength(aliasName);
         actualName[0] = 0;
         lenActual = sizeof(actualName);
-        rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, NULL, &valueType, 
+        rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, nullptr, &valueType,
                 (LPBYTE)actualName, &lenActual);
 
         if (rv != ERROR_SUCCESS || valueType != REG_SZ || lenAlias == 0) {
             continue;
         }
 
         if (aliasName[0] == WCHAR('@')) {
             continue;
--- a/gfx/thebes/gfxGDIFontList.h
+++ b/gfx/thebes/gfxGDIFontList.h
@@ -12,21 +12,21 @@
 #include "nsGkAtoms.h"
 
 #include <windows.h>
 
 class AutoDC // get the global device context, and auto-release it on destruction
 {
 public:
     AutoDC() {
-        mDC = ::GetDC(NULL);
+        mDC = ::GetDC(nullptr);
     }
 
     ~AutoDC() {
-        ::ReleaseDC(NULL, mDC);
+        ::ReleaseDC(nullptr, mDC);
     }
 
     HDC GetDC() {
         return mDC;
     }
 
 private:
     HDC mDC;
@@ -39,17 +39,17 @@ public:
         : mOwnsFont(false)
     {
         mFont = ::CreateFontIndirectW(aLogFont);
         if (mFont) {
             mOwnsFont = true;
             mDC = aDC;
             mOldFont = (HFONT)::SelectObject(aDC, mFont);
         } else {
-            mOldFont = NULL;
+            mOldFont = nullptr;
         }
     }
 
     AutoSelectFont(HDC aDC, HFONT aFont)
         : mOwnsFont(false)
     {
         mDC = aDC;
         mFont = aFont;
@@ -61,17 +61,17 @@ public:
             ::SelectObject(mDC, mOldFont);
             if (mOwnsFont) {
                 ::DeleteObject(mFont);
             }
         }
     }
 
     bool IsValid() const {
-        return mFont != NULL;
+        return mFont != nullptr;
     }
 
     HFONT GetFont() const {
         return mFont;
     }
 
 private:
     HDC    mDC;
--- a/gfx/thebes/gfxGDIShaper.cpp
+++ b/gfx/thebes/gfxGDIShaper.cpp
@@ -47,17 +47,17 @@ gfxGDIShaper::ShapeText(gfxContext      
     if (!partialWidthArray.SetLength(length)) {
         return false;
     }
 
     BOOL success = ::GetTextExtentExPointI(dc,
                                            glyphs,
                                            length,
                                            INT_MAX,
-                                           NULL,
+                                           nullptr,
                                            partialWidthArray.Elements(),
                                            &size);
     if (!success) {
         return false;
     }
 
     gfxTextRun::CompressedGlyph g;
     gfxTextRun::CompressedGlyph *charGlyphs =
--- a/gfx/thebes/gfxGdkNativeRenderer.cpp
+++ b/gfx/thebes/gfxGdkNativeRenderer.cpp
@@ -39,17 +39,17 @@ gfxGdkNativeRenderer::DrawWithXlib(gfxXl
         NS_ASSERTION(numClipRects == 1, "Too many clip rects");
         clipRect.x = clipRects[0].x;
         clipRect.y = clipRects[0].y;
         clipRect.width = clipRects[0].width;
         clipRect.height = clipRects[0].height;
     }
 
     return DrawWithGDK(drawable, offset.x, offset.y,
-                       numClipRects ? &clipRect : NULL, numClipRects);
+                       numClipRects ? &clipRect : nullptr, numClipRects);
 }
 
 void
 gfxGdkNativeRenderer::Draw(gfxContext* ctx, nsIntSize size,
                            uint32_t flags, GdkColormap* colormap)
 {
     mColormap = colormap;
 
--- a/gfx/thebes/gfxImageSurface.cpp
+++ b/gfx/thebes/gfxImageSurface.cpp
@@ -41,17 +41,17 @@ gfxImageSurface::gfxImageSurface(unsigne
 {
     InitWithData(aData, aSize, aStride, aFormat);
 }
 
 void
 gfxImageSurface::MakeInvalid()
 {
     mSize = gfxIntSize(-1, -1);
-    mData = NULL;
+    mData = nullptr;
     mStride = 0;
 }
 
 void
 gfxImageSurface::InitWithData(unsigned char *aData, const gfxIntSize& aSize,
                               long aStride, gfxImageFormat aFormat)
 {
     mSize = aSize;
--- a/gfx/thebes/gfxMacFont.cpp
+++ b/gfx/thebes/gfxMacFont.cpp
@@ -55,17 +55,17 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *a
     }
 
     cairo_matrix_t sizeMatrix, ctm;
     cairo_matrix_init_identity(&ctm);
     cairo_matrix_init_scale(&sizeMatrix, mAdjustedSize, mAdjustedSize);
 
     // synthetic oblique by skewing via the font matrix
     bool needsOblique =
-        (mFontEntry != NULL) &&
+        (mFontEntry != nullptr) &&
         (!mFontEntry->IsItalic() &&
          (mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)));
 
     if (needsOblique) {
         double skewfactor = (needsOblique ? Fix2X(kATSItalicQDSkew) : 0);
 
         cairo_matrix_t style;
         cairo_matrix_init(&style,
@@ -364,17 +364,17 @@ gfxMacFont::GetCharWidth(CFDataRef aCmap
 // We ONLY call this for local (platform) fonts that are not sfnt format;
 // for sfnts, including ALL downloadable fonts, we prefer to use
 // InitMetricsFromSfntTables and avoid platform APIs.
 void
 gfxMacFont::InitMetricsFromPlatform()
 {
     CTFontRef ctFont = ::CTFontCreateWithGraphicsFont(mCGFont,
                                                       mAdjustedSize,
-                                                      NULL, NULL);
+                                                      nullptr, nullptr);
     if (!ctFont) {
         return;
     }
 
     mMetrics.underlineOffset = ::CTFontGetUnderlinePosition(ctFont);
     mMetrics.underlineSize = ::CTFontGetUnderlineThickness(ctFont);
 
     mMetrics.externalLeading = ::CTFontGetLeading(ctFont);
--- a/gfx/thebes/gfxOS2Fonts.cpp
+++ b/gfx/thebes/gfxOS2Fonts.cpp
@@ -351,31 +351,31 @@ cairo_font_face_t *gfxOS2Font::CairoFont
         FcPatternAddInteger(fcPattern, FC_SLANT, fcProperty);
 
         // add the size we want
         FcPatternAddDouble(fcPattern, FC_PIXEL_SIZE,
                            mAdjustedSize ? mAdjustedSize : GetStyle()->size);
 
         // finally find a matching font
         FcResult fcRes;
-        FcPattern *fcMatch = FcFontMatch(NULL, fcPattern, &fcRes);
+        FcPattern *fcMatch = FcFontMatch(nullptr, fcPattern, &fcRes);
 
         // Most code that depends on FcFontMatch() assumes it won't fail,
         // then crashes when it does.  For now, at least, substitute the
         // default serif font when it fails to avoid those crashes.
         if (!fcMatch) {
 //#ifdef DEBUG
             printf("Could not match font for:\n"
                    "  family=%s, weight=%d, slant=%d, size=%f\n",
                    NS_LossyConvertUTF16toASCII(GetName()).get(),
                    GetStyle()->weight, GetStyle()->style, GetStyle()->size);
 //#endif
             // FcPatternAddString() will free the existing FC_FAMILY string
             FcPatternAddString(fcPattern, FC_FAMILY, (FcChar8*)"SERIF");
-            fcMatch = FcFontMatch(NULL, fcPattern, &fcRes);
+            fcMatch = FcFontMatch(nullptr, fcPattern, &fcRes);
 //#ifdef DEBUG
             printf("Attempt to substitute default SERIF font %s\n",
                    fcMatch ? "succeeded" : "failed");
 //#endif
         }
         FcPatternDestroy(fcPattern);
 
         if (fcMatch) {
@@ -444,17 +444,17 @@ cairo_scaled_font_t *gfxOS2Font::CairoSc
 bool gfxOS2Font::SetupCairoFont(gfxContext *aContext)
 {
 #ifdef DEBUG_thebes_2
     printf("gfxOS2Font[%#x]::SetupCairoFont(%#x)\n",
            (unsigned)this, (unsigned) aContext);
 #endif
     // gfxPangoFont checks the CTM but Windows doesn't so leave away here, too
 
-    // this implicitely ensures that mScaledFont is created if NULL
+    // this implicitely ensures that mScaledFont is created if nullptr
     cairo_scaled_font_t *scaledFont = CairoScaledFont();
     if (!scaledFont || cairo_scaled_font_status(scaledFont) != CAIRO_STATUS_SUCCESS) {
         // Don't cairo_set_scaled_font as that would propagate the error to
         // the cairo_t, precluding any further drawing.
         return false;
     }
     cairo_set_scaled_font(aContext->GetCairo(), scaledFont);
     return true;
--- a/gfx/thebes/gfxOS2Surface.cpp
+++ b/gfx/thebes/gfxOS2Surface.cpp
@@ -144,17 +144,17 @@ gfxOS2Surface::~gfxOS2Surface()
     // other hand were created on device contexts with the GPI functions, so
     // use those to clean up stuff.
     if (mWnd) {
         if (mPS) {
             WinReleasePS(mPS);
         }
     } else {
         if (mBitmap) {
-            GpiSetBitmap(mPS, NULL);
+            GpiSetBitmap(mPS, nullptr);
             GpiDeleteBitmap(mBitmap);
         }
         if (mPS) {
             GpiDestroyPS(mPS);
         }
         if (mDC) {
             DevCloseDC(mDC);
         }
--- a/gfx/thebes/gfxPangoFonts.cpp
+++ b/gfx/thebes/gfxPangoFonts.cpp
@@ -74,17 +74,17 @@ FindFunctionSymbol(const char *name)
         PR_UnloadLibrary(lib);
     }
 
     return result;
 }
 
 static bool HasChar(FcPattern *aFont, FcChar32 wc)
 {
-    FcCharSet *charset = NULL;
+    FcCharSet *charset = nullptr;
     FcPatternGetCharSet(aFont, FC_CHARSET, 0, &charset);
 
     return charset && FcCharSetHasChar(charset, wc);
 }
 
 /**
  * gfxFcFontEntry:
  *
@@ -182,32 +182,35 @@ public:
     // not a fully resolved pattern.
     gfxSystemFcFontEntry(cairo_font_face_t *aFontFace,
                          FcPattern *aFontPattern,
                          const nsAString& aName)
         : gfxFcFontEntry(aName), mFontFace(aFontFace),
           mFTFace(nullptr), mFTFaceInitialized(false)
     {
         cairo_font_face_reference(mFontFace);
-        cairo_font_face_set_user_data(mFontFace, &sFontEntryKey, this, NULL);
+        cairo_font_face_set_user_data(mFontFace, &sFontEntryKey, this, nullptr);
         mPatterns.AppendElement();
         // mPatterns is an nsAutoTArray with 1 space always available, so the
         // AppendElement always succeeds.
         mPatterns[0] = aFontPattern;
 
         FcChar8 *name;
         if (FcPatternGetString(aFontPattern,
                                FC_FAMILY, 0, &name) == FcResultMatch) {
             mFamilyName = NS_ConvertUTF8toUTF16((const char*)name);
         }
     }
 
     ~gfxSystemFcFontEntry()
     {
-        cairo_font_face_set_user_data(mFontFace, &sFontEntryKey, NULL, NULL);
+        cairo_font_face_set_user_data(mFontFace,
+                                      &sFontEntryKey,
+                                      nullptr,
+                                      nullptr);
         cairo_font_face_destroy(mFontFace);
     }
 
     virtual void ForgetHBFace();
     virtual void ReleaseGrFace(gr_face* aFace);
 
 protected:
     virtual nsresult
@@ -443,17 +446,17 @@ public:
 
 class gfxDownloadedFcFontEntry : public gfxUserFcFontEntry {
 public:
     // This takes ownership of the face and its underlying data
     gfxDownloadedFcFontEntry(const gfxProxyFontEntry &aProxyEntry,
                              const uint8_t *aData, FT_Face aFace)
         : gfxUserFcFontEntry(aProxyEntry), mFontData(aData), mFace(aFace)
     {
-        NS_PRECONDITION(aFace != NULL, "aFace is NULL!");
+        NS_PRECONDITION(aFace != nullptr, "aFace is NULL!");
         InitPattern();
     }
 
     virtual ~gfxDownloadedFcFontEntry();
 
     // Returns true on success
     bool SetCairoFace(cairo_font_face_t *aFace);
 
@@ -531,42 +534,46 @@ gfxDownloadedFcFontEntry::InitPattern()
     // FcFreeTypeQueryFace is the same function used to construct patterns for
     // system fonts and so is the preferred function to use for this purpose.
     // This will set up the langset property, which helps with sorting, and
     // the foundry, fullname, and fontversion properties, which properly
     // identify the font to fontconfig rules.  However, FcFreeTypeQueryFace is
     // available only from fontconfig-2.4.2 (December 2006).  (CentOS 5.0 has
     // fontconfig-2.4.1.)
     if (sQueryFacePtr) {
-        // The "file" argument cannot be NULL (in fontconfig-2.6.0 at least).
-        // The dummy file passed here is removed below.
+        // The "file" argument cannot be nullptr (in fontconfig-2.6.0 at
+        // least). The dummy file passed here is removed below.
         //
-        // When fontconfig scans the system fonts, FcConfigGetBlanks(NULL) is
-        // passed as the "blanks" argument, which provides that unexpectedly
-        // blank glyphs are elided.  Here, however, we pass NULL for "blanks",
-        // effectively assuming that, if the font has a blank glyph, then the
-        // author intends any associated character to be rendered blank.
+        // When fontconfig scans the system fonts, FcConfigGetBlanks(nullptr)
+        // is passed as the "blanks" argument, which provides that unexpectedly
+        // blank glyphs are elided.  Here, however, we pass nullptr for
+        // "blanks", effectively assuming that, if the font has a blank glyph,
+        // then the author intends any associated character to be rendered
+        // blank.
         pattern =
-            (*sQueryFacePtr)(mFace, gfxFontconfigUtils::ToFcChar8(""), 0, NULL);
+            (*sQueryFacePtr)(mFace,
+                             gfxFontconfigUtils::ToFcChar8(""),
+                             0,
+                             nullptr);
         if (!pattern)
             // Either OOM, or fontconfig chose to skip this font because it
             // has "no encoded characters", which I think means "BDF and PCF
             // fonts which are not in Unicode (or the effectively equivalent
             // ISO Latin-1) encoding".
             return;
 
         // These properties don't make sense for this face without a file.
         FcPatternDel(pattern, FC_FILE);
         FcPatternDel(pattern, FC_INDEX);
 
     } else {
         // Do the minimum necessary to construct a pattern for sorting.
 
         // FC_CHARSET is vital to determine which characters are supported.
-        nsAutoRef<FcCharSet> charset(FcFreeTypeCharSet(mFace, NULL));
+        nsAutoRef<FcCharSet> charset(FcFreeTypeCharSet(mFace, nullptr));
         // If there are no characters then assume we don't know how to read
         // this font.
         if (!charset || FcCharSetCount(charset) == 0)
             return;
 
         pattern = FcPatternCreate();
         FcPatternAddCharSet(pattern, FC_CHARSET, charset);
 
@@ -703,17 +710,17 @@ public:
     // A reference is held by the FontSet.
     // The caller may add a ref to keep the font alive longer than the FontSet.
     gfxFcFont *GetFontAt(uint32_t i, const gfxFontStyle *aFontStyle)
     {
         if (i >= mFonts.Length() || !mFonts[i].mFont) { 
             // GetFontPatternAt sets up mFonts
             FcPattern *fontPattern = GetFontPatternAt(i);
             if (!fontPattern)
-                return NULL;
+                return nullptr;
 
             mFonts[i].mFont =
                 gfxFcFont::GetOrMakeFont(mSortPattern, fontPattern,
                                          aFontStyle);
         }
         return mFonts[i].mFont;
     }
 
@@ -764,17 +771,17 @@ private:
     // fallback fonts.
     nsAutoRef<FcFontSet> mFcFontSet;
     // The set of characters supported by the fonts in mFonts.
     nsAutoRef<FcCharSet> mCharSet;
     // The index of the next font in mFcFontSet that has not yet been
     // considered for mFonts.
     int mFcFontsTrimmed;
     // True iff fallback fonts are either stored in mFcFontSet or have been
-    // trimmed and added to mFonts (so that mFcFontSet is NULL).
+    // trimmed and added to mFonts (so that mFcFontSet is nullptr).
     bool mHaveFallbackFonts;
     // True iff there was a user font set with pending downloads,
     // so the set may be updated when downloads complete
     bool mWaitingForUserFont;
 };
 
 // Find the FcPattern for an @font-face font suitable for CSS family |aFamily|
 // and style |aStyle| properties.
@@ -1051,17 +1058,17 @@ gfxFcFontSet::SortPreferredFonts(bool &a
                 // override the family name
                 if (!isUserFont) {
                     FcPatternReference(font);
                 }
             }
         }
     }
 
-    FcPattern *truncateMarker = NULL;
+    FcPattern *truncateMarker = nullptr;
     for (uint32_t r = 0; r < requiredLangs.Length(); ++r) {
         const nsTArray< nsCountedRef<FcPattern> >& langFonts =
             utils->GetFontsForLang(requiredLangs[r].mLang);
 
         bool haveLangFont = false;
         for (uint32_t f = 0; f < langFonts.Length(); ++f) {
             FcPattern *font = langFonts[f];
             if (!SlantIsAcceptable(font, requestedSlant))
@@ -1098,26 +1105,26 @@ gfxFcFontSet::SortPreferredFonts(bool &a
             }
             break;
         }
     }
 
     FcFontSet *sets[1] = { fontSet };
     FcResult result;
 #ifdef SOLARIS
-    // Get around a crash of FcFontSetSort when FcConfig is NULL
+    // Get around a crash of FcFontSetSort when FcConfig is nullptr
     // Solaris's FcFontSetSort needs an FcConfig (bug 474758)
     fontSet.own(FcFontSetSort(FcConfigGetCurrent(), sets, 1, mSortPattern,
-                              FcFalse, NULL, &result));
+                              FcFalse, nullptr, &result));
 #else
-    fontSet.own(FcFontSetSort(NULL, sets, 1, mSortPattern,
-                              FcFalse, NULL, &result));
+    fontSet.own(FcFontSetSort(nullptr, sets, 1, mSortPattern,
+                              FcFalse, nullptr, &result));
 #endif
 
-    if (truncateMarker != NULL && fontSet) {
+    if (truncateMarker != nullptr && fontSet) {
         nsAutoRef<FcFontSet> truncatedSet(FcFontSetCreate());
 
         for (int f = 0; f < fontSet->nfont; ++f) {
             FcPattern *font = fontSet->fonts[f];
             if (font == truncateMarker)
                 break;
 
             if (FcFontSetAdd(truncatedSet, font)) {
@@ -1138,33 +1145,33 @@ gfxFcFontSet::SortFallbackFonts()
     // but would take much longer due to comparing all the character sets.
     //
     // The references to fonts in this FcFontSet are almost free
     // as they are pointers into mmaped cache files.
     //
     // GetFontPatternAt() will trim lazily if and as needed, which will also
     // remove duplicates of preferred fonts.
     FcResult result;
-    return nsReturnRef<FcFontSet>(FcFontSort(NULL, mSortPattern,
-                                             FcFalse, NULL, &result));
+    return nsReturnRef<FcFontSet>(FcFontSort(nullptr, mSortPattern,
+                                             FcFalse, nullptr, &result));
 }
 
 // GetFontAt relies on this setting up all patterns up to |i|.
 FcPattern *
 gfxFcFontSet::GetFontPatternAt(uint32_t i)
 {
     while (i >= mFonts.Length()) {
         while (!mFcFontSet) {
             if (mHaveFallbackFonts)
                 return nullptr;
 
             mFcFontSet = SortFallbackFonts();
             mHaveFallbackFonts = true;
             mFcFontsTrimmed = 0;
-            // Loop to test that mFcFontSet is non-NULL.
+            // Loop to test that mFcFontSet is non-nullptr.
         }
 
         while (mFcFontsTrimmed < mFcFontSet->nfont) {
             FcPattern *font = mFcFontSet->fonts[mFcFontsTrimmed];
             ++mFcFontsTrimmed;
 
             if (mFonts.Length() != 0) {
                 // See if the next font provides support for any extra
@@ -1173,17 +1180,17 @@ gfxFcFontSet::GetFontPatternAt(uint32_t 
                 // allocating a new CharSet with Union.
                 FcCharSet *supportedChars = mCharSet;
                 if (!supportedChars) {
                     FcPatternGetCharSet(mFonts[mFonts.Length() - 1].mPattern,
                                         FC_CHARSET, 0, &supportedChars);
                 }
 
                 if (supportedChars) {
-                    FcCharSet *newChars = NULL;
+                    FcCharSet *newChars = nullptr;
                     FcPatternGetCharSet(font, FC_CHARSET, 0, &newChars);
                     if (newChars) {
                         if (FcCharSetIsSubset(newChars, supportedChars))
                             continue;
 
                         mCharSet.own(FcCharSetUnion(supportedChars, newChars));
                     } else if (!mCharSet) {
                         mCharSet.own(FcCharSetCopy(supportedChars));
@@ -1209,17 +1216,17 @@ gfxFcFontSet::GetFontPatternAt(uint32_t 
 static void ApplyGdkScreenFontOptions(FcPattern *aPattern);
 #endif
 
 // Apply user settings and defaults to pattern in preparation for matching.
 static void
 PrepareSortPattern(FcPattern *aPattern, double aFallbackSize,
                    double aSizeAdjustFactor, bool aIsPrinterFont)
 {
-    FcConfigSubstitute(NULL, aPattern, FcMatchPattern);
+    FcConfigSubstitute(nullptr, aPattern, FcMatchPattern);
 
     // This gets cairo_font_options_t for the Screen.  We should have
     // different font options for printing (no hinting) but we are not told
     // what we are measuring for.
     //
     // If cairo adds support for lcd_filter, gdk will not provide the default
     // setting for that option.  We could get the default setting by creating
     // an xlib surface once, recording its font_options, and then merging the
@@ -1548,17 +1555,17 @@ gfxPangoFontGroup::FindFontForChar(uint3
     //
     //   2. For system fonts, use the default Pango behavior to give
     //      consistency with other apps.  This is relevant when un-localized
     //      builds are run in non-Latin locales.  This special-case probably
     //      wouldn't be necessary but for bug 91190.
 
     gfxFcFontSet *fontSet = GetBaseFontSet();
     uint32_t nextFont = 0;
-    FcPattern *basePattern = NULL;
+    FcPattern *basePattern = nullptr;
     if (!mStyle.systemFont && mPangoLanguage) {
         basePattern = fontSet->GetFontPatternAt(0);
         if (HasChar(basePattern, aCh)) {
             *aMatchType = gfxTextRange::kFontGroup;
             return nsRefPtr<gfxFont>(GetBaseFont()).forget();
         }
 
         nextFont = 1;
@@ -1612,22 +1619,25 @@ CHECK_SCRIPT_CODE(NKO);
 
 cairo_user_data_key_t gfxFcFont::sGfxFontKey;
 
 gfxFcFont::gfxFcFont(cairo_scaled_font_t *aCairoFont,
                      gfxFcFontEntry *aFontEntry,
                      const gfxFontStyle *aFontStyle)
     : gfxFT2FontBase(aCairoFont, aFontEntry, aFontStyle)
 {
-    cairo_scaled_font_set_user_data(mScaledFont, &sGfxFontKey, this, NULL);
+    cairo_scaled_font_set_user_data(mScaledFont, &sGfxFontKey, this, nullptr);
 }
 
 gfxFcFont::~gfxFcFont()
 {
-    cairo_scaled_font_set_user_data(mScaledFont, &sGfxFontKey, NULL, NULL);
+    cairo_scaled_font_set_user_data(mScaledFont,
+                                    &sGfxFontKey,
+                                    nullptr,
+                                    nullptr);
 }
 
 bool
 gfxFcFont::ShapeText(gfxContext      *aContext,
                      const PRUnichar *aText,
                      uint32_t         aOffset,
                      uint32_t         aLength,
                      int32_t          aScript,
@@ -1664,17 +1674,17 @@ gfxFcFont::ShapeText(gfxContext      *aC
     return ok;
 }
 
 /* static */ void
 gfxPangoFontGroup::Shutdown()
 {
     // Resetting gFTLibrary in case this is wanted again after a
     // cairo_debug_reset_static_data.
-    gFTLibrary = NULL;
+    gFTLibrary = nullptr;
 }
 
 /* static */ gfxFontEntry *
 gfxPangoFontGroup::NewFontEntry(const gfxProxyFontEntry &aProxyEntry,
                                 const nsAString& aFullname)
 {
     gfxFontconfigUtils *utils = gfxFontconfigUtils::GetFontconfigUtils();
     if (!utils)
@@ -1699,17 +1709,17 @@ gfxPangoFontGroup::NewFontEntry(const gf
 
     nsAutoRef<FcPattern> pattern(FcPatternCreate());
     if (!pattern)
         return nullptr;
 
     NS_ConvertUTF16toUTF8 fullname(aFullname);
     FcPatternAddString(pattern, FC_FULLNAME,
                        gfxFontconfigUtils::ToFcChar8(fullname));
-    FcConfigSubstitute(NULL, pattern, FcMatchPattern);
+    FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
 
     FcChar8 *name;
     for (int v = 0;
          FcPatternGetString(pattern, FC_FULLNAME, v, &name) == FcResultMatch;
          ++v) {
         const nsTArray< nsCountedRef<FcPattern> >& fonts =
             utils->GetFontsForFullname(name);
 
@@ -1734,37 +1744,37 @@ gfxPangoFontGroup::GetFTLibrary()
         // likely to be also used elsewhere.
         gfxFontStyle style;
         nsRefPtr<gfxPangoFontGroup> fontGroup =
             new gfxPangoFontGroup(NS_LITERAL_STRING("sans-serif"),
                                   &style, nullptr);
 
         gfxFcFont *font = fontGroup->GetBaseFont();
         if (!font)
-            return NULL;
+            return nullptr;
 
         gfxFT2LockedFace face(font);
         if (!face.get())
-            return NULL;
+            return nullptr;
 
         gFTLibrary = face.get()->glyph->library;
     }
 
     return gFTLibrary;
 }
 
 /* static */ gfxFontEntry *
 gfxPangoFontGroup::NewFontEntry(const gfxProxyFontEntry &aProxyEntry,
                                 const uint8_t *aFontData, uint32_t aLength)
 {
     // Ownership of aFontData is passed in here, and transferred to the
     // new fontEntry, which will release it when no longer needed.
 
     // Using face_index = 0 for the first face in the font, as we have no
-    // other information.  FT_New_Memory_Face checks for a NULL FT_Library.
+    // other information.  FT_New_Memory_Face checks for a nullptr FT_Library.
     FT_Face face;
     FT_Error error =
         FT_New_Memory_Face(GetFTLibrary(), aFontData, aLength, 0, &face);
     if (error != 0) {
         NS_Free((void*)aFontData);
         return nullptr;
     }
 
@@ -1798,17 +1808,17 @@ GetPixelSize(FcPattern *aPattern)
  */
 
 /* static */
 already_AddRefed<gfxFcFont>
 gfxFcFont::GetOrMakeFont(FcPattern *aRequestedPattern, FcPattern *aFontPattern,
                          const gfxFontStyle *aFontStyle)
 {
     nsAutoRef<FcPattern> renderPattern
-        (FcFontRenderPrepare(NULL, aRequestedPattern, aFontPattern));
+        (FcFontRenderPrepare(nullptr, aRequestedPattern, aFontPattern));
     cairo_font_face_t *face =
         cairo_ft_font_face_create_for_pattern(renderPattern);
 
     // Reuse an existing font entry if available.
     nsRefPtr<gfxFcFontEntry> fe = gfxFcFontEntry::LookupFontEntry(face);
     if (!fe) {
         gfxDownloadedFcFontEntry *downloadedFontEntry =
             GetDownloadedFontEntry(aFontPattern);
@@ -2120,24 +2130,24 @@ CreateScaledFont(FcPattern *aPattern, ca
     return scaledFont;
 }
 
 /* static */
 PangoLanguage *
 GuessPangoLanguage(nsIAtom *aLanguage)
 {
     if (!aLanguage)
-        return NULL;
+        return nullptr;
 
     // Pango and fontconfig won't understand mozilla's internal langGroups, so
     // find a real language.
     nsAutoCString lang;
     gfxFontconfigUtils::GetSampleLangForGroup(aLanguage, &lang);
     if (lang.IsEmpty())
-        return NULL;
+        return nullptr;
 
     return pango_language_from_string(lang.get());
 }
 
 #ifdef MOZ_WIDGET_GTK
 /***************************************************************************
  *
  * This function must be last in the file because it uses the system cairo
--- a/gfx/thebes/gfxPangoFonts.h
+++ b/gfx/thebes/gfxPangoFonts.h
@@ -47,19 +47,20 @@ public:
                                       const nsAString &aFullname);
     // Used for @font-face { src: url(); }
     static gfxFontEntry *NewFontEntry(const gfxProxyFontEntry &aProxyEntry,
                                       const uint8_t *aFontData,
                                       uint32_t aLength);
 
 private:
     // @param aLang [in] language to use for pref fonts and system default font
-    //        selection, or NULL for the language guessed from the gfxFontStyle.
+    //        selection, or nullptr for the language guessed from the
+    //        gfxFontStyle.
     // The FontGroup holds a reference to this set.
-    gfxFcFontSet *GetFontSet(PangoLanguage *aLang = NULL);
+    gfxFcFontSet *GetFontSet(PangoLanguage *aLang = nullptr);
 
     class FontSetByLangEntry {
     public:
         FontSetByLangEntry(PangoLanguage *aLang, gfxFcFontSet *aFontSet);
         PangoLanguage *mLang;
         nsRefPtr<gfxFcFontSet> mFontSet;
     };
     // There is only one of entry in this array unless characters from scripts
@@ -68,21 +69,21 @@ private:
 
     gfxFloat mSizeAdjustFactor;
     PangoLanguage *mPangoLanguage;
 
     void GetFcFamilies(nsTArray<nsString> *aFcFamilyList,
                        nsIAtom *aLanguage);
 
     // @param aLang [in] language to use for pref fonts and system font
-    //        resolution, or NULL to guess a language from the gfxFontStyle.
-    // @param aMatchPattern [out] if non-NULL, will return the pattern used.
+    //        resolution, or nullptr to guess a language from the gfxFontStyle.
+    // @param aMatchPattern [out] if non-nullptr, will return the pattern used.
     already_AddRefed<gfxFcFontSet>
     MakeFontSet(PangoLanguage *aLang, gfxFloat aSizeAdjustFactor,
-                nsAutoRef<FcPattern> *aMatchPattern = NULL);
+                nsAutoRef<FcPattern> *aMatchPattern = nullptr);
 
     gfxFcFontSet *GetBaseFontSet();
     gfxFcFont *GetBaseFont();
 
     gfxFloat GetSizeAdjustFactor()
     {
         if (mFontSets.Length() == 0)
             GetBaseFontSet();
--- a/gfx/thebes/gfxPattern.cpp
+++ b/gfx/thebes/gfxPattern.cpp
@@ -10,54 +10,54 @@
 
 #include "cairo.h"
 
 #include <vector>
 
 using namespace mozilla::gfx;
 
 gfxPattern::gfxPattern(cairo_pattern_t *aPattern)
-  : mGfxPattern(NULL)
+  : mGfxPattern(nullptr)
 {
     mPattern = cairo_pattern_reference(aPattern);
 }
 
 gfxPattern::gfxPattern(const gfxRGBA& aColor)
-  : mGfxPattern(NULL)
+  : mGfxPattern(nullptr)
 {
     mPattern = cairo_pattern_create_rgba(aColor.r, aColor.g, aColor.b, aColor.a);
 }
 
 // from another surface
 gfxPattern::gfxPattern(gfxASurface *surface)
-  : mGfxPattern(NULL)
+  : mGfxPattern(nullptr)
 {
     mPattern = cairo_pattern_create_for_surface(surface->CairoSurface());
 }
 
 // linear
 gfxPattern::gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1)
-  : mGfxPattern(NULL)
+  : mGfxPattern(nullptr)
 {
     mPattern = cairo_pattern_create_linear(x0, y0, x1, y1);
 }
 
 // radial
 gfxPattern::gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0,
                        gfxFloat cx1, gfxFloat cy1, gfxFloat radius1)
-  : mGfxPattern(NULL)
+  : mGfxPattern(nullptr)
 {
     mPattern = cairo_pattern_create_radial(cx0, cy0, radius0,
                                            cx1, cy1, radius1);
 }
 
 // Azure
 gfxPattern::gfxPattern(SourceSurface *aSurface, const Matrix &aTransform)
-  : mPattern(NULL)
-  , mGfxPattern(NULL)
+  : mPattern(nullptr)
+  , mGfxPattern(nullptr)
   , mSourceSurface(aSurface)
   , mTransform(aTransform)
   , mExtend(EXTEND_NONE)
 {
 }
 
 gfxPattern::~gfxPattern()
 {
@@ -73,17 +73,17 @@ gfxPattern::CairoPattern()
 {
     return mPattern;
 }
 
 void
 gfxPattern::AddColorStop(gfxFloat offset, const gfxRGBA& c)
 {
   if (mPattern) {
-    mStops = NULL;
+    mStops = nullptr;
     if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
         gfxRGBA cms;
         qcms_transform *transform = gfxPlatform::GetCMSRGBTransform();
         if (transform)
           gfxPlatform::TransformPixel(c, cms, transform);
 
         // Use the original alpha to avoid unnecessary float->byte->float
         // conversion errors
@@ -172,17 +172,17 @@ gfxPattern::GetPattern(DrawTarget *aTarg
     }
   case CAIRO_PATTERN_TYPE_SURFACE:
     {
       GraphicsFilter filter = (GraphicsFilter)cairo_pattern_get_filter(mPattern);
       cairo_matrix_t mat;
       cairo_pattern_get_matrix(mPattern, &mat);
       gfxMatrix matrix(*reinterpret_cast<gfxMatrix*>(&mat));
 
-      cairo_surface_t *surf = NULL;
+      cairo_surface_t *surf = nullptr;
       cairo_pattern_get_surface(mPattern, &surf);
 
       if (!mSourceSurface) {
         nsRefPtr<gfxASurface> gfxSurf = gfxASurface::Wrap(surf);
         // The underlying surface here will be kept around by the gfxPattern.
         // This function is intended to be used right away.
         mSourceSurface =
           gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(aTarget, gfxSurf);
@@ -288,20 +288,20 @@ gfxPattern::GetPattern(DrawTarget *aTarg
   new (mColorPattern.addr()) ColorPattern(Color(0, 0, 0, 0));
   return mColorPattern.addr();
 }
 
 void
 gfxPattern::SetExtend(GraphicsExtend extend)
 {
   if (mPattern) {
-    mStops = NULL;
+    mStops = nullptr;
     if (extend == EXTEND_PAD_EDGE) {
         if (cairo_pattern_get_type(mPattern) == CAIRO_PATTERN_TYPE_SURFACE) {
-            cairo_surface_t *surf = NULL;
+            cairo_surface_t *surf = nullptr;
 
             cairo_pattern_get_surface (mPattern, &surf);
             if (surf) {
                 switch (cairo_surface_get_type(surf)) {
                     case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
                     case CAIRO_SURFACE_TYPE_QUARTZ:
                         extend = EXTEND_NONE;
                         break;
@@ -330,17 +330,17 @@ gfxPattern::SetExtend(GraphicsExtend ext
 
 bool
 gfxPattern::IsOpaque()
 {
   if (mPattern) {
     switch (cairo_pattern_get_type(mPattern)) {
     case CAIRO_PATTERN_TYPE_SURFACE:
       {
-        cairo_surface_t *surf = NULL;
+        cairo_surface_t *surf = nullptr;
         cairo_pattern_get_surface(mPattern, &surf);
 
         if (cairo_surface_get_content(surf) == CAIRO_CONTENT_COLOR) {
           return true;
         }
       }
     default:
       return false;
--- a/gfx/thebes/gfxPattern.h
+++ b/gfx/thebes/gfxPattern.h
@@ -40,17 +40,17 @@ public:
     void SetColorStops(mozilla::RefPtr<mozilla::gfx::GradientStops> aStops);
 
     void SetMatrix(const gfxMatrix& matrix);
     gfxMatrix GetMatrix() const;
     gfxMatrix GetInverseMatrix() const;
 
     /* Get an Azure Pattern for the current Cairo pattern. aPattern transform
      * specifies the transform that was set on the DrawTarget when the pattern
-     * was set. When this is NULL it is assumed the transform is identical
+     * was set. When this is nullptr it is assumed the transform is identical
      * to the current transform.
      */
     mozilla::gfx::Pattern *GetPattern(mozilla::gfx::DrawTarget *aTarget,
                                       mozilla::gfx::Matrix *aPatternTransform = nullptr);
     bool IsOpaque();
 
     enum GraphicsExtend {
         EXTEND_NONE,
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -551,17 +551,17 @@ gfxPlatform::OptimizeImage(gfxImageSurfa
 }
 
 cairo_user_data_key_t kDrawTarget;
 
 RefPtr<DrawTarget>
 gfxPlatform::CreateDrawTargetForSurface(gfxASurface *aSurface, const IntSize& aSize)
 {
   RefPtr<DrawTarget> drawTarget = Factory::CreateDrawTargetForCairoSurface(aSurface->CairoSurface(), aSize);
-  aSurface->SetData(&kDrawTarget, drawTarget, NULL);
+  aSurface->SetData(&kDrawTarget, drawTarget, nullptr);
   return drawTarget;
 }
 
 // This is a temporary function used by ContentClient to build a DrawTarget
 // around the gfxASurface. This should eventually be replaced by plumbing
 // the DrawTarget through directly
 RefPtr<DrawTarget>
 gfxPlatform::CreateDrawTargetForUpdateSurface(gfxASurface *aSurface, const IntSize& aSize)
@@ -599,23 +599,23 @@ void SourceBufferDestroy(void *srcSurfUD
 }
 
 #if MOZ_TREE_CAIRO
 void SourceSnapshotDetached(cairo_surface_t *nullSurf)
 {
   gfxImageSurface* origSurf =
     static_cast<gfxImageSurface*>(cairo_surface_get_user_data(nullSurf, &kSourceSurface));
 
-  origSurf->SetData(&kSourceSurface, NULL, NULL);
+  origSurf->SetData(&kSourceSurface, nullptr, nullptr);
 }
 #else
 void SourceSnapshotDetached(void *nullSurf)
 {
   gfxImageSurface* origSurf = static_cast<gfxImageSurface*>(nullSurf);
-  origSurf->SetData(&kSourceSurface, NULL, NULL);
+  origSurf->SetData(&kSourceSurface, nullptr, nullptr);
 }
 #endif
 
 void
 gfxPlatform::ClearSourceSurfaceForSurface(gfxASurface *aSurface)
 {
   aSurface->SetData(&kSourceSurface, nullptr, nullptr);
 }
@@ -733,17 +733,17 @@ gfxPlatform::GetSourceSurfaceForSurface(
     }
 
 #if MOZ_TREE_CAIRO
     cairo_surface_t *nullSurf =
 	cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
     cairo_surface_set_user_data(nullSurf,
                                 &kSourceSurface,
                                 imgSurface,
-                                NULL);
+                                nullptr);
     cairo_surface_attach_snapshot(imgSurface->CairoSurface(), nullSurf, SourceSnapshotDetached);
     cairo_surface_destroy(nullSurf);
 #else
     cairo_surface_set_mime_data(imgSurface->CairoSurface(), "mozilla/magic", (const unsigned char*) "data", 4, SourceSnapshotDetached, imgSurface.get());
 #endif
   }
 
   SourceSurfaceUserData *srcSurfUD = new SourceSurfaceUserData;
@@ -844,17 +844,17 @@ gfxPlatform::CreateDrawTargetForBackend(
   // mozilla::gfx::Factory can get away without having all this knowledge for
   // now, but this might need to change in the future (using
   // CreateOffscreenSurface() and CreateDrawTargetForSurface() for all
   // backends).
   if (aBackend == BACKEND_CAIRO) {
     nsRefPtr<gfxASurface> surf = CreateOffscreenSurface(ThebesIntSize(aSize),
                                                         ContentForFormat(aFormat));
     if (!surf || surf->CairoStatus()) {
-      return NULL;
+      return nullptr;
     }
 
     return CreateDrawTargetForSurface(surf, aSize);
   } else {
     return Factory::CreateDrawTarget(aBackend, aSize, aFormat);
   }
 }
 
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -488,17 +488,17 @@ public:
      *
      * See bug 444014 for details.
      */
     static int GetRenderingIntent();
 
     /**
      * Convert a pixel using a cms transform in an endian-aware manner.
      *
-     * Sets 'out' to 'in' if transform is NULL.
+     * Sets 'out' to 'in' if transform is nullptr.
      */
     static void TransformPixel(const gfxRGBA& in, gfxRGBA& out, qcms_transform *transform);
 
     /**
      * Return the output device ICC profile.
      */
     static qcms_profile* GetCMSOutputProfile();
 
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -54,21 +54,21 @@ using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::unicode;
 
 gfxFontconfigUtils *gfxPlatformGtk::sFontconfigUtils = nullptr;
 
 #ifndef MOZ_PANGO
 typedef nsDataHashtable<nsStringHashKey, nsRefPtr<FontFamily> > FontTable;
 typedef nsDataHashtable<nsCStringHashKey, nsTArray<nsRefPtr<gfxFontEntry> > > PrefFontTable;
-static FontTable *gPlatformFonts = NULL;
-static FontTable *gPlatformFontAliases = NULL;
-static PrefFontTable *gPrefFonts = NULL;
-static gfxSparseBitSet *gCodepointsWithNoFonts = NULL;
-static FT_Library gPlatformFTLibrary = NULL;
+static FontTable *gPlatformFonts = nullptr;
+static FontTable *gPlatformFontAliases = nullptr;
+static PrefFontTable *gPrefFonts = nullptr;
+static gfxSparseBitSet *gCodepointsWithNoFonts = nullptr;
+static FT_Library gPlatformFTLibrary = nullptr;
 #endif
 
 static cairo_user_data_key_t cairo_gdk_drawable_key;
 
 #ifdef MOZ_X11
     bool gfxPlatformGtk::sUseXRender = true;
 #endif
 
@@ -100,32 +100,32 @@ gfxPlatformGtk::~gfxPlatformGtk()
 {
     gfxFontconfigUtils::Shutdown();
     sFontconfigUtils = nullptr;
 
 #ifdef MOZ_PANGO
     gfxPangoFontGroup::Shutdown();
 #else
     delete gPlatformFonts;
-    gPlatformFonts = NULL;
+    gPlatformFonts = nullptr;
     delete gPlatformFontAliases;
-    gPlatformFontAliases = NULL;
+    gPlatformFontAliases = nullptr;
     delete gPrefFonts;
-    gPrefFonts = NULL;
+    gPrefFonts = nullptr;
     delete gCodepointsWithNoFonts;
-    gCodepointsWithNoFonts = NULL;
+    gCodepointsWithNoFonts = nullptr;
 
 #ifdef NS_FREE_PERMANENT_DATA
     // do cairo cleanup *before* closing down the FTLibrary,
     // otherwise we'll crash when the gfxPlatform destructor
     // calls it (bug 605009)
     cairo_debug_reset_static_data();
 
     FT_Done_FreeType(gPlatformFTLibrary);
-    gPlatformFTLibrary = NULL;
+    gPlatformFTLibrary = nullptr;
 #endif
 #endif
 
 #if 0
     // It would be nice to do this (although it might need to be after
     // the cairo shutdown that happens in ~gfxPlatform).  It even looks
     // idempotent.  But it has fatal assertions that fire if stuff is
     // leaked, and we hit them.
@@ -278,25 +278,25 @@ gfxPlatformGtk::GetFontList(nsIAtom *aLa
 {
     return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
                                          aListOfFonts);
 }
 
 nsresult
 gfxPlatformGtk::UpdateFontList()
 {
-    FcPattern *pat = NULL;
-    FcObjectSet *os = NULL;
-    FcFontSet *fs = NULL;
+    FcPattern *pat = nullptr;
+    FcObjectSet *os = nullptr;
+    FcFontSet *fs = nullptr;
     int32_t result = -1;
 
     pat = FcPatternCreate();
-    os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, FC_WEIGHT, FC_SLANT, FC_WIDTH, NULL);
+    os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, FC_WEIGHT, FC_SLANT, FC_WIDTH, nullptr);
 
-    fs = FcFontList(NULL, pat, os);
+    fs = FcFontList(nullptr, pat, os);
 
 
     for (int i = 0; i < fs->nfont; i++) {
         char *str;
 
         if (FcPatternGetString(fs->fonts[i], FC_FAMILY, 0, (FcChar8 **) &str) != FcResultMatch)
             continue;
 
@@ -371,18 +371,18 @@ gfxPlatformGtk::ResolveFontName(const ns
         aAborted = !(*aCallback)(ff->Name(), aClosure);
         return NS_OK;
     }
 
     nsAutoCString utf8Name = NS_ConvertUTF16toUTF8(aFontName);
 
     FcPattern *npat = FcPatternCreate();
     FcPatternAddString(npat, FC_FAMILY, (FcChar8*)utf8Name.get());
-    FcObjectSet *nos = FcObjectSetBuild(FC_FAMILY, NULL);
-    FcFontSet *nfs = FcFontList(NULL, npat, nos);
+    FcObjectSet *nos = FcObjectSetBuild(FC_FAMILY, nullptr);
+    FcFontSet *nfs = FcFontList(nullptr, npat, nos);
 
     for (int k = 0; k < nfs->nfont; k++) {
         FcChar8 *str;
         if (FcPatternGetString(nfs->fonts[k], FC_FAMILY, 0, (FcChar8 **) &str) != FcResultMatch)
             continue;
         nsAutoString altName = NS_ConvertUTF8toUTF16(nsDependentCString(reinterpret_cast<char*>(str)));
         ToLowerCase(altName);
         if (gPlatformFonts->Get(altName, &ff)) {
@@ -396,25 +396,25 @@ gfxPlatformGtk::ResolveFontName(const ns
     FcPatternDestroy(npat);
     FcObjectSetDestroy(nos);
     FcFontSetDestroy(nfs);
 
     {
     npat = FcPatternCreate();
     FcPatternAddString(npat, FC_FAMILY, (FcChar8*)utf8Name.get());
     FcPatternDel(npat, FC_LANG);
-    FcConfigSubstitute(NULL, npat, FcMatchPattern);
+    FcConfigSubstitute(nullptr, npat, FcMatchPattern);
     FcDefaultSubstitute(npat);
 
-    nos = FcObjectSetBuild(FC_FAMILY, NULL);
-    nfs = FcFontList(NULL, npat, nos);
+    nos = FcObjectSetBuild(FC_FAMILY, nullptr);
+    nfs = FcFontList(nullptr, npat, nos);
 
     FcResult fresult;
 
-    FcPattern *match = FcFontMatch(NULL, npat, &fresult);
+    FcPattern *match = FcFontMatch(nullptr, npat, &fresult);
     if (match)
         FcFontSetAdd(nfs, match);
 
     for (int k = 0; k < nfs->nfont; k++) {
         FcChar8 *str;
         if (FcPatternGetString(nfs->fonts[k], FC_FAMILY, 0, (FcChar8 **) &str) != FcResultMatch)
             continue;
         nsAutoString altName = NS_ConvertUTF8toUTF16(nsDependentCString(reinterpret_cast<char*>(str)));
@@ -516,19 +516,19 @@ gfxPlatformGtk::GetPlatformCMSOutputProf
 #ifdef MOZ_X11
     const char EDID1_ATOM_NAME[] = "XFree86_DDC_EDID1_RAWDATA";
     const char ICC_PROFILE_ATOM_NAME[] = "_ICC_PROFILE";
 
     Atom edidAtom, iccAtom;
     Display *dpy = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
     // In xpcshell tests, we never initialize X and hence don't have a Display.
     // In this case, there's no output colour management to be done, so we just
-    // return NULL.
+    // return nullptr.
     if (!dpy) {
-        return NULL;
+        return nullptr;
     }
 
     Window root = gdk_x11_get_default_root_xwindow();
 
     Atom retAtom;
     int retFormat;
     unsigned long retLength, retAfter;
     unsigned char *retProperty ;
@@ -536,17 +536,17 @@ gfxPlatformGtk::GetPlatformCMSOutputProf
     iccAtom = XInternAtom(dpy, ICC_PROFILE_ATOM_NAME, TRUE);
     if (iccAtom) {
         // read once to get size, once for the data
         if (Success == XGetWindowProperty(dpy, root, iccAtom,
                                           0, INT_MAX /* length */,
                                           False, AnyPropertyType,
                                           &retAtom, &retFormat, &retLength,
                                           &retAfter, &retProperty)) {
-            qcms_profile* profile = NULL;
+            qcms_profile* profile = nullptr;
 
             if (retLength > 0)
                 profile = qcms_profile_from_memory(retProperty, retLength);
 
             XFree(retProperty);
 
             if (profile) {
 #ifdef DEBUG_tor
@@ -734,49 +734,49 @@ gfxPlatformGtk::SetGdkDrawable(gfxASurfa
                                  drawable,
                                  g_object_unref);
 }
 
 GdkDrawable *
 gfxPlatformGtk::GetGdkDrawable(gfxASurface *target)
 {
     if (target->CairoStatus())
-        return NULL;
+        return nullptr;
 
     GdkDrawable *result;
 
     result = (GdkDrawable*) cairo_surface_get_user_data (target->CairoSurface(),
                                                          &cairo_gdk_drawable_key);
     if (result)
         return result;
 
 #ifdef MOZ_X11
     if (target->GetType() != gfxASurface::SurfaceTypeXlib)
-        return NULL;
+        return nullptr;
 
     gfxXlibSurface *xs = static_cast<gfxXlibSurface*>(target);
 
     // try looking it up in gdk's table
     result = (GdkDrawable*) gdk_xid_table_lookup(xs->XDrawable());
     if (result) {
         SetGdkDrawable(target, result);
         return result;
     }
 #endif
 
-    return NULL;
+    return nullptr;
 }
 #endif
 
 TemporaryRef<ScaledFont>
 gfxPlatformGtk::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
 {
     NativeFont nativeFont;
 
     if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) {
         nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE;
         nativeFont.mFont = aFont->GetCairoScaledFont();
         return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
     }
 
-    return NULL;
+    return nullptr;
 
 }
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -37,17 +37,17 @@ typedef uint32_t AutoActivationSetting;
 
 // bug 567552 - disable auto-activation of fonts
 
 static void 
 DisableFontActivation()
 {
     // get the main bundle identifier
     CFBundleRef mainBundle = ::CFBundleGetMainBundle();
-    CFStringRef mainBundleID = NULL;
+    CFStringRef mainBundleID = nullptr;
 
     if (mainBundle) {
         mainBundleID = ::CFBundleGetIdentifier(mainBundle);
     }
 
     // if possible, fetch CTFontManagerSetAutoActivationSetting
     void (*CTFontManagerSetAutoActivationSettingPtr)
             (CFStringRef, AutoActivationSetting);
@@ -465,17 +465,17 @@ gfxPlatformMac::GetPlatformCMSOutputProf
        corresponds directly to a CGSDisplayID */
     CGDirectDisplayID displayID = CGMainDisplayID();
 
     CMError err = CMGetProfileByAVID(static_cast<CMDisplayIDType>(displayID), &cmProfile);
     if (err != noErr)
         return nullptr;
 
     // get the size of location
-    err = NCMGetProfileLocation(cmProfile, NULL, &locationSize);
+    err = NCMGetProfileLocation(cmProfile, nullptr, &locationSize);
     if (err != noErr)
         return nullptr;
 
     // allocate enough room for location
     location = static_cast<CMProfileLocation*>(malloc(locationSize));
     if (!location)
         goto fail_close;
 
--- a/gfx/thebes/gfxQtNativeRenderer.cpp
+++ b/gfx/thebes/gfxQtNativeRenderer.cpp
@@ -33,17 +33,17 @@ gfxQtNativeRenderer::Draw(gfxContext* ct
                                gfxIntSize(size.width, size.height));
 
     if (!isOpaque) {
         nsRefPtr<gfxContext> tempCtx = new gfxContext(xsurf);
         tempCtx->SetOperator(gfxContext::OPERATOR_CLEAR);
         tempCtx->Paint();
     }
 
-    nsresult rv = DrawWithXlib(xsurf.get(), nsIntPoint(0, 0), NULL, 0);
+    nsresult rv = DrawWithXlib(xsurf.get(), nsIntPoint(0, 0), nullptr, 0);
 
     if (NS_FAILED(rv))
         return rv;
 
     ctx->SetSource(xsurf);
     ctx->Paint();
 
     return rv;
--- a/gfx/thebes/gfxQtPlatform.cpp
+++ b/gfx/thebes/gfxQtPlatform.cpp
@@ -73,21 +73,21 @@ static void do_qt_pixmap_unref (void *da
     delete pmap;
 }
 
 static gfxImageFormat sOffscreenFormat = gfxASurface::ImageFormatRGB24;
 
 #ifndef MOZ_PANGO
 typedef nsDataHashtable<nsStringHashKey, nsRefPtr<FontFamily> > FontTable;
 typedef nsDataHashtable<nsCStringHashKey, nsTArray<nsRefPtr<FontEntry> > > PrefFontTable;
-static FontTable *gPlatformFonts = NULL;
-static FontTable *gPlatformFontAliases = NULL;
-static PrefFontTable *gPrefFonts = NULL;
-static gfxSparseBitSet *gCodepointsWithNoFonts = NULL;
-static FT_Library gPlatformFTLibrary = NULL;
+static FontTable *gPlatformFonts = nullptr;
+static FontTable *gPlatformFontAliases = nullptr;
+static PrefFontTable *gPrefFonts = nullptr;
+static gfxSparseBitSet *gCodepointsWithNoFonts = nullptr;
+static FT_Library gPlatformFTLibrary = nullptr;
 #endif
 
 gfxQtPlatform::gfxQtPlatform()
 {
     mPrefFonts.Init(50);
 
     if (!sFontconfigUtils)
         sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
@@ -147,28 +147,28 @@ gfxQtPlatform::~gfxQtPlatform()
 {
     gfxFontconfigUtils::Shutdown();
     sFontconfigUtils = nullptr;
 
 #ifdef MOZ_PANGO
     gfxPangoFontGroup::Shutdown();
 #else
     delete gPlatformFonts;
-    gPlatformFonts = NULL;
+    gPlatformFonts = nullptr;
     delete gPlatformFontAliases;
-    gPlatformFontAliases = NULL;
+    gPlatformFontAliases = nullptr;
     delete gPrefFonts;
-    gPrefFonts = NULL;
+    gPrefFonts = nullptr;
     delete gCodepointsWithNoFonts;
-    gCodepointsWithNoFonts = NULL;
+    gCodepointsWithNoFonts = nullptr;
 
     cairo_debug_reset_static_data();
 
     FT_Done_FreeType(gPlatformFTLibrary);
-    gPlatformFTLibrary = NULL;
+    gPlatformFTLibrary = nullptr;
 #endif
 
 #if 0
     // It would be nice to do this (although it might need to be after
     // the cairo shutdown that happens in ~gfxPlatform).  It even looks
     // idempotent.  But it has fatal assertions that fire if stuff is
     // leaked, and we hit them.
     FcFini();
@@ -255,24 +255,24 @@ gfxQtPlatform::GetFontList(nsIAtom *aLan
     return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
                                          aListOfFonts);
 }
 
 nsresult
 gfxQtPlatform::UpdateFontList()
 {
 #ifndef MOZ_PANGO
-    FcPattern *pat = NULL;
-    FcObjectSet *os = NULL;
-    FcFontSet *fs = NULL;
+    FcPattern *pat = nullptr;
+    FcObjectSet *os = nullptr;
+    FcFontSet *fs = nullptr;
 
     pat = FcPatternCreate();
-    os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, FC_WEIGHT, FC_SLANT, FC_WIDTH, NULL);
+    os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, FC_WEIGHT, FC_SLANT, FC_WIDTH, nullptr);
 
-    fs = FcFontList(NULL, pat, os);
+    fs = FcFontList(nullptr, pat, os);
 
 
     for (int i = 0; i < fs->nfont; i++) {
         char *str;
 
         if (FcPatternGetString(fs->fonts[i], FC_FAMILY, 0, (FcChar8 **) &str) != FcResultMatch)
             continue;
 
@@ -378,18 +378,18 @@ gfxQtPlatform::ResolveFontName(const nsA
         aAborted = !(*aCallback)(ff->Name(), aClosure);
         return NS_OK;
     }
 
     nsAutoCString utf8Name = NS_ConvertUTF16toUTF8(aFontName);
 
     FcPattern *npat = FcPatternCreate();
     FcPatternAddString(npat, FC_FAMILY, (FcChar8*)utf8Name.get());
-    FcObjectSet *nos = FcObjectSetBuild(FC_FAMILY, NULL);
-    FcFontSet *nfs = FcFontList(NULL, npat, nos);
+    FcObjectSet *nos = FcObjectSetBuild(FC_FAMILY, nullptr);
+    FcFontSet *nfs = FcFontList(nullptr, npat, nos);
 
     for (int k = 0; k < nfs->nfont; k++) {
         FcChar8 *str;
         if (FcPatternGetString(nfs->fonts[k], FC_FAMILY, 0, (FcChar8 **) &str) != FcResultMatch)
             continue;
         nsAutoString altName = NS_ConvertUTF8toUTF16(nsDependentCString(reinterpret_cast<char*>(str)));
         ToLowerCase(altName);
         if (gPlatformFonts->Get(altName, &ff)) {
@@ -402,25 +402,25 @@ gfxQtPlatform::ResolveFontName(const nsA
     FcPatternDestroy(npat);
     FcObjectSetDestroy(nos);
     FcFontSetDestroy(nfs);
 
     {
     npat = FcPatternCreate();
     FcPatternAddString(npat, FC_FAMILY, (FcChar8*)utf8Name.get());
     FcPatternDel(npat, FC_LANG);
-    FcConfigSubstitute(NULL, npat, FcMatchPattern);
+    FcConfigSubstitute(nullptr, npat, FcMatchPattern);
     FcDefaultSubstitute(npat);
 
-    nos = FcObjectSetBuild(FC_FAMILY, NULL);
-    nfs = FcFontList(NULL, npat, nos);
+    nos = FcObjectSetBuild(FC_FAMILY, nullptr);
+    nfs = FcFontList(nullptr, npat, nos);
 
     FcResult fresult;
 
-    FcPattern *match = FcFontMatch(NULL, npat, &fresult);
+    FcPattern *match = FcFontMatch(nullptr, npat, &fresult);
     if (match)
         FcFontSetAdd(nfs, match);
 
     for (int k = 0; k < nfs->nfont; k++) {
         FcChar8 *str;
         if (FcPatternGetString(nfs->fonts[k], FC_FAMILY, 0, (FcChar8 **) &str) != FcResultMatch)
             continue;
         nsAutoString altName = NS_ConvertUTF8toUTF16(nsDependentCString(reinterpret_cast<char*>(str)));
--- a/gfx/thebes/gfxQuartzImageSurface.cpp
+++ b/gfx/thebes/gfxQuartzImageSurface.cpp
@@ -5,17 +5,17 @@
 
 #include "gfxQuartzImageSurface.h"
 
 #include "cairo-quartz.h"
 #include "cairo-quartz-image.h"
 
 gfxQuartzImageSurface::gfxQuartzImageSurface(gfxImageSurface *imageSurface)
 {
-    if (imageSurface->CairoSurface() == NULL)
+    if (imageSurface->CairoSurface() == nullptr)
         return;
 
     cairo_surface_t *surf = cairo_quartz_image_surface_create (imageSurface->CairoSurface());
     Init (surf);
     mSize = ComputeSize();
 }
 
 gfxQuartzImageSurface::gfxQuartzImageSurface(cairo_surface_t *csurf)
--- a/gfx/thebes/gfxQuartzSurface.cpp
+++ b/gfx/thebes/gfxQuartzSurface.cpp
@@ -11,17 +11,17 @@
 void
 gfxQuartzSurface::MakeInvalid()
 {
     mSize = gfxIntSize(-1, -1);    
 }
 
 gfxQuartzSurface::gfxQuartzSurface(const gfxSize& desiredSize, gfxImageFormat format,
                                    bool aForPrinting)
-    : mCGContext(NULL), mSize(desiredSize), mForPrinting(aForPrinting)
+    : mCGContext(nullptr), mSize(desiredSize), mForPrinting(aForPrinting)
 {
     gfxIntSize size((unsigned int) floor(desiredSize.width),
                     (unsigned int) floor(desiredSize.height));
     if (!CheckSurfaceSize(size))
         MakeInvalid();
 
     unsigned int width = static_cast<unsigned int>(mSize.width);
     unsigned int height = static_cast<unsigned int>(mSize.height);
--- a/gfx/thebes/gfxUniscribeShaper.cpp
+++ b/gfx/thebes/gfxUniscribeShaper.cpp
@@ -179,17 +179,17 @@ public:
         }
 
         SCRIPT_ANALYSIS sa = mScriptItem->a;
 
         while (true) {
             rv = ScriptPlace(placeDC, mShaper->ScriptCache(),
                              mGlyphs.Elements(), mNumGlyphs,
                              mAttr.Elements(), &sa,
-                             mAdvances.Elements(), mOffsets.Elements(), NULL);
+                             mAdvances.Elements(), mOffsets.Elements(), nullptr);
 
             if (rv == E_PENDING) {
                 SelectFont();
                 placeDC = mDC;
                 continue;
             }
 
             if (rv == USP_E_SCRIPT_NOT_IN_FONT) {
@@ -203,17 +203,17 @@ public:
         return rv;
     }
 
     void ScriptFontProperties(SCRIPT_FONTPROPERTIES *sfp) {
         HRESULT rv;
 
         memset(sfp, 0, sizeof(SCRIPT_FONTPROPERTIES));
         sfp->cBytes = sizeof(SCRIPT_FONTPROPERTIES);
-        rv = ScriptGetFontProperties(NULL, mShaper->ScriptCache(),
+        rv = ScriptGetFontProperties(nullptr, mShaper->ScriptCache(),
                                      sfp);
         if (rv == E_PENDING) {
             SelectFont();
             rv = ScriptGetFontProperties(mDC, mShaper->ScriptCache(),
                                          sfp);
         }
     }
 
--- a/gfx/thebes/gfxUniscribeShaper.h
+++ b/gfx/thebes/gfxUniscribeShaper.h
@@ -14,17 +14,17 @@
 #include <cairo-win32.h>
 
 
 class gfxUniscribeShaper : public gfxFontShaper
 {
 public:
     gfxUniscribeShaper(gfxGDIFont *aFont)
         : gfxFontShaper(aFont)
-        , mScriptCache(NULL)
+        , mScriptCache(nullptr)
     {
         MOZ_COUNT_CTOR(gfxUniscribeShaper);
     }
 
     virtual ~gfxUniscribeShaper()
     {
         MOZ_COUNT_DTOR(gfxUniscribeShaper);
     }
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -292,17 +292,17 @@ gfxUserFontSet::OTSMessage(void *aUserDa
     OTSCallbackUserData *d = static_cast<OTSCallbackUserData*>(aUserData);
     d->mFontSet->LogMessage(d->mFamily, d->mProxy, buf);
 
     return false;
 }
 #endif
 
 // Call the OTS library to sanitize an sfnt before attempting to use it.
-// Returns a newly-allocated block, or NULL in case of fatal errors.
+// Returns a newly-allocated block, or nullptr in case of fatal errors.
 const uint8_t*
 gfxUserFontSet::SanitizeOpenTypeData(gfxMixedFontFamily *aFamily,
                                      gfxProxyFontEntry *aProxy,
                                      const uint8_t* aData, uint32_t aLength,
                                      uint32_t& aSaneLength, bool aIsCompressed)
 {
     // limit output/expansion to 256MB
     ExpandingMemoryStream output(aIsCompressed ? aLength * 2 : aLength,
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -857,10 +857,10 @@ gfxUtils::CopyAsDataURL(DrawTarget* aDT)
   } else {
     NS_WARNING("Failed to get Thebes surface!");
   }
 }
 
 bool gfxUtils::sDumpPaintList = getenv("MOZ_DUMP_PAINT_LIST") != 0;
 bool gfxUtils::sDumpPainting = getenv("MOZ_DUMP_PAINT") != 0;
 bool gfxUtils::sDumpPaintingToFile = getenv("MOZ_DUMP_PAINT_TO_FILE") != 0;
-FILE *gfxUtils::sDumpPaintFile = NULL;
+FILE *gfxUtils::sDumpPaintFile = nullptr;
 #endif
--- a/gfx/thebes/gfxWindowsNativeDrawing.cpp
+++ b/gfx/thebes/gfxWindowsNativeDrawing.cpp
@@ -141,17 +141,17 @@ gfxWindowsNativeDrawing::BeginNativeDraw
             SetGraphicsMode(mDC, GM_ADVANCED);
             GetWorldTransform(mDC, &mOldWorldTransform);
             SetWorldTransform(mDC, &mWorldTransform);
         }
         GetViewportOrgEx(mDC, &mOrigViewportOrigin);
         SetViewportOrgEx(mDC,
                          mOrigViewportOrigin.x + (int)mDeviceOffset.x,
                          mOrigViewportOrigin.y + (int)mDeviceOffset.y,
-                         NULL);
+                         nullptr);
 
         return mDC;
     } else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_BLACK ||
                mRenderState == RENDER_STATE_ALPHA_RECOVERY_WHITE)
     {
         // we're going to use mWinSurface to create our temporary surface here
 
         // get us a RGB24 DIB; DIB is important, because
@@ -222,17 +222,17 @@ gfxWindowsNativeDrawing::ShouldRenderAga
     return false;
 }
 
 void
 gfxWindowsNativeDrawing::EndNativeDrawing()
 {
     if (mRenderState == RENDER_STATE_NATIVE_DRAWING) {
         // we drew directly to the HDC in the context; undo our changes
-        SetViewportOrgEx(mDC, mOrigViewportOrigin.x, mOrigViewportOrigin.y, NULL);
+        SetViewportOrgEx(mDC, mOrigViewportOrigin.x, mOrigViewportOrigin.y, nullptr);
 
         if (mTransformType != TRANSLATION_ONLY)
             SetWorldTransform(mDC, &mOldWorldTransform);
 
         mWinSurface->MarkDirty();
 
         mRenderState = RENDER_STATE_NATIVE_DRAWING_DONE;
     } else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_BLACK) {
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -357,19 +357,19 @@ gfxWindowsPlatform::gfxWindowsPlatform()
     mUseClearTypeForDownloadableFonts = UNINITIALIZED_VALUE;
     mUseClearTypeAlways = UNINITIALIZED_VALUE;
 
     mUsingGDIFonts = false;
 
     /* 
      * Initialize COM 
      */ 
-    CoInitialize(NULL); 
+    CoInitialize(nullptr); 
 
-    mScreenDC = GetDC(NULL);
+    mScreenDC = GetDC(nullptr);
 
 #ifdef CAIRO_HAS_D2D_SURFACE
     NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DCache));
     NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DVram));
     mD2DDevice = nullptr;
 #endif
     NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DVRAMDT));
     NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DVRAMSS));
@@ -379,17 +379,17 @@ gfxWindowsPlatform::gfxWindowsPlatform()
     mGPUAdapterMultiReporter = new GPUAdapterMultiReporter();
     NS_RegisterMemoryMultiReporter(mGPUAdapterMultiReporter);
 }
 
 gfxWindowsPlatform::~gfxWindowsPlatform()
 {
     NS_UnregisterMemoryMultiReporter(mGPUAdapterMultiReporter);
     
-    ::ReleaseDC(NULL, mScreenDC);
+    ::ReleaseDC(nullptr, mScreenDC);
     // not calling FT_Done_FreeType because cairo may still hold references to
     // these FT_Faces.  See bug 458169.
 #ifdef CAIRO_HAS_D2D_SURFACE
     if (mD2DDevice) {
         cairo_release_device(mD2DDevice);
     }
 #endif
 
@@ -516,17 +516,17 @@ gfxWindowsPlatform::CreateDevice(nsRefPt
     return E_FAIL;
   D3D10CreateDevice1Func createD3DDevice =
     (D3D10CreateDevice1Func)GetProcAddress(d3d10module, "D3D10CreateDevice1");
   if (!createD3DDevice)
     return E_FAIL;
 
   nsRefPtr<ID3D10Device1> device;
   HRESULT hr =
-    createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, NULL,
+    createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr,
                     D3D10_CREATE_DEVICE_BGRA_SUPPORT |
                     D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
                     static_cast<D3D10_FEATURE_LEVEL1>(kSupportedFeatureLevels[featureLevelIndex]),
                     D3D10_1_SDK_VERSION, getter_AddRefs(device));
 
   // If we fail here, the DirectX version or video card probably
   // changed.  We previously could use 10.1 but now we can't
   // anymore.  Revert back to doing a 10.0 check first before
@@ -747,33 +747,33 @@ gfxWindowsPlatform::GetScaledFontForFont
 
 already_AddRefed<gfxASurface>
 gfxWindowsPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
 {
 #ifdef XP_WIN
   if (aTarget->GetType() == BACKEND_DIRECT2D) {
     if (!GetD2DDevice()) {
       // We no longer have a D2D device, can't do this.
-      return NULL;
+      return nullptr;
     }
 
     RefPtr<ID3D10Texture2D> texture =
       static_cast<ID3D10Texture2D*>(aTarget->GetNativeSurface(NATIVE_SURFACE_D3D10_TEXTURE));
 
     if (!texture) {
       return gfxPlatform::GetThebesSurfaceForDrawTarget(aTarget);
     }
 
     aTarget->Flush();
 
     nsRefPtr<gfxASurface> surf =
       new gfxD2DSurface(texture, ContentForFormat(aTarget->GetFormat()));
 
     // shouldn't this hold a reference?
-    surf->SetData(&kDrawTarget, aTarget, NULL);
+    surf->SetData(&kDrawTarget, aTarget, nullptr);
     return surf.forget();
   }
 #endif
 
   return gfxPlatform::GetThebesSurfaceForDrawTarget(aTarget);
 }
 
 nsresult
@@ -1167,17 +1167,17 @@ gfxWindowsPlatform::WindowsOSVersion(int
 }
 
 void 
 gfxWindowsPlatform::GetDLLVersion(const PRUnichar *aDLLPath, nsAString& aVersion)
 {
     DWORD versInfoSize, vers[4] = {0};
     // version info not available case
     aVersion.Assign(NS_LITERAL_STRING("0.0.0.0"));
-    versInfoSize = GetFileVersionInfoSizeW(aDLLPath, NULL);
+    versInfoSize = GetFileVersionInfoSizeW(aDLLPath, nullptr);
     nsAutoTArray<BYTE,512> versionInfo;
     
     if (versInfoSize == 0 ||
         !versionInfo.AppendElements(uint32_t(versInfoSize)))
     {
         return;
     }
 
@@ -1226,17 +1226,18 @@ gfxWindowsPlatform::GetCleartypeParams(n
 
     if (rv != ERROR_SUCCESS) {
         return;
     }
 
     // enumerate over subkeys
     for (i = 0, rv = ERROR_SUCCESS; rv != ERROR_NO_MORE_ITEMS; i++) {
         size = ArrayLength(displayName);
-        rv = RegEnumKeyExW(hKey, i, displayName, &size, NULL, NULL, NULL, NULL);
+        rv = RegEnumKeyExW(hKey, i, displayName, &size,
+                           nullptr, nullptr, nullptr, nullptr);
         if (rv != ERROR_SUCCESS) {
             continue;
         }
 
         ClearTypeParameterInfo ctinfo;
         ctinfo.displayName.Assign(displayName);
 
         DWORD subrv, value;
@@ -1246,50 +1247,50 @@ gfxWindowsPlatform::GetCleartypeParams(n
                    L"Software\\Microsoft\\Avalon.Graphics\\%s", displayName);
 
         // subkey for gamma, pixel structure
         subrv = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                               subkeyName, 0, KEY_QUERY_VALUE, &subKey);
 
         if (subrv == ERROR_SUCCESS) {
             size = sizeof(value);
-            subrv = RegQueryValueExW(subKey, L"GammaLevel", NULL, &type,
+            subrv = RegQueryValueExW(subKey, L"GammaLevel", nullptr, &type,
                                      (LPBYTE)&value, &size);
             if (subrv == ERROR_SUCCESS && type == REG_DWORD) {
                 foundData = true;
                 ctinfo.gamma = value;
             }
 
             size = sizeof(value);
-            subrv = RegQueryValueExW(subKey, L"PixelStructure", NULL, &type,
+            subrv = RegQueryValueExW(subKey, L"PixelStructure", nullptr, &type,
                                      (LPBYTE)&value, &size);
             if (subrv == ERROR_SUCCESS && type == REG_DWORD) {
                 foundData = true;
                 ctinfo.pixelStructure = value;
             }
 
             RegCloseKey(subKey);
         }
 
         // subkey for cleartype level, enhanced contrast
         subrv = RegOpenKeyExW(HKEY_CURRENT_USER,
                               subkeyName, 0, KEY_QUERY_VALUE, &subKey);
 
         if (subrv == ERROR_SUCCESS) {
             size = sizeof(value);
-            subrv = RegQueryValueExW(subKey, L"ClearTypeLevel", NULL, &type,
+            subrv = RegQueryValueExW(subKey, L"ClearTypeLevel", nullptr, &type,
                                      (LPBYTE)&value, &size);
             if (subrv == ERROR_SUCCESS && type == REG_DWORD) {
                 foundData = true;
                 ctinfo.clearTypeLevel = value;
             }
       
             size = sizeof(value);
             subrv = RegQueryValueExW(subKey, L"EnhancedContrastLevel",
-                                     NULL, &type, (LPBYTE)&value, &size);
+                                     nullptr, &type, (LPBYTE)&value, &size);
             if (subrv == ERROR_SUCCESS && type == REG_DWORD) {
                 foundData = true;
                 ctinfo.enhancedContrast = value;
             }
 
             RegCloseKey(subKey);
         }
 
@@ -1473,17 +1474,17 @@ gfxWindowsPlatform::GetD3D11Device()
   featureLevels.AppendElement(D3D_FEATURE_LEVEL_9_3);
 
   RefPtr<IDXGIAdapter1> adapter = GetDXGIAdapter();
 
   if (!adapter) {
     return nullptr;
   }
 
-  HRESULT hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL,
+  HRESULT hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
                                  D3D11_CREATE_DEVICE_BGRA_SUPPORT,
                                  featureLevels.Elements(), featureLevels.Length(),
                                  D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr);
 
   // We leak these everywhere and we need them our entire runtime anyway, let's
   // leak it here as well.
   d3d11Module.disown();
 
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -47,40 +47,40 @@ class ID3D11Device;
 class IDXGIAdapter1;
 
 class nsIMemoryMultiReporter;
 
 // Utility to get a Windows HDC from a thebes context,
 // used by both GDI and Uniscribe font shapers
 struct DCFromContext {
     DCFromContext(gfxContext *aContext) {
-        dc = NULL;
+        dc = nullptr;
         nsRefPtr<gfxASurface> aSurface = aContext->CurrentSurface();
         NS_ASSERTION(aSurface, "DCFromContext: null surface");
         if (aSurface &&
             (aSurface->GetType() == gfxASurface::SurfaceTypeWin32 ||
              aSurface->GetType() == gfxASurface::SurfaceTypeWin32Printing))
         {
             dc = static_cast<gfxWindowsSurface*>(aSurface.get())->GetDC();
             needsRelease = false;
             SaveDC(dc);
             cairo_scaled_font_t* scaled =
                 cairo_get_scaled_font(aContext->GetCairo());
             cairo_win32_scaled_font_select_font(scaled, dc);
         }
         if (!dc) {
-            dc = GetDC(NULL);
+            dc = GetDC(nullptr);
             SetGraphicsMode(dc, GM_ADVANCED);
             needsRelease = true;
         }
     }
 
     ~DCFromContext() {
         if (needsRelease) {
-            ReleaseDC(NULL, dc);
+            ReleaseDC(nullptr, dc);
         } else {
             RestoreDC(dc, -1);
         }
     }
 
     operator HDC () {
         return dc;
     }
--- a/gfx/thebes/gfxWindowsSurface.cpp
+++ b/gfx/thebes/gfxWindowsSurface.cpp
@@ -219,17 +219,17 @@ gfxWindowsSurface::BeginPrinting(const n
         titleStr.SetLength(DOC_TITLE_LENGTH-3);
         titleStr.AppendLiteral("...");
     }
 
     nsString docName(aPrintToFileName);
     docinfo.cbSize = sizeof(docinfo);
     docinfo.lpszDocName = titleStr.Length() > 0 ? titleStr.get() : L"Mozilla Document";
     docinfo.lpszOutput = docName.Length() > 0 ? docName.get() : nullptr;
-    docinfo.lpszDatatype = NULL;
+    docinfo.lpszDatatype = nullptr;
     docinfo.fwType = 0;
 
     ::StartDocW(mDC, &docinfo);
 
     return NS_OK;
 #else
     return NS_ERROR_FAILURE;
 #endif
--- a/gfx/thebes/gfxWindowsSurface.h
+++ b/gfx/thebes/gfxWindowsSurface.h
@@ -26,17 +26,17 @@ public:
 
     gfxWindowsSurface(HWND wnd, uint32_t flags = 0);
     gfxWindowsSurface(HDC dc, uint32_t flags = 0);
 
     // Create a DIB surface
     gfxWindowsSurface(const gfxIntSize& size,
                       gfxImageFormat imageFormat = ImageFormatRGB24);
 
-    // Create a DDB surface; dc may be NULL to use the screen DC
+    // Create a DDB surface; dc may be nullptr to use the screen DC
     gfxWindowsSurface(HDC dc,
                       const gfxIntSize& size,
                       gfxImageFormat imageFormat = ImageFormatRGB24);
 
     gfxWindowsSurface(cairo_surface_t *csurf);
 
     virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType,
                                                                const gfxIntSize& aSize);
--- a/gfx/thebes/gfxXlibNativeRenderer.cpp
+++ b/gfx/thebes/gfxXlibNativeRenderer.cpp
@@ -315,18 +315,18 @@ CreateTempXlibSurface (gfxASurface *dest
         // (If !drawIsOpaque, we'll need doCopyBackground or an alpha channel.)
         visual = DefaultVisualOfScreen(target_screen);
         screen = target_screen;
 
     } else if (doCopyBackground || (supportsAlternateVisual && drawIsOpaque)) {
         // Analyse the pixel formats either to check whether we can
         // doCopyBackground or to see if we can find a better visual for
         // opaque drawing.
-        Visual *target_visual = NULL;
-        XRenderPictFormat *target_format = NULL;
+        Visual *target_visual = nullptr;
+        XRenderPictFormat *target_format = nullptr;
         switch (target_type) {
         case CAIRO_SURFACE_TYPE_XLIB:
             target_visual = cairo_xlib_surface_get_visual (target);
             target_format = cairo_xlib_surface_get_xrender_format (target);
             break;
         case CAIRO_SURFACE_TYPE_IMAGE: {
             gfxASurface::gfxImageFormat imageFormat =
                 static_cast<gfxImageSurface*>(destination)->Format();
@@ -414,17 +414,17 @@ CreateTempXlibSurface (gfxASurface *dest
 
 bool
 gfxXlibNativeRenderer::DrawOntoTempSurface(gfxXlibSurface *tempXlibSurface,
                                            nsIntPoint offset)
 {
     tempXlibSurface->Flush();
     /* no clipping is needed because the callback can't draw outside the native
        surface anyway */
-    nsresult rv = DrawWithXlib(tempXlibSurface, offset, NULL, 0);
+    nsresult rv = DrawWithXlib(tempXlibSurface, offset, nullptr, 0);
     tempXlibSurface->MarkDirty();
     return NS_SUCCEEDED(rv);
 }
 
 static already_AddRefed<gfxImageSurface>
 CopyXlibSurfaceToImage(gfxXlibSurface *tempXlibSurface,
                        gfxASurface::gfxImageFormat format)
 {
@@ -440,17 +440,17 @@ CopyXlibSurfaceToImage(gfxXlibSurface *t
 }
 
 void
 gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size,
                             uint32_t flags, Screen *screen, Visual *visual,
                             DrawOutput* result)
 {
     if (result) {
-        result->mSurface = NULL;
+        result->mSurface = nullptr;
         result->mUniformAlpha = false;
         result->mUniformColor = false;
     }
 
     bool drawIsOpaque = (flags & DRAW_IS_OPAQUE) != 0;
     gfxMatrix matrix = ctx->CurrentMatrix();
 
     // We can only draw direct or onto a copied background if pixels align and
@@ -515,17 +515,17 @@ gfxXlibNativeRenderer::Draw(gfxContext* 
                               canDrawOverBackground, flags, screen, visual,
                               &method);
     if (!tempXlibSurface)
         return;
   
     if (drawingRect.Size() != size || method == eCopyBackground) {
         // Only drawing a portion, or copying background,
         // so won't return a result.
-        result = NULL;
+        result = nullptr;
     }
 
     nsRefPtr<gfxContext> tmpCtx;
     if (!drawIsOpaque) {
         tmpCtx = new gfxContext(tempXlibSurface);
         if (method == eCopyBackground) {
             tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
             tmpCtx->SetSource(target, -(offset + matrix.GetTranslation()));
--- a/gfx/thebes/gfxXlibSurface.cpp
+++ b/gfx/thebes/gfxXlibSurface.cpp
@@ -453,17 +453,17 @@ gfxXlibSurface::FindVisual(Screen *scree
             depth = 16;
             red_mask = 0xf800;
             green_mask = 0x7e0;
             blue_mask = 0x1f;
             break;
         case ImageFormatA8:
         case ImageFormatA1:
         default:
-            return NULL;
+            return nullptr;
     }
 
     for (int d = 0; d < screen->ndepths; d++) {
         const Depth& d_info = screen->depths[d];
         if (d_info.depth != depth)
             continue;
 
         for (int v = 0; v < d_info.nvisuals; v++) {
@@ -472,17 +472,17 @@ gfxXlibSurface::FindVisual(Screen *scree
             if (visual->c_class == TrueColor &&
                 visual->red_mask == red_mask &&
                 visual->green_mask == green_mask &&
                 visual->blue_mask == blue_mask)
                 return visual;
         }
     }
 
-    return NULL;
+    return nullptr;
 }
 
 /* static */
 XRenderPictFormat*
 gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
 {
     switch (format) {
         case ImageFormatARGB32:
@@ -490,28 +490,28 @@ gfxXlibSurface::FindRenderFormat(Display
         case ImageFormatRGB24:
             return XRenderFindStandardFormat (dpy, PictStandardRGB24);
         case ImageFormatRGB16_565: {
             // PictStandardRGB16_565 is not standard Xrender format
             // we should try to find related visual
             // and find xrender format by visual
             Visual *visual = FindVisual(DefaultScreenOfDisplay(dpy), format);
             if (!visual)
-                return NULL;
+                return nullptr;
             return XRenderFindVisualFormat(dpy, visual);
         }
         case ImageFormatA8:
             return XRenderFindStandardFormat (dpy, PictStandardA8);
         case ImageFormatA1:
             return XRenderFindStandardFormat (dpy, PictStandardA1);
         default:
             break;
     }
 
-    return (XRenderPictFormat*)NULL;
+    return nullptr;
 }
 
 Screen*
 gfxXlibSurface::XScreen()
 {
     return cairo_xlib_surface_get_screen(CairoSurface());
 }
 
--- a/gfx/thebes/nsSurfaceTexture.cpp
+++ b/gfx/thebes/nsSurfaceTexture.cpp
@@ -47,21 +47,21 @@ public:
 
     mInitialized = true;
     return true;
   }
 
   jobject CreateSurfaceTexture(GLuint aTexture)
   {
     if (!EnsureInitialized())
-      return NULL;
+      return nullptr;
 
     JNIEnv* env = GetJNIForThread();
     if (!env)
-      return NULL;
+      return nullptr;
 
     AutoLocalJNIFrame jniFrame(env);
 
     return env->NewGlobalRef(env->NewObject(jSurfaceTextureClass, jSurfaceTexture_Ctor, (int) aTexture));
   }
 
   void ReleaseSurfaceTexture(jobject aSurfaceTexture)
   {
@@ -88,17 +88,17 @@ public:
     if (!env)
       return false;
 
     AutoLocalJNIFrame jniFrame(env);
 
     jfloatArray jarray = env->NewFloatArray(16);
     env->CallVoidMethod(aSurfaceTexture, jSurfaceTexture_getTransformMatrix, jarray);
 
-    jfloat* array = env->GetFloatArrayElements(jarray, NULL);
+    jfloat* array = env->GetFloatArrayElements(jarray, nullptr);
 
     aMatrix._11 = array[0];
     aMatrix._12 = array[1];
     aMatrix._13 = array[2];
     aMatrix._14 = array[3];
 
     aMatrix._21 = array[4];
     aMatrix._22 = array[5];
@@ -131,36 +131,36 @@ private:
 } sJNIFunctions;
 
 nsSurfaceTexture*
 nsSurfaceTexture::Create(GLuint aTexture)
 {
   // Right now we only support creating this on the main thread because
   // of the JNIEnv assumptions in JNIHelper and elsewhere
   if (!NS_IsMainThread())
-    return NULL;
+    return nullptr;
 
   nsSurfaceTexture* st = new nsSurfaceTexture();
   if (!st->Init(aTexture)) {
     LOG("Failed to initialize nsSurfaceTexture");
     delete st;
-    st = NULL;
+    st = nullptr;
   }
 
   return st;
 }
 
 nsSurfaceTexture*
 nsSurfaceTexture::Find(int id)
 {
   std::map<int, nsSurfaceTexture*>::iterator it;
 
   it = sInstances.find(id);
   if (it == sInstances.end())
-    return NULL;
+    return nullptr;
 
   return it->second;
 }
 
 bool
 nsSurfaceTexture::Check()
 {
   return sJNIFunctions.EnsureInitialized();
@@ -184,40 +184,40 @@ nsSurfaceTexture::Init(GLuint aTexture)
 
   mID = ++sNextID;
   sInstances.insert(std::pair<int, nsSurfaceTexture*>(mID, this));
 
   return true;
 }
 
 nsSurfaceTexture::nsSurfaceTexture()
-  : mSurfaceTexture(NULL), mNativeWindow(NULL)
+  : mSurfaceTexture(nullptr), mNativeWindow(nullptr)
 {
 }
 
 nsSurfaceTexture::~nsSurfaceTexture()
 {
   sInstances.erase(mID);
 
-  mFrameAvailableCallback = NULL;
+  mFrameAvailableCallback = nullptr;
 
   if (mNativeWindow) {
     AndroidBridge::Bridge()->ReleaseNativeWindowForSurfaceTexture(mSurfaceTexture);
-    mNativeWindow = NULL;
+    mNativeWindow = nullptr;
   }
 
   JNIEnv* env = GetJNIForThread();
   if (!env)
     return;
 
   if (mSurfaceTexture && env) {
     AndroidBridge::Bridge()->UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
 
     env->DeleteGlobalRef(mSurfaceTexture);
-    mSurfaceTexture = NULL;
+    mSurfaceTexture = nullptr;
   }
 }
 
 void*
 nsSurfaceTexture::GetNativeWindow()
 {
   return mNativeWindow;
 }