diff --git a/dom/animation/DocumentTimeline.cpp b/dom/animation/DocumentTimeline.cpp index c86df04845b2..ba9485d5368a 100644 --- a/dom/animation/DocumentTimeline.cpp +++ b/dom/animation/DocumentTimeline.cpp @@ -8,10 +8,11 @@ #include "mozilla/dom/DocumentTimelineBinding.h" #include "AnimationUtils.h" #include "nsContentUtils.h" +#include "nsDOMMutationObserver.h" +#include "nsDOMNavigationTiming.h" #include "nsIPresShell.h" #include "nsPresContext.h" #include "nsRefreshDriver.h" -#include "nsDOMNavigationTiming.h" namespace mozilla { namespace dom { @@ -113,15 +114,26 @@ DocumentTimeline::WillRefresh(mozilla::TimeStamp aTime) bool needsTicks = false; AnimationArray animationsToKeep(mAnimationOrder.Length()); + nsAutoAnimationMutationBatch mb(mDocument); + for (Animation* animation : mAnimationOrder) { - if (animation->GetTimeline() != this || - (!animation->IsRelevant() && !animation->NeedsTicks())) { + // Skip any animations that are longer need associated with this timeline. + if (animation->GetTimeline() != this) { mAnimations.RemoveEntry(animation); continue; } needsTicks |= animation->NeedsTicks(); - animationsToKeep.AppendElement(animation); + // Even if |animation| doesn't need future ticks, we should still + // Tick it this time around since it might just need a one-off tick in + // order to dispatch events. + animation->Tick(); + + if (animation->IsRelevant() || animation->NeedsTicks()) { + animationsToKeep.AppendElement(animation); + } else { + mAnimations.RemoveEntry(animation); + } } mAnimationOrder.SwapElements(animationsToKeep); diff --git a/dom/animation/moz.build b/dom/animation/moz.build index 4f4af71b08cf..39af00c28323 100644 --- a/dom/animation/moz.build +++ b/dom/animation/moz.build @@ -31,3 +31,7 @@ UNIFIED_SOURCES += [ ] FINAL_LIBRARY = 'xul' + +LOCAL_INCLUDES += [ + '/dom/base', +] diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 2d9df4ee2baa..17085632b9f4 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -427,13 +427,6 @@ CommonAnimationManager::WillRefresh(TimeStamp aTime) return; } - nsAutoAnimationMutationBatch mb(mPresContext->Document()); - - for (AnimationCollection* collection = mElementCollections.getFirst(); - collection; collection = collection->getNext()) { - collection->Tick(); - } - MaybeStartOrStopObservingRefreshDriver(); }