Bug 1195180 part 8 - Tick animations from their timeline; r=heycam

This commit is contained in:
Brian Birtles 2015-09-28 12:38:41 +09:00
parent 62b28f9716
commit bbba42f6eb
3 changed files with 20 additions and 11 deletions

View File

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

View File

@ -31,3 +31,7 @@ UNIFIED_SOURCES += [
]
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/dom/base',
]

View File

@ -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();
}