Bug 1178662 part 7 - Remove relationship of timeline and animation when setting new timeline. r?birtles draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Tue, 31 May 2016 09:42:38 +0900
changeset 373073 571632b078948e23857b949d8e35d2c4b73e7a52
parent 373072 48003f8e0da2b039a6f978584a2b254076f05c90
child 522321 ff769f48b378a7f95d3e7f593513687b23690bfc
push id19674
push usermantaroh@gmail.com
push dateTue, 31 May 2016 00:42:59 +0000
reviewersbirtles
bugs1178662
milestone49.0a1
Bug 1178662 part 7 - Remove relationship of timeline and animation when setting new timeline. r?birtles If we run following code, content process will crash. ------ anim1.timeline = timeline; anim2.timeline = document.timeline; anim2.timeline = timeline; ------ The AnimationTimeline has LinkedList variant. (called mAnimationOrder) And Animation is sub-class of LinkedListElement. We will create the relationship of AnimationTimeline and Animation when calling the AnimationTimeline::NotifyAnimationUpdated. However we didn't remove these relation ship when setting new timeline. So we should remove these relationship when setting new timeline object. MozReview-Commit-ID: RDyranduTA
dom/animation/Animation.cpp
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -159,16 +159,20 @@ Animation::SetTimeline(AnimationTimeline
 void
 Animation::SetTimelineNoUpdate(AnimationTimeline* aTimeline)
 {
   RefPtr<AnimationTimeline> oldTimeline = mTimeline;
   if (mTimeline == aTimeline) {
     return;
   }
 
+  if (mTimeline) {
+    mTimeline->RemoveAnimation(this);
+  }
+
   mTimeline = aTimeline;
   if (!mStartTime.IsNull()) {
     mHoldTime.SetNull();
   }
 
   UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
 }