Bug 1283417 - part1 : implement function to notify cue's display states changed. r=bechen
authorAlastor Wu <alwu@mozilla.com>
Tue, 09 Aug 2016 16:43:07 +0800
changeset 398788 00dfeaac18145c2f07a8760d20f2de0d16273e9e
parent 398787 f38875b13ca370bf23407270ddc9ad7fe21e16fa
child 398789 b47abe0917b074d95b7e240a8deda72bf4a71b84
push id25628
push userbmo:gps@mozilla.com
push dateTue, 09 Aug 2016 18:38:55 +0000
reviewersbechen
bugs1283417
milestone51.0a1
Bug 1283417 - part1 : implement function to notify cue's display states changed. r=bechen MozReview-Commit-ID: AF2S2UOLCt1
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMediaElement.h
dom/media/TextTrackCue.cpp
dom/media/TextTrackCue.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -6202,10 +6202,21 @@ HTMLMediaElement::OnVisibilityChange(Vis
     }
     case Visibility::IN_DISPLAYPORT: {
       mDecoder->NotifyOwnerActivityChanged(true);
       break;
     }
   }
 
 }
+
+void
+HTMLMediaElement::NotifyCueDisplayStatesChanged()
+{
+  if (!mTextTrackManager) {
+    return;
+  }
+
+  mTextTrackManager->DispatchUpdateCueDisplay();
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -704,16 +704,18 @@ public:
     }
   }
   void NotifyCueUpdated(TextTrackCue *aCue) {
     if (mTextTrackManager) {
       mTextTrackManager->NotifyCueUpdated(aCue);
     }
   }
 
+  void NotifyCueDisplayStatesChanged();
+
   bool GetHasUserInteraction()
   {
     return mHasUserInteraction;
   }
 
   // A method to check whether we are currently playing.
   bool IsCurrentlyPlaying() const;
 
--- a/dom/media/TextTrackCue.cpp
+++ b/dom/media/TextTrackCue.cpp
@@ -227,10 +227,26 @@ TextTrackCue::ComputedPositionAlign()
   } else if (mAlign == AlignSetting::Left) {
     return PositionAlignSetting::Line_left;
   } else if (mAlign == AlignSetting::Right) {
     return PositionAlignSetting::Line_right;
   }
   return PositionAlignSetting::Center;
 }
 
+void
+TextTrackCue::NotifyDisplayStatesChanged()
+{
+  if (!mReset) {
+    return;
+  }
+
+  if (!mTrack ||
+      !mTrack->GetTextTrackList() ||
+      !mTrack->GetTextTrackList()->GetMediaElement()) {
+    return;
+  }
+
+  mTrack->GetTextTrackList()->GetMediaElement()->NotifyCueDisplayStatesChanged();
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/TextTrackCue.h
+++ b/dom/media/TextTrackCue.h
@@ -355,16 +355,19 @@ private:
   ~TextTrackCue();
 
   void NotifyCueUpdated(TextTrackCue* aCue)
   {
     if (mTrack) {
       mTrack->NotifyCueUpdated(aCue);
     }
   }
+
+  void NotifyDisplayStatesChanged();
+
   void SetDefaultCueSettings();
   nsresult StashDocument();
 
   RefPtr<nsIDocument> mDocument;
   nsString mText;
   double mStartTime;
   double mEndTime;