Bug 784739 - Switch from NULL to nullptr in image/. r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Fri, 23 Aug 2013 15:51:00 -0400
changeset 157069 7db2236a37750641eb099a8b11c45ea4601bff11
parent 157044 76a5ca209147c633797bfdb0c3ea3fc0e7ff7c9a
child 157070 5c8591a9369a462c734e168daa0d04e4825c578c
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs784739
milestone26.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 image/. r=ehsan
image/build/nsImageModule.cpp
image/decoders/icon/gtk/nsIconChannel.cpp
image/decoders/icon/nsIconModule.cpp
image/decoders/icon/win/nsIconChannel.cpp
image/decoders/nsPNGDecoder.cpp
image/decoders/nsPNGDecoder.h
image/src/DiscardTracker.cpp
image/src/RasterImage.cpp
image/src/imgFrame.cpp
image/src/imgLoader.cpp
--- a/image/build/nsImageModule.cpp
+++ b/image/build/nsImageModule.cpp
@@ -34,52 +34,52 @@ NS_DEFINE_NAMED_CID(NS_IMGLOADER_CID);
 NS_DEFINE_NAMED_CID(NS_IMGREQUESTPROXY_CID);
 NS_DEFINE_NAMED_CID(NS_IMGTOOLS_CID);
 NS_DEFINE_NAMED_CID(NS_ICOENCODER_CID);
 NS_DEFINE_NAMED_CID(NS_JPEGENCODER_CID);
 NS_DEFINE_NAMED_CID(NS_PNGENCODER_CID);
 NS_DEFINE_NAMED_CID(NS_BMPENCODER_CID);
 
 static const mozilla::Module::CIDEntry kImageCIDs[] = {
-  { &kNS_IMGLOADER_CID, false, NULL, imgLoaderConstructor, },
-  { &kNS_IMGREQUESTPROXY_CID, false, NULL, imgRequestProxyConstructor, },
-  { &kNS_IMGTOOLS_CID, false, NULL, imgToolsConstructor, },
-  { &kNS_ICOENCODER_CID, false, NULL, nsICOEncoderConstructor, },
-  { &kNS_JPEGENCODER_CID, false, NULL, nsJPEGEncoderConstructor, },
-  { &kNS_PNGENCODER_CID, false, NULL, nsPNGEncoderConstructor, },
-  { &kNS_BMPENCODER_CID, false, NULL, nsBMPEncoderConstructor, },
-  { NULL }
+  { &kNS_IMGLOADER_CID, false, nullptr, imgLoaderConstructor, },
+  { &kNS_IMGREQUESTPROXY_CID, false, nullptr, imgRequestProxyConstructor, },
+  { &kNS_IMGTOOLS_CID, false, nullptr, imgToolsConstructor, },
+  { &kNS_ICOENCODER_CID, false, nullptr, nsICOEncoderConstructor, },
+  { &kNS_JPEGENCODER_CID, false, nullptr, nsJPEGEncoderConstructor, },
+  { &kNS_PNGENCODER_CID, false, nullptr, nsPNGEncoderConstructor, },
+  { &kNS_BMPENCODER_CID, false, nullptr, nsBMPEncoderConstructor, },
+  { nullptr }
 };
 
 static const mozilla::Module::ContractIDEntry kImageContracts[] = {
   { "@mozilla.org/image/cache;1", &kNS_IMGLOADER_CID },
   { "@mozilla.org/image/loader;1", &kNS_IMGLOADER_CID },
   { "@mozilla.org/image/request;1", &kNS_IMGREQUESTPROXY_CID },
   { "@mozilla.org/image/tools;1", &kNS_IMGTOOLS_CID },
   { "@mozilla.org/image/encoder;2?type=" IMAGE_ICO_MS, &kNS_ICOENCODER_CID },
   { "@mozilla.org/image/encoder;2?type=" IMAGE_JPEG, &kNS_JPEGENCODER_CID },
   { "@mozilla.org/image/encoder;2?type=" IMAGE_PNG, &kNS_PNGENCODER_CID },
   { "@mozilla.org/image/encoder;2?type=" IMAGE_BMP, &kNS_BMPENCODER_CID },
-  { NULL }
+  { nullptr }
 };
 
 static const mozilla::Module::CategoryEntry kImageCategories[] = {
   { "Gecko-Content-Viewers", IMAGE_GIF, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_JPEG, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_PJPEG, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_JPG, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_ICO, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_ICO_MS, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_BMP, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_BMP_MS, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_ICON_MS, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_PNG, "@mozilla.org/content/document-loader-factory;1" },
   { "Gecko-Content-Viewers", IMAGE_X_PNG, "@mozilla.org/content/document-loader-factory;1" },
   { "content-sniffing-services", "@mozilla.org/image/loader;1", "@mozilla.org/image/loader;1" },
-  { NULL }
+  { nullptr }
 };
 
 static nsresult
 imglib_Initialize()
 {
   mozilla::image::DiscardTracker::Initialize();
   mozilla::image::RasterImage::Initialize();
   imgLoader::GlobalInit();
@@ -93,14 +93,14 @@ imglib_Shutdown()
   mozilla::image::DiscardTracker::Shutdown();
 }
 
 static const mozilla::Module kImageModule = {
   mozilla::Module::kVersion,
   kImageCIDs,
   kImageContracts,
   kImageCategories,
-  NULL,
+  nullptr,
   imglib_Initialize,
   imglib_Shutdown
 };
 
 NSMODULE_DEFN(nsImageLib2Module) = &kImageModule;
--- a/image/decoders/icon/gtk/nsIconChannel.cpp
+++ b/image/decoders/icon/gtk/nsIconChannel.cpp
@@ -263,17 +263,17 @@ GetIconSize(nsIMozIconURI *aIconURI)
     uint32_t size;
     mozilla::DebugOnly<nsresult> rv = aIconURI->GetImageSize(&size);
     NS_ASSERTION(NS_SUCCEEDED(rv), "GetImageSize failed");
     return size; 
   } else {
     int size;
 
     GtkIconSize icon_size = moz_gtk_icon_size(iconSizeString.get());
-    gtk_icon_size_lookup(icon_size, &size, NULL);
+    gtk_icon_size_lookup(icon_size, &size, nullptr);
     return size;
   }
 }
 
 /* Scale icon buffer to preferred size */
 static nsresult
 ScaleIconBuf(GdkPixbuf **aBuf, int32_t iconSize)
 {
@@ -323,17 +323,18 @@ nsIconChannel::InitWithGnome(nsIMozIconU
       bundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
                                 getter_Copies(appName));
     } else {
       NS_WARNING("brand.properties not present, using default application name");
       appName.Assign(NS_LITERAL_STRING("Gecko"));
     }
 
     char* empty[] = { "" };
-    _gnome_init(NS_ConvertUTF16toUTF8(appName).get(), "1.0", 1, empty, NULL, 0, NULL);
+    _gnome_init(NS_ConvertUTF16toUTF8(appName).get(),
+                "1.0", 1, empty, nullptr, 0, nullptr);
   }
 
   uint32_t iconSize = GetIconSize(aIconURI);
   nsAutoCString type;
   aIconURI->GetContentType(type);
 
   GnomeVFSFileInfo fileInfo = {0};
   fileInfo.refcount = 1; // In case some GnomeVFS function addrefs and releases it
@@ -381,19 +382,19 @@ nsIconChannel::InitWithGnome(nsIMozIconU
     gIconTheme = _gnome_icon_theme_new();
 
     if (!gIconTheme) {
       _gnome_vfs_file_info_clear(&fileInfo);
       return NS_ERROR_NOT_AVAILABLE;
     }
   }
 
-  char* name = _gnome_icon_lookup(gIconTheme, NULL, spec.get(), NULL, &fileInfo,
-                                  type.get(), GNOME_ICON_LOOKUP_FLAGS_NONE,
-                                  NULL);
+  char* name = _gnome_icon_lookup(gIconTheme, nullptr, spec.get(), nullptr,
+                                  &fileInfo, type.get(),
+                                  GNOME_ICON_LOOKUP_FLAGS_NONE, nullptr);
 
   _gnome_vfs_file_info_clear(&fileInfo);
   if (!name)
     return NS_ERROR_NOT_AVAILABLE;
   
   // Get the default theme associated with the screen
   // Do NOT free.
   GtkIconTheme *theme = gtk_icon_theme_get_default();
@@ -421,32 +422,33 @@ nsIconChannel::InitWithGnome(nsIMozIconU
   return rv;
 }
 #endif // MOZ_ENABLE_GNOMEUI
 
 #ifdef MOZ_ENABLE_GIO
 nsresult
 nsIconChannel::InitWithGIO(nsIMozIconURI *aIconURI)
 {
-  GIcon *icon = NULL;
+  GIcon *icon = nullptr;
   nsCOMPtr<nsIURL> fileURI;
 
   // Read icon content
   aIconURI->GetIconURL(getter_AddRefs(fileURI));
 
   // Get icon for file specified by URI
   if (fileURI) {
     bool isFile;
     nsAutoCString spec;
     fileURI->GetAsciiSpec(spec);
     if (NS_SUCCEEDED(fileURI->SchemeIs("file", &isFile)) && isFile) {
       GFile *file = g_file_new_for_uri(spec.get());
       GFileInfo *fileInfo = g_file_query_info(file,
                                               G_FILE_ATTRIBUTE_STANDARD_ICON,
-                                              G_FILE_QUERY_INFO_NONE, NULL, NULL);
+                                              G_FILE_QUERY_INFO_NONE,
+                                              nullptr, nullptr);
       g_object_unref(file);
       if (fileInfo) {
         // icon from g_content_type_get_icon doesn't need unref
         icon = g_file_info_get_icon(fileInfo);
         if (icon)
           g_object_ref(icon);
         g_object_unref(fileInfo);
       }
@@ -461,29 +463,29 @@ nsIconChannel::InitWithGIO(nsIMozIconURI
     if (type.IsEmpty()) {
       nsCOMPtr<nsIMIMEService> ms(do_GetService("@mozilla.org/mime;1"));
       if (ms) {
         nsAutoCString fileExt;
         aIconURI->GetFileExtension(fileExt);
         ms->GetTypeFromExtension(fileExt, type);
       }
     }
-    char *ctype = NULL; // character representation of content type
+    char *ctype = nullptr; // character representation of content type
     if (!type.IsEmpty()) {
       ctype = g_content_type_from_mime_type(type.get());
     }
     if (ctype) {
       icon = g_content_type_get_icon(ctype);
       g_free(ctype);
     }
   }
 
   // Get default icon theme
   GtkIconTheme *iconTheme = gtk_icon_theme_get_default();  
-  GtkIconInfo *iconInfo = NULL;
+  GtkIconInfo *iconInfo = nullptr;
   // Get icon size
   int32_t iconSize = GetIconSize(aIconURI);
 
   if (icon) {
     // Use icon and theme to get GtkIconInfo
     iconInfo = gtk_icon_theme_lookup_by_gicon(iconTheme,
                                               icon, iconSize,
                                               (GtkIconLookupFlags)0);
@@ -496,17 +498,17 @@ nsIconChannel::InitWithGIO(nsIMozIconURI
                                           "unknown", iconSize,
                                           (GtkIconLookupFlags)0);
     if (!iconInfo) {
       return NS_ERROR_NOT_AVAILABLE;
     }
   }
   
   // Create a GdkPixbuf buffer containing icon and scale it
-  GdkPixbuf* buf = gtk_icon_info_load_icon(iconInfo, NULL);
+  GdkPixbuf* buf = gtk_icon_info_load_icon(iconInfo, nullptr);
   gtk_icon_info_free(iconInfo);
   if (!buf) {
     return NS_ERROR_UNEXPECTED;
   }
   
   nsresult rv = ScaleIconBuf(&buf, iconSize);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -588,17 +590,17 @@ nsIconChannel::Init(nsIURI* aURI)
         useIconName = true;
         gtk_icon_info_free(icon);
       }
     }
   }
 
   ensure_stock_image_widget();
   GtkStyle *style = gtk_widget_get_style(gStockImageWidget);
-  GtkIconSet *icon_set = NULL;
+  GtkIconSet *icon_set = nullptr;
   if (!useIconName) {
     icon_set = gtk_style_lookup_icon_set(style, stockID.get());
   }
 
   if (!icon_set) {
     // Either we have choosen icon-name lookup for a bidi icon, or stockIcon is
     // not a stock id so we assume it is an icon name.
     useIconName = true;
@@ -609,25 +611,25 @@ nsIconChannel::Init(nsIURI* aURI)
     GtkIconSource *icon_source = gtk_icon_source_new();
     
     gtk_icon_source_set_icon_name(icon_source, stockIcon.get());
     gtk_icon_set_add_source(icon_set, icon_source);
     gtk_icon_source_free(icon_source);
   }
 
   GdkPixbuf *icon =
-    gtk_icon_set_render_icon (icon_set, style, direction, state,
-                              icon_size, gStockImageWidget, NULL);
+    gtk_icon_set_render_icon(icon_set, style, direction, state,
+                             icon_size, gStockImageWidget, nullptr);
   if (useIconName) {
     gtk_icon_set_unref(icon_set);
   }
 
   // According to documentation, gtk_icon_set_render_icon() never returns
-  // NULL, but it does return NULL when we have the problem reported here:
-  // https://bugzilla.gnome.org/show_bug.cgi?id=629878#c13
+  // nullptr, but it does return nullptr when we have the problem reported
+  // here: https://bugzilla.gnome.org/show_bug.cgi?id=629878#c13
   if (!icon)
     return NS_ERROR_NOT_AVAILABLE;
   
   nsresult rv = moz_gdk_pixbuf_to_channel(icon, iconURI,
                                           getter_AddRefs(mRealChannel));
 
   g_object_unref(icon);
 
--- a/image/decoders/icon/nsIconModule.cpp
+++ b/image/decoders/icon/nsIconModule.cpp
@@ -17,40 +17,40 @@
  */
 #define NS_ICONPROTOCOL_CID   { 0xd0f9db12, 0x249c, 0x11d5, { 0x99, 0x5, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } } 
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIconProtocolHandler)
 
 NS_DEFINE_NAMED_CID(NS_ICONPROTOCOL_CID);
 
 static const mozilla::Module::CIDEntry kIconCIDs[] = {
-  { &kNS_ICONPROTOCOL_CID, false, NULL, nsIconProtocolHandlerConstructor },
-  { NULL }
+  { &kNS_ICONPROTOCOL_CID, false, nullptr, nsIconProtocolHandlerConstructor },
+  { nullptr }
 };
 
 static const mozilla::Module::ContractIDEntry kIconContracts[] = {
   { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-icon", &kNS_ICONPROTOCOL_CID },
-  { NULL }
+  { nullptr }
 };
 
 static const mozilla::Module::CategoryEntry kIconCategories[] = {
-  { NULL }
+  { nullptr }
 };
 
 static void
 IconDecoderModuleDtor()
 {
 #ifdef MOZ_WIDGET_GTK2
   nsIconChannel::Shutdown();
 #endif
 }
 
 static const mozilla::Module kIconModule = {
   mozilla::Module::kVersion,
   kIconCIDs,
   kIconContracts,
   kIconCategories,
-  NULL,
-  NULL,
+  nullptr,
+  nullptr,
   IconDecoderModuleDtor
 };
 
 NSMODULE_DEFN(nsIconDecoderModule) = &kIconModule;
--- a/image/decoders/icon/win/nsIconChannel.cpp
+++ b/image/decoders/icon/win/nsIconChannel.cpp
@@ -231,17 +231,17 @@ static DWORD GetSpecialFolderIcon(nsIFil
     return shellResult;
 
   PRUnichar fileNativePath[MAX_PATH];
   nsAutoString fileNativePathStr;
   aFile->GetPath(fileNativePathStr);
   ::GetShortPathNameW(fileNativePathStr.get(), fileNativePath, ArrayLength(fileNativePath));
 
   LPITEMIDLIST idList;
-  HRESULT hr = ::SHGetSpecialFolderLocation(NULL, aFolder, &idList);
+  HRESULT hr = ::SHGetSpecialFolderLocation(nullptr, aFolder, &idList);
   if (SUCCEEDED(hr)) {
     PRUnichar specialNativePath[MAX_PATH];
     ::SHGetPathFromIDListW(idList, specialNativePath);
     ::GetShortPathNameW(specialNativePath, specialNativePath, ArrayLength(specialNativePath));
   
     if (!wcsicmp(fileNativePath, specialNativePath)) {
       aInfoFlags |= (SHGFI_PIDL | SHGFI_SYSICONINDEX);
       shellResult = ::SHGetFileInfoW((LPCWSTR)(LPCITEMIDLIST)idList, 0, aSFI,
@@ -451,17 +451,17 @@ static BITMAPINFO* CreateBitmapInfo(BITM
 }
 
 nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, bool nonBlocking)
 {
   // Check whether the icon requested's a file icon or a stock icon
   nsresult rv = NS_ERROR_NOT_AVAILABLE;
 
   // GetDIBits does not exist on windows mobile.
-  HICON hIcon = NULL;
+  HICON hIcon = nullptr;
 
   nsCOMPtr<nsIMozIconURI> iconURI(do_QueryInterface(mUrl, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString stockIcon;
   iconURI->GetStockIcon(stockIcon);
   if (!stockIcon.IsEmpty())
     rv = GetStockHIcon(iconURI, &hIcon);
@@ -472,22 +472,22 @@ nsresult nsIconChannel::MakeInputStream(
 
   if (hIcon)
   {
     // we got a handle to an icon. Now we want to get a bitmap for the icon using GetIconInfo....
     ICONINFO iconInfo;
     if (GetIconInfo(hIcon, &iconInfo))
     {
       // we got the bitmaps, first find out their size
-      HDC hDC = CreateCompatibleDC(NULL); // get a device context for the screen.
+      HDC hDC = CreateCompatibleDC(nullptr); // get a device context for the screen.
       BITMAPINFOHEADER maskHeader  = {sizeof(BITMAPINFOHEADER)};
       BITMAPINFOHEADER colorHeader = {sizeof(BITMAPINFOHEADER)};
       int colorTableSize, maskTableSize;
-      if (GetDIBits(hDC, iconInfo.hbmMask,  0, 0, NULL, (BITMAPINFO*)&maskHeader,  DIB_RGB_COLORS) &&
-          GetDIBits(hDC, iconInfo.hbmColor, 0, 0, NULL, (BITMAPINFO*)&colorHeader, DIB_RGB_COLORS) &&
+      if (GetDIBits(hDC, iconInfo.hbmMask,  0, 0, nullptr, (BITMAPINFO*)&maskHeader,  DIB_RGB_COLORS) &&
+          GetDIBits(hDC, iconInfo.hbmColor, 0, 0, nullptr, (BITMAPINFO*)&colorHeader, DIB_RGB_COLORS) &&
           maskHeader.biHeight == colorHeader.biHeight &&
           maskHeader.biWidth  == colorHeader.biWidth  &&
           colorHeader.biBitCount > 8 &&
           colorHeader.biSizeImage > 0 &&
           colorHeader.biWidth >= 0 && colorHeader.biWidth <= 255 &&
           colorHeader.biHeight >= 0 && colorHeader.biHeight <= 255 &&
           maskHeader.biSizeImage > 0  &&
           (colorTableSize = GetColorTableSize(&colorHeader)) >= 0 &&
--- a/image/decoders/nsPNGDecoder.cpp
+++ b/image/decoders/nsPNGDecoder.cpp
@@ -116,17 +116,17 @@ nsPNGDecoder::nsPNGDecoder(RasterImage &
    mDisablePremultipliedAlpha(false),
    mNumFrames(0)
 {
 }
 
 nsPNGDecoder::~nsPNGDecoder()
 {
   if (mPNG)
-    png_destroy_read_struct(&mPNG, mInfo ? &mInfo : NULL, NULL);
+    png_destroy_read_struct(&mPNG, mInfo ? &mInfo : nullptr, nullptr);
   if (mCMSLine)
     nsMemory::Free(mCMSLine);
   if (interlacebuf)
     nsMemory::Free(interlacebuf);
   if (mInProfile) {
     qcms_profile_release(mInProfile);
 
     /* mTransform belongs to us only if mInProfile is non-null */
@@ -232,27 +232,27 @@ nsPNGDecoder::InitInternal()
 #endif
 
   /* For full decodes, do png init stuff */
 
   /* Initialize the container's source image header. */
   /* Always decode to 24 bit pixdepth */
 
   mPNG = png_create_read_struct(PNG_LIBPNG_VER_STRING,
-                                NULL, nsPNGDecoder::error_callback,
+                                nullptr, nsPNGDecoder::error_callback,
                                 nsPNGDecoder::warning_callback);
   if (!mPNG) {
     PostDecoderError(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   mInfo = png_create_info_struct(mPNG);
   if (!mInfo) {
     PostDecoderError(NS_ERROR_OUT_OF_MEMORY);
-    png_destroy_read_struct(&mPNG, NULL, NULL);
+    png_destroy_read_struct(&mPNG, nullptr, nullptr);
     return;
   }
 
 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
   /* Ignore unused chunks */
   if (mCMSMode == eCMSMode_Off)
     png_set_keep_unknown_chunks(mPNG, 1, color_chunks, 2);
 
@@ -343,17 +343,17 @@ nsPNGDecoder::WriteInternal(const char *
     // libpng uses setjmp/longjmp for error handling - set the buffer
     if (setjmp(png_jmpbuf(mPNG))) {
 
       // We might not really know what caused the error, but it makes more
       // sense to blame the data.
       if (!HasError())
         PostDataError();
 
-      png_destroy_read_struct(&mPNG, &mInfo, NULL);
+      png_destroy_read_struct(&mPNG, &mInfo, nullptr);
       return;
     }
 
     // Pass the data off to libpng
     png_process_data(mPNG, mInfo, (unsigned char *)aBuffer, aCount);
 
   }
 }
@@ -493,17 +493,17 @@ PNGGetColorProfile(png_structp png_ptr, 
 void
 nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr)
 {
 /*  int number_passes;   NOT USED  */
   png_uint_32 width, height;
   int bit_depth, color_type, interlace_type, compression_type, filter_type;
   unsigned int channels;
 
-  png_bytep trans = NULL;
+  png_bytep trans = nullptr;
   int num_trans = 0;
 
   nsPNGDecoder *decoder =
                static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
 
   /* always decode to 24-bit RGB or 32-bit RGBA  */
   png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
                &interlace_type, &compression_type, &filter_type);
@@ -628,17 +628,18 @@ nsPNGDecoder::info_callback(png_structp 
 
   if (channels == 1 || channels == 3)
     decoder->format = gfxASurface::ImageFormatRGB24;
   else if (channels == 2 || channels == 4)
     decoder->format = gfxASurface::ImageFormatARGB32;
 
 #ifdef PNG_APNG_SUPPORTED
   if (png_get_valid(png_ptr, info_ptr, PNG_INFO_acTL))
-    png_set_progressive_frame_fn(png_ptr, nsPNGDecoder::frame_info_callback, NULL);
+    png_set_progressive_frame_fn(png_ptr, nsPNGDecoder::frame_info_callback,
+                                 nullptr);
 
   if (png_get_first_frame_is_hidden(png_ptr, info_ptr)) {
     decoder->mFrameIsHidden = true;
   } else {
 #endif
     decoder->CreateFrame(0, 0, width, height, decoder->format);
 #ifdef PNG_APNG_SUPPORTED
   }
@@ -675,24 +676,24 @@ nsPNGDecoder::row_callback(png_structp p
                            png_uint_32 row_num, int pass)
 {
   /* libpng comments:
    *
    * this function is called for every row in the image.  If the
    * image is interlacing, and you turned on the interlace handler,
    * this function will be called for every row in every pass.
    * Some of these rows will not be changed from the previous pass.
-   * When the row is not changed, the new_row variable will be NULL.
-   * The rows and passes are called in order, so you don't really
-   * need the row_num and pass, but I'm supplying them because it
-   * may make your life easier.
+   * When the row is not changed, the new_row variable will be
+   * nullptr. The rows and passes are called in order, so you don't
+   * really need the row_num and pass, but I'm supplying them
+   * because it may make your life easier.
    *
-   * For the non-NULL rows of interlaced images, you must call
+   * For the non-nullptr rows of interlaced images, you must call
    * png_progressive_combine_row() passing in the row and the
-   * old row.  You can call this function for NULL rows (it will
+   * old row.  You can call this function for nullptr rows (it will
    * just return) and for non-interlaced images (it just does the
    * memcpy for you) if it will make the code easier.  Thus, you
    * can just do this for all cases:
    *
    *    png_progressive_combine_row(png_ptr, old_row, new_row);
    *
    * where old_row is what was displayed for previous rows.  Note
    * that the first pass (pass == 0 really) will completely cover
--- a/image/decoders/nsPNGDecoder.h
+++ b/image/decoders/nsPNGDecoder.h
@@ -52,17 +52,17 @@ public:
     png_uint_32
         png_width,  // Unused
         png_height; // Unused
 
     int png_bit_depth,
         png_color_type;
 
     if (png_get_IHDR(mPNG, mInfo, &png_width, &png_height, &png_bit_depth,
-                     &png_color_type, NULL, NULL, NULL)) {
+                     &png_color_type, nullptr, nullptr, nullptr)) {
 
       return ((png_color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
                png_color_type == PNG_COLOR_TYPE_RGB) &&
               png_bit_depth == 8);
     } else {
       return false;
     }
   }
--- a/image/src/DiscardTracker.cpp
+++ b/image/src/DiscardTracker.cpp
@@ -17,17 +17,17 @@ static const char* sDiscardTimeoutPref =
 /* static */ LinkedList<DiscardTracker::Node> DiscardTracker::sDiscardableImages;
 /* static */ nsCOMPtr<nsITimer> DiscardTracker::sTimer;
 /* static */ bool DiscardTracker::sInitialized = false;
 /* static */ bool DiscardTracker::sTimerOn = false;
 /* static */ Atomic<int32_t> DiscardTracker::sDiscardRunnablePending(0);
 /* static */ int64_t DiscardTracker::sCurrentDecodedImageBytes = 0;
 /* static */ uint32_t DiscardTracker::sMinDiscardTimeoutMs = 10000;
 /* static */ uint32_t DiscardTracker::sMaxDecodedImageKB = 42 * 1024;
-/* static */ PRLock * DiscardTracker::sAllocationLock = NULL;
+/* static */ PRLock * DiscardTracker::sAllocationLock = nullptr;
 
 /*
  * When we notice we're using too much memory for decoded images, we enqueue a
  * DiscardRunnable, which runs this code.
  */
 NS_IMETHODIMP
 DiscardTracker::DiscardRunnable::Run()
 {
@@ -95,17 +95,17 @@ DiscardTracker::Remove(Node *node)
  */
 void
 DiscardTracker::Shutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (sTimer) {
     sTimer->Cancel();
-    sTimer = NULL;
+    sTimer = nullptr;
   }
 
   // Clear the sDiscardableImages linked list so that its destructor
   // (LinkedList.h) finds an empty array, which is required after bug 803688.
   DiscardAll();
 }
 
 /*
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -1047,24 +1047,24 @@ RasterImage::HeapSizeOfDecodedWithComput
   return SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MEMORY_IN_PROCESS_HEAP,
                                                  aMallocSizeOf);
 }
 
 size_t
 RasterImage::NonHeapSizeOfDecoded() const
 {
   return SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MEMORY_IN_PROCESS_NONHEAP,
-                                                 NULL);
+                                                 nullptr);
 }
 
 size_t
 RasterImage::OutOfProcessSizeOfDecoded() const
 {
   return SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MEMORY_OUT_OF_PROCESS,
-                                                 NULL);
+                                                 nullptr);
 }
 
 void
 RasterImage::EnsureAnimExists()
 {
   if (!mAnim) {
 
     // Create the animation context
--- a/image/src/imgFrame.cpp
+++ b/image/src/imgFrame.cpp
@@ -835,17 +835,17 @@ void imgFrame::SetCompositingFailed(bool
 
 // If |aLocation| indicates this is heap memory, we try to measure things with
 // |aMallocSizeOf|.  If that fails (because the platform doesn't support it) or
 // it's non-heap memory, we fall back to computing the size analytically.
 size_t
 imgFrame::SizeOfExcludingThisWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation, mozilla::MallocSizeOf aMallocSizeOf) const
 {
   // aMallocSizeOf is only used if aLocation==MEMORY_IN_PROCESS_HEAP.  It
-  // should be NULL otherwise.
+  // should be nullptr otherwise.
   NS_ABORT_IF_FALSE(
     (aLocation == gfxASurface::MEMORY_IN_PROCESS_HEAP &&  aMallocSizeOf) ||
     (aLocation != gfxASurface::MEMORY_IN_PROCESS_HEAP && !aMallocSizeOf),
     "mismatch between aLocation and aMallocSizeOf");
 
   size_t n = 0;
 
   if (mPalettedImageData && aLocation == gfxASurface::MEMORY_IN_PROCESS_HEAP) {
--- a/image/src/imgLoader.cpp
+++ b/image/src/imgLoader.cpp
@@ -444,19 +444,19 @@ static nsresult NewImageChannel(nsIChann
     // XXX: This is not exactly correct, because the network request could be
     //      referenced by multiple windows...  However, the new channel needs
     //      something.  So, using the 'first' notification callbacks is better
     //      than nothing...
     //
     aLoadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks));
   }
 
-  // Pass in a NULL loadgroup because this is the underlying network request.
-  // This request may be referenced by several proxy image requests (psossibly
-  // in different documents).
+  // Pass in a nullptr loadgroup because this is the underlying network
+  // request. This request may be referenced by several proxy image requests
+  // (possibly in different documents).
   // If all of the proxy requests are canceled then this request should be
   // canceled too.
   //
   rv = NS_NewChannel(aResult,
                      aURI,        // URI
                      nullptr,      // Cached IOService
                      nullptr,      // LoadGroup
                      callbacks,   // Notification Callbacks
@@ -1633,17 +1633,17 @@ nsresult imgLoader::LoadImage(nsIURI *aU
 
         if (mCacheTracker)
           mCacheTracker->MarkUsed(entry);
       }
 
       entry->Touch();
 
 #ifdef DEBUG_joe
-      printf("CACHEGET: %d %s %d\n", time(NULL), spec.get(), entry->SizeOfData());
+      printf("CACHEGET: %d %s %d\n", time(nullptr), spec.get(), entry->SizeOfData());
 #endif
     }
     else {
       // We can't use this entry. We'll try to load it off the network, and if
       // successful, overwrite the old entry in the cache with a new one.
       entry = nullptr;
     }
   }
@@ -1986,17 +1986,17 @@ nsresult imgLoader::GetMimeTypeFromConte
      ((unsigned char)aContents[1])==0xD8 &&
      ((unsigned char)aContents[2])==0xFF)
   {
     aContentType.AssignLiteral(IMAGE_JPEG);
   }
 
   /* or how about ART? */
   /* ART begins with JG (4A 47). Major version offset 2.
-   * Minor version offset 3. Offset 4 must be NULL.
+   * Minor version offset 3. Offset 4 must be nullptr.
    */
   else if (aLength >= 5 &&
    ((unsigned char) aContents[0])==0x4a &&
    ((unsigned char) aContents[1])==0x47 &&
    ((unsigned char) aContents[4])==0x00 )
   {
     aContentType.AssignLiteral(IMAGE_ART);
   }