Bug 1319486 - Remove the old relation when adding cue to a new TextTrack. r=rillian
authorbechen <bechen@mozilla.com>
Thu, 24 Nov 2016 15:30:52 +0800
changeset 324236 508d7a0ac7a005df7a4765ebd449506b2b639b54
parent 324235 dfa353352f30da222393cfd72a420ef26d556ebd
child 324237 fcdea0f0691b930b8d7ef78d6d17a1ee92ae8bce
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +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);
     }
   }