Bug 882718 - Implement ActiveFlag at TextTrackCue object. r=rillian
☠☠ backed out by 767ae8716c5b ☠ ☠
authorbechen <bechen@mozilla.com>
Tue, 24 May 2016 11:30:22 +0800
changeset 340718 453431d7a2c8842d757e98dd566e81c5a9419dd1
parent 340717 26a475c764e27b36d50199e15389e371e2e30061
child 340719 f2bf27c13c370a06e62934d811cf6a42115c97c8
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs882718
milestone49.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 882718 - Implement ActiveFlag at TextTrackCue object. r=rillian MozReview-Commit-ID: 4FksCKzB0Ep
dom/html/HTMLMediaElement.cpp
dom/media/TextTrack.cpp
dom/media/TextTrack.h
dom/media/TextTrackCue.cpp
dom/media/TextTrackCue.h
dom/media/TextTrackCueList.cpp
dom/media/TextTrackCueList.h
dom/media/TextTrackList.cpp
dom/media/TextTrackList.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -771,16 +771,21 @@ void HTMLMediaElement::AbortExistingLoad
   if (mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
     NS_ASSERTION(!mDecoder && !mSrcStream, "How did someone setup a new stream/decoder already?");
     // ChangeNetworkState() will call UpdateAudioChannelPlayingState()
     // indirectly which depends on mPaused. So we need to update mPaused first.
     mPaused = true;
     ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_EMPTY);
     ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_NOTHING);
 
+    //TODO: Apply the rules for text track cue rendering Bug 865407
+    if (mTextTrackManager) {
+      mTextTrackManager->GetTextTracks()->SetCuesInactive();
+    }
+
     if (fireTimeUpdate) {
       // Since we destroyed the decoder above, the current playback position
       // will now be reported as 0. The playback position was non-zero when
       // we destroyed the decoder, so fire a timeupdate event so that the
       // change will be reflected in the controls.
       FireTimeUpdate(false);
     }
     DispatchAsyncEvent(NS_LITERAL_STRING("emptied"));
--- a/dom/media/TextTrack.cpp
+++ b/dom/media/TextTrack.cpp
@@ -87,16 +87,20 @@ TextTrack::WrapObject(JSContext* aCx, JS
   return TextTrackBinding::Wrap(aCx, this, aGivenProto);
 }
 
 void
 TextTrack::SetMode(TextTrackMode aValue)
 {
   if (mMode != aValue) {
     mMode = aValue;
+    if (aValue == TextTrackMode::Disabled) {
+      SetCuesInactive();
+      //TODO: Apply the rules for text track cue rendering Bug 865407
+    }
     if (mTextTrackList) {
       mTextTrackList->CreateAndDispatchChangeEvent();
     }
   }
 }
 
 void
 TextTrack::GetId(nsAString& aId) const
@@ -120,16 +124,19 @@ TextTrack::AddCue(TextTrackCue& aCue)
     }
   }
   SetDirty();
 }
 
 void
 TextTrack::RemoveCue(TextTrackCue& aCue, ErrorResult& aRv)
 {
+  //TODO: Apply the rules for text track cue rendering Bug 865407
+  aCue.SetActive(false);
+
   mCueList->RemoveCue(aCue, aRv);
   SetDirty();
 }
 
 void
 TextTrack::SetCuesDirty()
 {
   for (uint32_t i = 0; i < mCueList->Length(); i++) {
@@ -258,10 +265,16 @@ TextTrack::GetTrackElement() {
   return mTrackElement;
 }
 
 void
 TextTrack::SetTrackElement(HTMLTrackElement* aTrackElement) {
   mTrackElement = aTrackElement;
 }
 
+void
+TextTrack::SetCuesInactive()
+{
+  mCueList->SetCuesInactive();
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/TextTrack.h
+++ b/dom/media/TextTrack.h
@@ -113,16 +113,18 @@ public:
 
   HTMLTrackElement* GetTrackElement();
   void SetTrackElement(HTMLTrackElement* aTrackElement);
 
   TextTrackSource GetTextTrackSource() {
     return mTextTrackSource;
   }
 
+  void SetCuesInactive();
+
 private:
   ~TextTrack();
 
   RefPtr<TextTrackList> mTextTrackList;
 
   TextTrackKind mKind;
   nsString mLabel;
   nsString mLanguage;
--- a/dom/media/TextTrackCue.cpp
+++ b/dom/media/TextTrackCue.cpp
@@ -36,16 +36,17 @@ TextTrackCue::SetDefaultCueSettings()
   mPositionAlign = AlignSetting::Middle;
   mSize = 100;
   mPauseOnExit = false;
   mSnapToLines = true;
   mLineIsAutoKeyword = true;
   mAlign = AlignSetting::Middle;
   mLineAlign = AlignSetting::Start;
   mVertical = DirectionSetting::_empty;
+  mActive = false;
 }
 
 TextTrackCue::TextTrackCue(nsPIDOMWindowInner* aOwnerWindow,
                            double aStartTime,
                            double aEndTime,
                            const nsAString& aText,
                            ErrorResult& aRv)
   : DOMEventTargetHelper(aOwnerWindow)
--- a/dom/media/TextTrackCue.h
+++ b/dom/media/TextTrackCue.h
@@ -327,16 +327,26 @@ public:
    *
    * Returns a DocumentFragment that is the head of the tree of anonymous
    * content.
    */
   already_AddRefed<DocumentFragment> GetCueAsHTML();
 
   void SetTrackElement(HTMLTrackElement* aTrackElement);
 
+  void SetActive(bool aActive)
+  {
+    mActive = aActive;
+  }
+
+  bool GetActive()
+  {
+    return mActive;
+  }
+
 private:
   ~TextTrackCue();
 
   void SetDefaultCueSettings();
   nsresult StashDocument();
 
   RefPtr<nsIDocument> mDocument;
   nsString mText;
@@ -361,15 +371,17 @@ private:
   // Holds the computed DOM elements that represent the parsed cue text.
   // http://www.whatwg.org/specs/web-apps/current-work/#text-track-cue-display-state
   RefPtr<nsGenericHTMLElement> mDisplayState;
   // Tells whether or not we need to recompute mDisplayState. This is set
   // anytime a property that relates to the display of the TextTrackCue is
   // changed.
   bool mReset;
 
+  bool mActive;
+
   static StaticRefPtr<nsIWebVTTParserWrapper> sParserWrapper;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_TextTrackCue_h
--- a/dom/media/TextTrackCueList.cpp
+++ b/dom/media/TextTrackCueList.cpp
@@ -112,10 +112,18 @@ TextTrackCueList::RemoveAll()
 
 void
 TextTrackCueList::GetArray(nsTArray<RefPtr<TextTrackCue> >& aCues)
 {
   aCues = nsTArray<RefPtr<TextTrackCue> >(mList);
 }
 
 
+void
+TextTrackCueList::SetCuesInactive()
+{
+  for(uint32_t i = 0; i < mList.Length(); ++i) {
+    mList[i]->SetActive(false);
+  }
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/TextTrackCueList.h
+++ b/dom/media/TextTrackCueList.h
@@ -49,16 +49,18 @@ public:
   // from the end of the current array should be more efficient than a general
   // sort step after all cues are loaded.
   void AddCue(TextTrackCue& aCue);
   void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
   void RemoveCueAt(uint32_t aIndex);
   void RemoveAll();
   void GetArray(nsTArray<RefPtr<TextTrackCue> >& aCues);
 
+  void SetCuesInactive();
+
 private:
   ~TextTrackCueList();
 
   nsCOMPtr<nsISupports> mParent;
 
   // A sorted list of TextTrackCues sorted by earliest start time. If the start
   // times are equal then it will be sorted by end time, earliest first.
   nsTArray< RefPtr<TextTrackCue> > mList;
--- a/dom/media/TextTrackList.cpp
+++ b/dom/media/TextTrackList.cpp
@@ -206,10 +206,18 @@ TextTrackList::GetMediaElement()
 }
 
 void
 TextTrackList::SetTextTrackManager(TextTrackManager* aTextTrackManager)
 {
   mTextTrackManager = aTextTrackManager;
 }
 
+void
+TextTrackList::SetCuesInactive()
+{
+  for (uint32_t i = 0; i < Length(); i++) {
+    mTextTracks[i]->SetCuesInactive();
+  }
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/TextTrackList.h
+++ b/dom/media/TextTrackList.h
@@ -56,16 +56,17 @@ public:
   void RemoveTextTrack(TextTrack* aTrack);
   void DidSeek();
 
   HTMLMediaElement* GetMediaElement();
   void SetTextTrackManager(TextTrackManager* aTextTrackManager);
 
   nsresult DispatchTrackEvent(nsIDOMEvent* aEvent);
   void CreateAndDispatchChangeEvent();
+  void SetCuesInactive();
 
   IMPL_EVENT_HANDLER(change)
   IMPL_EVENT_HANDLER(addtrack)
   IMPL_EVENT_HANDLER(removetrack)
 
 private:
   ~TextTrackList();