Bug 1552081 - part1. Sometimes we should run 'TimeMarchesOn' only when the media element's show poster flag is false. r=jya

In the following situations, we should only run `TimeMarchesOn` when the media element's `show-poster` flag is false.

- add cue : https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource:time-marches-on-2
- remove cue : https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource:time-marches-on-3
- track mode changes : https://html.spec.whatwg.org/multipage/media.html#text-track-model:time-marches-on
- cue's startTime changes : https://html.spec.whatwg.org/multipage/media.html#text-track-api:time-marches-on
- cue's endTime changes : https://html.spec.whatwg.org/multipage/media.html#text-track-api:time-marches-on-2

Differential Revision: https://phabricator.services.mozilla.com/D31376

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alastor Wu 2019-05-17 01:59:34 +00:00
Родитель 73b7b12f0d
Коммит f5fd3008d6
3 изменённых файлов: 24 добавлений и 5 удалений

Просмотреть файл

@ -729,6 +729,8 @@ class HTMLMediaElement : public nsGenericHTMLElement,
// that we can start AudioContext if it was not allowed to start.
RefPtr<GenericNonExclusivePromise> GetAllowedToPlayPromise();
bool GetShowPosterFlag() const { return mShowPoster; }
protected:
virtual ~HTMLMediaElement();

Просмотреть файл

@ -202,7 +202,7 @@ void TextTrackManager::AddCues(TextTrack* aTextTrack) {
for (uint32_t i = 0; i < cueList->Length(); ++i) {
mNewCues->AddCue(*cueList->IndexedGetter(i, dummy));
}
TimeMarchesOn();
MaybeRunTimeMarchesOn();
}
}
@ -226,7 +226,7 @@ void TextTrackManager::RemoveTextTrack(TextTrack* aTextTrack,
for (uint32_t i = 0; i < removeCueList->Length(); ++i) {
mNewCues->RemoveCue(*((*removeCueList)[i]));
}
TimeMarchesOn();
MaybeRunTimeMarchesOn();
}
}
@ -281,7 +281,7 @@ void TextTrackManager::NotifyCueAdded(TextTrackCue& aCue) {
if (mNewCues) {
mNewCues->AddCue(aCue);
}
TimeMarchesOn();
MaybeRunTimeMarchesOn();
ReportTelemetryForCue();
}
@ -290,7 +290,7 @@ void TextTrackManager::NotifyCueRemoved(TextTrackCue& aCue) {
if (mNewCues) {
mNewCues->RemoveCue(aCue);
}
TimeMarchesOn();
MaybeRunTimeMarchesOn();
DispatchUpdateCueDisplay();
}
@ -819,7 +819,7 @@ void TextTrackManager::TimeMarchesOn() {
void TextTrackManager::NotifyCueUpdated(TextTrackCue* aCue) {
// TODO: Add/Reorder the cue to mNewCues if we have some optimization?
WEBVTT_LOG("NotifyCueUpdated, cue=%p", aCue);
TimeMarchesOn();
MaybeRunTimeMarchesOn();
// For the case "Texttrack.mode = hidden/showing", if the mode
// changing between showing and hidden, TimeMarchesOn
// doesn't render the cue. Call DispatchUpdateCueDisplay() explicitly.
@ -864,5 +864,18 @@ bool TextTrackManager::IsShutdown() const {
return (mShutdown || !sParserWrapper);
}
void TextTrackManager::MaybeRunTimeMarchesOn() {
MOZ_ASSERT(mMediaElement);
// According to spec, we should check media element's show poster flag before
// running `TimeMarchesOn` in following situations, (1) add cue (2) remove cue
// (3) cue's start time changes (4) cues's end time changes
// https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource:time-marches-on
// https://html.spec.whatwg.org/multipage/media.html#text-track-api:time-marches-on
if (mMediaElement->GetShowPosterFlag()) {
return;
}
TimeMarchesOn();
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -155,6 +155,10 @@ class TextTrackManager final : public nsIDOMEventListener {
// report the usage of cue to Telemetry.
bool mCueTelemetryReported;
// This function will check media element's show poster flag to decide whether
// we need to run `TimeMarchesOn`.
void MaybeRunTimeMarchesOn();
class ShutdownObserverProxy final : public nsIObserver {
NS_DECL_ISUPPORTS