Bug 1343799 - lable runnables in texttracklist.cpp. r=jwwang
MozReview-Commit-ID: 39MmwAMaDdk
--- a/dom/media/TextTrackList.cpp
+++ b/dom/media/TextTrackList.cpp
@@ -2,16 +2,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/TextTrackList.h"
#include "mozilla/dom/TextTrackListBinding.h"
#include "mozilla/dom/TrackEvent.h"
#include "nsThreadUtils.h"
+#include "nsGlobalWindow.h"
#include "mozilla/dom/TextTrackCue.h"
#include "mozilla/dom/TextTrackManager.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_INHERITED(TextTrackList,
DOMEventTargetHelper,
@@ -169,24 +170,31 @@ TextTrackList::DispatchTrackEvent(nsIDOM
return DispatchTrustedEvent(aEvent);
}
void
TextTrackList::CreateAndDispatchChangeEvent()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mPendingTextTrackChange) {
+ nsPIDOMWindowInner* win = GetOwner();
+ if (!win) {
+ return;
+ }
+
mPendingTextTrackChange = true;
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
event->InitEvent(NS_LITERAL_STRING("change"), false, false);
event->SetTrusted(true);
nsCOMPtr<nsIRunnable> eventRunner = new ChangeEventRunner(this, event);
- NS_DispatchToMainThread(eventRunner);
+ nsGlobalWindow::Cast(win)->Dispatch(
+ "TextTrackList::CreateAndDispatchChangeEvent", TaskCategory::Other,
+ eventRunner.forget());
}
}
void
TextTrackList::CreateAndDispatchTrackEventRunner(TextTrack* aTrack,
const nsAString& aEventName)
{
nsCOMPtr<nsIThread> thread;