Bug 1302648 part 3 - Change order of releasing owning element when cancel animation. r?birtles draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 10 Feb 2017 12:32:44 +0900
changeset 481635 bb2941d84a7c1b5db170030cd9ee4f57160df40c
parent 481634 9160fc8d6f92b41fe63a73fa4ccb31003aeba90c
child 481636 8b7ba1a464a19d9f66b2a253e036647eaa2a534e
push id44889
push usermantaroh@gmail.com
push dateFri, 10 Feb 2017 08:41:14 +0000
reviewersbirtles
bugs1302648
milestone54.0a1
Bug 1302648 part 3 - Change order of releasing owning element when cancel animation. r?birtles The first step of Animation::Cancel(), it will release owning element. However we will use owning element for queueing the CSS-Animations event, So we will need to release owning element after calling Animation::Cancel() in order to fire the animationcancel event. MozReview-Commit-ID: ATqkIGkqREx
layout/style/nsAnimationManager.h
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -105,32 +105,36 @@ public:
 
   virtual AnimationPlayState PlayStateFromJS() const override;
   virtual void PlayFromJS(ErrorResult& aRv) override;
 
   void PlayFromStyle();
   void PauseFromStyle();
   void CancelFromStyle() override
   {
-    mOwningElement = OwningElementRef();
 
     // When an animation is disassociated with style it enters an odd state
     // where its composite order is undefined until it first transitions
     // out of the idle state.
     //
     // Even if the composite order isn't defined we don't want it to be random
     // in case we need to determine the order to dispatch events associated
     // with an animation in this state. To solve this we treat the animation as
     // if it had been added to the end of the global animation list so that
     // its sort order is defined. We'll update this index again once the
     // animation leaves the idle state.
     mAnimationIndex = sNextAnimationIndex++;
     mNeedsNewAnimationIndexWhenRun = true;
 
     Animation::CancelFromStyle();
+
+    // We need to do this *after* calling CancelFromStyle() since
+    // CancelFromStyle might synchronously trigger a cancel event for which
+    // we need an owning element to target the event at.
+    mOwningElement = OwningElementRef();
   }
 
   void Tick() override;
   void QueueEvents();
 
   bool IsStylePaused() const { return mIsStylePaused; }
 
   bool HasLowerCompositeOrderThan(const CSSAnimation& aOther) const;