Bug 784739 - Switch from NULL to nullptr in widget/windows/ (1/3); r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Tue, 08 Oct 2013 14:48:02 -0400
changeset 150105 4ea080e6ae838f25732a221f2793b79b2d7abdae
parent 150104 89a576ec25cf9b52c087f6ecb6505e423f534d69
child 150106 1e7a720a0f6321316add6834f0ebc5d4811e374a
push id25423
push usercbook@mozilla.com
push dateWed, 09 Oct 2013 08:10:49 +0000
treeherdermozilla-central@2a8a173a0ae1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs784739
milestone27.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 widget/windows/ (1/3); r=ehsan
widget/windows/AudioSession.cpp
widget/windows/GfxInfo.cpp
widget/windows/IEnumFE.cpp
widget/windows/JumpListBuilder.cpp
widget/windows/JumpListItem.cpp
widget/windows/KeyboardLayout.cpp
widget/windows/LSPAnnotator.cpp
widget/windows/nsAppShell.cpp
widget/windows/nsAppShell.h
widget/windows/nsClipboard.cpp
widget/windows/nsColorPicker.cpp
widget/windows/nsDataObj.cpp
widget/windows/nsDataObjCollection.cpp
widget/windows/nsDeviceContextSpecWin.cpp
widget/windows/nsDragService.cpp
widget/windows/nsFilePicker.cpp
--- a/widget/windows/AudioSession.cpp
+++ b/widget/windows/AudioSession.cpp
@@ -120,17 +120,17 @@ RecvAudioSessionData(const nsID& aID,
                      const nsString& aSessionName,
                      const nsString& aIconPath)
 {
   return AudioSession::GetSingleton()->SetSessionData(aID,
                                                       aSessionName,
                                                       aIconPath);
 }
 
-AudioSession* AudioSession::sService = NULL;
+AudioSession* AudioSession::sService = nullptr;
 
 AudioSession::AudioSession()
 {
   mState = UNINITIALIZED;
 }
 
 AudioSession::~AudioSession()
 {
@@ -182,17 +182,17 @@ AudioSession::Start()
   const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
   const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
   const IID IID_IAudioSessionManager = __uuidof(IAudioSessionManager);
 
   HRESULT hr;
 
   // Don't check for errors in case something already initialized COM
   // on this thread.
-  CoInitialize(NULL);
+  CoInitialize(nullptr);
 
   if (mState == UNINITIALIZED) {
     mState = FAILED;
 
     // XXXkhuey implement this for content processes
     if (XRE_GetProcessType() == GeckoProcessType_Content)
       return NS_ERROR_FAILURE;
 
@@ -210,32 +210,32 @@ AudioSession::Start()
     bundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
                               getter_Copies(mDisplayName));
 
     PRUnichar *buffer;
     mIconPath.GetMutableData(&buffer, MAX_PATH);
 
     // XXXkhuey we should provide a way for a xulrunner app to specify an icon
     // that's not in the product binary.
-    ::GetModuleFileNameW(NULL, buffer, MAX_PATH);
+    ::GetModuleFileNameW(nullptr, buffer, MAX_PATH);
 
     nsCOMPtr<nsIUUIDGenerator> uuidgen =
       do_GetService("@mozilla.org/uuid-generator;1");
     NS_ENSURE_TRUE(uuidgen, NS_ERROR_FAILURE);
     uuidgen->GenerateUUIDInPlace(&mSessionGroupingParameter);
   }
 
   mState = FAILED;
 
   NS_ABORT_IF_FALSE(!mDisplayName.IsEmpty() || !mIconPath.IsEmpty(),
                     "Should never happen ...");
 
   nsRefPtr<IMMDeviceEnumerator> enumerator;
   hr = ::CoCreateInstance(CLSID_MMDeviceEnumerator,
-                          NULL,
+                          nullptr,
                           CLSCTX_ALL,
                           IID_IMMDeviceEnumerator,
                           getter_AddRefs(enumerator));
   if (FAILED(hr))
     return NS_ERROR_NOT_AVAILABLE;
 
   nsRefPtr<IMMDevice> device;
   hr = enumerator->GetDefaultAudioEndpoint(EDataFlow::eRender,
@@ -245,41 +245,41 @@ AudioSession::Start()
     if (hr == E_NOTFOUND)
       return NS_ERROR_NOT_AVAILABLE;
     return NS_ERROR_FAILURE;
   }
 
   nsRefPtr<IAudioSessionManager> manager;
   hr = device->Activate(IID_IAudioSessionManager,
                         CLSCTX_ALL,
-                        NULL,
+                        nullptr,
                         getter_AddRefs(manager));
   if (FAILED(hr))
     return NS_ERROR_FAILURE;
 
-  hr = manager->GetAudioSessionControl(NULL,
+  hr = manager->GetAudioSessionControl(nullptr,
                                        FALSE,
                                        getter_AddRefs(mAudioSessionControl));
   if (FAILED(hr))
     return NS_ERROR_FAILURE;
 
   hr = mAudioSessionControl->SetGroupingParam((LPCGUID)&mSessionGroupingParameter,
-                                              NULL);
+                                              nullptr);
   if (FAILED(hr)) {
     StopInternal();
     return NS_ERROR_FAILURE;
   }
 
-  hr = mAudioSessionControl->SetDisplayName(mDisplayName.get(), NULL);
+  hr = mAudioSessionControl->SetDisplayName(mDisplayName.get(), nullptr);
   if (FAILED(hr)) {
     StopInternal();
     return NS_ERROR_FAILURE;
   }
 
-  hr = mAudioSessionControl->SetIconPath(mIconPath.get(), NULL);
+  hr = mAudioSessionControl->SetIconPath(mIconPath.get(), nullptr);
   if (FAILED(hr)) {
     StopInternal();
     return NS_ERROR_FAILURE;
   }
 
   hr = mAudioSessionControl->RegisterAudioSessionNotification(this);
   if (FAILED(hr)) {
     StopInternal();
@@ -292,17 +292,17 @@ AudioSession::Start()
 }
 
 void
 AudioSession::StopInternal()
 {
   static const nsID blankId = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} };
 
   if (mAudioSessionControl) {
-    mAudioSessionControl->SetGroupingParam((LPCGUID)&blankId, NULL);
+    mAudioSessionControl->SetGroupingParam((LPCGUID)&blankId, nullptr);
     mAudioSessionControl->UnregisterAudioSessionNotification(this);
     mAudioSessionControl = nullptr;
   }
 }
 
 nsresult
 AudioSession::Stop()
 {
--- a/widget/windows/GfxInfo.cpp
+++ b/widget/windows/GfxInfo.cpp
@@ -150,31 +150,33 @@ static nsresult GetKeyValue(const WCHAR*
   if (result != ERROR_SUCCESS) {
     return NS_ERROR_FAILURE;
   }
 
   switch (type) {
     case REG_DWORD: {
       // We only use this for vram size
       dwcbData = sizeof(dValue);
-      result = RegQueryValueExW(key, keyName, NULL, &resultType, (LPBYTE)&dValue, &dwcbData);
+      result = RegQueryValueExW(key, keyName, nullptr, &resultType,
+                                (LPBYTE)&dValue, &dwcbData);
       if (result == ERROR_SUCCESS && resultType == REG_DWORD) {
         dValue = dValue / 1024 / 1024;
         destString.AppendInt(int32_t(dValue));
       } else {
         retval = NS_ERROR_FAILURE;
       }
       break;
     }
     case REG_MULTI_SZ: {
       // A chain of null-separated strings; we convert the nulls to spaces
       WCHAR wCharValue[1024];
       dwcbData = sizeof(wCharValue);
 
-      result = RegQueryValueExW(key, keyName, NULL, &resultType, (LPBYTE)wCharValue, &dwcbData);
+      result = RegQueryValueExW(key, keyName, nullptr, &resultType,
+                                (LPBYTE)wCharValue, &dwcbData);
       if (result == ERROR_SUCCESS && resultType == REG_MULTI_SZ) {
         // This bit here could probably be cleaner.
         bool isValid = false;
 
         DWORD strLen = dwcbData/sizeof(wCharValue[0]);
         for (DWORD i = 0; i < strLen; i++) {
           if (wCharValue[i] == '\0') {
             if (i < strLen - 1 && wCharValue[i + 1] == '\0') {
@@ -251,28 +253,28 @@ GfxInfo::Init()
   if (spoofedWindowsVersion) {
     PR_sscanf(spoofedWindowsVersion, "%x", &mWindowsVersion);
   } else {
     mWindowsVersion = gfxWindowsPlatform::WindowsOSVersion();
   }
 
   mDeviceKeyDebug = NS_LITERAL_STRING("PrimarySearch");
 
-  while (EnumDisplayDevicesW(NULL, deviceIndex, &displayDevice, 0)) {
+  while (EnumDisplayDevicesW(nullptr, deviceIndex, &displayDevice, 0)) {
     if (displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
       mDeviceKeyDebug = NS_LITERAL_STRING("NullSearch");
       break;
     }
     deviceIndex++;
   }
 
-  // make sure the string is NULL terminated
+  // make sure the string is nullptr terminated
   if (wcsnlen(displayDevice.DeviceKey, ArrayLength(displayDevice.DeviceKey))
       == ArrayLength(displayDevice.DeviceKey)) {
-    // we did not find a NULL
+    // we did not find a nullptr
     return rv;
   }
 
   mDeviceKeyDebug = displayDevice.DeviceKey;
 
   /* DeviceKey is "reserved" according to MSDN so we'll be careful with it */
   /* check that DeviceKey begins with DEVICE_KEY_PREFIX */
   /* some systems have a DeviceKey starting with \REGISTRY\Machine\ so we need to compare case insenstively */
@@ -285,17 +287,17 @@ GfxInfo::Init()
   mDeviceID = displayDevice.DeviceID;
   mDeviceString = displayDevice.DeviceString;
 
   // On Windows 8 and Server 2012 hosts, we want to not block RDP
   // sessions from attempting hardware acceleration.  RemoteFX
   // provides features and functionaltiy that can give a good D3D10 +
   // D2D + DirectWrite experience emulated via a software GPU.
   //
-  // Unfortunately, the Device ID is NULL, and we can't enumerate
+  // Unfortunately, the Device ID is nullptr, and we can't enumerate
   // it using the setup infrastructure (SetupDiGetClassDevsW below
   // will return INVALID_HANDLE_VALUE).
   if (mWindowsVersion == gfxWindowsPlatform::kWindows8 &&
       mDeviceID.Length() == 0 &&
       mDeviceString.EqualsLiteral("RDPUDD Chained DD"))
   {
     WCHAR sysdir[255];
     UINT len = GetSystemDirectory(sysdir, sizeof(sysdir));
@@ -306,17 +308,17 @@ GfxInfo::Init()
       mDriverDate.AssignLiteral("01-01-1970");
 
       // 0x1414 is Microsoft; 0xfefe is an invented (and unused) code
       mDeviceID.AssignLiteral("PCI\\VEN_1414&DEV_FEFE&SUBSYS_00000000");
     }
   }
 
   /* create a device information set composed of the current display device */
-  HDEVINFO devinfo = SetupDiGetClassDevsW(NULL, mDeviceID.get(), NULL,
+  HDEVINFO devinfo = SetupDiGetClassDevsW(nullptr, mDeviceID.get(), nullptr,
                                           DIGCF_PRESENT | DIGCF_PROFILE | DIGCF_ALLCLASSES);
 
   if (devinfo != INVALID_HANDLE_VALUE) {
     HKEY key;
     LONG result;
     WCHAR value[255];
     DWORD dwcbData;
     SP_DEVINFO_DATA devinfoData;
@@ -325,35 +327,37 @@ GfxInfo::Init()
     devinfoData.cbSize = sizeof(devinfoData);
     NS_NAMED_LITERAL_STRING(driverKeyPre, "System\\CurrentControlSet\\Control\\Class\\");
     /* enumerate device information elements in the device information set */
     while (SetupDiEnumDeviceInfo(devinfo, memberIndex++, &devinfoData)) {
       /* get a string that identifies the device's driver key */
       if (SetupDiGetDeviceRegistryPropertyW(devinfo,
                                             &devinfoData,
                                             SPDRP_DRIVER,
-                                            NULL,
+                                            nullptr,
                                             (PBYTE)value,
                                             sizeof(value),
-                                            NULL)) {
+                                            nullptr)) {
         nsAutoString driverKey(driverKeyPre);
         driverKey += value;
         result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, driverKey.BeginReading(), 0, KEY_QUERY_VALUE, &key);
         if (result == ERROR_SUCCESS) {
           /* we've found the driver we're looking for */
           dwcbData = sizeof(value);
-          result = RegQueryValueExW(key, L"DriverVersion", NULL, NULL, (LPBYTE)value, &dwcbData);
+          result = RegQueryValueExW(key, L"DriverVersion", nullptr, nullptr,
+                                    (LPBYTE)value, &dwcbData);
           if (result == ERROR_SUCCESS) {
             mDriverVersion = value;
           } else {
             // If the entry wasn't found, assume the worst (0.0.0.0).
             mDriverVersion.AssignLiteral("0.0.0.0");
           }
           dwcbData = sizeof(value);
-          result = RegQueryValueExW(key, L"DriverDate", NULL, NULL, (LPBYTE)value, &dwcbData);
+          result = RegQueryValueExW(key, L"DriverDate", nullptr, nullptr,
+                                    (LPBYTE)value, &dwcbData);
           if (result == ERROR_SUCCESS) {
             mDriverDate = value;
           } else {
             // Again, assume the worst
             mDriverDate.AssignLiteral("01-01-1970");
           }
           RegCloseKey(key); 
           break;
@@ -370,17 +374,18 @@ GfxInfo::Init()
 
   // We now check for second display adapter.
 
   // Device interface class for display adapters.
   CLSID GUID_DISPLAY_DEVICE_ARRIVAL;
   HRESULT hresult = CLSIDFromString(L"{1CA05180-A699-450A-9A0C-DE4FBE3DDD89}",
                                &GUID_DISPLAY_DEVICE_ARRIVAL);
   if (hresult == NOERROR) {
-    devinfo = SetupDiGetClassDevsW(&GUID_DISPLAY_DEVICE_ARRIVAL, NULL, NULL,
+    devinfo = SetupDiGetClassDevsW(&GUID_DISPLAY_DEVICE_ARRIVAL,
+                                   nullptr, nullptr,
                                    DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
 
     if (devinfo != INVALID_HANDLE_VALUE) {
       HKEY key;
       LONG result;
       WCHAR value[255];
       DWORD dwcbData;
       SP_DEVINFO_DATA devinfoData;
@@ -396,26 +401,27 @@ GfxInfo::Init()
 
       NS_NAMED_LITERAL_STRING(driverKeyPre, "System\\CurrentControlSet\\Control\\Class\\");
       /* enumerate device information elements in the device information set */
       while (SetupDiEnumDeviceInfo(devinfo, memberIndex++, &devinfoData)) {
         /* get a string that identifies the device's driver key */
         if (SetupDiGetDeviceRegistryPropertyW(devinfo,
                                               &devinfoData,
                                               SPDRP_DRIVER,
-                                              NULL,
+                                              nullptr,
                                               (PBYTE)value,
                                               sizeof(value),
-                                              NULL)) {
+                                              nullptr)) {
           nsAutoString driverKey2(driverKeyPre);
           driverKey2 += value;
           result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, driverKey2.BeginReading(), 0, KEY_QUERY_VALUE, &key);
           if (result == ERROR_SUCCESS) {
             dwcbData = sizeof(value);
-            result = RegQueryValueExW(key, L"MatchingDeviceId", NULL, NULL, (LPBYTE)value, &dwcbData);
+            result = RegQueryValueExW(key, L"MatchingDeviceId", nullptr,
+                                      nullptr, (LPBYTE)value, &dwcbData);
             if (result != ERROR_SUCCESS) {
               continue;
             }
             deviceID2 = value;
             nsAutoString adapterVendorID2String;
             nsAutoString adapterDeviceID2String;
             adapterVendorID2 = ParseIDFromDeviceID(deviceID2, "VEN_", 4);
             adapterVendorID2String.AppendPrintf("0x%04x", adapterVendorID2);
@@ -430,34 +436,38 @@ GfxInfo::Init()
             // If this device is missing driver information, it is unlikely to
             // be a real display adapter.
             if (NS_FAILED(GetKeyValue(driverKey2.BeginReading(), L"InstalledDisplayDrivers",
                            adapterDriver2, REG_MULTI_SZ))) {
               RegCloseKey(key);
               continue;
             }
             dwcbData = sizeof(value);
-            result = RegQueryValueExW(key, L"DriverVersion", NULL, NULL, (LPBYTE)value, &dwcbData);
+            result = RegQueryValueExW(key, L"DriverVersion", nullptr, nullptr,
+                                      (LPBYTE)value, &dwcbData);
             if (result != ERROR_SUCCESS) {
               RegCloseKey(key);
               continue;
             }
             driverVersion2 = value;
             dwcbData = sizeof(value);
-            result = RegQueryValueExW(key, L"DriverDate", NULL, NULL, (LPBYTE)value, &dwcbData);
+            result = RegQueryValueExW(key, L"DriverDate", nullptr, nullptr,
+                                      (LPBYTE)value, &dwcbData);
             if (result != ERROR_SUCCESS) {
               RegCloseKey(key);
               continue;
             }
             driverDate2 = value;
             dwcbData = sizeof(value);
-            result = RegQueryValueExW(key, L"Device Description", NULL, NULL, (LPBYTE)value, &dwcbData);
+            result = RegQueryValueExW(key, L"Device Description", nullptr,
+                                      nullptr, (LPBYTE)value, &dwcbData);
             if (result != ERROR_SUCCESS) {
               dwcbData = sizeof(value);
-              result = RegQueryValueExW(key, L"DriverDesc", NULL, NULL, (LPBYTE)value, &dwcbData);
+              result = RegQueryValueExW(key, L"DriverDesc", nullptr, nullptr,
+                                        (LPBYTE)value, &dwcbData);
             }
             RegCloseKey(key);
             if (result == ERROR_SUCCESS) {
               mHasDualGPU = true;
               mDeviceString2 = value;
               mDeviceID2 = deviceID2;
               mDeviceKey2 = driverKey2;
               mDriverVersion2 = driverVersion2;
--- a/widget/windows/IEnumFE.cpp
+++ b/widget/windows/IEnumFE.cpp
@@ -26,23 +26,23 @@ CEnumFormatEtc::~CEnumFormatEtc()
 {
 }
 
 /* IUnknown impl. */
 
 STDMETHODIMP
 CEnumFormatEtc::QueryInterface(REFIID riid, LPVOID *ppv)
 {
-  *ppv = NULL;
+  *ppv = nullptr;
 
   if (IsEqualIID(riid, IID_IUnknown) ||
       IsEqualIID(riid, IID_IEnumFORMATETC))
       *ppv = (LPVOID)this;
 
-  if (*ppv == NULL)
+  if (*ppv == nullptr)
       return E_NOINTERFACE;
 
   // AddRef any interface we'll return.
   ((LPUNKNOWN)*ppv)->AddRef();
   return S_OK;
 }
 
 STDMETHODIMP_(ULONG)
--- a/widget/windows/JumpListBuilder.cpp
+++ b/widget/windows/JumpListBuilder.cpp
@@ -41,19 +41,19 @@ bool JumpListBuilder::sBuildingList = fa
 const char kPrefTaskbarEnabled[] = "browser.taskbar.lists.enabled";
 
 NS_IMPL_ISUPPORTS2(JumpListBuilder, nsIJumpListBuilder, nsIObserver)
 
 JumpListBuilder::JumpListBuilder() :
   mMaxItems(0),
   mHasCommit(false)
 {
-  ::CoInitialize(NULL);
+  ::CoInitialize(nullptr);
   
-  CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER,
+  CoCreateInstance(CLSID_DestinationList, nullptr, CLSCTX_INPROC_SERVER,
                    IID_ICustomDestinationList, getter_AddRefs(mJumpListMgr));
 
   // Make a lazy thread for any IO
   mIOThread = new LazyIdleThread(DEFAULT_THREAD_TIMEOUT_MS,
                                  NS_LITERAL_CSTRING("Jump List"),
                                  LazyIdleThread::ManualShutdown);
   Preferences::AddStrongObserver(this, kPrefTaskbarEnabled);
 }
@@ -252,18 +252,19 @@ NS_IMETHODIMP JumpListBuilder::AddListTo
 
   switch(aCatType) {
     case nsIJumpListBuilder::JUMPLIST_CATEGORY_TASKS:
     {
       NS_ENSURE_ARG_POINTER(items);
 
       HRESULT hr;
       nsRefPtr<IObjectCollection> collection;
-      hr = CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER,
-                            IID_IObjectCollection, getter_AddRefs(collection));
+      hr = CoCreateInstance(CLSID_EnumerableObjectCollection, nullptr,
+                            CLSCTX_INPROC_SERVER, IID_IObjectCollection,
+                            getter_AddRefs(collection));
       if (FAILED(hr))
         return NS_ERROR_UNEXPECTED;
 
       // Build the list
       uint32_t length;
       items->GetLength(&length);
       for (uint32_t i = 0; i < length; ++i) {
         nsCOMPtr<nsIJumpListItem> item = do_QueryElementAt(items, i);
@@ -317,18 +318,19 @@ NS_IMETHODIMP JumpListBuilder::AddListTo
     {
       NS_ENSURE_ARG_POINTER(items);
 
       if (catName.IsEmpty())
         return NS_ERROR_INVALID_ARG;
 
       HRESULT hr;
       nsRefPtr<IObjectCollection> collection;
-      hr = CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER,
-                            IID_IObjectCollection, getter_AddRefs(collection));
+      hr = CoCreateInstance(CLSID_EnumerableObjectCollection, nullptr,
+                            CLSCTX_INPROC_SERVER, IID_IObjectCollection,
+                            getter_AddRefs(collection));
       if (FAILED(hr))
         return NS_ERROR_UNEXPECTED;
 
       uint32_t length;
       items->GetLength(&length);
       for (uint32_t i = 0; i < length; ++i) {
         nsCOMPtr<nsIJumpListItem> item = do_QueryElementAt(items, i);
         if (!item)
--- a/widget/windows/JumpListItem.cpp
+++ b/widget/windows/JumpListItem.cpp
@@ -281,17 +281,17 @@ NS_IMETHODIMP JumpListShortcut::Equals(n
 
 // (static) Creates a ShellLink that encapsulate a separator.
 nsresult JumpListSeparator::GetSeparator(nsRefPtr<IShellLinkW>& aShellLink)
 {
   HRESULT hr;
   IShellLinkW* psl;
 
   // Create a IShellLink.
-  hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, 
+  hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, 
                         IID_IShellLinkW, (LPVOID*)&psl);
   if (FAILED(hr))
     return NS_ERROR_UNEXPECTED;
 
   IPropertyStore* pPropStore = nullptr;
   hr = psl->QueryInterface(IID_IPropertyStore, (LPVOID*)&pPropStore);
   if (FAILED(hr))
     return NS_ERROR_UNEXPECTED;
@@ -333,17 +333,17 @@ nsresult JumpListShortcut::GetShellLink(
   nsCOMPtr<nsIJumpListShortcut> shortcut = do_QueryInterface(item, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsILocalHandlerApp> handlerApp;
   rv = shortcut->GetApp(getter_AddRefs(handlerApp));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Create a IShellLink 
-  hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
+  hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
                         IID_IShellLinkW, (LPVOID*)&psl);
   if (FAILED(hr))
     return NS_ERROR_UNEXPECTED;
 
   // Retrieve the app path, title, description and optional command line args.
   nsAutoString appPath, appTitle, appDescription, appArgs;
   int32_t appIconIndex = 0;
 
@@ -471,17 +471,17 @@ nsresult JumpListShortcut::GetJumpListSh
 
   nsCOMPtr<nsILocalHandlerApp> handlerApp = 
     do_CreateInstance(NS_LOCALHANDLERAPP_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRUnichar buf[MAX_PATH];
 
   // Path
-  hres = pLink->GetPath((LPWSTR)&buf, MAX_PATH, NULL, SLGP_UNCPRIORITY);
+  hres = pLink->GetPath((LPWSTR)&buf, MAX_PATH, nullptr, SLGP_UNCPRIORITY);
   if (FAILED(hres))
     return NS_ERROR_INVALID_ARG;
 
   nsCOMPtr<nsIFile> file;
   nsDependentString filepath(buf);
   rv = NS_NewLocalFile(filepath, false, getter_AddRefs(file));
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -558,17 +558,18 @@ nsresult JumpListLink::GetShellItem(nsCO
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString spec;
   rv = uri->GetSpec(spec);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Create the IShellItem
   if (FAILED(WinUtils::SHCreateItemFromParsingName(
-               NS_ConvertASCIItoUTF16(spec).get(), NULL, IID_PPV_ARGS(&psi)))) {
+               NS_ConvertASCIItoUTF16(spec).get(),
+               nullptr, IID_PPV_ARGS(&psi)))) {
     return NS_ERROR_INVALID_ARG;
   }
 
   // Set the title
   nsAutoString linkTitle;
   link->GetUriTitle(linkTitle);
 
   IPropertyStore* pPropStore = nullptr;
@@ -594,17 +595,17 @@ nsresult JumpListLink::GetShellItem(nsCO
 // (static) For a given IShellItem, create and return a populated nsIJumpListLink.
 nsresult JumpListLink::GetJumpListLink(IShellItem *pItem, nsCOMPtr<nsIJumpListLink>& aLink)
 {
   NS_ENSURE_ARG_POINTER(pItem);
 
   // We assume for now these are URI links, but through properties we could
   // query and create other types.
   nsresult rv;
-  LPWSTR lpstrName = NULL;
+  LPWSTR lpstrName = nullptr;
 
   if (SUCCEEDED(pItem->GetDisplayName(SIGDN_URL, &lpstrName))) {
     nsCOMPtr<nsIURI> uri;
     nsAutoString spec(lpstrName);
 
     rv = NS_NewURI(getter_AddRefs(uri), NS_ConvertUTF16toUTF8(spec));
     if (NS_FAILED(rv))
       return NS_ERROR_INVALID_ARG;
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -2229,31 +2229,31 @@ KeyboardLayout::ConvertNativeKeyCodeToKe
 nsresult
 KeyboardLayout::SynthesizeNativeKeyEvent(nsWindowBase* aWidget,
                                          int32_t aNativeKeyboardLayout,
                                          int32_t aNativeKeyCode,
                                          uint32_t aModifierFlags,
                                          const nsAString& aCharacters,
                                          const nsAString& aUnmodifiedCharacters)
 {
-  UINT keyboardLayoutListCount = ::GetKeyboardLayoutList(0, NULL);
+  UINT keyboardLayoutListCount = ::GetKeyboardLayoutList(0, nullptr);
   NS_ASSERTION(keyboardLayoutListCount > 0,
                "One keyboard layout must be installed at least");
   HKL keyboardLayoutListBuff[50];
   HKL* keyboardLayoutList =
     keyboardLayoutListCount < 50 ? keyboardLayoutListBuff :
                                    new HKL[keyboardLayoutListCount];
   keyboardLayoutListCount =
     ::GetKeyboardLayoutList(keyboardLayoutListCount, keyboardLayoutList);
   NS_ASSERTION(keyboardLayoutListCount > 0,
                "Failed to get all keyboard layouts installed on the system");
 
   nsPrintfCString layoutName("%08x", aNativeKeyboardLayout);
   HKL loadedLayout = LoadKeyboardLayoutA(layoutName.get(), KLF_NOTELLSHELL);
-  if (loadedLayout == NULL) {
+  if (loadedLayout == nullptr) {
     if (keyboardLayoutListBuff != keyboardLayoutList) {
       delete [] keyboardLayoutList;
     }
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Setup clean key state and load desired layout
   BYTE originalKbdState[256];
--- a/widget/windows/LSPAnnotator.cpp
+++ b/widget/windows/LSPAnnotator.cpp
@@ -51,28 +51,28 @@ LSPAnnotationGatherer::Run()
 {
   PR_SetCurrentThreadName("LSP Annotator");
 
   mThread = NS_GetCurrentThread();
 
   DWORD size = 0;
   int err;
   // Get the size of the buffer we need
-  if (SOCKET_ERROR != WSCEnumProtocols(NULL, NULL, &size, &err) ||
+  if (SOCKET_ERROR != WSCEnumProtocols(nullptr, nullptr, &size, &err) ||
       err != WSAENOBUFS) {
     // Er, what?
     NS_NOTREACHED("WSCEnumProtocols suceeded when it should have failed ...");
     return NS_ERROR_FAILURE;
   }
 
   nsAutoArrayPtr<char> byteArray(new char[size]);
   WSAPROTOCOL_INFOW* providers =
     reinterpret_cast<WSAPROTOCOL_INFOW*>(byteArray.get());
 
-  int n = WSCEnumProtocols(NULL, providers, &size, &err);
+  int n = WSCEnumProtocols(nullptr, providers, &size, &err);
   if (n == SOCKET_ERROR) {
     // Lame. We provided the right size buffer; we'll just give up now.
     NS_WARNING("Could not get LSP list");
     return NS_ERROR_FAILURE;
   }
 
   nsCString str;
   for (int i = 0; i < n; i++) {
--- a/widget/windows/nsAppShell.cpp
+++ b/widget/windows/nsAppShell.cpp
@@ -73,35 +73,35 @@ nsAppShell::Init()
 #endif
 
   mLastNativeEventScheduled = TimeStamp::NowLoRes();
 
   sTaskbarButtonCreatedMsg = ::RegisterWindowMessageW(kTaskbarButtonEventId);
   NS_ASSERTION(sTaskbarButtonCreatedMsg, "Could not register taskbar button creation message");
 
   WNDCLASSW wc;
-  HINSTANCE module = GetModuleHandle(NULL);
+  HINSTANCE module = GetModuleHandle(nullptr);
 
   const PRUnichar *const kWindowClass = L"nsAppShell:EventWindowClass";
   if (!GetClassInfoW(module, kWindowClass, &wc)) {
     wc.style         = 0;
     wc.lpfnWndProc   = EventWindowProc;
     wc.cbClsExtra    = 0;
     wc.cbWndExtra    = 0;
     wc.hInstance     = module;
-    wc.hIcon         = NULL;
-    wc.hCursor       = NULL;
-    wc.hbrBackground = (HBRUSH) NULL;
-    wc.lpszMenuName  = (LPCWSTR) NULL;
+    wc.hIcon         = nullptr;
+    wc.hCursor       = nullptr;
+    wc.hbrBackground = (HBRUSH) nullptr;
+    wc.lpszMenuName  = (LPCWSTR) nullptr;
     wc.lpszClassName = kWindowClass;
     RegisterClassW(&wc);
   }
 
   mEventWnd = CreateWindowW(kWindowClass, L"nsAppShell:EventWindow",
-                           0, 0, 0, 10, 10, NULL, NULL, module, NULL);
+                           0, 0, 0, 10, 10, nullptr, nullptr, module, nullptr);
   NS_ENSURE_STATE(mEventWnd);
 
   return nsBaseAppShell::Init();
 }
 
 
 NS_IMETHODIMP
 nsAppShell::Run(void)
@@ -186,25 +186,25 @@ nsAppShell::ProcessNextNativeEvent(bool 
     // For avoiding deadlock between our process and plugin process by
     // mouse wheel messages, we're handling actually when we receive one of
     // following internal messages which is posted by native mouse wheel
     // message handler. Any other events, especially native modifier key
     // events, should not be handled between native message and posted
     // internal message because it may make different modifier key state or
     // mouse cursor position between them.
     if (mozilla::widget::MouseScrollHandler::IsWaitingInternalMessage()) {
-      gotMessage = WinUtils::PeekMessage(&msg, NULL, MOZ_WM_MOUSEWHEEL_FIRST,
+      gotMessage = WinUtils::PeekMessage(&msg, nullptr, MOZ_WM_MOUSEWHEEL_FIRST,
                                          MOZ_WM_MOUSEWHEEL_LAST, PM_REMOVE);
       NS_ASSERTION(gotMessage,
                    "waiting internal wheel message, but it has not come");
       uiMessage = gotMessage;
     }
 
     if (!gotMessage) {
-      gotMessage = WinUtils::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
+      gotMessage = WinUtils::PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE);
       uiMessage =
         (msg.message >= WM_KEYFIRST && msg.message <= WM_IME_KEYLAST) ||
         (msg.message >= NS_WM_IMEFIRST && msg.message <= NS_WM_IMELAST) ||
         (msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST);
     }
 
     if (gotMessage) {
       if (msg.message == WM_QUIT) {
--- a/widget/windows/nsAppShell.h
+++ b/widget/windows/nsAppShell.h
@@ -17,17 +17,17 @@
 
 /**
  * Native Win32 Application shell wrapper
  */
 class nsAppShell : public nsBaseAppShell
 {
 public:
   nsAppShell() :
-    mEventWnd(NULL),
+    mEventWnd(nullptr),
     mNativeCallbackPending(false),
     mLastNativeEventScheduledMutex("nsAppShell::mLastNativeEventScheduledMutex")
   {}
   typedef mozilla::TimeStamp TimeStamp;
   typedef mozilla::Mutex Mutex;
 
   nsresult Init();
   void DoProcessMoreGeckoEvents();
--- a/widget/windows/nsClipboard.cpp
+++ b/widget/windows/nsClipboard.cpp
@@ -252,39 +252,39 @@ NS_IMETHODIMP nsClipboard::SetNativeClip
   mIgnoreEmptyNotification = true;
 
   // make sure we have a good transferable
   if (nullptr == mTransferable) {
     return NS_ERROR_FAILURE;
   }
 
   IDataObject * dataObj;
-  if ( NS_SUCCEEDED(CreateNativeDataObject(mTransferable, &dataObj, NULL)) ) { // this add refs dataObj
+  if ( NS_SUCCEEDED(CreateNativeDataObject(mTransferable, &dataObj, nullptr)) ) { // this add refs dataObj
     ::OleSetClipboard(dataObj);
     dataObj->Release();
   } else {
     // Clear the native clipboard
-    ::OleSetClipboard(NULL);
+    ::OleSetClipboard(nullptr);
   }
 
   mIgnoreEmptyNotification = false;
 
   return NS_OK;
 }
 
 
 //-------------------------------------------------------------------------
 nsresult nsClipboard::GetGlobalData(HGLOBAL aHGBL, void ** aData, uint32_t * aLen)
 {
   // Allocate a new memory buffer and copy the data from global memory.
   // Recall that win98 allocates to nearest DWORD boundary. As a safety
   // precaution, allocate an extra 2 bytes (but don't report them!) and
   // null them out to ensure that all of our strlen calls will succeed.
   nsresult  result = NS_ERROR_FAILURE;
-  if (aHGBL != NULL) {
+  if (aHGBL != nullptr) {
     LPSTR lpStr = (LPSTR) GlobalLock(aHGBL);
     DWORD allocSize = GlobalSize(aHGBL);
     char* data = static_cast<char*>(nsMemory::Alloc(allocSize + sizeof(PRUnichar)));
     if ( data ) {    
       memcpy ( data, lpStr, allocSize );
       data[allocSize] = data[allocSize + 1] = '\0';     // null terminate for safety
 
       GlobalUnlock(aHGBL);
@@ -300,26 +300,27 @@ nsresult nsClipboard::GetGlobalData(HGLO
     // We really shouldn't ever get here
     // but just in case
     *aData = nullptr;
     *aLen  = 0;
     LPVOID lpMsgBuf;
 
     FormatMessageW( 
         FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
-        NULL,
+        nullptr,
         GetLastError(),
         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
         (LPWSTR) &lpMsgBuf,
         0,
-        NULL 
+        nullptr 
     );
 
     // Display the string.
-    MessageBoxW( NULL, (LPCWSTR) lpMsgBuf, L"GetLastError", MB_OK|MB_ICONINFORMATION );
+    MessageBoxW( nullptr, (LPCWSTR) lpMsgBuf, L"GetLastError",
+                 MB_OK | MB_ICONINFORMATION );
 
     // Free the buffer.
     LocalFree( lpMsgBuf );    
   }
 
   return result;
 }
 
@@ -483,17 +484,17 @@ nsresult nsClipboard::GetNativeDataOffCl
             case CF_HDROP : 
               {
                 // in the case of a file drop, multiple files are stashed within a
                 // single data object. In order to match mozilla's D&D apis, we
                 // just pull out the file at the requested index, pretending as
                 // if there really are multiple drag items.
                 HDROP dropFiles = (HDROP) GlobalLock(stm.hGlobal);
 
-                UINT numFiles = ::DragQueryFileW(dropFiles, 0xFFFFFFFF, NULL, 0);
+                UINT numFiles = ::DragQueryFileW(dropFiles, 0xFFFFFFFF, nullptr, 0);
                 NS_ASSERTION ( numFiles > 0, "File drop flavor, but no files...hmmmm" );
                 NS_ASSERTION ( aIndex < numFiles, "Asked for a file index out of range of list" );
                 if (numFiles > 0) {
                   UINT fileNameLen = ::DragQueryFileW(dropFiles, aIndex, nullptr, 0);
                   PRUnichar* buffer = reinterpret_cast<PRUnichar*>(nsMemory::Alloc((fileNameLen + 1) * sizeof(PRUnichar)));
                   if ( buffer ) {
                     ::DragQueryFileW(dropFiles, aIndex, buffer, fileNameLen + 1);
                     *aData = buffer;
@@ -949,17 +950,17 @@ NS_IMETHODIMP
 nsClipboard::EmptyClipboard(int32_t aWhichClipboard)
 {
   // Some programs such as ZoneAlarm monitor clipboard usage and then open the
   // clipboard to scan it.  If we i) empty and then ii) set data, then the
   // 'set data' can sometimes fail with access denied becacuse another program
   // has the clipboard open.  So to avoid this race condition for OpenClipboard
   // we do not empty the clipboard when we're setting it.
   if (aWhichClipboard == kGlobalClipboard && !mEmptyingForSetData) {
-    OleSetClipboard(NULL);
+    OleSetClipboard(nullptr);
   }
   return nsBaseClipboard::EmptyClipboard(aWhichClipboard);
 }
 
 //-------------------------------------------------------------------------
 NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(const char** aFlavorList,
                                                   uint32_t aLength,
                                                   int32_t aWhichClipboard,
--- a/widget/windows/nsColorPicker.cpp
+++ b/widget/windows/nsColorPicker.cpp
@@ -98,17 +98,17 @@ AsyncColorChooser::AsyncColorChooser(DWO
 
 NS_IMETHODIMP
 AsyncColorChooser::Run()
 {
   CHOOSECOLOR options;
   static COLORREF customColors[16] = {0} ;
 
   AutoDestroyTmpWindow adtw((HWND) (mParentWidget.get() ?
-    mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : NULL));
+    mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr));
 
   options.lStructSize   = sizeof(options);
   options.hwndOwner     = adtw.get();
   options.Flags         = CC_RGBINIT | CC_FULLOPEN;
   options.rgbResult     = mInitialColor;
   options.lpCustColors  = customColors;
 
   if (ChooseColor(&options)) {
--- a/widget/windows/nsDataObj.cpp
+++ b/widget/windows/nsDataObj.cpp
@@ -70,25 +70,25 @@ nsresult nsDataObj::CStream::Init(nsIURI
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // IUnknown's QueryInterface, nsISupport's AddRef and Release are shared by
 // IUnknown and nsIStreamListener.
 STDMETHODIMP nsDataObj::CStream::QueryInterface(REFIID refiid, void** ppvResult)
 {
-  *ppvResult = NULL;
+  *ppvResult = nullptr;
   if (IID_IUnknown == refiid ||
       refiid == IID_IStream)
 
   {
     *ppvResult = this;
   }
 
-  if (NULL != *ppvResult)
+  if (nullptr != *ppvResult)
   {
     ((LPUNKNOWN)*ppvResult)->AddRef();
     return S_OK;
   }
 
   return E_NOINTERFACE;
 }
 
@@ -97,17 +97,17 @@ NS_IMETHODIMP
 nsDataObj::CStream::OnDataAvailable(nsIRequest *aRequest,
                                     nsISupports *aContext,
                                     nsIInputStream *aInputStream,
                                     uint64_t aOffset, // offset within the stream
                                     uint32_t aCount) // bytes available on this call
 {
     // Extend the write buffer for the incoming data.
     uint8_t* buffer = mChannelData.AppendElements(aCount);
-    if (buffer == NULL)
+    if (buffer == nullptr)
       return NS_ERROR_OUT_OF_MEMORY;
     NS_ASSERTION((mChannelData.Length() == (aOffset + aCount)),
       "stream length mismatch w/write buffer");
 
     // Read() may not return aCount on a single call, so loop until we've
     // accumulated all the data OnDataAvailable has promised.
     nsresult rv;
     uint32_t odaBytesReadTotal = 0;
@@ -210,17 +210,17 @@ STDMETHODIMP nsDataObj::CStream::Revert(
   return E_NOTIMPL;
 }
 
 //-----------------------------------------------------------------------------
 STDMETHODIMP nsDataObj::CStream::Seek(LARGE_INTEGER nMove,
                                       DWORD dwOrigin,
                                       ULARGE_INTEGER* nNewPos)
 {
-  if (nNewPos == NULL)
+  if (nNewPos == nullptr)
     return STG_E_INVALIDPOINTER;
 
   if (nMove.LowPart == 0 && nMove.HighPart == 0 &&
       (dwOrigin == STREAM_SEEK_SET || dwOrigin == STREAM_SEEK_CUR)) { 
     nNewPos->LowPart = 0;
     nNewPos->HighPart = 0;
     return S_OK;
   }
@@ -232,17 +232,17 @@ STDMETHODIMP nsDataObj::CStream::Seek(LA
 STDMETHODIMP nsDataObj::CStream::SetSize(ULARGE_INTEGER nNewSize)
 {
   return E_NOTIMPL;
 }
 
 //-----------------------------------------------------------------------------
 STDMETHODIMP nsDataObj::CStream::Stat(STATSTG* statstg, DWORD dwFlags)
 {
-  if (statstg == NULL)
+  if (statstg == nullptr)
     return STG_E_INVALIDPOINTER;
 
   if (!mChannel || NS_FAILED(WaitForCompletion()))
     return E_FAIL;
 
   memset((void*)statstg, 0, sizeof(STATSTG));
 
   if (dwFlags != STATFLAG_NONAME) 
@@ -389,17 +389,17 @@ nsDataObj::~nsDataObj()
 }
 
 
 //-----------------------------------------------------
 // IUnknown interface methods - see inknown.h for documentation
 //-----------------------------------------------------
 STDMETHODIMP nsDataObj::QueryInterface(REFIID riid, void** ppv)
 {
-	*ppv=NULL;
+	*ppv=nullptr;
 
 	if ( (IID_IUnknown == riid) || (IID_IDataObject	== riid) ) {
 		*ppv = this;
 		AddRef();
 		return S_OK;
   } else if (IID_IAsyncOperation == riid) {
     *ppv = static_cast<IAsyncOperation*>(this);
     AddRef();
@@ -435,17 +435,17 @@ STDMETHODIMP_(ULONG) nsDataObj::Release(
     nsresult rv;
     mTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
     if (NS_SUCCEEDED(rv)) {
       mTimer->InitWithFuncCallback(nsDataObj::RemoveTempFile, this,
                                    500, nsITimer::TYPE_ONE_SHOT);
       return AddRef();
     }
     mCachedTempFile->Remove(false);
-    mCachedTempFile = NULL;
+    mCachedTempFile = nullptr;
   }
 
 	delete this;
 
 	return 0;
 }
 
 //-----------------------------------------------------
@@ -489,17 +489,17 @@ STDMETHODIMP nsDataObj::GetData(LPFORMAT
   // Firefox internal formats
   ULONG count;
   FORMATETC fe;
   m_enumFE->Reset();
   while (NOERROR == m_enumFE->Next(1, &fe, &count)
          && dfInx < mDataFlavors.Length()) {
     nsCString& df = mDataFlavors.ElementAt(dfInx);
     if (FormatsMatch(fe, *aFormat)) {
-      pSTM->pUnkForRelease = NULL;        // caller is responsible for deleting this data
+      pSTM->pUnkForRelease = nullptr;     // caller is responsible for deleting this data
       CLIPFORMAT format = aFormat->cfFormat;
       switch(format) {
 
       // Someone is asking for plain or unicode text
       case CF_TEXT:
       case CF_UNICODETEXT:
       return GetText(df, *aFormat, *pSTM);
 
@@ -613,19 +613,19 @@ STDMETHODIMP nsDataObj::SetData(LPFORMAT
     ReleaseStgMedium(aMedium);
 
   return S_OK;
 }
 
 bool
 nsDataObj::LookupArbitraryFormat(FORMATETC *aFormat, LPDATAENTRY *aDataEntry, BOOL aAddorUpdate)
 {
-  *aDataEntry = NULL;
+  *aDataEntry = nullptr;
 
-  if (aFormat->ptd != NULL)
+  if (aFormat->ptd != nullptr)
     return false;
 
   // See if it's already in our list. If so return the data entry.
   for (uint32_t idx = 0; idx < mDataEntryList.Length(); idx++) {
     if (mDataEntryList[idx]->fe.cfFormat == aFormat->cfFormat &&
         mDataEntryList[idx]->fe.dwAspect == aFormat->dwAspect &&
         mDataEntryList[idx]->fe.lindex == aFormat->lindex) {
       if (aAddorUpdate || (mDataEntryList[idx]->fe.tymed & aFormat->tymed)) {
@@ -706,20 +706,20 @@ STDMETHODIMP nsDataObj::EnumFormatEtc(DW
 {
   switch (dwDir) {
     case DATADIR_GET:
       m_enumFE->Clone(ppEnum);
       break;
     case DATADIR_SET:
       // fall through
     default:
-      *ppEnum = NULL;
+      *ppEnum = nullptr;
   } // switch
 
-  if (NULL == *ppEnum)
+  if (nullptr == *ppEnum)
     return E_FAIL;
 
   (*ppEnum)->Reset();
   // Clone already AddRefed the result so don't addref it again.
   return NOERROR;
 }
 
 //-----------------------------------------------------
@@ -944,17 +944,17 @@ CreateFilenameFromTextA(nsString & aText
   // way ensures that even in MBCS environments there will be a valid MBCS filename of
   // the correct length.
   int maxUsableFilenameLen = aFilenameLen - strlen(aExtension) - 1; // space for ext + null byte
   int currLen, textLen = (int) std::min(aText.Length(), aFilenameLen);
   char defaultChar = '_';
   do {
     currLen = WideCharToMultiByte(CP_ACP, 
       WC_COMPOSITECHECK|WC_DEFAULTCHAR,
-      aText.get(), textLen--, aFilename, maxUsableFilenameLen, &defaultChar, NULL);
+      aText.get(), textLen--, aFilename, maxUsableFilenameLen, &defaultChar, nullptr);
   }
   while (currLen == 0 && textLen > 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
   if (currLen > 0 && textLen > 0) {
     strcpy(&aFilename[currLen], aExtension);
     return true;
   }
   else {
     // empty names aren't permitted
@@ -1201,18 +1201,18 @@ bool nsDataObj :: IsFlavourPresent(const
 
   return retval;
 }
 
 HRESULT nsDataObj::GetPreferredDropEffect ( FORMATETC& aFE, STGMEDIUM& aSTG )
 {
   HRESULT res = S_OK;
   aSTG.tymed = TYMED_HGLOBAL;
-  aSTG.pUnkForRelease = NULL;    
-  HGLOBAL hGlobalMemory = NULL;
+  aSTG.pUnkForRelease = nullptr;    
+  HGLOBAL hGlobalMemory = nullptr;
   hGlobalMemory = ::GlobalAlloc(GMEM_MOVEABLE, sizeof(DWORD));
   if (hGlobalMemory) {
     DWORD* pdw = (DWORD*) GlobalLock(hGlobalMemory);
     // The PreferredDropEffect clipboard format is only registered if a drag/drop
     // of an image happens from Mozilla to the desktop.  We want its value
     // to be DROPEFFECT_MOVE in that case so that the file is moved from the
     // temporary location, not copied.
     // This value should, ideally, be set on the data object via SetData() but 
@@ -1226,17 +1226,17 @@ HRESULT nsDataObj::GetPreferredDropEffec
   }
   aSTG.hGlobal = hGlobalMemory;
   return res;
 }
 
 //-----------------------------------------------------
 HRESULT nsDataObj::GetText(const nsACString & aDataFlavor, FORMATETC& aFE, STGMEDIUM& aSTG)
 {
-  void* data = NULL;
+  void* data = nullptr;
   uint32_t   len;
   
   // if someone asks for text/plain, look up text/unicode instead in the transferable.
   const char* flavorStr;
   const nsPromiseFlatCString& flat = PromiseFlatCString(aDataFlavor);
   if ( aDataFlavor.Equals("text/plain") )
     flavorStr = kUnicodeMime;
   else
@@ -1246,20 +1246,20 @@ HRESULT nsDataObj::GetText(const nsACStr
   nsCOMPtr<nsISupports> genericDataWrapper;
   mTransferable->GetTransferData(flavorStr, getter_AddRefs(genericDataWrapper), &len);
   if ( !len )
     return E_FAIL;
   nsPrimitiveHelpers::CreateDataFromPrimitive ( flavorStr, genericDataWrapper, &data, len );
   if ( !data )
     return E_FAIL;
 
-  HGLOBAL     hGlobalMemory = NULL;
+  HGLOBAL     hGlobalMemory = nullptr;
 
   aSTG.tymed          = TYMED_HGLOBAL;
-  aSTG.pUnkForRelease = NULL;
+  aSTG.pUnkForRelease = nullptr;
 
   // We play games under the hood and advertise flavors that we know we
   // can support, only they require a bit of conversion or munging of the data.
   // Do that here.
   //
   // The transferable gives us data that is null-terminated, but this isn't reflected in
   // the |len| parameter. Windoze apps expect this null to be there so bump our data buffer
   // by the appropriate size to account for the null (one char for CF_TEXT, one PRUnichar for
@@ -1362,25 +1362,25 @@ HRESULT nsDataObj::DropFile(FORMATETC& a
     if (ptr)
       ptr->GetData(getter_AddRefs(file));
   }
 
   if (!file)
     return E_FAIL;
 
   aSTG.tymed = TYMED_HGLOBAL;
-  aSTG.pUnkForRelease = NULL;
+  aSTG.pUnkForRelease = nullptr;
 
   nsAutoString path;
   rv = file->GetPath(path);
   if (NS_FAILED(rv))
     return E_FAIL;
 
   uint32_t allocLen = path.Length() + 2;
-  HGLOBAL hGlobalMemory = NULL;
+  HGLOBAL hGlobalMemory = nullptr;
   PRUnichar *dest;
 
   hGlobalMemory = GlobalAlloc(GMEM_MOVEABLE, sizeof(DROPFILES) +
                                              allocLen * sizeof(PRUnichar));
   if (!hGlobalMemory)
     return E_FAIL;
 
   DROPFILES* pDropFile = (DROPFILES*)GlobalLock(hGlobalMemory);
@@ -1507,22 +1507,22 @@ HRESULT nsDataObj::DropImage(FORMATETC& 
   
   // Pass the file name back to the drop target so that it can access the file.
   nsAutoString path;
   rv = mCachedTempFile->GetPath(path);
   if (NS_FAILED(rv))
     return E_FAIL;
 
   // Two null characters are needed to terminate the file name list.
-  HGLOBAL hGlobalMemory = NULL;
+  HGLOBAL hGlobalMemory = nullptr;
 
   uint32_t allocLen = path.Length() + 2;
 
   aSTG.tymed = TYMED_HGLOBAL;
-  aSTG.pUnkForRelease = NULL;
+  aSTG.pUnkForRelease = nullptr;
 
   hGlobalMemory = GlobalAlloc(GMEM_MOVEABLE, sizeof(DROPFILES) + allocLen * sizeof(PRUnichar));
   if (!hGlobalMemory)
     return E_FAIL;
 
   DROPFILES* pDropFile = (DROPFILES*)GlobalLock(hGlobalMemory);
 
   // First, populate the drop file structure.
@@ -1580,17 +1580,17 @@ HRESULT nsDataObj::DropTempFile(FORMATET
     dropFile->Clone(getter_AddRefs(mCachedTempFile));
 
     // Write the data to disk.
     nsCOMPtr<nsIOutputStream> outStream;
     rv = NS_NewLocalFileOutputStream(getter_AddRefs(outStream), dropFile);
     if (NS_FAILED(rv))
       return E_FAIL;
 
-    IStream *pStream = NULL;
+    IStream *pStream = nullptr;
     nsDataObj::CreateStream(&pStream);
     NS_ENSURE_TRUE(pStream, E_FAIL);
 
     char buffer[512];
     ULONG readCount = 0;
     uint32_t writeCount = 0;
     while (1) {
       HRESULT hres = pStream->Read(buffer, sizeof(buffer), &readCount);
@@ -1610,20 +1610,20 @@ HRESULT nsDataObj::DropTempFile(FORMATET
   nsAutoString path;
   rv = mCachedTempFile->GetPath(path);
   if (NS_FAILED(rv))
     return E_FAIL;
 
   uint32_t allocLen = path.Length() + 2;
 
   // Two null characters are needed to terminate the file name list.
-  HGLOBAL hGlobalMemory = NULL;
+  HGLOBAL hGlobalMemory = nullptr;
 
   aSTG.tymed = TYMED_HGLOBAL;
-  aSTG.pUnkForRelease = NULL;
+  aSTG.pUnkForRelease = nullptr;
 
   hGlobalMemory = GlobalAlloc(GMEM_MOVEABLE, sizeof(DROPFILES) + allocLen * sizeof(PRUnichar));
   if (!hGlobalMemory)
     return E_FAIL;
 
   DROPFILES* pDropFile = (DROPFILES*)GlobalLock(hGlobalMemory);
 
   // First, populate the drop file structure.
@@ -2103,29 +2103,29 @@ HRESULT nsDataObj::GetFileDescriptor_ISt
   aSTG.hGlobal = fileGroupDescHandle;
   aSTG.tymed = TYMED_HGLOBAL;
 
   return S_OK;
 }
 
 HRESULT nsDataObj::GetFileContents_IStream(FORMATETC& aFE, STGMEDIUM& aSTG)
 {
-  IStream *pStream = NULL;
+  IStream *pStream = nullptr;
 
   nsDataObj::CreateStream(&pStream);
   NS_ENSURE_TRUE(pStream, E_FAIL);
 
   aSTG.tymed = TYMED_ISTREAM;
   aSTG.pstm = pStream;
-  aSTG.pUnkForRelease = NULL;
+  aSTG.pUnkForRelease = nullptr;
 
   return S_OK;
 }
 
 void nsDataObj::RemoveTempFile(nsITimer* aTimer, void* aClosure)
 {
   nsDataObj *timedDataObj = static_cast<nsDataObj *>(aClosure);
   if (timedDataObj->mCachedTempFile) {
     timedDataObj->mCachedTempFile->Remove(false);
-    timedDataObj->mCachedTempFile = NULL;
+    timedDataObj->mCachedTempFile = nullptr;
   }
   timedDataObj->Release();
 }
--- a/widget/windows/nsDataObjCollection.cpp
+++ b/widget/windows/nsDataObjCollection.cpp
@@ -33,17 +33,17 @@ nsDataObjCollection::~nsDataObjCollectio
 
   m_enumFE->Release();
 }
 
 
 // IUnknown interface methods - see iunknown.h for documentation
 STDMETHODIMP nsDataObjCollection::QueryInterface(REFIID riid, void** ppv)
 {
-  *ppv=NULL;
+  *ppv=nullptr;
 
   if ( (IID_IUnknown == riid) || (IID_IDataObject  == riid) ) {
     *ppv = static_cast<IDataObject*>(this); 
     AddRef();
     return NOERROR;
   }
 
   if ( IID_IDataObjCollection  == riid ) {
@@ -247,26 +247,26 @@ HRESULT nsDataObjCollection::GetFile(LPF
       case DV_E_FORMATETC:
         continue;
       default:
         return hr;
       }
     }
     // Now we need to pull out the filename
     PRUnichar* buffer = (PRUnichar*)GlobalLock(workingmedium.hGlobal);
-    if (buffer == NULL)
+    if (buffer == nullptr)
       return E_FAIL;
     buffer += sizeof(DROPFILES)/sizeof(PRUnichar);
     filename = buffer;
     GlobalUnlock(workingmedium.hGlobal);
     ReleaseStgMedium(&workingmedium);
     // Now put the filename into our buffer
     alloclen = (filename.Length() + 1) * sizeof(PRUnichar);
     hGlobalMemory = ::GlobalReAlloc(hGlobalMemory, buffersize + alloclen, GHND);
-    if (hGlobalMemory == NULL)
+    if (hGlobalMemory == nullptr)
       return E_FAIL;
     realbuffer = (PRUnichar*)((char*)GlobalLock(hGlobalMemory) + buffersize);
     if (!realbuffer)
       return E_FAIL;
     realbuffer--; // Overwrite the preceding null
     memcpy(realbuffer, filename.get(), alloclen);
     GlobalUnlock(hGlobalMemory);
     buffersize += alloclen;
@@ -280,17 +280,17 @@ HRESULT nsDataObjCollection::GetFile(LPF
   df->pFiles = sizeof(DROPFILES); //Offset to start of file name string
   df->fNC    = 0;
   df->pt.x   = 0;
   df->pt.y   = 0;
   df->fWide  = TRUE; // utf-16 chars
   GlobalUnlock(hGlobalMemory);
   // Finally fill out the STGMEDIUM struct
   pSTM->tymed = TYMED_HGLOBAL;
-  pSTM->pUnkForRelease = NULL; // Caller gets to free the data
+  pSTM->pUnkForRelease = nullptr; // Caller gets to free the data
   pSTM->hGlobal = hGlobalMemory;
   return S_OK;
 }
 
 HRESULT nsDataObjCollection::GetText(LPFORMATETC pFE, LPSTGMEDIUM pSTM)
 {
   STGMEDIUM workingmedium;
   FORMATETC fe = *pFE;
@@ -311,37 +311,37 @@ HRESULT nsDataObjCollection::GetText(LPF
         case DV_E_FORMATETC:
           continue;
         default:
           return hr;
         }
       }
       // Now we need to pull out the text
       char* buffer = (char*)GlobalLock(workingmedium.hGlobal);
-      if (buffer == NULL)
+      if (buffer == nullptr)
         return E_FAIL;
       text = buffer;
       GlobalUnlock(workingmedium.hGlobal);
       ReleaseStgMedium(&workingmedium);
       // Now put the text into our buffer
       alloclen = text.Length();
       hGlobalMemory = ::GlobalReAlloc(hGlobalMemory, buffersize + alloclen,
                                       GHND);
-      if (hGlobalMemory == NULL)
+      if (hGlobalMemory == nullptr)
         return E_FAIL;
       buffer = ((char*)GlobalLock(hGlobalMemory) + buffersize);
       if (!buffer)
         return E_FAIL;
       buffer--; // Overwrite the preceding null
       memcpy(buffer, text.get(), alloclen);
       GlobalUnlock(hGlobalMemory);
       buffersize += alloclen;
     }
     pSTM->tymed = TYMED_HGLOBAL;
-    pSTM->pUnkForRelease = NULL; // Caller gets to free the data
+    pSTM->pUnkForRelease = nullptr; // Caller gets to free the data
     pSTM->hGlobal = hGlobalMemory;
     return S_OK;
   }
   if (pFE->cfFormat == CF_UNICODETEXT) {
     buffersize = sizeof(PRUnichar);
     nsAutoString text;
     for (uint32_t i = 0; i < mDataObjects.Length(); ++i) {
       nsDataObj* dataObj = mDataObjects.ElementAt(i);
@@ -351,37 +351,37 @@ HRESULT nsDataObjCollection::GetText(LPF
         case DV_E_FORMATETC:
           continue;
         default:
           return hr;
         }
       }
       // Now we need to pull out the text
       PRUnichar* buffer = (PRUnichar*)GlobalLock(workingmedium.hGlobal);
-      if (buffer == NULL)
+      if (buffer == nullptr)
         return E_FAIL;
       text = buffer;
       GlobalUnlock(workingmedium.hGlobal);
       ReleaseStgMedium(&workingmedium);
       // Now put the text into our buffer
       alloclen = text.Length() * sizeof(PRUnichar);
       hGlobalMemory = ::GlobalReAlloc(hGlobalMemory, buffersize + alloclen,
                                       GHND);
-      if (hGlobalMemory == NULL)
+      if (hGlobalMemory == nullptr)
         return E_FAIL;
       buffer = (PRUnichar*)((char*)GlobalLock(hGlobalMemory) + buffersize);
       if (!buffer)
         return E_FAIL;
       buffer--; // Overwrite the preceding null
       memcpy(buffer, text.get(), alloclen);
       GlobalUnlock(hGlobalMemory);
       buffersize += alloclen;
     }
     pSTM->tymed = TYMED_HGLOBAL;
-    pSTM->pUnkForRelease = NULL; // Caller gets to free the data
+    pSTM->pUnkForRelease = nullptr; // Caller gets to free the data
     pSTM->hGlobal = hGlobalMemory;
     return S_OK;
   }
 
   return E_FAIL;
 }
 
 HRESULT nsDataObjCollection::GetFileDescriptors(LPFORMATETC pFE,
@@ -405,35 +405,35 @@ HRESULT nsDataObjCollection::GetFileDesc
         continue;
       default:
         return hr;
       }
     }
     // Now we need to pull out the filedescriptor
     FILEDESCRIPTOR* buffer =
      (FILEDESCRIPTOR*)((char*)GlobalLock(workingmedium.hGlobal) + sizeof(UINT));
-    if (buffer == NULL)
+    if (buffer == nullptr)
       return E_FAIL;
     hGlobalMemory = ::GlobalReAlloc(hGlobalMemory, buffersize + alloclen, GHND);
-    if (hGlobalMemory == NULL)
+    if (hGlobalMemory == nullptr)
       return E_FAIL;
     FILEGROUPDESCRIPTOR* realbuffer =
                                 (FILEGROUPDESCRIPTOR*)GlobalLock(hGlobalMemory);
     if (!realbuffer)
       return E_FAIL;
     FILEDESCRIPTOR* copyloc = (FILEDESCRIPTOR*)((char*)realbuffer + buffersize);
     memcpy(copyloc, buffer, sizeof(FILEDESCRIPTOR));
     realbuffer->cItems++;
     GlobalUnlock(hGlobalMemory);
     GlobalUnlock(workingmedium.hGlobal);
     ReleaseStgMedium(&workingmedium);
     buffersize += alloclen;
   }
   pSTM->tymed = TYMED_HGLOBAL;
-  pSTM->pUnkForRelease = NULL; // Caller gets to free the data
+  pSTM->pUnkForRelease = nullptr; // Caller gets to free the data
   pSTM->hGlobal = hGlobalMemory;
   return S_OK;
 }
 
 HRESULT nsDataObjCollection::GetFileContents(LPFORMATETC pFE, LPSTGMEDIUM pSTM)
 {
   ULONG num = 0;
   ULONG numwanted = (pFE->lindex == -1) ? 0 : pFE->lindex;
--- a/widget/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/windows/nsDeviceContextSpecWin.cpp
@@ -140,36 +140,36 @@ const NativePaperSizes kPaperSizes[] = {
 };
 const int32_t kNumPaperSizes = 41;
 
 //----------------------------------------------------------------------------------
 nsDeviceContextSpecWin::nsDeviceContextSpecWin()
 {
   mDriverName    = nullptr;
   mDeviceName    = nullptr;
-  mDevMode       = NULL;
+  mDevMode       = nullptr;
 
 }
 
 
 //----------------------------------------------------------------------------------
 
 NS_IMPL_ISUPPORTS1(nsDeviceContextSpecWin, nsIDeviceContextSpec)
 
 nsDeviceContextSpecWin::~nsDeviceContextSpecWin()
 {
   SetDeviceName(nullptr);
   SetDriverName(nullptr);
-  SetDevMode(NULL);
+  SetDevMode(nullptr);
 
   nsCOMPtr<nsIPrintSettingsWin> psWin(do_QueryInterface(mPrintSettings));
   if (psWin) {
     psWin->SetDeviceName(nullptr);
     psWin->SetDriverName(nullptr);
-    psWin->SetDevMode(NULL);
+    psWin->SetDevMode(nullptr);
   }
 
   // Free them, we won't need them for a while
   GlobalPrinters::GetInstance()->FreeGlobalPrinters();
 }
 
 
 //------------------------------------------------------------------
@@ -182,31 +182,31 @@ static PRUnichar * GetDefaultPrinterName
 }
 
 //----------------------------------------------------------------
 static nsresult 
 EnumerateNativePrinters(DWORD aWhichPrinters, LPWSTR aPrinterName, bool& aIsFound, bool& aIsFile)
 {
   DWORD             dwSizeNeeded = 0;
   DWORD             dwNumItems   = 0;
-  LPPRINTER_INFO_2W  lpInfo        = NULL;
+  LPPRINTER_INFO_2W  lpInfo        = nullptr;
 
   // Get buffer size
-  if (::EnumPrintersW(aWhichPrinters, NULL, 2, NULL, 0, &dwSizeNeeded,
+  if (::EnumPrintersW(aWhichPrinters, nullptr, 2, nullptr, 0, &dwSizeNeeded,
                       &dwNumItems)) {
     return NS_ERROR_FAILURE;
   }
 
   // allocate memory
   lpInfo = (LPPRINTER_INFO_2W) malloc(dwSizeNeeded);
   if (!lpInfo) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  if (::EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)lpInfo,
+  if (::EnumPrintersW(PRINTER_ENUM_LOCAL, nullptr, 2, (LPBYTE)lpInfo,
                       dwSizeNeeded, &dwSizeNeeded, &dwNumItems) == 0) {
     free(lpInfo);
     return NS_OK;
   }
 
   for (DWORD i = 0; i < dwNumItems; i++ ) {
     if (wcscmp(lpInfo[i].pPrinterName, aPrinterName) == 0) {
       aIsFound = true;
@@ -494,17 +494,17 @@ NS_IMETHODIMP nsDeviceContextSpecWin::Ge
     rv = stream->Init(file, -1, -1, 0);
     if (NS_FAILED(rv))
       return rv;
 
     newSurface = new gfxPDFSurface(stream, gfxSize(width, height));
   } else {
     if (mDevMode) {
       NS_WARN_IF_FALSE(mDriverName, "No driver!");
-      HDC dc = ::CreateDCW(mDriverName, mDeviceName, NULL, mDevMode);
+      HDC dc = ::CreateDCW(mDriverName, mDeviceName, nullptr, mDevMode);
 
       // have this surface take over ownership of this DC
       newSurface = new gfxWindowsSurface(dc, gfxWindowsSurface::FLAG_TAKE_DC | gfxWindowsSurface::FLAG_FOR_PRINTING);
     }
   }
 
   if (newSurface) {
     *surface = newSurface;
@@ -648,42 +648,42 @@ nsDeviceContextSpecWin::GetDataFromPrint
     rv = GlobalPrinters::GetInstance()->EnumeratePrinterList();
     if (NS_FAILED(rv)) {
       PR_PL(("***** nsDeviceContextSpecWin::GetDataFromPrinter - Couldn't enumerate printers!\n"));
       DISPLAY_LAST_ERROR
     }
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  HANDLE hPrinter = NULL;
+  HANDLE hPrinter = nullptr;
   
   BOOL status = ::OpenPrinterW((LPWSTR)(aName),
-                              &hPrinter, NULL);
+                              &hPrinter, nullptr);
   if (status) {
 
     LPDEVMODEW   pDevMode;
     DWORD       dwNeeded, dwRet;
 
     // Allocate a buffer of the correct size.
-    dwNeeded = ::DocumentPropertiesW(NULL, hPrinter,
+    dwNeeded = ::DocumentPropertiesW(nullptr, hPrinter,
                                     const_cast<wchar_t*>(aName),
-                                    NULL, NULL, 0);
+                                    nullptr, nullptr, 0);
 
     pDevMode = (LPDEVMODEW)::HeapAlloc (::GetProcessHeap(), HEAP_ZERO_MEMORY, dwNeeded);
     if (!pDevMode) return NS_ERROR_FAILURE;
 
     // Get the default DevMode for the printer and modify it for our needs.
-    dwRet = DocumentPropertiesW(NULL, hPrinter, 
+    dwRet = DocumentPropertiesW(nullptr, hPrinter, 
                                const_cast<wchar_t*>(aName),
-                               pDevMode, NULL, DM_OUT_BUFFER);
+                               pDevMode, nullptr, DM_OUT_BUFFER);
 
     if (dwRet == IDOK && aPS) {
       SetupDevModeFromSettings(pDevMode, aPS);
       // Sets back the changes we made to the DevMode into the Printer Driver
-      dwRet = ::DocumentPropertiesW(NULL, hPrinter,
+      dwRet = ::DocumentPropertiesW(nullptr, hPrinter,
                                    const_cast<wchar_t*>(aName),
                                    pDevMode, pDevMode,
                                    DM_IN_BUFFER | DM_OUT_BUFFER);
     }
 
     if (dwRet != IDOK) {
       ::HeapFree(::GetProcessHeap(), 0, pDevMode);
       ::ClosePrinter(hPrinter);
--- a/widget/windows/nsDragService.cpp
+++ b/widget/windows/nsDragService.cpp
@@ -112,22 +112,22 @@ nsDragService::CreateDragImage(nsIDOMNod
   bmih.bV5Planes      = 1;
   bmih.bV5BitCount    = 32;
   bmih.bV5Compression = BI_BITFIELDS;
   bmih.bV5RedMask     = 0x00FF0000;
   bmih.bV5GreenMask   = 0x0000FF00;
   bmih.bV5BlueMask    = 0x000000FF;
   bmih.bV5AlphaMask   = 0xFF000000;
 
-  HDC hdcSrc = CreateCompatibleDC(NULL);
-  void *lpBits = NULL;
+  HDC hdcSrc = CreateCompatibleDC(nullptr);
+  void *lpBits = nullptr;
   if (hdcSrc) {
     psdi->hbmpDragImage = 
     ::CreateDIBSection(hdcSrc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
-                       (void**)&lpBits, NULL, 0);
+                       (void**)&lpBits, nullptr, 0);
     if (psdi->hbmpDragImage && lpBits) {
       memcpy(lpBits,imgSurface->Data(),(bmWidth*bmHeight*4));
     }
 
     psdi->sizeDragImage.cx = bmWidth;
     psdi->sizeDragImage.cy = bmHeight;
 
     // Mouse position in center
@@ -139,17 +139,17 @@ nsDragService::CreateDragImage(nsIDOMNod
       ConvertToUnscaledDevPixels(pc, &sx, &sy);
       psdi->ptOffset.x = sx - dragRect.x;
       psdi->ptOffset.y = sy - dragRect.y;
     }
 
     DeleteDC(hdcSrc);
   }
 
-  return psdi->hbmpDragImage != NULL;
+  return psdi->hbmpDragImage != nullptr;
 }
 
 //-------------------------------------------------------------------------
 NS_IMETHODIMP
 nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
                                  nsISupportsArray *anArrayTransferables,
                                  nsIScriptableRegion *aRegion,
                                  uint32_t aActionType)
@@ -212,17 +212,18 @@ nsDragService::InvokeDragSession(nsIDOMN
                                                getter_AddRefs(itemToDrag),
                                                uri);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   } // else dragging a single object
 
   // Create a drag image if support is available
   IDragSourceHelper *pdsh;
-  if (SUCCEEDED(CoCreateInstance(CLSID_DragDropHelper, NULL, CLSCTX_INPROC_SERVER,
+  if (SUCCEEDED(CoCreateInstance(CLSID_DragDropHelper, nullptr,
+                                 CLSCTX_INPROC_SERVER,
                                  IID_IDragSourceHelper, (void**)&pdsh))) {
     SHDRAGIMAGE sdi;
     if (CreateDragImage(aDOMNode, aRegion, &sdi)) {
       if (FAILED(pdsh->InitializeFromBitmap(&sdi, itemToDrag)))
         DeleteObject(sdi.hbmpDragImage);
     }
     pdsh->Release();
   }
@@ -362,17 +363,17 @@ nsDragService::GetNumDropItems(uint32_t 
     // the file drop as the number of items we have, pretending like we
     // actually have > 1 drag item.
     FORMATETC fe2;
     SET_FORMATETC(fe2, CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL);
     if (mDataObject->QueryGetData(&fe2) == S_OK) {
       STGMEDIUM stm;
       if (mDataObject->GetData(&fe2, &stm) == S_OK) {
         HDROP hdrop = (HDROP)GlobalLock(stm.hGlobal);
-        *aNumItems = ::DragQueryFileW(hdrop, 0xFFFFFFFF, NULL, 0);
+        *aNumItems = ::DragQueryFileW(hdrop, 0xFFFFFFFF, nullptr, 0);
         ::GlobalUnlock(stm.hGlobal);
         ::ReleaseStgMedium(&stm);
         // Data may be provided later, so assume we have 1 item
         if (*aNumItems == 0)
           *aNumItems = 1;
       }
       else
         *aNumItems = 1;
--- a/widget/windows/nsFilePicker.cpp
+++ b/widget/windows/nsFilePicker.cpp
@@ -64,31 +64,31 @@ private:
   nsRefPtr<nsWindow> mWindow;
 };
 
 // Manages the current working path.
 class AutoRestoreWorkingPath
 {
 public:
   AutoRestoreWorkingPath() {
-    DWORD bufferLength = GetCurrentDirectoryW(0, NULL);
+    DWORD bufferLength = GetCurrentDirectoryW(0, nullptr);
     mWorkingPath = new PRUnichar[bufferLength];
     if (GetCurrentDirectoryW(bufferLength, mWorkingPath) == 0) {
-      mWorkingPath = NULL;
+      mWorkingPath = nullptr;
     }
   }
 
   ~AutoRestoreWorkingPath() {
     if (HasWorkingPath()) {
       ::SetCurrentDirectoryW(mWorkingPath);
     }
   }
 
   inline bool HasWorkingPath() const {
-    return mWorkingPath != NULL;
+    return mWorkingPath != nullptr;
   }
 private:
   nsAutoArrayPtr<PRUnichar> mWorkingPath;
 };
 
 // Manages NS_NATIVE_TMP_WINDOW child windows. NS_NATIVE_TMP_WINDOWs are
 // temporary child windows of mParentWidget created to address RTL issues
 // in picker dialogs. We are responsible for destroying these.
@@ -165,51 +165,51 @@ private:
     
 };
 
 ///////////////////////////////////////////////////////////////////////////////
 // nsIFilePicker
 
 nsFilePicker::nsFilePicker() :
   mSelectedType(1)
-  , mDlgWnd(NULL)
+  , mDlgWnd(nullptr)
   , mFDECookie(0)
 {
-   CoInitialize(NULL);
+   CoInitialize(nullptr);
 }
 
 nsFilePicker::~nsFilePicker()
 {
   if (mLastUsedUnicodeDirectory) {
     NS_Free(mLastUsedUnicodeDirectory);
     mLastUsedUnicodeDirectory = nullptr;
   }
   CoUninitialize();
 }
 
 NS_IMPL_ISUPPORTS1(nsFilePicker, nsIFilePicker)
 
 NS_IMETHODIMP nsFilePicker::Init(nsIDOMWindow *aParent, const nsAString& aTitle, int16_t aMode)
 {
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aParent);
-  nsIDocShell* docShell = window ? window->GetDocShell() : NULL;  
+  nsIDocShell* docShell = window ? window->GetDocShell() : nullptr;  
   mLoadContext = do_QueryInterface(docShell);
   
   return nsBaseFilePicker::Init(aParent, aTitle, aMode);
 }
 
 STDMETHODIMP nsFilePicker::QueryInterface(REFIID refiid, void** ppvResult)
 {
-  *ppvResult = NULL;
+  *ppvResult = nullptr;
   if (IID_IUnknown == refiid ||
       refiid == IID_IFileDialogEvents) {
     *ppvResult = this;
   }
 
-  if (NULL != *ppvResult) {
+  if (nullptr != *ppvResult) {
     ((LPUNKNOWN)*ppvResult)->AddRef();
     return S_OK;
   }
 
   return E_NOINTERFACE;
 }
 
 /*
@@ -230,24 +230,24 @@ BrowseCallbackProc(HWND hwnd, UINT uMsg,
   }
   return 0;
 }
 
 static void
 EnsureWindowVisible(HWND hwnd) 
 {
   // Obtain the monitor which has the largest area of intersection 
-  // with the window, or NULL if there is no intersection.
+  // with the window, or nullptr if there is no intersection.
   HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL);
   if (!monitor) {
     // The window is not visible, we should reposition it to the same place as its parent
     HWND parentHwnd = GetParent(hwnd);
     RECT parentRect;
     GetWindowRect(parentHwnd, &parentRect);
-    SetWindowPos(hwnd, NULL, parentRect.left, parentRect.top, 0, 0,
+    SetWindowPos(hwnd, nullptr, parentRect.left, parentRect.top, 0, 0,
                  SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
   }
 }
 
 // Callback hook which will ensure that the window is visible. Currently
 // only in use on os <= XP.
 UINT_PTR CALLBACK
 nsFilePicker::FilePickerHook(HWND hwnd,
@@ -276,17 +276,17 @@ nsFilePicker::FilePickerHook(HWND hwnd,
       break;
     case WM_INITDIALOG:
       {
         OPENFILENAMEW* pofn = reinterpret_cast<OPENFILENAMEW*>(lParam);
         SetProp(hwnd, kDialogPtrProp, (HANDLE)pofn->lCustData);
         nsFilePicker* picker = reinterpret_cast<nsFilePicker*>(pofn->lCustData);
         if (picker) {
           picker->SetDialogHandle(hwnd);
-          SetTimer(hwnd, kDialogTimerID, kDialogTimerTimeout, NULL);
+          SetTimer(hwnd, kDialogTimerID, kDialogTimerTimeout, nullptr);
         }
       }
       break;
     case WM_TIMER:
       {
         // Check to see if our parent has been torn down, if so, we close too.
         if (wParam == kDialogTimerID) {
           nsFilePicker* picker = 
@@ -311,28 +311,28 @@ nsFilePicker::MultiFilePickerHook(HWND h
                                   LPARAM lParam)
 {
   switch (msg) {
     case WM_INITDIALOG:
       {
         // Finds the child drop down of a File Picker dialog and sets the 
         // maximum amount of text it can hold when typed in manually.
         // A wParam of 0 mean 0x7FFFFFFE characters.
-        HWND comboBox = FindWindowEx(GetParent(hwnd), NULL, 
-                                     L"ComboBoxEx32", NULL );
+        HWND comboBox = FindWindowEx(GetParent(hwnd), nullptr, 
+                                     L"ComboBoxEx32", nullptr );
         if(comboBox)
           SendMessage(comboBox, CB_LIMITTEXT, 0, 0);
         // Store our nsFilePicker ptr for future use
         OPENFILENAMEW* pofn = reinterpret_cast<OPENFILENAMEW*>(lParam);
         SetProp(hwnd, kDialogPtrProp, (HANDLE)pofn->lCustData);
         nsFilePicker* picker =
           reinterpret_cast<nsFilePicker*>(pofn->lCustData);
         if (picker) {
           picker->SetDialogHandle(hwnd);
-          SetTimer(hwnd, kDialogTimerID, kDialogTimerTimeout, NULL);
+          SetTimer(hwnd, kDialogTimerID, kDialogTimerTimeout, nullptr);
         }
       }
       break;
     case WM_NOTIFY:
       {
         LPOFNOTIFYW lpofn = (LPOFNOTIFYW) lParam;
         if (!lpofn || !lpofn->lpOFN) {
           return 0;
@@ -340,28 +340,28 @@ nsFilePicker::MultiFilePickerHook(HWND h
         // CDN_SELCHANGE is sent when the selection in the list box of the file
         // selection dialog changes
         if (lpofn->hdr.code == CDN_SELCHANGE) {
           HWND parentHWND = GetParent(hwnd);
 
           // Get the required size for the selected files buffer
           UINT newBufLength = 0; 
           int requiredBufLength = CommDlg_OpenSave_GetSpecW(parentHWND, 
-                                                            NULL, 0);
+                                                            nullptr, 0);
           if(requiredBufLength >= 0)
             newBufLength += requiredBufLength;
           else
             newBufLength += MAX_PATH;
 
           // If the user selects multiple files, the buffer contains the 
           // current directory followed by the file names of the selected 
           // files. So make room for the directory path.  If the user
           // selects a single file, it is no harm to add extra space.
           requiredBufLength = CommDlg_OpenSave_GetFolderPathW(parentHWND, 
-                                                              NULL, 0);
+                                                              nullptr, 0);
           if(requiredBufLength >= 0)
             newBufLength += requiredBufLength;
           else
             newBufLength += MAX_PATH;
 
           // Check if lpstrFile and nMaxFile are large enough
           if (newBufLength > lpofn->lpOFN->nMaxFile) {
             if (lpofn->lpOFN->lpstrFile)
@@ -440,17 +440,17 @@ nsFilePicker::OnTypeChange(IFileDialog *
 {
   // Failures here result in errors due to security concerns.
   nsRefPtr<IOleWindow> win;
   pfd->QueryInterface(IID_IOleWindow, getter_AddRefs(win));
   if (!win) {
     NS_ERROR("Could not retrieve the IOleWindow interface for IFileDialog.");
     return S_OK;
   }
-  HWND hwnd = NULL;
+  HWND hwnd = nullptr;
   win->GetWindow(&hwnd);
   if (!hwnd) {
     NS_ERROR("Could not retrieve the HWND for IFileDialog.");
     return S_OK;
   }
   
   SetDialogHandle(hwnd);
   return S_OK;
@@ -483,17 +483,17 @@ nsFilePicker::ClosePickerIfNeeded(bool a
   else
     dlgWnd = mDlgWnd;
   if (IsWindow(dlgWnd) && IsWindowVisible(dlgWnd) && win->DestroyCalled()) {
     PRUnichar className[64];
     // Make sure we have the right window
     if (GetClassNameW(dlgWnd, className, mozilla::ArrayLength(className)) &&
         !wcscmp(className, L"#32770") &&
         DestroyWindow(dlgWnd)) {
-      mDlgWnd = NULL;
+      mDlgWnd = nullptr;
       return true;
     }
   }
   return false;
 }
 
 void
 nsFilePicker::PickerCallbackTimerFunc(nsITimer *aTimer, void *aCtx)
@@ -523,17 +523,17 @@ nsFilePicker::ShowXPFolderPicker(const n
 {
   bool result = false;
 
   nsAutoArrayPtr<PRUnichar> dirBuffer(new PRUnichar[FILE_BUFFER_SIZE]);
   wcsncpy(dirBuffer, aInitialDir.get(), FILE_BUFFER_SIZE);
   dirBuffer[FILE_BUFFER_SIZE-1] = '\0';
 
   AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ?
-    mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : NULL));
+    mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr));
 
   BROWSEINFOW browserInfo = {0};
   browserInfo.pidlRoot       = nullptr;
   browserInfo.pszDisplayName = (LPWSTR)dirBuffer;
   browserInfo.lpszTitle      = mTitle.get();
   browserInfo.ulFlags        = BIF_USENEWUI | BIF_RETURNONLYFSDIRS;
   browserInfo.hwndOwner      = adtw.get(); 
   browserInfo.iImage         = 0;
@@ -541,17 +541,17 @@ nsFilePicker::ShowXPFolderPicker(const n
 
   if (!aInitialDir.IsEmpty()) {
     // the dialog is modal so that |initialDir.get()| will be valid in 
     // BrowserCallbackProc. Thus, we don't need to clone it.
     browserInfo.lParam = (LPARAM) aInitialDir.get();
     browserInfo.lpfn   = &BrowseCallbackProc;
   } else {
     browserInfo.lParam = 0;
-    browserInfo.lpfn   = NULL;
+    browserInfo.lpfn   = nullptr;
   }
 
   LPITEMIDLIST list = ::SHBrowseForFolderW(&browserInfo);
   if (list) {
     result = ::SHGetPathFromIDListW(list, (LPWSTR)dirBuffer);
     if (result)
       mUnicodeFile.Assign(dirBuffer);
     // free PIDL
@@ -569,17 +569,17 @@ nsFilePicker::ShowXPFolderPicker(const n
  * @param aWasInitError Out parameter will hold true if there was an error
  *                      before the folder picker is shown.
  * @return true if a file was selected successfully.
 */
 bool
 nsFilePicker::ShowFolderPicker(const nsString& aInitialDir, bool &aWasInitError)
 {
   nsRefPtr<IFileOpenDialog> dialog;
-  if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
+  if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC,
                               IID_IFileOpenDialog,
                               getter_AddRefs(dialog)))) {
     aWasInitError = true;
     return false;
   }
   aWasInitError = false;
 
   // hook up event callbacks
@@ -589,25 +589,25 @@ nsFilePicker::ShowFolderPicker(const nsS
   FILEOPENDIALOGOPTIONS fos = FOS_PICKFOLDERS;
   dialog->SetOptions(fos);
  
   // initial strings
   dialog->SetTitle(mTitle.get());
   if (!aInitialDir.IsEmpty()) {
     nsRefPtr<IShellItem> folder;
     if (SUCCEEDED(
-          WinUtils::SHCreateItemFromParsingName(aInitialDir.get(), NULL,
+          WinUtils::SHCreateItemFromParsingName(aInitialDir.get(), nullptr,
                                                 IID_IShellItem,
                                                 getter_AddRefs(folder)))) {
       dialog->SetFolder(folder);
     }
   }
 
   AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ?
-    mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : NULL));
+    mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr));
  
   // display
   nsRefPtr<IShellItem> item;
   if (FAILED(dialog->Show(adtw.get())) ||
       FAILED(dialog->GetResult(getter_AddRefs(item))) ||
       !item) {
     dialog->Unadvise(mFDECookie);
     return false;
@@ -615,18 +615,18 @@ nsFilePicker::ShowFolderPicker(const nsS
   dialog->Unadvise(mFDECookie);
 
   // results
 
   // If the user chose a Win7 Library, resolve to the library's
   // default save folder.
   nsRefPtr<IShellItem> folderPath;
   nsRefPtr<IShellLibrary> shellLib;
-  CoCreateInstance(CLSID_ShellLibrary, NULL, CLSCTX_INPROC, IID_IShellLibrary,
-                   getter_AddRefs(shellLib));
+  CoCreateInstance(CLSID_ShellLibrary, nullptr, CLSCTX_INPROC,
+                   IID_IShellLibrary, getter_AddRefs(shellLib));
   if (shellLib &&
       SUCCEEDED(shellLib->LoadLibraryFromItem(item, STGM_READ)) &&
       SUCCEEDED(shellLib->GetDefaultSaveFolder(DSFT_DETECT, IID_IShellItem,
                                                getter_AddRefs(folderPath)))) {
     item.swap(folderPath);
   }
 
   // get the folder's file system path
@@ -667,17 +667,17 @@ nsFilePicker::ShowXPFilePicker(const nsS
   wcsncpy(fileBuffer,  mDefaultFilePath.get(), FILE_BUFFER_SIZE);
   fileBuffer[FILE_BUFFER_SIZE-1] = '\0'; // null terminate in case copy truncated
 
   if (!aInitialDir.IsEmpty()) {
     ofn.lpstrInitialDir = aInitialDir.get();
   }
 
   AutoDestroyTmpWindow adtw((HWND) (mParentWidget.get() ?
-    mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : NULL));
+    mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr));
 
   ofn.lpstrTitle   = (LPCWSTR)mTitle.get();
   ofn.lpstrFilter  = (LPCWSTR)filterBuffer.get();
   ofn.nFilterIndex = mSelectedType;
   ofn.lpstrFile    = fileBuffer;
   ofn.nMaxFile     = FILE_BUFFER_SIZE;
   ofn.hwndOwner    = adtw.get();
   ofn.lCustData    = reinterpret_cast<LPARAM>(this);
@@ -795,18 +795,18 @@ nsFilePicker::ShowXPFilePicker(const nsS
   // Single file selection, we're done
   if (mMode != modeOpenMultiple) {
     GetQualifiedPath(fileBuffer, mUnicodeFile);
     return true;
   }
 
   // Set user-selected location of file or directory.  From msdn's "Open and
   // Save As Dialog Boxes" section:
-  // If you specify OFN_EXPLORER, the directory and file name strings are NULL
-  // separated, with an extra NULL character after the last file name. This
+  // If you specify OFN_EXPLORER, the directory and file name strings are '\0'
+  // separated, with an extra '\0' character after the last file name. This
   // format enables the Explorer-style dialog boxes to return long file names
   // that include spaces. 
   PRUnichar *current = fileBuffer;
   
   nsAutoString dirName(current);
   // Sometimes dirName contains a trailing slash and sometimes it doesn't:
   if (current[dirName.Length() - 1] != '\\')
     dirName.Append((PRUnichar)'\\');
@@ -858,24 +858,24 @@ nsFilePicker::ShowXPFilePicker(const nsS
  *                      before the file picker is shown.
  * @return true if a file was selected successfully.
 */
 bool
 nsFilePicker::ShowFilePicker(const nsString& aInitialDir, bool &aWasInitError)
 {
   nsRefPtr<IFileDialog> dialog;
   if (mMode != modeSave) {
-    if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
+    if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC,
                                 IID_IFileOpenDialog,
                                 getter_AddRefs(dialog)))) {
       aWasInitError = true;
       return false;
     }
   } else {
-    if (FAILED(CoCreateInstance(CLSID_FileSaveDialog, NULL, CLSCTX_INPROC,
+    if (FAILED(CoCreateInstance(CLSID_FileSaveDialog, nullptr, CLSCTX_INPROC,
                                 IID_IFileSaveDialog,
                                 getter_AddRefs(dialog)))) {
       aWasInitError = true;
       return false;
     }
   }
   aWasInitError = false;
 
@@ -936,34 +936,34 @@ nsFilePicker::ShowFilePicker(const nsStr
   } else if (IsDefaultPathHtml()) {
     dialog->SetDefaultExtension(htmExt.get());
   }
 
   // initial location
   if (!aInitialDir.IsEmpty()) {
     nsRefPtr<IShellItem> folder;
     if (SUCCEEDED(
-          WinUtils::SHCreateItemFromParsingName(aInitialDir.get(), NULL,
+          WinUtils::SHCreateItemFromParsingName(aInitialDir.get(), nullptr,
                                                 IID_IShellItem,
                                                 getter_AddRefs(folder)))) {
       dialog->SetFolder(folder);
     }
   }
 
   // filter types and the default index
   if (!mComFilterList.IsEmpty()) {
     dialog->SetFileTypes(mComFilterList.Length(), mComFilterList.get());
     dialog->SetFileTypeIndex(mSelectedType);
   }
 
   // display
 
   {
     AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ?
-      mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : NULL));
+      mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr));
     AutoTimerCallbackCancel atcc(this, PickerCallbackTimerFunc);
     AutoWidgetPickerState awps(mParentWidget);
 
     if (FAILED(dialog->Show(adtw.get()))) {
       dialog->Unadvise(mFDECookie);
       return false;
     }
     dialog->Unadvise(mFDECookie);