Bug 784739 - Switch from NULL to nullptr in dom/plugins/test/; r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Wed, 23 Oct 2013 16:35:10 -0400
changeset 151902 d8b4feaa9add82a7e7c7dc690ff56f776d7dc894
parent 151901 298d6746f0afbafa3d33b812d839199b85269979
child 151903 e2540bc9686eefabcbae0435ebad45455510c0af
push id25512
push usercbook@mozilla.com
push dateThu, 24 Oct 2013 05:06:01 +0000
treeherderautoland@19fd3388c372 [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 dom/plugins/test/; r=ehsan
dom/plugins/test/testplugin/nptest.cpp
dom/plugins/test/testplugin/nptest_gtk2.cpp
dom/plugins/test/testplugin/nptest_qt.cpp
dom/plugins/test/testplugin/nptest_utils.cpp
dom/plugins/test/testplugin/nptest_windows.cpp
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -73,33 +73,33 @@ static char sPluginVersion[] = PLUGIN_VE
 //
 // Intentional crash
 //
 
 int gCrashCount = 0;
 
 static void Crash()
 {
-  int *pi = NULL;
+  int *pi = nullptr;
   *pi = 55; // Crash dereferencing null pointer
   ++gCrashCount;
 }
 
 static void
 IntentionalCrash()
 {
   mozilla::NoteIntentionalCrash("plugin");
   Crash();
 }
 
 //
 // static data
 //
 
-static NPNetscapeFuncs* sBrowserFuncs = NULL;
+static NPNetscapeFuncs* sBrowserFuncs = nullptr;
 static NPClass sNPClass;
 
 void
 asyncCallback(void* cookie);
 
 //
 // identifiers
 //
@@ -314,22 +314,22 @@ struct URLNotifyData
   NPObject* redirectCallback;
   bool allowRedirects;
   uint32_t size;
   char* data;
 };
 
 static URLNotifyData kNotifyData = {
   "static-cookie",
-  NULL,
-  NULL,
-  NULL,
+  nullptr,
+  nullptr,
+  nullptr,
   false,
   0,
-  NULL
+  nullptr
 };
 
 static const char* SUCCESS_STRING = "pass";
 
 static bool sIdentifiersInitialized = false;
 
 struct timerEvent {
   int32_t timerIdReceive;
@@ -382,19 +382,19 @@ static void initializeIdentifiers()
   if (!sIdentifiersInitialized) {
     NPN_GetStringIdentifiers(sPluginMethodIdentifierNames,
         ARRAY_LENGTH(sPluginMethodIdentifierNames), sPluginMethodIdentifiers);
     NPN_GetStringIdentifiers(sPluginPropertyIdentifierNames,
         ARRAY_LENGTH(sPluginPropertyIdentifierNames), sPluginPropertyIdentifiers);
 
     sIdentifiersInitialized = true;    
 
-    // Check whether NULL is handled in NPN_GetStringIdentifiers
+    // Check whether nullptr is handled in NPN_GetStringIdentifiers
     NPIdentifier IDList[2];
-    static char const *const kIDNames[2] = { NULL, "setCookie" };
+    static char const *const kIDNames[2] = { nullptr, "setCookie" };
     NPN_GetStringIdentifiers(const_cast<const NPUTF8**>(kIDNames), 2, IDList);
   }
 }
 
 static void clearIdentifiers()
 {
   memset(sPluginMethodIdentifiers, 0,
       ARRAY_LENGTH(sPluginMethodIdentifiers) * sizeof(NPIdentifier));
@@ -404,17 +404,17 @@ static void clearIdentifiers()
   sIdentifiersInitialized = false;
 }
 
 static void addRange(InstanceData* instanceData, const char* range)
 {
   char rangestr[16];
   strncpy(rangestr, range, sizeof(rangestr));
   const char* str1 = strtok(rangestr, ",");
-  const char* str2 = str1 ? strtok(NULL, ",") : NULL;
+  const char* str2 = str1 ? strtok(nullptr, ",") : nullptr;
   if (str1 && str2) {
     TestRange* byterange = new TestRange;
     byterange->offset = atoi(str1);
     byterange->length = atoi(str2);
     byterange->waiting = true;
     byterange->next = instanceData->testrange;
     instanceData->testrange = byterange;
   }
@@ -521,17 +521,17 @@ getFuncFromString(const char* funcname)
 {
   FunctionTable funcTable[] = 
     {
       { FUNCTION_NPP_NEWSTREAM, "npp_newstream" },
       { FUNCTION_NPP_WRITEREADY, "npp_writeready" },
       { FUNCTION_NPP_WRITE, "npp_write" },
       { FUNCTION_NPP_DESTROYSTREAM, "npp_destroystream" },
       { FUNCTION_NPP_WRITE_RPC, "npp_write_rpc" },
-      { FUNCTION_NONE, NULL }
+      { FUNCTION_NONE, nullptr }
     };
   int32_t i = 0;
   while(funcTable[i].funcName) {
     if (!strcmp(funcname, funcTable[i].funcName)) return funcTable[i].funcId;
     i++;
   }
   return FUNCTION_NONE;
 }
@@ -577,17 +577,17 @@ drawAsyncBitmapColor(InstanceData* insta
   memcpy(&premultiplied, subpixels, sizeof(premultiplied));
 
   for (uint32_t* lastPixel = pixelData + instanceData->backBuffer->size.width * instanceData->backBuffer->size.height;
 	pixelData < lastPixel;
 	++pixelData) {
     *pixelData = premultiplied;
   }
 
-  NPN_SetCurrentAsyncSurface(npp, instanceData->backBuffer, NULL);
+  NPN_SetCurrentAsyncSurface(npp, instanceData->backBuffer, nullptr);
   NPAsyncSurface *oldFront = instanceData->frontBuffer;
   instanceData->frontBuffer = instanceData->backBuffer;
   instanceData->backBuffer = oldFront;
 }
 
 static bool bug813906(NPP npp, const char* const function, const char* const url, const char* const frame)
 {
   NPObject *windowObj = nullptr;
@@ -767,17 +767,17 @@ NPError OSCALL NP_Shutdown()
   }
 
   return NPERR_NO_ERROR;
 }
 
 NPError
 NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
 {
-  // Make sure our pdata field is NULL at this point. If it isn't, that
+  // Make sure our pdata field is nullptr at this point. If it isn't, that
   // probably means the browser gave us uninitialized memory.
   if (instance->pdata) {
     printf("NPP_New called with non-NULL NPP->pdata pointer!\n");
     return NPERR_GENERIC_ERROR;
   }
 
   // Make sure we can render this plugin
   NPBool browserSupportsWindowless = false;
@@ -791,25 +791,25 @@ NPP_New(NPMIMEType pluginType, NPP insta
   InstanceData* instanceData = new InstanceData;
   if (!instanceData)
     return NPERR_OUT_OF_MEMORY_ERROR;
   instanceData->npp = instance;
   instanceData->streamMode = NP_ASFILEONLY;
   instanceData->testFunction = FUNCTION_NONE;
   instanceData->functionToFail = FUNCTION_NONE;
   instanceData->failureCode = 0;
-  instanceData->callOnDestroy = NULL;
+  instanceData->callOnDestroy = nullptr;
   instanceData->streamChunkSize = 1024;
-  instanceData->streamBuf = NULL;
+  instanceData->streamBuf = nullptr;
   instanceData->streamBufSize = 0;
-  instanceData->fileBuf = NULL;
+  instanceData->fileBuf = nullptr;
   instanceData->fileBufSize = 0;
   instanceData->throwOnNextInvoke = false;
   instanceData->runScriptOnPaint = false;
-  instanceData->testrange = NULL;
+  instanceData->testrange = nullptr;
   instanceData->hasWidget = false;
   instanceData->npnNewStream = false;
   instanceData->invalidateDuringPaint = false;
   instanceData->slowPaint = false;
   instanceData->writeCount = 0;
   instanceData->writeReadyCount = 0;
   memset(&instanceData->window, 0, sizeof(instanceData->window));
   instanceData->crashOnDestroy = false;
@@ -817,18 +817,18 @@ NPP_New(NPMIMEType pluginType, NPP insta
   instanceData->topLevelWindowActivationState = ACTIVATION_STATE_UNKNOWN;
   instanceData->topLevelWindowActivationEventCount = 0;
   instanceData->focusState = ACTIVATION_STATE_UNKNOWN;
   instanceData->focusEventCount = 0;
   instanceData->eventModel = 0;
   instanceData->closeStream = false;
   instanceData->wantsAllStreams = false;
   instanceData->asyncDrawing = AD_NONE;
-  instanceData->frontBuffer = NULL;
-  instanceData->backBuffer = NULL;
+  instanceData->frontBuffer = nullptr;
+  instanceData->backBuffer = nullptr;
   instanceData->mouseUpEventCount = 0;
   instanceData->bugMode = -1;
   instance->pdata = instanceData;
 
   TestNPObject* scriptableObject = (TestNPObject*)NPN_CreateObject(instance, &sNPClass);
   if (!scriptableObject) {
     printf("NPN_CreateObject failed to create an object, can't create a plugin instance\n");
     free(instanceData);
@@ -1012,45 +1012,45 @@ NPP_New(NPMIMEType pluginType, NPP insta
     free(instanceData);
     return err;
   }
 
   NPVariant variantTrue;
   BOOLEAN_TO_NPVARIANT(true, variantTrue);
 
   // Set a property on NPNVPluginElementNPObject
-  NPObject* o = NULL;
+  NPObject* o = nullptr;
   err = NPN_GetValue(instance, NPNVPluginElementNPObject, &o);
   if (err == NPERR_NO_ERROR) {
     NPN_SetProperty(instance, o,
                     NPN_GetStringIdentifier("pluginFoundElement"), &variantTrue);
     NPN_ReleaseObject(o);
-    o = NULL;
+    o = nullptr;
   }
   
   // Set a property on NPNVWindowNPObject
   err = NPN_GetValue(instance, NPNVWindowNPObject, &o);
   if (err == NPERR_NO_ERROR) {
     NPN_SetProperty(instance, o,
                     NPN_GetStringIdentifier("pluginFoundWindow"), &variantTrue);
     NPN_ReleaseObject(o);
-    o = NULL;
+    o = nullptr;
   }
 
   ++sInstanceCount;
 
   if (instanceData->testFunction == FUNCTION_NPP_GETURL) {
-    NPError err = NPN_GetURL(instance, instanceData->testUrl.c_str(), NULL);
+    NPError err = NPN_GetURL(instance, instanceData->testUrl.c_str(), nullptr);
     if (err != NPERR_NO_ERROR) {
       instanceData->err << "NPN_GetURL returned " << err;
     }
   }
   else if (instanceData->testFunction == FUNCTION_NPP_GETURLNOTIFY) {
     NPError err = NPN_GetURLNotify(instance, instanceData->testUrl.c_str(), 
-                                   NULL, static_cast<void*>(&kNotifyData));
+                                   nullptr, static_cast<void*>(&kNotifyData));
     if (err != NPERR_NO_ERROR) {
       instanceData->err << "NPN_GetURLNotify returned " << err;
     }
   }
 
   if ((instanceData->bugMode == 813906) && instanceData->frame.length()) {
     bug813906(instance, "f", "browser.xul", instanceData->frame.c_str());
   }
@@ -1064,38 +1064,38 @@ NPP_Destroy(NPP instance, NPSavedData** 
   printf("NPP_Destroy\n");
   InstanceData* instanceData = (InstanceData*)(instance->pdata);
 
   if (instanceData->crashOnDestroy)
     IntentionalCrash();
 
   if (instanceData->callOnDestroy) {
     NPVariant result;
-    NPN_InvokeDefault(instance, instanceData->callOnDestroy, NULL, 0, &result);
+    NPN_InvokeDefault(instance, instanceData->callOnDestroy, nullptr, 0, &result);
     NPN_ReleaseVariantValue(&result);
     NPN_ReleaseObject(instanceData->callOnDestroy);
   }
 
   if (instanceData->streamBuf) {
     free(instanceData->streamBuf);
   }
   if (instanceData->fileBuf) {
     free(instanceData->fileBuf);
   }
 
   TestRange* currentrange = instanceData->testrange;
   TestRange* nextrange;
-  while (currentrange != NULL) {
+  while (currentrange != nullptr) {
     nextrange = reinterpret_cast<TestRange*>(currentrange->next);
     delete currentrange;
     currentrange = nextrange;
   }
 
   if (instanceData->frontBuffer) {
-    NPN_SetCurrentAsyncSurface(instance, NULL, NULL);
+    NPN_SetCurrentAsyncSurface(instance, nullptr, nullptr);
     NPN_FinalizeAsyncSurface(instance, instanceData->frontBuffer);
     NPN_MemFree(instanceData->frontBuffer);
   }
   if (instanceData->backBuffer) {
     NPN_FinalizeAsyncSurface(instance, instanceData->backBuffer);
     NPN_MemFree(instanceData->backBuffer);
   }
 
@@ -1151,18 +1151,18 @@ NPP_SetWindow(NPP instance, NPWindow* wi
     instanceData->backBuffer = (NPAsyncSurface*)NPN_MemAlloc(sizeof(NPAsyncSurface));
 
     NPSize size;
     size.width = window->width;
     size.height = window->height;
 
     memcpy(instanceData->backBuffer, instanceData->frontBuffer, sizeof(NPAsyncSurface));
 
-    NPN_InitAsyncSurface(instance, &size, NPImageFormatBGRA32, NULL, instanceData->frontBuffer);
-    NPN_InitAsyncSurface(instance, &size, NPImageFormatBGRA32, NULL, instanceData->backBuffer);
+    NPN_InitAsyncSurface(instance, &size, NPImageFormatBGRA32, nullptr, instanceData->frontBuffer);
+    NPN_InitAsyncSurface(instance, &size, NPImageFormatBGRA32, nullptr, instanceData->backBuffer);
 
     drawAsyncBitmapColor(instanceData);
   }
   return NPERR_NO_ERROR;
 }
 
 NPError
 NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
@@ -1256,17 +1256,17 @@ NPP_DestroyStream(NPP instance, NPStream
   }
   if (instanceData->frame.length() > 0 && 
       instanceData->testFunction != FUNCTION_NPP_GETURLNOTIFY &&
       instanceData->testFunction != FUNCTION_NPP_POSTURL) {
     sendBufferToFrame(instance);
   }
   if (instanceData->testFunction == FUNCTION_NPP_POSTURL) {
     NPError err = NPN_PostURL(instance, instanceData->testUrl.c_str(), 
-      instanceData->postMode == POSTMODE_FRAME ? instanceData->frame.c_str() : NULL, 
+      instanceData->postMode == POSTMODE_FRAME ? instanceData->frame.c_str() : nullptr, 
       instanceData->streamBufSize,
       reinterpret_cast<char *>(instanceData->streamBuf), false);
     if (err != NPERR_NO_ERROR)
       instanceData->err << "Error: NPN_PostURL returned error value " << err;
   }
   return NPERR_NO_ERROR;
 }
 
@@ -1297,17 +1297,17 @@ NPP_Write(NPP instance, NPStream* stream
   // temporarily disabled per bug 519870
   //if (instanceData->writeReadyCount == 1) {
   //  instanceData->err << "NPP_Write called even though NPP_WriteReady " <<
   //      "returned 0";
   //}
 
   if (instanceData->functionToFail == FUNCTION_NPP_WRITE_RPC) {
     // Make an RPC call and pretend to consume the data
-    NPObject* windowObject = NULL;
+    NPObject* windowObject = nullptr;
     NPN_GetValue(instance, NPNVWindowNPObject, &windowObject);
     if (windowObject)
       NPN_ReleaseObject(windowObject);
 
     return len;
   }
   
   if (instanceData->functionToFail == FUNCTION_NPP_NEWSTREAM) {
@@ -1334,30 +1334,30 @@ NPP_Write(NPP instance, NPStream* stream
     nd->data = (char*) realloc(nd->data, newsize);
     memcpy(nd->data + nd->size, buffer, len);
     nd->size = newsize;
     return len;
   }
 
   if (instanceData->closeStream) {
     instanceData->closeStream = false;
-    if (instanceData->testrange != NULL) {
+    if (instanceData->testrange != nullptr) {
       NPN_RequestRead(stream, instanceData->testrange);
     }
     NPN_DestroyStream(instance, stream, NPRES_USER_BREAK);
   }
   else if (instanceData->streamMode == NP_SEEK &&
       stream->end != 0 && 
       stream->end == ((uint32_t)instanceData->streamBufSize + len)) {
     // If the complete stream has been written, and we're doing a seek test,
     // then call NPN_RequestRead.
     // prevent recursion
     instanceData->streamMode = NP_NORMAL;
 
-    if (instanceData->testrange != NULL) {
+    if (instanceData->testrange != nullptr) {
       NPError err = NPN_RequestRead(stream, instanceData->testrange);
       if (err != NPERR_NO_ERROR) {
         instanceData->err << "NPN_RequestRead returned error %d" << err;
       }
       printf("called NPN_RequestRead, return %d\n", err);
     }
   }
 
@@ -1367,17 +1367,17 @@ NPP_Write(NPP instance, NPStream* stream
       instanceData->err << 
           "Error: data written from NPN_RequestRead doesn't match";
     }
     else {
       printf("data matches!\n");
     }
     TestRange* range = instanceData->testrange;
     bool stillwaiting = false;
-    while(range != NULL) {
+    while(range != nullptr) {
       if (offset == range->offset &&
         (uint32_t)len == range->length) {
         range->waiting = false;
       }
       if (range->waiting) stillwaiting = true;
       range = reinterpret_cast<TestRange*>(range->next);
     }
     if (!stillwaiting) {
@@ -1592,20 +1592,20 @@ NPP_GetSitesWithData()
   int length = 0;
   char** result;
 
   if (sSitesWithData)
     length = sSitesWithData->size();
 
   // Allocate the maximum possible size the list could be.
   result = static_cast<char**>(NPN_MemAlloc((length + 1) * sizeof(char*)));
-  result[length] = NULL;
+  result[length] = nullptr;
 
   if (length == 0) {
-    // Represent the no site data case as an array of length 1 with a NULL
+    // Represent the no site data case as an array of length 1 with a nullptr
     // entry.
     return result;
   }
 
   // Iterate the list of stored data, and build a list of strings.
   list<string> sites;
   {
     list<siteData>::iterator iter = sSitesWithData->begin();
@@ -1626,17 +1626,17 @@ NPP_GetSitesWithData()
     list<string>::iterator iter = sites.begin();
     list<string>::iterator end = sites.end();
     for (; iter != end; ++iter, ++i) {
       const string& site = *iter;
       result[i] = static_cast<char*>(NPN_MemAlloc(site.length() + 1));
       memcpy(result[i], site.c_str(), site.length() + 1);
     }
   }
-  result[sites.size()] = NULL;
+  result[sites.size()] = nullptr;
 
   return result;
 }
 
 //
 // npapi browser functions
 //
 
@@ -1941,17 +1941,17 @@ NPN_SetCurrentAsyncSurface(NPP instance,
 // npruntime object functions
 //
 
 NPObject*
 scriptableAllocate(NPP npp, NPClass* aClass)
 {
   TestNPObject* object = (TestNPObject*)NPN_MemAlloc(sizeof(TestNPObject));
   if (!object)
-    return NULL;
+    return nullptr;
   memset(object, 0, sizeof(TestNPObject));
   return object;
 }
 
 void
 scriptableDeallocate(NPObject* npobj)
 {
   NPN_MemFree(npobj);
@@ -1975,17 +1975,17 @@ scriptableHasMethod(NPObject* npobj, NPI
 bool
 scriptableInvoke(NPObject* npobj, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
   InstanceData* id = static_cast<InstanceData*>(npp->pdata);
   if (id->throwOnNextInvoke) {
     id->throwOnNextInvoke = false;
     if (argCount == 0) {
-      NPN_SetException(npobj, NULL);
+      NPN_SetException(npobj, nullptr);
     }
     else {
       for (uint32_t i = 0; i < argCount; i++) {
         const NPString* argstr = &NPVARIANT_TO_STRING(args[i]);
         NPN_SetException(npobj, argstr->UTF8Characters);
       }
     }
     return false;
@@ -2001,17 +2001,17 @@ scriptableInvoke(NPObject* npobj, NPIden
 bool
 scriptableInvokeDefault(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
   InstanceData* id = static_cast<InstanceData*>(npp->pdata);
   if (id->throwOnNextInvoke) {
     id->throwOnNextInvoke = false;
     if (argCount == 0) {
-      NPN_SetException(npobj, NULL);
+      NPN_SetException(npobj, nullptr);
     }
     else {
       for (uint32_t i = 0; i < argCount; i++) {
         const NPString* argstr = &NPVARIANT_TO_STRING(args[i]);
         NPN_SetException(npobj, argstr->UTF8Characters);
       }
     }
     return false;
@@ -2255,19 +2255,19 @@ npnInvokeDefaultTest(NPObject* npobj, co
   if (!objectIdentifier)
     return false;
 
   NPVariant objectVariant;
   if (NPN_GetProperty(npp, windowObject, objectIdentifier,
       &objectVariant)) {
     if (NPVARIANT_IS_OBJECT(objectVariant)) {
       NPObject* selfObject = NPVARIANT_TO_OBJECT(objectVariant);
-      if (selfObject != NULL) {
+      if (selfObject != nullptr) {
         NPVariant resultVariant;
-        if (NPN_InvokeDefault(npp, selfObject, argCount > 1 ? &args[1] : NULL, 
+        if (NPN_InvokeDefault(npp, selfObject, argCount > 1 ? &args[1] : nullptr, 
             argCount - 1, &resultVariant)) {
           *result = resultVariant;
           success = true;
         }
       }
     }
     NPN_ReleaseVariantValue(&objectVariant);
   }
@@ -2291,17 +2291,17 @@ npnInvokeTest(NPObject* npobj, const NPV
   
   NPObject* windowObject;
   NPN_GetValue(npp, NPNVWindowNPObject, &windowObject);
   if (!windowObject)
     return false;
   
   NPVariant invokeResult;
   bool invokeReturn = NPN_Invoke(npp, windowObject, function,
-      argCount > 2 ? &args[2] : NULL, argCount - 2, &invokeResult);
+      argCount > 2 ? &args[2] : nullptr, argCount - 2, &invokeResult);
       
   bool compareResult = compareVariants(npp, &invokeResult, &args[1]);
       
   NPN_ReleaseObject(windowObject);
   NPN_ReleaseVariantValue(&invokeResult);
   BOOLEAN_TO_NPVARIANT(invokeReturn && compareResult, *result);
   return true;
 }
@@ -2671,47 +2671,47 @@ streamTest(NPObject* npobj, const NPVari
   if (!NPVARIANT_IS_STRING(args[0]))
     return false;
   NPString url = NPVARIANT_TO_STRING(args[0]);
 
   if (!NPVARIANT_IS_BOOLEAN(args[1]))
     return false;
   bool doPost = NPVARIANT_TO_BOOLEAN(args[1]);
 
-  NPString postData = { NULL, 0 };
+  NPString postData = { nullptr, 0 };
   if (NPVARIANT_IS_STRING(args[2])) {
     postData = NPVARIANT_TO_STRING(args[2]);
   }
   else {
     if (!NPVARIANT_IS_NULL(args[2])) {
       return false;
     }
   }
 
-  NPObject* writeCallback = NULL;
+  NPObject* writeCallback = nullptr;
   if (NPVARIANT_IS_OBJECT(args[3])) {
     writeCallback = NPVARIANT_TO_OBJECT(args[3]);
   }
   else {
     if (!NPVARIANT_IS_NULL(args[3])) {
       return false;
     }
   }
 
-  NPObject* notifyCallback = NULL;
+  NPObject* notifyCallback = nullptr;
   if (NPVARIANT_IS_OBJECT(args[4])) {
     notifyCallback = NPVARIANT_TO_OBJECT(args[4]);
   }
   else {
     if (!NPVARIANT_IS_NULL(args[4])) {
       return false;
     }
   }
 
-  NPObject* redirectCallback = NULL;
+  NPObject* redirectCallback = nullptr;
   if (NPVARIANT_IS_OBJECT(args[5])) {
     redirectCallback = NPVARIANT_TO_OBJECT(args[5]);
   }
   else {
     if (!NPVARIANT_IS_NULL(args[5])) {
       return false;
     }
   }
@@ -2721,32 +2721,32 @@ streamTest(NPObject* npobj, const NPVari
   bool allowRedirects = NPVARIANT_TO_BOOLEAN(args[6]);
 
   URLNotifyData* ndata = new URLNotifyData;
   ndata->cookie = "dynamic-cookie";
   ndata->writeCallback = writeCallback;
   ndata->notifyCallback = notifyCallback;
   ndata->redirectCallback = redirectCallback;
   ndata->size = 0;
-  ndata->data = NULL;
+  ndata->data = nullptr;
   ndata->allowRedirects = allowRedirects;
 
   /* null-terminate "url" */
   char* urlstr = (char*) malloc(url.UTF8Length + 1);
   strncpy(urlstr, url.UTF8Characters, url.UTF8Length);
   urlstr[url.UTF8Length] = '\0';
 
   NPError err;
   if (doPost) {
-    err = NPN_PostURLNotify(npp, urlstr, NULL,
+    err = NPN_PostURLNotify(npp, urlstr, nullptr,
                             postData.UTF8Length, postData.UTF8Characters,
                             false, ndata);
   }
   else {
-    err = NPN_GetURLNotify(npp, urlstr, NULL, ndata);
+    err = NPN_GetURLNotify(npp, urlstr, nullptr, ndata);
   }
 
   free(urlstr);
 
   if (NPERR_NO_ERROR == err) {
     if (ndata->writeCallback) {
       NPN_RetainObject(ndata->writeCallback);
     }
@@ -2852,17 +2852,17 @@ void notifyDidPaint(InstanceData* instan
     NPN_InvalidateRect(instanceData->npp, &r);
   }
 
   if (instanceData->slowPaint) {
     XPSleep(1);
   }
 
   if (instanceData->runScriptOnPaint) {
-    NPObject* o = NULL;
+    NPObject* o = nullptr;
     NPN_GetValue(instanceData->npp, NPNVPluginElementNPObject, &o);
     if (o) {
       NPVariant param;
       STRINGZ_TO_NPVARIANT("paintscript", param);
       NPVariant result;
       NPN_Invoke(instanceData->npp, o, NPN_GetStringIdentifier("getAttribute"),
                  &param, 1, &result);
 
@@ -2881,17 +2881,17 @@ void notifyDidPaint(InstanceData* instan
       NPN_ReleaseVariantValue(&result);
       NPN_ReleaseObject(o);
     }
   }
 }
 
 static const NPClass kTestSharedNPClass = {
   NP_CLASS_STRUCT_VERSION,
-  // Everything else is NULL
+  // Everything else is nullptr
 };
 
 static bool getObjectValue(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
 
   NPObject* o = NPN_CreateObject(npp,
                                  const_cast<NPClass*>(&kTestSharedNPClass));
@@ -2927,22 +2927,22 @@ static bool enableFPExceptions(NPObject*
   return true;
 #else
   return false;
 #endif
 }
 
 // caller is responsible for freeing return buffer
 static char* URLForInstanceWindow(NPP instance) {
-  char *outString = NULL;
+  char *outString = nullptr;
   
-  NPObject* windowObject = NULL;
+  NPObject* windowObject = nullptr;
   NPError err = NPN_GetValue(instance, NPNVWindowNPObject, &windowObject);
   if (err != NPERR_NO_ERROR || !windowObject)
-    return NULL;
+    return nullptr;
   
   NPIdentifier locationIdentifier = NPN_GetStringIdentifier("location");
   NPVariant locationVariant;
   if (NPN_GetProperty(instance, windowObject, locationIdentifier, &locationVariant)) {
     NPObject *locationObject = locationVariant.value.objectValue;
     if (locationObject) {
       NPIdentifier hrefIdentifier = NPN_GetStringIdentifier("href");
       NPVariant hrefVariant;
@@ -2992,17 +2992,17 @@ getCookie(NPObject* npobj, const NPVaria
   if (argCount != 0)
     return false;
   
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
   
   char* url = URLForInstanceWindow(npp);
   if (!url)
     return false;
-  char* cookie = NULL;
+  char* cookie = nullptr;
   unsigned int length = 0;
   NPError err = NPN_GetValueForURL(npp, NPNURLVCookie, url, &cookie, &length);
   free(url);
   if (err != NPERR_NO_ERROR || !cookie)
     return false;
   
   STRINGZ_TO_NPVARIANT(cookie, *result);
   return true;
@@ -3022,18 +3022,18 @@ getAuthInfo(NPObject* npobj, const NPVar
     return false;
 
   const NPString* protocol = &NPVARIANT_TO_STRING(args[0]);
   const NPString* host = &NPVARIANT_TO_STRING(args[1]);
   uint32_t port = NPVARIANT_TO_INT32(args[2]);
   const NPString* scheme = &NPVARIANT_TO_STRING(args[3]);
   const NPString* realm = &NPVARIANT_TO_STRING(args[4]);
 
-  char* username = NULL;
-  char* password = NULL;
+  char* username = nullptr;
+  char* password = nullptr;
   uint32_t ulen = 0, plen = 0;
   
   NPError err = NPN_GetAuthenticationInfo(npp, 
       protocol->UTF8Characters, 
       host->UTF8Characters, 
       port, 
       scheme->UTF8Characters, 
       realm->UTF8Characters,
@@ -3122,17 +3122,17 @@ ThreadProc(void* cookie)
 #endif
 {
   NPObject* npobj = (NPObject*)cookie;
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
   InstanceData* id = static_cast<InstanceData*>(npp->pdata);
   id->asyncTestPhase = 1;
   NPN_PluginThreadAsyncCall(npp, asyncCallback, (void*)npobj);
 #ifndef XP_WIN
-  return NULL;
+  return nullptr;
 #endif
 }
 
 void
 asyncCallback(void* cookie)
 {
   NPObject* npobj = (NPObject*)cookie;
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
@@ -3198,28 +3198,28 @@ GCRaceInvokeDefault(NPObject* o, const N
       35 != NPVARIANT_TO_INT32(args[0]))
     return false;
 
   return true;
 }
 
 static const NPClass kGCRaceClass = {
   NP_CLASS_STRUCT_VERSION,
-  NULL,
-  NULL,
-  NULL,
-  NULL,
+  nullptr,
+  nullptr,
+  nullptr,
+  nullptr,
   GCRaceInvoke,
   GCRaceInvokeDefault,
-  NULL,
-  NULL,
-  NULL,
-  NULL,
-  NULL,
-  NULL
+  nullptr,
+  nullptr,
+  nullptr,
+  nullptr,
+  nullptr,
+  nullptr
 };
 
 struct GCRaceData
 {
   GCRaceData(NPP npp, NPObject* callback, NPObject* localFunc)
     : npp_(npp)
     , callback_(callback)
     , localFunc_(localFunc)
@@ -3285,18 +3285,18 @@ hangPlugin(NPObject* npobj, const NPVari
   mozilla::NoteIntentionalCrash("plugin");
 
   bool busyHang = false;
   if ((argCount == 1) && NPVARIANT_IS_BOOLEAN(args[0])) {
     busyHang = NPVARIANT_TO_BOOLEAN(args[0]);
   }
 
   if (busyHang) {    
-    const time_t start = std::time(NULL);
-    while ((std::time(NULL) - start) < 100000) {
+    const time_t start = std::time(nullptr);
+    while ((std::time(nullptr) - start) < 100000) {
       volatile int dummy = 0;
       for (int i=0; i<1000; ++i) {
         dummy++;
       }
     }
   } else {
 #ifdef XP_WIN
   Sleep(100000000);
@@ -3549,28 +3549,28 @@ ReflectorGetProperty(NPObject* npobj, NP
   }
 
   INT32_TO_NPVARIANT(NPN_IntFromIdentifier(name), *result);
   return true;
 }
 
 static const NPClass kReflectorNPClass = {
   NP_CLASS_STRUCT_VERSION,
-  NULL,
-  NULL,
-  NULL,
+  nullptr,
+  nullptr,
+  nullptr,
   ReflectorHasMethod,
-  NULL,
-  NULL,
+  nullptr,
+  nullptr,
   ReflectorHasProperty,
   ReflectorGetProperty,
-  NULL,
-  NULL,
-  NULL,
-  NULL
+  nullptr,
+  nullptr,
+  nullptr,
+  nullptr
 };
 
 bool
 getReflector(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   if (0 != argCount)
     return false;
 
@@ -3595,17 +3595,17 @@ bool isVisible(NPObject* npobj, const NP
   return true;
 }
 
 bool getWindowPosition(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
   InstanceData* id = static_cast<InstanceData*>(npp->pdata);
 
-  NPObject* window = NULL;
+  NPObject* window = nullptr;
   NPError err = NPN_GetValue(npp, NPNVWindowNPObject, &window);
   if (NPERR_NO_ERROR != err || !window)
     return false;
 
   NPIdentifier arrayID = NPN_GetStringIdentifier("Array");
   NPVariant arrayFunctionV;
   bool ok = NPN_GetProperty(npp, window, arrayID, &arrayFunctionV);
 
@@ -3715,17 +3715,17 @@ bool getNPNVdocumentOrigin(NPObject* npo
                            NPVariant* result)
 {
   if (argCount != 0) {
     return false;
   }
 
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
 
-  char *origin = NULL;
+  char *origin = nullptr;
   NPError err = NPN_GetValue(npp, NPNVdocumentOrigin, &origin);
   if (err != NPERR_NO_ERROR) {
     return false;
   }
 
   STRINGZ_TO_NPVARIANT(origin, *result);
   return true;
 }
--- a/dom/plugins/test/testplugin/nptest_gtk2.cpp
+++ b/dom/plugins/test/testplugin/nptest_gtk2.cpp
@@ -80,20 +80,20 @@ NPError
 pluginInstanceInit(InstanceData* instanceData)
 {
 #ifdef MOZ_X11
   instanceData->platformData = static_cast<PlatformData*>
     (NPN_MemAlloc(sizeof(PlatformData)));
   if (!instanceData->platformData)
     return NPERR_OUT_OF_MEMORY_ERROR;
 
-  instanceData->platformData->display = NULL;
-  instanceData->platformData->visual = NULL;
+  instanceData->platformData->display = nullptr;
+  instanceData->platformData->visual = nullptr;
   instanceData->platformData->colormap = None;  
-  instanceData->platformData->plug = NULL;
+  instanceData->platformData->plug = nullptr;
 
   return NPERR_NO_ERROR;
 #else
   // we only support X11 here, since thats what the plugin system uses
   return NPERR_INCOMPATIBLE_VERSION_ERROR;
 #endif
 }
 
@@ -117,17 +117,17 @@ pluginInstanceShutdown(InstanceData* ins
   if (plug) {
     instanceData->platformData->plug = 0;
     if (instanceData->cleanupWidget) {
       // Default/tidy behavior
       gtk_widget_destroy(plug);
     } else {
       // Flash Player style: let the GtkPlug destroy itself on disconnect.
       g_signal_handlers_disconnect_matched(plug, G_SIGNAL_MATCH_DATA, 0, 0,
-                                           NULL, NULL, instanceData);
+                                           nullptr, nullptr, instanceData);
     }
   }
 
   NPN_MemFree(instanceData->platformData);
   instanceData->platformData = 0;
 }
 
 static void 
@@ -483,20 +483,20 @@ int32_t pluginGetEdge(InstanceData* inst
 
 #ifdef MOZ_X11
 static void intersectWithShapeRects(Display* display, Window window,
                                     int kind, GdkRegion* region)
 {
   int count = -1, order;
   XRectangle* shapeRects =
     XShapeGetRectangles(display, window, kind, &count, &order);
-  // The documentation says that shapeRects will be NULL when the
+  // The documentation says that shapeRects will be nullptr when the
   // extension is not supported. Unfortunately XShapeGetRectangles
-  // also returns NULL when the region is empty, so we can't treat
-  // NULL as failure. I hope this way is OK.
+  // also returns nullptr when the region is empty, so we can't treat
+  // nullptr as failure. I hope this way is OK.
   if (count < 0)
     return;
 
   GdkRegion* shapeRegion = gdk_region_new();
   if (!shapeRegion) {
     XFree(shapeRects);
     return;
   }
@@ -688,28 +688,28 @@ CrasherThread(void* data)
 
   // Exit (without running atexit hooks) rather than crashing with a signal
   // so as to make timing more reliable.  The process terminates immediately
   // rather than waiting for a thread in the parent process to attach and
   // generate a minidump.
   _exit(1);
 
   // not reached
-  return(NULL);
+  return(nullptr);
 }
 
 bool
 pluginCrashInNestedLoop(InstanceData* instanceData)
 {
   // wait at least long enough for nested loop detector task to be pending ...
   sleep(1);
 
   // Run the nested loop detector by processing all events that are waiting.
   bool found_event = false;
-  while (g_main_context_iteration(NULL, FALSE)) {
+  while (g_main_context_iteration(nullptr, FALSE)) {
     found_event = true;
   }
   if (!found_event) {
     g_warning("DetectNestedEventLoop did not fire");
     return true; // trigger a test failure
   }
 
   // wait at least long enough for the "process browser events" task to be
@@ -717,26 +717,26 @@ pluginCrashInNestedLoop(InstanceData* in
   sleep(1);
 
   // we'll be crashing soon, note that fact now to avoid messing with
   // timing too much
   mozilla::NoteIntentionalCrash("plugin");
 
   // schedule the crasher thread ...
   pthread_t crasherThread;
-  if (0 != pthread_create(&crasherThread, NULL, CrasherThread, NULL)) {
+  if (0 != pthread_create(&crasherThread, nullptr, CrasherThread, nullptr)) {
     g_warning("Failed to create thread");
     return true; // trigger a test failure
   }
 
   // .. and hope it crashes at about the same time as the "process browser
   // events" task (that should run in this loop) is being processed in the
   // parent.
   found_event = false;
-  while (g_main_context_iteration(NULL, FALSE)) {
+  while (g_main_context_iteration(nullptr, FALSE)) {
     found_event = true;
   }
   if (found_event) {
     g_warning("Should have crashed in ProcessBrowserEvents");
   } else {
     g_warning("ProcessBrowserEvents did not fire");
   }
 
--- a/dom/plugins/test/testplugin/nptest_qt.cpp
+++ b/dom/plugins/test/testplugin/nptest_qt.cpp
@@ -69,18 +69,18 @@ pluginInstanceInit(InstanceData* instanc
 #ifdef MOZ_X11
   instanceData->platformData = static_cast<PlatformData*>
     (NPN_MemAlloc(sizeof(PlatformData)));
   if (!instanceData->platformData){
     //printf("NPERR_OUT_OF_MEMORY_ERROR\n");
     return NPERR_OUT_OF_MEMORY_ERROR;
   }
 
-  instanceData->platformData->display = NULL;
-  instanceData->platformData->visual = NULL;
+  instanceData->platformData->display = nullptr;
+  instanceData->platformData->visual = nullptr;
   instanceData->platformData->colormap = None;
 
   return NPERR_NO_ERROR;
 #else
   printf("NPERR_INCOMPATIBLE_VERSION_ERROR\n");
   return NPERR_INCOMPATIBLE_VERSION_ERROR;
 #endif
   return NPERR_NO_ERROR;
--- a/dom/plugins/test/testplugin/nptest_utils.cpp
+++ b/dom/plugins/test/testplugin/nptest_utils.cpp
@@ -100,14 +100,14 @@ parseHexColor(const char* color, int len
   // start from the right and work to the left
   while (len >= 2) { // we have at least #AA or AA left.
     char byte[3];
     // parse two hex digits
     byte[0] = color[len - 2];
     byte[1] = color[len - 1];
     byte[2] = '\0';
 
-    bgra[i] = (uint8_t)(strtoul(byte, NULL, 16) & 0xFF);
+    bgra[i] = (uint8_t)(strtoul(byte, nullptr, 16) & 0xFF);
     i++;
     len -= 2;
   }
   return (bgra[3] << 24) | (bgra[2] << 16) | (bgra[1] << 8) | bgra[0];
 }
--- a/dom/plugins/test/testplugin/nptest_windows.cpp
+++ b/dom/plugins/test/testplugin/nptest_windows.cpp
@@ -91,20 +91,20 @@ pluginInstanceInit(InstanceData* instanc
 {
   NPP npp = instanceData->npp;
 
   instanceData->platformData = static_cast<PlatformData*>
     (NPN_MemAlloc(sizeof(PlatformData)));
   if (!instanceData->platformData)
     return NPERR_OUT_OF_MEMORY_ERROR;
   
-  instanceData->platformData->childWindow = NULL;
-  instanceData->platformData->device = NULL;
-  instanceData->platformData->frontBuffer = NULL;
-  instanceData->platformData->backBuffer = NULL;
+  instanceData->platformData->childWindow = nullptr;
+  instanceData->platformData->device = nullptr;
+  instanceData->platformData->frontBuffer = nullptr;
+  instanceData->platformData->backBuffer = nullptr;
   return NPERR_NO_ERROR;
 }
 
 void
 pluginInstanceShutdown(InstanceData* instanceData)
 {
   PlatformData *pd = instanceData->platformData;
   if (pd->frontBuffer) {
@@ -141,35 +141,35 @@ getD3D10Device()
     IDXGIAdapter1 *adapter1;
     if (createDXGIFactory1) {
       IDXGIFactory1 *factory1;
       hr = createDXGIFactory1(__uuidof(IDXGIFactory1),
                               (void**)&factory1);
 
       if (FAILED(hr) || !factory1) {
         // Uh-oh
-        return NULL;
+        return nullptr;
       }
 
       hr = factory1->EnumAdapters1(0, &adapter1);
 
       if (SUCCEEDED(hr) && adapter1) {
         hr = adapter1->CheckInterfaceSupport(__uuidof(ID3D10Device),
-                                             NULL);
+                                             nullptr);
         if (FAILED(hr)) {
-            adapter1 = NULL;
+            adapter1 = nullptr;
         }
       }
       factory1->Release();
     }
 
     hr = createD3DDevice(
           adapter1, 
           D3D10_DRIVER_TYPE_HARDWARE,
-          NULL,
+          nullptr,
           D3D10_CREATE_DEVICE_BGRA_SUPPORT |
           D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
           D3D10_FEATURE_LEVEL_10_0,
           D3D10_1_SDK_VERSION,
           &device);
 
     adapter1->Release();
   }
@@ -186,23 +186,23 @@ pluginDoSetWindow(InstanceData* instance
   if (instanceData->asyncDrawing == AD_DXGI) {
     if (instanceData->frontBuffer &&
         instanceData->frontBuffer->size.width == newWindow->width &&
         instanceData->frontBuffer->size.height == newWindow->height) {
           return;
     }
     if (instanceData->frontBuffer) {
       instanceData->platformData->frontBuffer->Release();
-      instanceData->platformData->frontBuffer = NULL;
+      instanceData->platformData->frontBuffer = nullptr;
       NPN_FinalizeAsyncSurface(npp, instanceData->frontBuffer);
       NPN_MemFree(instanceData->frontBuffer);
     }
     if (instanceData->backBuffer) {
       instanceData->platformData->backBuffer->Release();
-      instanceData->platformData->backBuffer = NULL;
+      instanceData->platformData->backBuffer = nullptr;
       NPN_FinalizeAsyncSurface(npp, instanceData->backBuffer);
       NPN_MemFree(instanceData->backBuffer);
     }
 
     if (!instanceData->platformData->device) {
       instanceData->platformData->device = getD3D10Device();
     }
 
@@ -217,18 +217,18 @@ pluginDoSetWindow(InstanceData* instance
 
     NPSize size;
     size.width = newWindow->width;
     size.height = newWindow->height;
 
     memset(instanceData->frontBuffer, 0, sizeof(NPAsyncSurface));
     memset(instanceData->backBuffer, 0, sizeof(NPAsyncSurface));
 
-    NPN_InitAsyncSurface(npp, &size, NPImageFormatBGRA32, NULL, instanceData->frontBuffer);
-    NPN_InitAsyncSurface(npp, &size, NPImageFormatBGRA32, NULL, instanceData->backBuffer);
+    NPN_InitAsyncSurface(npp, &size, NPImageFormatBGRA32, nullptr, instanceData->frontBuffer);
+    NPN_InitAsyncSurface(npp, &size, NPImageFormatBGRA32, nullptr, instanceData->backBuffer);
 
     dev->OpenSharedResource(instanceData->frontBuffer->sharedHandle, __uuidof(ID3D10Texture2D), (void**)&instanceData->platformData->frontBuffer);
     dev->OpenSharedResource(instanceData->backBuffer->sharedHandle, __uuidof(ID3D10Texture2D), (void**)&instanceData->platformData->backBuffer);
 
     pluginDrawAsyncDxgiColor(instanceData);
   }
 }
 
@@ -246,18 +246,18 @@ pluginWidgetInit(InstanceData* instanceD
       ::DestroyWindow(instanceData->platformData->childWindow);
     }
   }
 
   SetSubclass(hWnd, instanceData);
 
   instanceData->platformData->childWindow =
     ::CreateWindowW(L"SCROLLBAR", L"Dummy child window", 
-                    WS_CHILD, 0, 0, CHILD_WIDGET_SIZE, CHILD_WIDGET_SIZE, hWnd, NULL,
-                    NULL, NULL);
+                    WS_CHILD, 0, 0, CHILD_WIDGET_SIZE, CHILD_WIDGET_SIZE, hWnd, nullptr,
+                    nullptr, nullptr);
 }
 
 static void
 drawToDC(InstanceData* instanceData, HDC dc,
          int x, int y, int width, int height)
 {
   switch (instanceData->scriptableObject->drawMode) {
     case DM_DEFAULT:
@@ -360,27 +360,27 @@ drawToDC(InstanceData* instanceData, HDC
 
 void
 pluginDraw(InstanceData* instanceData)
 {
   NPP npp = instanceData->npp;
   if (!npp)
     return;
 
-  HDC hdc = NULL;
+  HDC hdc = nullptr;
   PAINTSTRUCT ps;
 
   notifyDidPaint(instanceData);
 
   if (instanceData->hasWidget)
     hdc = ::BeginPaint((HWND)instanceData->window.window, &ps);
   else
     hdc = (HDC)instanceData->window.window;
 
-  if (hdc == NULL)
+  if (hdc == nullptr)
     return;
 
   // Push the browser's hdc on the resource stack. If this test plugin is windowless,
   // we share the drawing surface with the rest of the browser.
   int savedDCID = SaveDC(hdc);
 
   // When we have a widget, window.x/y are meaningless since our widget
   // is always positioned correctly and we just draw into it at 0,0.
@@ -404,17 +404,18 @@ pluginGetEdge(InstanceData* instanceData
 {
   if (!instanceData || !instanceData->hasWidget)
     return NPTEST_INT32_ERROR;
 
   // Get the plugin client rect in screen coordinates
   RECT rect = {0};
   if (!::GetClientRect((HWND)instanceData->window.window, &rect))
     return NPTEST_INT32_ERROR;
-  ::MapWindowPoints((HWND)instanceData->window.window, NULL, (LPPOINT)&rect, 2);
+  ::MapWindowPoints((HWND)instanceData->window.window, nullptr,
+                    (LPPOINT)&rect, 2);
 
   // Get the toplevel window frame rect in screen coordinates
   HWND rootWnd = ::GetAncestor((HWND)instanceData->window.window, GA_ROOT);
   if (!rootWnd)
     return NPTEST_INT32_ERROR;
   RECT rootRect;
   if (!::GetWindowRect(rootWnd, &rootRect))
     return NPTEST_INT32_ERROR;
@@ -446,51 +447,51 @@ getWindowRegion(HWND wnd, HRGN rgn)
 }
 
 static RGNDATA*
 computeClipRegion(InstanceData* instanceData)
 {
   HWND wnd = (HWND)instanceData->window.window;
   HRGN rgn = ::CreateRectRgn(0, 0, 0, 0);
   if (!rgn)
-    return NULL;
+    return nullptr;
   HRGN ancestorRgn = ::CreateRectRgn(0, 0, 0, 0);
   if (!ancestorRgn) {
     ::DeleteObject(rgn);
-    return NULL;
+    return nullptr;
   }
   if (!getWindowRegion(wnd, rgn)) {
     ::DeleteObject(ancestorRgn);
     ::DeleteObject(rgn);
-    return NULL;
+    return nullptr;
   }
 
   HWND ancestor = wnd;
   for (;;) {
     ancestor = ::GetAncestor(ancestor, GA_PARENT);
     if (!ancestor || ancestor == ::GetDesktopWindow()) {
       ::DeleteObject(ancestorRgn);
 
-      DWORD size = ::GetRegionData(rgn, 0, NULL);
+      DWORD size = ::GetRegionData(rgn, 0, nullptr);
       if (!size) {
         ::DeleteObject(rgn);
-        return NULL;
+        return nullptr;
       }
 
       HANDLE heap = ::GetProcessHeap();
       RGNDATA* data = static_cast<RGNDATA*>(::HeapAlloc(heap, 0, size));
       if (!data) {
         ::DeleteObject(rgn);
-        return NULL;
+        return nullptr;
       }
       DWORD result = ::GetRegionData(rgn, size, data);
       ::DeleteObject(rgn);
       if (!result) {
         ::HeapFree(heap, 0, data);
-        return NULL;
+        return nullptr;
       }
 
       return data;
     }
 
     if (!getWindowRegion(ancestor, ancestorRgn)) {
       ::DeleteObject(ancestorRgn);
       ::DeleteObject(rgn);
@@ -616,17 +617,18 @@ handleEventInternal(InstanceData* instan
     case WM_CHAR: {
       *result = 0;
       wchar_t uniChar = static_cast<wchar_t>(pe->wParam);
       if (!uniChar) {
         return true;
       }
       char utf8Char[6];
       int len =
-        ::WideCharToMultiByte(CP_UTF8, 0, &uniChar, 1, utf8Char, 6, NULL, NULL);
+        ::WideCharToMultiByte(CP_UTF8, 0, &uniChar, 1, utf8Char, 6,
+                              nullptr, nullptr);
       if (len == 0 || len > 6) {
         return true;
       }
       instanceData->lastKeyText.append(utf8Char, len);
       return true;
     }
 
     default:
@@ -634,17 +636,17 @@ handleEventInternal(InstanceData* instan
   }
 }
 
 int16_t
 pluginHandleEvent(InstanceData* instanceData, void* event)
 {
   NPEvent* pe = (NPEvent*)event;
 
-  if (pe == NULL || instanceData == NULL ||
+  if (pe == nullptr || instanceData == nullptr ||
       instanceData->window.type != NPWindowTypeDrawable)
     return 0;   
 
   LRESULT result = 0;
   return handleEventInternal(instanceData, pe, &result);
 }
 
 /* windowed plugin events */
@@ -724,17 +726,17 @@ pluginDrawAsyncDxgiColor(InstanceData* i
 
   ID3D10Device1 *dev = pd->device;
 
   IDXGIKeyedMutex *mutex;
   pd->backBuffer->QueryInterface(&mutex);
 
   mutex->AcquireSync(0, INFINITE);
   ID3D10RenderTargetView *rtView;
-  dev->CreateRenderTargetView(pd->backBuffer, NULL, &rtView);
+  dev->CreateRenderTargetView(pd->backBuffer, nullptr, &rtView);
 
   uint32_t rgba = id->scriptableObject->drawColor;
 
   unsigned char subpixels[4];
   subpixels[0] = rgba & 0xFF;
   subpixels[1] = (rgba & 0xFF00) >> 8;
   subpixels[2] = (rgba & 0xFF0000) >> 16;
   subpixels[3] = (rgba & 0xFF000000) >> 24;
@@ -745,16 +747,16 @@ pluginDrawAsyncDxgiColor(InstanceData* i
   color[0] = float(subpixels[3] * subpixels[2]) / 0xFE01;
   color[3] = float(subpixels[3]) / 0xFF;
   dev->ClearRenderTargetView(rtView, color);
   rtView->Release();
 
   mutex->ReleaseSync(0);
   mutex->Release();
 
-  NPN_SetCurrentAsyncSurface(id->npp, id->backBuffer, NULL);
+  NPN_SetCurrentAsyncSurface(id->npp, id->backBuffer, nullptr);
   NPAsyncSurface *oldFront = id->frontBuffer;
   id->frontBuffer = id->backBuffer;
   id->backBuffer = oldFront;
   ID3D10Texture2D *oldFrontT = pd->frontBuffer;
   pd->frontBuffer = pd->backBuffer;
   pd->backBuffer = oldFrontT;
 }