mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 15:27:32 +09:00
Issue #2452 - Ensure DOM events aren't dispatched at unexpected time
https://bugzilla.mozilla.org/show_bug.cgi?id=1409985 https://bugzilla.mozilla.org/show_bug.cgi?id=1443746
This commit is contained in:
parent
728b8ad60b
commit
d6dd1f8133
5 changed files with 53 additions and 6 deletions
|
|
@ -59,15 +59,30 @@ public:
|
|||
switch (event) {
|
||||
case MediaStreamGraphEvent::EVENT_FINISHED:
|
||||
{
|
||||
RefPtr<SynthStreamListener> self = this;
|
||||
if (!mStarted) {
|
||||
mStarted = true;
|
||||
nsCOMPtr<nsIRunnable> startRunnable =
|
||||
NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted);
|
||||
nsCOMPtr<nsIRunnable> startRunnable = NS_NewRunnableFunction(
|
||||
[self] {
|
||||
// "start" event will be fired in DoNotifyStarted() which is
|
||||
// not allowed in stable state, so we do it asynchronously in
|
||||
// next run.
|
||||
NS_DispatchToMainThread(NewRunnableMethod(
|
||||
self,
|
||||
&SynthStreamListener::DoNotifyStarted));
|
||||
});
|
||||
aGraph->DispatchToMainThreadAfterStreamStateUpdate(startRunnable.forget());
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> endRunnable =
|
||||
NewRunnableMethod(this, &SynthStreamListener::DoNotifyFinished);
|
||||
nsCOMPtr<nsIRunnable> endRunnable = NS_NewRunnableFunction(
|
||||
[self] {
|
||||
// "end" event will be fired in DoNotifyFinished() which is
|
||||
// not allowed in stable state, so we do it asynchronously in
|
||||
// next run.
|
||||
NS_DispatchToMainThread(NewRunnableMethod(
|
||||
self,
|
||||
&SynthStreamListener::DoNotifyFinished));
|
||||
});
|
||||
aGraph->DispatchToMainThreadAfterStreamStateUpdate(endRunnable.forget());
|
||||
}
|
||||
break;
|
||||
|
|
@ -85,8 +100,16 @@ public:
|
|||
{
|
||||
if (aBlocked == MediaStreamListener::UNBLOCKED && !mStarted) {
|
||||
mStarted = true;
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted);
|
||||
RefPtr<SynthStreamListener> self = this;
|
||||
nsCOMPtr<nsIRunnable> event = NS_NewRunnableFunction(
|
||||
[self] {
|
||||
// "start" event will be fired in DoNotifyStarted() which is
|
||||
// not allowed in stable state, so we do it asynchronously in
|
||||
// next run.
|
||||
NS_DispatchToMainThread(NewRunnableMethod(
|
||||
self,
|
||||
&SynthStreamListener::DoNotifyStarted));
|
||||
});
|
||||
aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue