From 47597aeb6bd822a19f8e8c64d2b8d768da28d67f Mon Sep 17 00:00:00 2001 From: alwu Date: Thu, 23 May 2019 09:05:02 +0000 Subject: [PATCH] Bug 1550633 - part2 : maybe start loading resource when the track's mode changes. r=jya According to the spec [1], the user agent must start the track processing model when text track has its text track mode changed. [1] https://html.spec.whatwg.org/multipage/media.html#sourcing-out-of-band-text-tracks:start-the-track-processing-model Differential Revision: https://phabricator.services.mozilla.com/D31372 --HG-- extra : moz-landing-system : lando --- dom/html/HTMLTrackElement.cpp | 5 +++++ dom/media/TextTrack.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/dom/html/HTMLTrackElement.cpp b/dom/html/HTMLTrackElement.cpp index a783e903c524..0abe44642585 100644 --- a/dom/html/HTMLTrackElement.cpp +++ b/dom/html/HTMLTrackElement.cpp @@ -256,6 +256,11 @@ void HTMLTrackElement::MaybeDispatchLoadResource() { return; } + if (ReadyState() == TextTrackReadyState::Loaded) { + LOG(LogLevel::Info, ("%p Has already loaded resource", this)); + return; + } + // step5, await a stable state and run the rest of steps. if (!mLoadResourceDispatched) { RefPtr listener = new WebVTTListener(this); diff --git a/dom/media/TextTrack.cpp b/dom/media/TextTrack.cpp index a5aeb99653df..131989a7bb98 100644 --- a/dom/media/TextTrack.cpp +++ b/dom/media/TextTrack.cpp @@ -129,6 +129,12 @@ void TextTrack::SetMode(TextTrackMode aValue) { if (mediaElement) { mediaElement->NotifyTextTrackModeChanged(); } + // https://html.spec.whatwg.org/multipage/media.html#sourcing-out-of-band-text-tracks:start-the-track-processing-model + // Run the `start-the-track-processing-model` to track's corresponding track + // element whenever track's mode changes. + if (mTrackElement) { + mTrackElement->MaybeDispatchLoadResource(); + } // Ensure the TimeMarchesOn is called in case that the mCueList // is empty. NotifyCueUpdated(nullptr);