Skip to content

Commit 28ba747

Browse files
committed
Bug 784739 - Switch from NULL to nullptr in widget/; r=ehsan
1 parent 145d3ff commit 28ba747

13 files changed

+59
-55
lines changed

widget/gonk/nsAppShell.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ using namespace mozilla::services;
8383
using namespace mozilla::widget;
8484

8585
bool gDrawRequest = false;
86-
static nsAppShell *gAppShell = NULL;
86+
static nsAppShell *gAppShell = nullptr;
8787
static int epollfd = 0;
8888
static int signalfds[2] = {0};
8989
static bool sDevInputAudioJack;
@@ -145,7 +145,7 @@ struct UserInputData {
145145
static void
146146
sendMouseEvent(uint32_t msg, uint64_t timeMs, int x, int y, bool forwardToChildren)
147147
{
148-
WidgetMouseEvent event(true, msg, NULL,
148+
WidgetMouseEvent event(true, msg, nullptr,
149149
WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
150150

151151
event.refPoint.x = x;
@@ -198,7 +198,7 @@ sendTouchEvent(UserInputData& data, bool* captured)
198198
break;
199199
}
200200

201-
WidgetTouchEvent event(true, msg, NULL);
201+
WidgetTouchEvent event(true, msg, nullptr);
202202

203203
event.time = data.timeMs;
204204

@@ -221,7 +221,7 @@ sendKeyEventWithMsg(uint32_t keyCode,
221221
uint32_t msg,
222222
uint64_t timeMs)
223223
{
224-
WidgetKeyboardEvent event(true, msg, NULL);
224+
WidgetKeyboardEvent event(true, msg, nullptr);
225225
event.keyCode = keyCode;
226226
event.mKeyNameIndex = keyNameIndex;
227227
event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_MOBILE;
@@ -393,7 +393,7 @@ deviceId)
393393
virtual void notifyInputDevicesChanged(const android::Vector<InputDeviceInfo>& inputDevices) {};
394394
virtual sp<KeyCharacterMap> getKeyboardLayoutOverlay(const String8& inputDeviceDescriptor)
395395
{
396-
return NULL;
396+
return nullptr;
397397
};
398398
virtual String8 getDeviceAlias(const InputDeviceIdentifier& identifier)
399399
{
@@ -707,7 +707,7 @@ nsAppShell::~nsAppShell()
707707
if (result)
708708
LOG("Could not stop reader thread - %d", result);
709709
}
710-
gAppShell = NULL;
710+
gAppShell = nullptr;
711711
}
712712

713713
nsresult

widget/gonk/nsWidgetFactory.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ ScreenManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
7171
}
7272

7373
static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
74-
{ &kNS_WINDOW_CID, false, NULL, nsWindowConstructor },
75-
{ &kNS_CHILD_CID, false, NULL, nsWindowConstructor },
76-
{ &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor },
77-
{ &kNS_SCREENMANAGER_CID, false, NULL, ScreenManagerConstructor },
78-
{ &kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor },
79-
{ &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceGonkConstructor },
80-
{ &kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor },
81-
{ &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor },
82-
{ NULL }
74+
{ &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor },
75+
{ &kNS_CHILD_CID, false, nullptr, nsWindowConstructor },
76+
{ &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor },
77+
{ &kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor },
78+
{ &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor },
79+
{ &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceGonkConstructor },
80+
{ &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor },
81+
{ &kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor },
82+
{ nullptr }
8383
};
8484

8585
static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
@@ -91,7 +91,7 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
9191
{ "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
9292
{ "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
9393
{ "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
94-
{ NULL }
94+
{ nullptr }
9595
};
9696

9797
static void
@@ -105,8 +105,8 @@ static const mozilla::Module kWidgetModule = {
105105
mozilla::Module::kVersion,
106106
kWidgetCIDs,
107107
kWidgetContracts,
108-
NULL,
109-
NULL,
108+
nullptr,
109+
nullptr,
110110
nsAppShellInit,
111111
nsWidgetGonkModuleDtor
112112
};

widget/nsGUIEventIPC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
289289
ReadParam(aMsg, aIter, &aResult->mUniqueId))
290290
{
291291
aResult->mKeyNameIndex = static_cast<mozilla::KeyNameIndex>(keyNameIndex);
292-
aResult->mNativeKeyEvent = NULL;
292+
aResult->mNativeKeyEvent = nullptr;
293293
return true;
294294
}
295295
return false;

widget/shared/WidgetUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ class WidgetUtils
4141
* @param aUnshiftedCharCode CharCode for aKeyCode without Shift key.
4242
* This may be zero if aKeyCode key doesn't input
4343
* a Latin character.
44-
* Note that must not be NULL.
44+
* Note that must not be nullptr.
4545
* @param aShiftedCharCode CharCode for aKeyCOde with Shift key.
4646
* This is always 0 when aKeyCode isn't
4747
* NS_VK_[A-Z].
48-
* Note that must not be NULL.
48+
* Note that must not be nullptr.
4949
*/
5050
static void GetLatinCharCodeForKeyCode(uint32_t aKeyCode,
5151
bool aIsCapsLock,

widget/tests/TestAppShellSteadyState.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class ScheduleNestedStableStateRunnable : public ScheduleStableStateRunnable
141141
fail("Failed to dispatch check runnable");
142142
}
143143

144-
if (NS_FAILED(NS_ProcessPendingEvents(NULL))) {
144+
if (NS_FAILED(NS_ProcessPendingEvents(nullptr))) {
145145
fail("Failed to process all pending events");
146146
}
147147

@@ -239,7 +239,7 @@ class EventListener MOZ_FINAL : public nsIDOMEventListener
239239
{
240240
if (sWindowUtils) {
241241
nsCOMPtr<nsIDOMWindowUtils> utils = dont_AddRef(sWindowUtils);
242-
sWindowUtils = NULL;
242+
sWindowUtils = nullptr;
243243

244244
if (gStableStateEventHasRun) {
245245
fail("StableStateRunnable ran at wrong time");
@@ -258,7 +258,7 @@ class EventListener MOZ_FINAL : public nsIDOMEventListener
258258
return;
259259
}
260260

261-
KillTimer(NULL, idEvent);
261+
KillTimer(nullptr, idEvent);
262262

263263
nsCOMPtr<nsIAppShell> appShell = dont_AddRef(sAppShell);
264264

@@ -280,7 +280,7 @@ class EventListener MOZ_FINAL : public nsIDOMEventListener
280280
ScheduleTimer(nsIDOMWindowUtils* aWindowUtils)
281281
{
282282
#ifdef XP_WIN
283-
UINT_PTR timerId = SetTimer(NULL, 0, 1000, (TIMERPROC)TimerCallback);
283+
UINT_PTR timerId = SetTimer(nullptr, 0, 1000, (TIMERPROC)TimerCallback);
284284
if (!timerId) {
285285
fail("SetTimer failed!");
286286
return false;
@@ -299,8 +299,8 @@ class EventListener MOZ_FINAL : public nsIDOMEventListener
299299
}
300300
};
301301

302-
nsIDOMWindowUtils* EventListener::sWindowUtils = NULL;
303-
nsIAppShell* EventListener::sAppShell = NULL;
302+
nsIDOMWindowUtils* EventListener::sWindowUtils = nullptr;
303+
nsIAppShell* EventListener::sAppShell = nullptr;
304304

305305
NS_IMPL_ISUPPORTS1(EventListener, nsIDOMEventListener)
306306

@@ -399,15 +399,15 @@ Test4Internal(nsIAppShell* aAppShell)
399399
}
400400

401401
nsCOMPtr<nsIURI> uri;
402-
if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), "about:", NULL))) {
402+
if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), "about:", nullptr))) {
403403
fail("Failed to create new uri");
404404
return false;
405405
}
406406

407407
uint32_t flags = nsIWebBrowserChrome::CHROME_DEFAULT;
408408

409409
nsCOMPtr<nsIXULWindow> xulWindow;
410-
if (NS_FAILED(appService->CreateTopLevelWindow(NULL, uri, flags, 100, 100,
410+
if (NS_FAILED(appService->CreateTopLevelWindow(nullptr, uri, flags, 100, 100,
411411
getter_AddRefs(xulWindow)))) {
412412
fail("Failed to create new window");
413413
return false;

widget/tests/TestWinTSF.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class TSFRangeImpl : public ITfRangeACP
234234

235235
STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk)
236236
{
237-
*ppUnk = NULL;
237+
*ppUnk = nullptr;
238238
if (IID_IUnknown == riid || IID_ITfRange == riid || IID_ITfRangeACP == riid)
239239
*ppUnk = static_cast<ITfRangeACP*>(this);
240240
if (*ppUnk)
@@ -446,7 +446,7 @@ class TSFEnumRangeImpl : public IEnumTfRanges
446446

447447
STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk)
448448
{
449-
*ppUnk = NULL;
449+
*ppUnk = nullptr;
450450
if (IID_IUnknown == riid || IID_IEnumTfRanges == riid)
451451
*ppUnk = static_cast<IEnumTfRanges*>(this);
452452
if (*ppUnk)
@@ -538,7 +538,7 @@ class TSFDispAttrInfoImpl : public ITfDisplayAttributeInfo
538538

539539
STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk)
540540
{
541-
*ppUnk = NULL;
541+
*ppUnk = nullptr;
542542
if (IID_IUnknown == riid || IID_ITfDisplayAttributeInfo == riid)
543543
*ppUnk = static_cast<ITfDisplayAttributeInfo*>(this);
544544
if (*ppUnk)
@@ -617,7 +617,7 @@ class TSFAttrPropImpl : public ITfProperty
617617

618618
STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk)
619619
{
620-
*ppUnk = NULL;
620+
*ppUnk = nullptr;
621621
if (IID_IUnknown == riid || IID_ITfProperty == riid ||
622622
IID_ITfReadOnlyProperty == riid)
623623
*ppUnk = static_cast<ITfProperty*>(this);
@@ -777,7 +777,7 @@ class TSFContextImpl : public ITfContext,
777777

778778
STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk)
779779
{
780-
*ppUnk = NULL;
780+
*ppUnk = nullptr;
781781
if (IID_IUnknown == riid || IID_ITfContext == riid)
782782
*ppUnk = static_cast<ITfContext*>(this);
783783
else if (IID_ITextStoreACPSink == riid)
@@ -1005,7 +1005,7 @@ class TSFDocumentMgrImpl : public ITfDocumentMgr
10051005

10061006
STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk)
10071007
{
1008-
*ppUnk = NULL;
1008+
*ppUnk = nullptr;
10091009
if (IID_IUnknown == riid || IID_ITfDocumentMgr == riid)
10101010
*ppUnk = static_cast<ITfDocumentMgr*>(this);
10111011
if (*ppUnk)
@@ -1033,7 +1033,7 @@ class TSFDocumentMgrImpl : public ITfDocumentMgr
10331033
mStore->AdviseSink(IID_ITextStoreACPSink,
10341034
static_cast<ITextStoreACPSink*>(context.get()),
10351035
TS_AS_ALL_SINKS);
1036-
if (FAILED(hr)) mStore = NULL;
1036+
if (FAILED(hr)) mStore = nullptr;
10371037
NS_ENSURE_TRUE(SUCCEEDED(hr), E_FAIL);
10381038
(*ppic) = context;
10391039
(*ppic)->AddRef();
@@ -1067,7 +1067,7 @@ class TSFDocumentMgrImpl : public ITfDocumentMgr
10671067
if (dwFlags == TF_POPF_ALL) {
10681068
NS_ENSURE_TRUE(mContextBase, E_FAIL);
10691069
mStore->UnadviseSink(static_cast<ITextStoreACPSink*>(mContextBase.get()));
1070-
mStore = NULL;
1070+
mStore = nullptr;
10711071
mContextBase = nullptr;
10721072
mContextTop = nullptr;
10731073
return S_OK;
@@ -1136,7 +1136,7 @@ class TSFMgrImpl : public ITfThreadMgr,
11361136

11371137
STDMETHODIMP QueryInterface(REFIID riid, void** ppUnk)
11381138
{
1139-
*ppUnk = NULL;
1139+
*ppUnk = nullptr;
11401140
if (IID_IUnknown == riid || IID_ITfThreadMgr == riid)
11411141
*ppUnk = static_cast<ITfThreadMgr*>(this);
11421142
else if (IID_ITfDisplayAttributeMgr == riid)
@@ -1485,7 +1485,7 @@ TestApp::Init(void)
14851485
if (*threadMgr) {
14861486
(*threadMgr)->Deactivate();
14871487
(*threadMgr)->Release();
1488-
(*threadMgr) = NULL;
1488+
(*threadMgr) = nullptr;
14891489
} else {
14901490
// This is only for information. The test does not need TSF to run.
14911491
printf("TSF not initialized properly (TSF is not enabled/installed?)\n");
@@ -1495,13 +1495,13 @@ TestApp::Init(void)
14951495
widget->GetNativeData(NS_NATIVE_TSF_CATEGORY_MGR));
14961496
if (*catMgr) {
14971497
(*catMgr)->Release();
1498-
(*catMgr) = NULL;
1498+
(*catMgr) = nullptr;
14991499
}
15001500
ITfDisplayAttributeMgr **daMgr = reinterpret_cast<ITfDisplayAttributeMgr**>(
15011501
widget->GetNativeData(NS_NATIVE_TSF_DISPLAY_ATTR_MGR));
15021502
if (*daMgr) {
15031503
(*daMgr)->Release();
1504-
(*daMgr) = NULL;
1504+
(*daMgr) = nullptr;
15051505
}
15061506

15071507
mMgr = new TSFMgrImpl(this);
@@ -2393,7 +2393,8 @@ TestApp::TestComposition(void)
23932393
hr = mMgr->GetFocusedStore()->InsertTextAtSelection(TF_IAS_NOQUERY,
23942394
insertString1.get(),
23952395
insertString1.Length(),
2396-
NULL, NULL, &textChange);
2396+
nullptr, nullptr,
2397+
&textChange);
23972398
if (!(SUCCEEDED(hr) &&
23982399
sel.acpEnd == textChange.acpStart &&
23992400
sel.acpEnd == textChange.acpOldEnd &&
@@ -2578,7 +2579,7 @@ TestApp::TestNotificationTextChange(nsIWidget* aWidget,
25782579
LONG aNewEnd)
25792580
{
25802581
MSG msg;
2581-
if (::PeekMessageW(&msg, NULL, WM_USER_TSF_TEXTCHANGE,
2582+
if (::PeekMessageW(&msg, nullptr, WM_USER_TSF_TEXTCHANGE,
25822583
WM_USER_TSF_TEXTCHANGE, PM_REMOVE))
25832584
::DispatchMessageW(&msg);
25842585
if (!mMgr->GetFocusedContext()) {
@@ -2588,7 +2589,7 @@ TestApp::TestNotificationTextChange(nsIWidget* aWidget,
25882589
mMgr->GetFocusedContext()->mTextChanged = false;
25892590
nsresult nsr = aWidget->SynthesizeNativeKeyEvent(0, aCode, 0,
25902591
aCharacter, aCharacter);
2591-
if (::PeekMessageW(&msg, NULL, WM_USER_TSF_TEXTCHANGE,
2592+
if (::PeekMessageW(&msg, nullptr, WM_USER_TSF_TEXTCHANGE,
25922593
WM_USER_TSF_TEXTCHANGE, PM_REMOVE))
25932594
::DispatchMessageW(&msg);
25942595
return NS_SUCCEEDED(nsr) &&

widget/windows/nsTextStore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ nsTextStore::GetText(LONG acpStart,
17551755
return TS_E_INVALIDPOS;
17561756
}
17571757

1758-
// Making sure to NULL-terminate string just to be on the safe side
1758+
// Making sure to null-terminate string just to be on the safe side
17591759
*pcchPlainOut = 0;
17601760
if (pchPlain && cchPlainReq) *pchPlain = 0;
17611761
if (pulRunInfoOut) *pulRunInfoOut = 0;

widget/xpwidgets/GfxInfoBase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ BlacklistEntryToDriverInfo(nsIDOMNode* aBlacklistEntry,
390390
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("osversion"),
391391
getter_AddRefs(dataNode))) {
392392
BlacklistNodeToTextValue(dataNode, dataValue);
393-
aDriverInfo.mOperatingSystemVersion = strtoul(NS_LossyConvertUTF16toASCII(dataValue).get(), NULL, 10);
393+
aDriverInfo.mOperatingSystemVersion = strtoul(NS_LossyConvertUTF16toASCII(dataValue).get(),
394+
nullptr, 10);
394395
}
395396

396397
// <vendor>0x8086</vendor>

widget/xpwidgets/GfxInfoCollector.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ InfoObject::DefineProperty(const char *name, int value)
1818
if (!mOk)
1919
return;
2020

21-
mOk = JS_DefineProperty(mCx, mObj, name, INT_TO_JSVAL(value), NULL, NULL, JSPROP_ENUMERATE);
21+
mOk = JS_DefineProperty(mCx, mObj, name, INT_TO_JSVAL(value),
22+
nullptr, nullptr, JSPROP_ENUMERATE);
2223
}
2324

2425
void
@@ -35,7 +36,8 @@ InfoObject::DefineProperty(const char *name, nsAString &value)
3536
if (!mOk)
3637
return;
3738

38-
mOk = JS_DefineProperty(mCx, mObj, name, STRING_TO_JSVAL(string), NULL, NULL, JSPROP_ENUMERATE);
39+
mOk = JS_DefineProperty(mCx, mObj, name, STRING_TO_JSVAL(string),
40+
nullptr, nullptr, JSPROP_ENUMERATE);
3941
}
4042

4143
void
@@ -47,7 +49,7 @@ InfoObject::DefineProperty(const char *name, const char *value)
4749

4850
InfoObject::InfoObject(JSContext *aCx) : mCx(aCx), mObj(aCx), mOk(true)
4951
{
50-
mObj = JS_NewObject(mCx, NULL, NULL, NULL);
52+
mObj = JS_NewObject(mCx, nullptr, nullptr, nullptr);
5153
if (!mObj)
5254
mOk = false;
5355
}

widget/xpwidgets/nsClipboardPrivacyHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ nsClipboardPrivacyHandler::Observe(nsISupports *aSubject, char const *aTopic, PR
9090
// 32-bit/64-bit boundaries, which could lead Explorer to crash.
9191
// We work around the problem by clearing the clipboard using
9292
// the usual Win32 API.
93-
NS_ENSURE_TRUE(SUCCEEDED(::OleSetClipboard(NULL)), NS_ERROR_FAILURE);
93+
NS_ENSURE_TRUE(SUCCEEDED(::OleSetClipboard(nullptr)), NS_ERROR_FAILURE);
9494
#else
9595
// Empty the native clipboard by copying an empty transferable
9696
nsCOMPtr<nsITransferable> nullData =

widget/xpwidgets/nsIdleService.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ using namespace mozilla;
4545
#define SECONDS_PER_DAY 86400
4646

4747
#ifdef PR_LOGGING
48-
static PRLogModuleInfo *sLog = NULL;
48+
static PRLogModuleInfo *sLog = nullptr;
4949
#endif
5050

5151
// Use this to find previously added observers in our array:
@@ -392,7 +392,7 @@ nsIdleService::nsIdleService() : mCurrentlySetToTimeoutAt(TimeStamp()),
392392
mLastUserInteraction(TimeStamp::Now())
393393
{
394394
#ifdef PR_LOGGING
395-
if (sLog == NULL)
395+
if (sLog == nullptr)
396396
sLog = PR_NewLogModule("idleService");
397397
#endif
398398
MOZ_ASSERT(!gIdleService);

0 commit comments

Comments
 (0)