Bug 1548923 - part5 : run `TimeMarchesOn` in correct order r=jya
authoralwu <alwu@mozilla.com>
Thu, 09 May 2019 01:34:57 +0000
changeset 532076 005917cd9f361ea5bebcd9af1000d5799ef724ac
parent 532075 c64974ef15b2e1d1b58c8fa5ed16a641179af213
child 532077 258bcf1c182c88ee2e59f0720b50d729259df1ba
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1548923
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1548923 - part5 : run `TimeMarchesOn` in correct order r=jya To run `TimeMarchesOn` in correct spec's steps order. Differential Revision: https://phabricator.services.mozilla.com/D30391
dom/html/TextTrackManager.cpp
--- a/dom/html/TextTrackManager.cpp
+++ b/dom/html/TextTrackManager.cpp
@@ -620,48 +620,47 @@ void TextTrackManager::TimeMarchesOn() {
   WEBVTT_LOG("TimeMarchesOn");
 
   // Early return if we don't have any TextTracks or shutting down.
   if (!mTextTracks || mTextTracks->Length() == 0 || IsShutdown() ||
       !mMediaElement) {
     return;
   }
 
-  nsISupports* parentObject = mMediaElement->OwnerDoc()->GetParentObject();
-  if (NS_WARN_IF(!parentObject)) {
-    return;
-  }
-  nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(parentObject);
-
   if (mMediaElement->ReadyState() == HTMLMediaElement_Binding::HAVE_NOTHING) {
     WEBVTT_LOG(
         "TimeMarchesOn return because media doesn't contain any data yet");
     return;
   }
 
   if (mMediaElement->Seeking()) {
     WEBVTT_LOG("TimeMarchesOn return during seeking");
     return;
   }
 
+  // Step 1, 2.
+  nsISupports* parentObject = mMediaElement->OwnerDoc()->GetParentObject();
+  if (NS_WARN_IF(!parentObject)) {
+    return;
+  }
+  nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(parentObject);
+  RefPtr<TextTrackCueList> currentCues = new TextTrackCueList(window);
+  RefPtr<TextTrackCueList> otherCues = new TextTrackCueList(window);
+
   // Step 3.
   auto currentPlaybackTime =
       media::TimeUnit::FromSeconds(mMediaElement->CurrentTime());
   bool hasNormalPlayback = !mHasSeeked;
   mHasSeeked = false;
   WEBVTT_LOG(
       "TimeMarchesOn mLastTimeMarchesOnCalled %lf currentPlaybackTime %lf "
       "hasNormalPlayback %d",
       mLastTimeMarchesOnCalled.ToSeconds(), currentPlaybackTime.ToSeconds(),
       hasNormalPlayback);
 
-  // Step 1, 2.
-  RefPtr<TextTrackCueList> currentCues = new TextTrackCueList(window);
-  RefPtr<TextTrackCueList> otherCues = new TextTrackCueList(window);
-
   // The reason we collect other cues is (1) to change active cues to inactive,
   // (2) find missing cues, so we actually no need to process all cues. We just
   // need to handle cues which are in the time interval [lastTime:currentTime]
   // or [currentTime:lastTime] (seeking forward). That can help us to reduce the
   // size of other cues, which can improve execution time.
   auto start = std::min(mLastTimeMarchesOnCalled, currentPlaybackTime);
   auto end = std::max(mLastTimeMarchesOnCalled, currentPlaybackTime);
   media::TimeInterval interval(start, end);