Skip to content

Commit 48a594a

Browse files
committed
Bug 1268313: Part 7 - Move NS_NewRunnableMethod and friends to mozilla::NewRunnableMethod. r=froydnj
1 parent 12d497c commit 48a594a

File tree

237 files changed

+1046
-1280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+1046
-1280
lines changed

docshell/shistory/nsSHistory.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,10 +1383,8 @@ nsSHistory::RemoveEntries(nsTArray<uint64_t>& aIDs, int32_t aStartIndex)
13831383
--index;
13841384
}
13851385
if (didRemove && mRootDocShell) {
1386-
nsCOMPtr<nsIRunnable> ev =
1387-
NS_NewRunnableMethod(static_cast<nsDocShell*>(mRootDocShell),
1388-
&nsDocShell::FireDummyOnLocationChange);
1389-
NS_DispatchToCurrentThread(ev);
1386+
NS_DispatchToCurrentThread(NewRunnableMethod(static_cast<nsDocShell*>(mRootDocShell),
1387+
&nsDocShell::FireDummyOnLocationChange));
13901388
}
13911389
}
13921390

dom/animation/Animation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ Animation::DoFinishNotification(SyncNotifyFlag aSyncNotifyFlag)
12361236
DoFinishNotificationImmediately();
12371237
} else if (!mFinishNotificationTask.IsPending()) {
12381238
RefPtr<nsRunnableMethod<Animation>> runnable =
1239-
NS_NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately);
1239+
NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately);
12401240
runtime->DispatchToMicroTask(runnable);
12411241
mFinishNotificationTask = runnable;
12421242
}

dom/archivereader/ArchiveEvent.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ ArchiveReaderEvent::RunShare(nsresult aStatus)
8686
{
8787
mStatus = aStatus;
8888

89-
nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &ArchiveReaderEvent::ShareMainThread);
90-
NS_DispatchToMainThread(event);
89+
NS_DispatchToMainThread(NewRunnableMethod(this, &ArchiveReaderEvent::ShareMainThread));
9190

9291
return NS_OK;
9392
}

dom/base/Element.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ Element::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
517517
}
518518
else {
519519
nsContentUtils::AddScriptRunner(
520-
NS_NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler));
520+
NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler));
521521
}
522522
}
523523
}

dom/base/EventSource.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,7 @@ EventSource::OnStartRequest(nsIRequest *aRequest,
364364
return NS_ERROR_ABORT;
365365
}
366366

367-
nsCOMPtr<nsIRunnable> event =
368-
NS_NewRunnableMethod(this, &EventSource::AnnounceConnection);
369-
NS_ENSURE_STATE(event);
370-
371-
rv = NS_DispatchToMainThread(event);
367+
rv = NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::AnnounceConnection));
372368
NS_ENSURE_SUCCESS(rv, rv);
373369

374370
mStatus = PARSE_STATE_BEGIN_OF_STREAM;
@@ -474,11 +470,7 @@ EventSource::OnStopRequest(nsIRequest *aRequest,
474470

475471
ClearFields();
476472

477-
nsCOMPtr<nsIRunnable> event =
478-
NS_NewRunnableMethod(this, &EventSource::ReestablishConnection);
479-
NS_ENSURE_STATE(event);
480-
481-
rv = NS_DispatchToMainThread(event);
473+
rv = NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::ReestablishConnection));
482474
NS_ENSURE_SUCCESS(rv, rv);
483475

484476
return NS_OK;
@@ -907,11 +899,8 @@ EventSource::ConsoleError()
907899
nsresult
908900
EventSource::DispatchFailConnection()
909901
{
910-
nsCOMPtr<nsIRunnable> event =
911-
NS_NewRunnableMethod(this, &EventSource::FailConnection);
912-
NS_ENSURE_STATE(event);
913902

914-
return NS_DispatchToMainThread(event);
903+
return NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::FailConnection));
915904
}
916905

917906
void
@@ -985,7 +974,7 @@ EventSource::Thaw()
985974
nsresult rv;
986975
if (!mGoingToDispatchAllMessages && mMessagesToDispatch.GetSize() > 0) {
987976
nsCOMPtr<nsIRunnable> event =
988-
NS_NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents);
977+
NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents);
989978
NS_ENSURE_STATE(event);
990979

991980
mGoingToDispatchAllMessages = true;
@@ -1045,7 +1034,7 @@ EventSource::DispatchCurrentMessageEvent()
10451034

10461035
if (!mGoingToDispatchAllMessages) {
10471036
nsCOMPtr<nsIRunnable> event =
1048-
NS_NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents);
1037+
NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents);
10491038
NS_ENSURE_STATE(event);
10501039

10511040
mGoingToDispatchAllMessages = true;

dom/base/ScreenOrientation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ ScreenOrientation::Notify(const hal::ScreenConfiguration& aConfiguration)
540540
doc->SetOrientationPendingPromise(nullptr);
541541
}
542542

543-
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableMethod(this,
543+
nsCOMPtr<nsIRunnable> runnable = NewRunnableMethod(this,
544544
&ScreenOrientation::DispatchChangeEvent);
545545
rv = NS_DispatchToMainThread(runnable);
546546
NS_WARN_IF(NS_FAILED(rv));
@@ -615,7 +615,7 @@ ScreenOrientation::VisibleEventListener::HandleEvent(nsIDOMEvent* aEvent)
615615
doc->SetOrientationPendingPromise(nullptr);
616616
}
617617

618-
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableMethod(orientation,
618+
nsCOMPtr<nsIRunnable> runnable = NewRunnableMethod(orientation,
619619
&ScreenOrientation::DispatchChangeEvent);
620620
rv = NS_DispatchToMainThread(runnable);
621621
if (NS_WARN_IF(rv.Failed())) {

dom/base/nsContentSink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ nsContentSink::ProcessHTTPHeaders(nsIChannel* aChannel)
271271
"Already dispatched an event?");
272272

273273
mProcessLinkHeaderEvent =
274-
NS_NewNonOwningRunnableMethod(this,
274+
NewNonOwningRunnableMethod(this,
275275
&nsContentSink::DoProcessLinkHeader);
276276
rv = NS_DispatchToCurrentThread(mProcessLinkHeaderEvent.get());
277277
if (NS_FAILED(rv)) {

dom/base/nsContentUtils.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5042,22 +5042,29 @@ nsContentUtils::WarnScriptWasIgnored(nsIDocument* aDocument)
50425042

50435043
/* static */
50445044
bool
5045-
nsContentUtils::AddScriptRunner(nsIRunnable* aRunnable)
5045+
nsContentUtils::AddScriptRunner(already_AddRefed<nsIRunnable> aRunnable)
50465046
{
5047-
if (!aRunnable) {
5047+
nsCOMPtr<nsIRunnable> runnable = aRunnable;
5048+
if (!runnable) {
50485049
return false;
50495050
}
50505051

50515052
if (sScriptBlockerCount) {
5052-
return sBlockedScriptRunners->AppendElement(aRunnable) != nullptr;
5053+
return sBlockedScriptRunners->AppendElement(runnable.forget()) != nullptr;
50535054
}
50545055

5055-
nsCOMPtr<nsIRunnable> run = aRunnable;
5056-
run->Run();
5056+
runnable->Run();
50575057

50585058
return true;
50595059
}
50605060

5061+
/* static */
5062+
bool
5063+
nsContentUtils::AddScriptRunner(nsIRunnable* aRunnable) {
5064+
nsCOMPtr<nsIRunnable> runnable = aRunnable;
5065+
return AddScriptRunner(runnable.forget());
5066+
}
5067+
50615068
/* static */
50625069
void
50635070
nsContentUtils::RunInStableState(already_AddRefed<nsIRunnable> aRunnable)

dom/base/nsContentUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,7 @@ class nsContentUtils
16081608
* has not yet been AddRefed.
16091609
* @return false on out of memory, true otherwise.
16101610
*/
1611+
static bool AddScriptRunner(already_AddRefed<nsIRunnable> aRunnable);
16111612
static bool AddScriptRunner(nsIRunnable* aRunnable);
16121613

16131614
/**

dom/base/nsDOMWindowUtils.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ nsDOMWindowUtils::SendNativeKeyEvent(int32_t aNativeKeyboardLayout,
10081008
if (!widget)
10091009
return NS_ERROR_FAILURE;
10101010

1011-
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
1011+
NS_DispatchToMainThread(NewRunnableMethod
10121012
<int32_t, int32_t, uint32_t, nsString, nsString, nsIObserver*>
10131013
(widget, &nsIWidget::SynthesizeNativeKeyEvent, aNativeKeyboardLayout,
10141014
aNativeKeyCode, aModifiers, aCharacters, aUnmodifiedCharacters, aObserver));
@@ -1028,7 +1028,7 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX,
10281028
if (!widget)
10291029
return NS_ERROR_FAILURE;
10301030

1031-
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
1031+
NS_DispatchToMainThread(NewRunnableMethod
10321032
<LayoutDeviceIntPoint, int32_t, int32_t, nsIObserver*>
10331033
(widget, &nsIWidget::SynthesizeNativeMouseEvent,
10341034
LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aModifierFlags,
@@ -1047,7 +1047,7 @@ nsDOMWindowUtils::SendNativeMouseMove(int32_t aScreenX,
10471047
if (!widget)
10481048
return NS_ERROR_FAILURE;
10491049

1050-
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
1050+
NS_DispatchToMainThread(NewRunnableMethod
10511051
<LayoutDeviceIntPoint, nsIObserver*>
10521052
(widget, &nsIWidget::SynthesizeNativeMouseMove,
10531053
LayoutDeviceIntPoint(aScreenX, aScreenY), aObserver));
@@ -1072,7 +1072,7 @@ nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX,
10721072
return NS_ERROR_FAILURE;
10731073
}
10741074

1075-
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
1075+
NS_DispatchToMainThread(NewRunnableMethod
10761076
<mozilla::LayoutDeviceIntPoint, uint32_t, double, double, double, uint32_t, uint32_t, nsIObserver*>
10771077
(widget, &nsIWidget::SynthesizeNativeMouseScrollEvent,
10781078
LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aDeltaX, aDeltaY,
@@ -1098,7 +1098,7 @@ nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId,
10981098
return NS_ERROR_INVALID_ARG;
10991099
}
11001100

1101-
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
1101+
NS_DispatchToMainThread(NewRunnableMethod
11021102
<uint32_t, nsIWidget::TouchPointerState, LayoutDeviceIntPoint, double, uint32_t, nsIObserver*>
11031103
(widget, &nsIWidget::SynthesizeNativeTouchPoint, aPointerId,
11041104
(nsIWidget::TouchPointerState)aTouchState,
@@ -1118,7 +1118,7 @@ nsDOMWindowUtils::SendNativeTouchTap(int32_t aScreenX,
11181118
return NS_ERROR_FAILURE;
11191119
}
11201120

1121-
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
1121+
NS_DispatchToMainThread(NewRunnableMethod
11221122
<LayoutDeviceIntPoint, bool, nsIObserver*>
11231123
(widget, &nsIWidget::SynthesizeNativeTouchTap,
11241124
LayoutDeviceIntPoint(aScreenX, aScreenY), aLongTap, aObserver));
@@ -1133,7 +1133,7 @@ nsDOMWindowUtils::ClearNativeTouchSequence(nsIObserver* aObserver)
11331133
return NS_ERROR_FAILURE;
11341134
}
11351135

1136-
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs<nsIObserver*>
1136+
NS_DispatchToMainThread(NewRunnableMethod<nsIObserver*>
11371137
(widget, &nsIWidget::ClearNativeTouchSequence, aObserver));
11381138
return NS_OK;
11391139
}

0 commit comments

Comments
 (0)