From 28ba747e91fefcfbd43db5d5bd924092a2e4d93c Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Mon, 28 Oct 2013 10:05:51 -0400 Subject: [PATCH] Bug 784739 - Switch from NULL to nullptr in widget/; r=ehsan --- widget/gonk/nsAppShell.cpp | 12 +++---- widget/gonk/nsWidgetFactory.cpp | 24 +++++++------- widget/nsGUIEventIPC.h | 2 +- widget/shared/WidgetUtils.h | 4 +-- widget/tests/TestAppShellSteadyState.cpp | 16 +++++----- widget/tests/TestWinTSF.cpp | 31 ++++++++++--------- widget/windows/nsTextStore.cpp | 2 +- widget/xpwidgets/GfxInfoBase.cpp | 3 +- widget/xpwidgets/GfxInfoCollector.cpp | 8 +++-- .../xpwidgets/nsClipboardPrivacyHandler.cpp | 2 +- widget/xpwidgets/nsIdleService.cpp | 4 +-- widget/xpwidgets/nsPrintSettingsImpl.cpp | 2 +- widget/xremoteclient/XRemoteClient.cpp | 4 +-- 13 files changed, 59 insertions(+), 55 deletions(-) diff --git a/widget/gonk/nsAppShell.cpp b/widget/gonk/nsAppShell.cpp index 158a7b7b11a5..3c1bdb6d5312 100644 --- a/widget/gonk/nsAppShell.cpp +++ b/widget/gonk/nsAppShell.cpp @@ -83,7 +83,7 @@ using namespace mozilla::services; using namespace mozilla::widget; bool gDrawRequest = false; -static nsAppShell *gAppShell = NULL; +static nsAppShell *gAppShell = nullptr; static int epollfd = 0; static int signalfds[2] = {0}; static bool sDevInputAudioJack; @@ -145,7 +145,7 @@ struct UserInputData { static void sendMouseEvent(uint32_t msg, uint64_t timeMs, int x, int y, bool forwardToChildren) { - WidgetMouseEvent event(true, msg, NULL, + WidgetMouseEvent event(true, msg, nullptr, WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); event.refPoint.x = x; @@ -198,7 +198,7 @@ sendTouchEvent(UserInputData& data, bool* captured) break; } - WidgetTouchEvent event(true, msg, NULL); + WidgetTouchEvent event(true, msg, nullptr); event.time = data.timeMs; @@ -221,7 +221,7 @@ sendKeyEventWithMsg(uint32_t keyCode, uint32_t msg, uint64_t timeMs) { - WidgetKeyboardEvent event(true, msg, NULL); + WidgetKeyboardEvent event(true, msg, nullptr); event.keyCode = keyCode; event.mKeyNameIndex = keyNameIndex; event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_MOBILE; @@ -393,7 +393,7 @@ deviceId) virtual void notifyInputDevicesChanged(const android::Vector& inputDevices) {}; virtual sp getKeyboardLayoutOverlay(const String8& inputDeviceDescriptor) { - return NULL; + return nullptr; }; virtual String8 getDeviceAlias(const InputDeviceIdentifier& identifier) { @@ -707,7 +707,7 @@ nsAppShell::~nsAppShell() if (result) LOG("Could not stop reader thread - %d", result); } - gAppShell = NULL; + gAppShell = nullptr; } nsresult diff --git a/widget/gonk/nsWidgetFactory.cpp b/widget/gonk/nsWidgetFactory.cpp index 78c6bae7e95a..62430a6cd276 100644 --- a/widget/gonk/nsWidgetFactory.cpp +++ b/widget/gonk/nsWidgetFactory.cpp @@ -71,15 +71,15 @@ ScreenManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) } static const mozilla::Module::CIDEntry kWidgetCIDs[] = { - { &kNS_WINDOW_CID, false, NULL, nsWindowConstructor }, - { &kNS_CHILD_CID, false, NULL, nsWindowConstructor }, - { &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor }, - { &kNS_SCREENMANAGER_CID, false, NULL, ScreenManagerConstructor }, - { &kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor }, - { &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceGonkConstructor }, - { &kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor }, - { &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor }, - { NULL } + { &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor }, + { &kNS_CHILD_CID, false, nullptr, nsWindowConstructor }, + { &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor }, + { &kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor }, + { &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor }, + { &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceGonkConstructor }, + { &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor }, + { &kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor }, + { nullptr } }; static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { @@ -91,7 +91,7 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID }, { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID }, { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID }, - { NULL } + { nullptr } }; static void @@ -105,8 +105,8 @@ static const mozilla::Module kWidgetModule = { mozilla::Module::kVersion, kWidgetCIDs, kWidgetContracts, - NULL, - NULL, + nullptr, + nullptr, nsAppShellInit, nsWidgetGonkModuleDtor }; diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index 8edeca984bb5..982cd4c5052c 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -289,7 +289,7 @@ struct ParamTraits ReadParam(aMsg, aIter, &aResult->mUniqueId)) { aResult->mKeyNameIndex = static_cast(keyNameIndex); - aResult->mNativeKeyEvent = NULL; + aResult->mNativeKeyEvent = nullptr; return true; } return false; diff --git a/widget/shared/WidgetUtils.h b/widget/shared/WidgetUtils.h index 65cf04b188f4..681b4b3e4a90 100644 --- a/widget/shared/WidgetUtils.h +++ b/widget/shared/WidgetUtils.h @@ -41,11 +41,11 @@ public: * @param aUnshiftedCharCode CharCode for aKeyCode without Shift key. * This may be zero if aKeyCode key doesn't input * a Latin character. - * Note that must not be NULL. + * Note that must not be nullptr. * @param aShiftedCharCode CharCode for aKeyCOde with Shift key. * This is always 0 when aKeyCode isn't * NS_VK_[A-Z]. - * Note that must not be NULL. + * Note that must not be nullptr. */ static void GetLatinCharCodeForKeyCode(uint32_t aKeyCode, bool aIsCapsLock, diff --git a/widget/tests/TestAppShellSteadyState.cpp b/widget/tests/TestAppShellSteadyState.cpp index 977b07a4d354..e51db2c2e0bc 100644 --- a/widget/tests/TestAppShellSteadyState.cpp +++ b/widget/tests/TestAppShellSteadyState.cpp @@ -141,7 +141,7 @@ public: fail("Failed to dispatch check runnable"); } - if (NS_FAILED(NS_ProcessPendingEvents(NULL))) { + if (NS_FAILED(NS_ProcessPendingEvents(nullptr))) { fail("Failed to process all pending events"); } @@ -239,7 +239,7 @@ public: { if (sWindowUtils) { nsCOMPtr utils = dont_AddRef(sWindowUtils); - sWindowUtils = NULL; + sWindowUtils = nullptr; if (gStableStateEventHasRun) { fail("StableStateRunnable ran at wrong time"); @@ -258,7 +258,7 @@ public: return; } - KillTimer(NULL, idEvent); + KillTimer(nullptr, idEvent); nsCOMPtr appShell = dont_AddRef(sAppShell); @@ -280,7 +280,7 @@ public: ScheduleTimer(nsIDOMWindowUtils* aWindowUtils) { #ifdef XP_WIN - UINT_PTR timerId = SetTimer(NULL, 0, 1000, (TIMERPROC)TimerCallback); + UINT_PTR timerId = SetTimer(nullptr, 0, 1000, (TIMERPROC)TimerCallback); if (!timerId) { fail("SetTimer failed!"); return false; @@ -299,8 +299,8 @@ public: } }; -nsIDOMWindowUtils* EventListener::sWindowUtils = NULL; -nsIAppShell* EventListener::sAppShell = NULL; +nsIDOMWindowUtils* EventListener::sWindowUtils = nullptr; +nsIAppShell* EventListener::sAppShell = nullptr; NS_IMPL_ISUPPORTS1(EventListener, nsIDOMEventListener) @@ -399,7 +399,7 @@ Test4Internal(nsIAppShell* aAppShell) } nsCOMPtr uri; - if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), "about:", NULL))) { + if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), "about:", nullptr))) { fail("Failed to create new uri"); return false; } @@ -407,7 +407,7 @@ Test4Internal(nsIAppShell* aAppShell) uint32_t flags = nsIWebBrowserChrome::CHROME_DEFAULT; nsCOMPtr xulWindow; - if (NS_FAILED(appService->CreateTopLevelWindow(NULL, uri, flags, 100, 100, + if (NS_FAILED(appService->CreateTopLevelWindow(nullptr, uri, flags, 100, 100, getter_AddRefs(xulWindow)))) { fail("Failed to create new window"); return false; diff --git a/widget/tests/TestWinTSF.cpp b/widget/tests/TestWinTSF.cpp index 40e19944e114..eb5e9b783600 100644 --- a/widget/tests/TestWinTSF.cpp +++ b/widget/tests/TestWinTSF.cpp @@ -234,7 +234,7 @@ public: // IUnknown STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk) { - *ppUnk = NULL; + *ppUnk = nullptr; if (IID_IUnknown == riid || IID_ITfRange == riid || IID_ITfRangeACP == riid) *ppUnk = static_cast(this); if (*ppUnk) @@ -446,7 +446,7 @@ public: // IUnknown STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk) { - *ppUnk = NULL; + *ppUnk = nullptr; if (IID_IUnknown == riid || IID_IEnumTfRanges == riid) *ppUnk = static_cast(this); if (*ppUnk) @@ -538,7 +538,7 @@ public: // IUnknown STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk) { - *ppUnk = NULL; + *ppUnk = nullptr; if (IID_IUnknown == riid || IID_ITfDisplayAttributeInfo == riid) *ppUnk = static_cast(this); if (*ppUnk) @@ -617,7 +617,7 @@ public: // IUnknown STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk) { - *ppUnk = NULL; + *ppUnk = nullptr; if (IID_IUnknown == riid || IID_ITfProperty == riid || IID_ITfReadOnlyProperty == riid) *ppUnk = static_cast(this); @@ -777,7 +777,7 @@ public: // IUnknown STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk) { - *ppUnk = NULL; + *ppUnk = nullptr; if (IID_IUnknown == riid || IID_ITfContext == riid) *ppUnk = static_cast(this); else if (IID_ITextStoreACPSink == riid) @@ -1005,7 +1005,7 @@ public: // IUnknown STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk) { - *ppUnk = NULL; + *ppUnk = nullptr; if (IID_IUnknown == riid || IID_ITfDocumentMgr == riid) *ppUnk = static_cast(this); if (*ppUnk) @@ -1033,7 +1033,7 @@ public: // ITfDocumentMgr mStore->AdviseSink(IID_ITextStoreACPSink, static_cast(context.get()), TS_AS_ALL_SINKS); - if (FAILED(hr)) mStore = NULL; + if (FAILED(hr)) mStore = nullptr; NS_ENSURE_TRUE(SUCCEEDED(hr), E_FAIL); (*ppic) = context; (*ppic)->AddRef(); @@ -1067,7 +1067,7 @@ public: // ITfDocumentMgr if (dwFlags == TF_POPF_ALL) { NS_ENSURE_TRUE(mContextBase, E_FAIL); mStore->UnadviseSink(static_cast(mContextBase.get())); - mStore = NULL; + mStore = nullptr; mContextBase = nullptr; mContextTop = nullptr; return S_OK; @@ -1136,7 +1136,7 @@ public: // IUnknown STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk) { - *ppUnk = NULL; + *ppUnk = nullptr; if (IID_IUnknown == riid || IID_ITfThreadMgr == riid) *ppUnk = static_cast(this); else if (IID_ITfDisplayAttributeMgr == riid) @@ -1485,7 +1485,7 @@ TestApp::Init(void) if (*threadMgr) { (*threadMgr)->Deactivate(); (*threadMgr)->Release(); - (*threadMgr) = NULL; + (*threadMgr) = nullptr; } else { // This is only for information. The test does not need TSF to run. printf("TSF not initialized properly (TSF is not enabled/installed?)\n"); @@ -1495,13 +1495,13 @@ TestApp::Init(void) widget->GetNativeData(NS_NATIVE_TSF_CATEGORY_MGR)); if (*catMgr) { (*catMgr)->Release(); - (*catMgr) = NULL; + (*catMgr) = nullptr; } ITfDisplayAttributeMgr **daMgr = reinterpret_cast( widget->GetNativeData(NS_NATIVE_TSF_DISPLAY_ATTR_MGR)); if (*daMgr) { (*daMgr)->Release(); - (*daMgr) = NULL; + (*daMgr) = nullptr; } mMgr = new TSFMgrImpl(this); @@ -2393,7 +2393,8 @@ TestApp::TestComposition(void) hr = mMgr->GetFocusedStore()->InsertTextAtSelection(TF_IAS_NOQUERY, insertString1.get(), insertString1.Length(), - NULL, NULL, &textChange); + nullptr, nullptr, + &textChange); if (!(SUCCEEDED(hr) && sel.acpEnd == textChange.acpStart && sel.acpEnd == textChange.acpOldEnd && @@ -2578,7 +2579,7 @@ TestApp::TestNotificationTextChange(nsIWidget* aWidget, LONG aNewEnd) { MSG msg; - if (::PeekMessageW(&msg, NULL, WM_USER_TSF_TEXTCHANGE, + if (::PeekMessageW(&msg, nullptr, WM_USER_TSF_TEXTCHANGE, WM_USER_TSF_TEXTCHANGE, PM_REMOVE)) ::DispatchMessageW(&msg); if (!mMgr->GetFocusedContext()) { @@ -2588,7 +2589,7 @@ TestApp::TestNotificationTextChange(nsIWidget* aWidget, mMgr->GetFocusedContext()->mTextChanged = false; nsresult nsr = aWidget->SynthesizeNativeKeyEvent(0, aCode, 0, aCharacter, aCharacter); - if (::PeekMessageW(&msg, NULL, WM_USER_TSF_TEXTCHANGE, + if (::PeekMessageW(&msg, nullptr, WM_USER_TSF_TEXTCHANGE, WM_USER_TSF_TEXTCHANGE, PM_REMOVE)) ::DispatchMessageW(&msg); return NS_SUCCEEDED(nsr) && diff --git a/widget/windows/nsTextStore.cpp b/widget/windows/nsTextStore.cpp index 633d3ace0d57..9da72774fe86 100644 --- a/widget/windows/nsTextStore.cpp +++ b/widget/windows/nsTextStore.cpp @@ -1755,7 +1755,7 @@ nsTextStore::GetText(LONG acpStart, return TS_E_INVALIDPOS; } - // Making sure to NULL-terminate string just to be on the safe side + // Making sure to null-terminate string just to be on the safe side *pcchPlainOut = 0; if (pchPlain && cchPlainReq) *pchPlain = 0; if (pulRunInfoOut) *pulRunInfoOut = 0; diff --git a/widget/xpwidgets/GfxInfoBase.cpp b/widget/xpwidgets/GfxInfoBase.cpp index 0cd60fea4907..8a77a6549da3 100644 --- a/widget/xpwidgets/GfxInfoBase.cpp +++ b/widget/xpwidgets/GfxInfoBase.cpp @@ -390,7 +390,8 @@ BlacklistEntryToDriverInfo(nsIDOMNode* aBlacklistEntry, if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("osversion"), getter_AddRefs(dataNode))) { BlacklistNodeToTextValue(dataNode, dataValue); - aDriverInfo.mOperatingSystemVersion = strtoul(NS_LossyConvertUTF16toASCII(dataValue).get(), NULL, 10); + aDriverInfo.mOperatingSystemVersion = strtoul(NS_LossyConvertUTF16toASCII(dataValue).get(), + nullptr, 10); } // 0x8086 diff --git a/widget/xpwidgets/GfxInfoCollector.cpp b/widget/xpwidgets/GfxInfoCollector.cpp index bdc7972152d0..db5377ee0491 100644 --- a/widget/xpwidgets/GfxInfoCollector.cpp +++ b/widget/xpwidgets/GfxInfoCollector.cpp @@ -18,7 +18,8 @@ InfoObject::DefineProperty(const char *name, int value) if (!mOk) return; - mOk = JS_DefineProperty(mCx, mObj, name, INT_TO_JSVAL(value), NULL, NULL, JSPROP_ENUMERATE); + mOk = JS_DefineProperty(mCx, mObj, name, INT_TO_JSVAL(value), + nullptr, nullptr, JSPROP_ENUMERATE); } void @@ -35,7 +36,8 @@ InfoObject::DefineProperty(const char *name, nsAString &value) if (!mOk) return; - mOk = JS_DefineProperty(mCx, mObj, name, STRING_TO_JSVAL(string), NULL, NULL, JSPROP_ENUMERATE); + mOk = JS_DefineProperty(mCx, mObj, name, STRING_TO_JSVAL(string), + nullptr, nullptr, JSPROP_ENUMERATE); } void @@ -47,7 +49,7 @@ InfoObject::DefineProperty(const char *name, const char *value) InfoObject::InfoObject(JSContext *aCx) : mCx(aCx), mObj(aCx), mOk(true) { - mObj = JS_NewObject(mCx, NULL, NULL, NULL); + mObj = JS_NewObject(mCx, nullptr, nullptr, nullptr); if (!mObj) mOk = false; } diff --git a/widget/xpwidgets/nsClipboardPrivacyHandler.cpp b/widget/xpwidgets/nsClipboardPrivacyHandler.cpp index 3f0558c8ddc6..09e96db72ad6 100644 --- a/widget/xpwidgets/nsClipboardPrivacyHandler.cpp +++ b/widget/xpwidgets/nsClipboardPrivacyHandler.cpp @@ -90,7 +90,7 @@ nsClipboardPrivacyHandler::Observe(nsISupports *aSubject, char const *aTopic, PR // 32-bit/64-bit boundaries, which could lead Explorer to crash. // We work around the problem by clearing the clipboard using // the usual Win32 API. - NS_ENSURE_TRUE(SUCCEEDED(::OleSetClipboard(NULL)), NS_ERROR_FAILURE); + NS_ENSURE_TRUE(SUCCEEDED(::OleSetClipboard(nullptr)), NS_ERROR_FAILURE); #else // Empty the native clipboard by copying an empty transferable nsCOMPtr nullData = diff --git a/widget/xpwidgets/nsIdleService.cpp b/widget/xpwidgets/nsIdleService.cpp index 06bd6e11d167..f394ccde1062 100644 --- a/widget/xpwidgets/nsIdleService.cpp +++ b/widget/xpwidgets/nsIdleService.cpp @@ -45,7 +45,7 @@ using namespace mozilla; #define SECONDS_PER_DAY 86400 #ifdef PR_LOGGING -static PRLogModuleInfo *sLog = NULL; +static PRLogModuleInfo *sLog = nullptr; #endif // Use this to find previously added observers in our array: @@ -392,7 +392,7 @@ nsIdleService::nsIdleService() : mCurrentlySetToTimeoutAt(TimeStamp()), mLastUserInteraction(TimeStamp::Now()) { #ifdef PR_LOGGING - if (sLog == NULL) + if (sLog == nullptr) sLog = PR_NewLogModule("idleService"); #endif MOZ_ASSERT(!gIdleService); diff --git a/widget/xpwidgets/nsPrintSettingsImpl.cpp b/widget/xpwidgets/nsPrintSettingsImpl.cpp index 1248b23e45e1..278fe3b651b6 100644 --- a/widget/xpwidgets/nsPrintSettingsImpl.cpp +++ b/widget/xpwidgets/nsPrintSettingsImpl.cpp @@ -97,7 +97,7 @@ NS_IMETHODIMP nsPrintSettings::GetPrintSession(nsIPrintSession **aPrintSession) } NS_IMETHODIMP nsPrintSettings::SetPrintSession(nsIPrintSession *aPrintSession) { - // Clearing it by passing NULL is not allowed. That's why we + // Clearing it by passing nullptr is not allowed. That's why we // use a weak ref so that it doesn't have to be cleared. NS_ENSURE_ARG(aPrintSession); diff --git a/widget/xremoteclient/XRemoteClient.cpp b/widget/xremoteclient/XRemoteClient.cpp index dd676ea5f2b4..3ece6dc4560a 100644 --- a/widget/xremoteclient/XRemoteClient.cpp +++ b/widget/xremoteclient/XRemoteClient.cpp @@ -51,7 +51,7 @@ #define ARRAY_LENGTH(array_) (sizeof(array_)/sizeof(array_[0])) -static PRLogModuleInfo *sRemoteLm = NULL; +static PRLogModuleInfo *sRemoteLm = nullptr; static int (*sOldHandler)(Display *, XErrorEvent *); static bool sGotBadWindow; @@ -403,7 +403,7 @@ XRemoteClient::GetLock(Window aWindow, bool *aDestroyed) // add the x event queue to the select set FD_SET(ConnectionNumber(mDisplay), &select_set); select_retval = select(ConnectionNumber(mDisplay) + 1, - &select_set, NULL, NULL, &delay); + &select_set, nullptr, nullptr, &delay); // did we time out? if (select_retval == 0) { PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("timed out waiting for window\n"));