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
--- 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;