Bug 1319486 - Remove the old relation when adding cue to a new TextTrack. r=rillian draft
authorbechen <bechen@mozilla.com>
Thu, 24 Nov 2016 15:30:52 +0800
changeset 443315 2aeb67215202860b7a62a6669d79aaaf99e6d53a
parent 442775 0ddfec7126ec503b54df9c4b7c3b988906f6c882
child 538024 e9fc8ed539015ddd79ae13f0abc2d72f686c1b72
push id36960
push userbechen@mozilla.com
push dateThu, 24 Nov 2016 08:11:45 +0000
reviewersrillian
bugs1319486
milestone53.0a1
Bug 1319486 - Remove the old relation when adding cue to a new TextTrack. r=rillian MozReview-Commit-ID: GScxPQWMUTR
dom/media/TextTrack.cpp
--- a/dom/media/TextTrack.cpp
+++ b/dom/media/TextTrack.cpp
@@ -131,16 +131,21 @@ TextTrack::GetId(nsAString& aId) const
   if (mTrackElement) {
     mTrackElement->GetAttribute(NS_LITERAL_STRING("id"), aId);
   }
 }
 
 void
 TextTrack::AddCue(TextTrackCue& aCue)
 {
+  TextTrack* oldTextTrack = aCue.GetTrack();
+  if (oldTextTrack) {
+    ErrorResult dummy;
+    oldTextTrack->RemoveCue(aCue, dummy);
+  }
   mCueList->AddCue(aCue);
   aCue.SetTrack(this);
   if (mTextTrackList) {
     HTMLMediaElement* mediaElement = mTextTrackList->GetMediaElement();
     if (mediaElement && (mMode != TextTrackMode::Disabled)) {
       mediaElement->NotifyCueAdded(aCue);
     }
   }