Bug 1285897 - Async dispatch cuechange event on TextTrack object. r=rillian

MozReview-Commit-ID: DKWCAEaT58J

--HG--
extra : transplant_source : %F4%CAT%AD%05v%A4%94%B8%13%2C%8E%9Ex%DDg%89Q%CFR
This commit is contained in:
bechen 2016-07-12 17:41:41 +08:00
parent b7387e8701
commit c610f50aae
3 changed files with 14 additions and 1 deletions

View File

@ -740,7 +740,7 @@ TextTrackManager::TimeMarchesOn()
for (uint32_t i = 0; i < affectedTracks.Length(); ++i) {
TextTrack* ttrack = affectedTracks[i];
if (ttrack) {
ttrack->DispatchTrustedEvent(NS_LITERAL_STRING("cuechange"));
ttrack->DispatchAsyncTrustedEvent(NS_LITERAL_STRING("cuechange"));
HTMLTrackElement* trackElement = ttrack->GetTrackElement();
if (trackElement) {
trackElement->DispatchTrackRunnable(NS_LITERAL_STRING("cuechange"));

View File

@ -318,5 +318,16 @@ TextTrack::GetLanguage(nsAString& aLanguage) const
}
}
void
TextTrack::DispatchAsyncTrustedEvent(const nsString& aEventName)
{
RefPtr<TextTrack> self = this;
NS_DispatchToMainThread(
NS_NewRunnableFunction([self, aEventName]() {
self->DispatchTrustedEvent(aEventName);
})
);
}
} // namespace dom
} // namespace mozilla

View File

@ -116,6 +116,8 @@ public:
void NotifyCueUpdated(TextTrackCue *aCue);
void DispatchAsyncTrustedEvent(const nsString& aEventName);
private:
~TextTrack();