Bug 1123523 - Part 8: Dispatch nsIAnimationObserver notifications when an animation is added or removed. r=birtles

This commit is contained in:
Cameron McCormack 2015-03-14 16:34:40 +11:00
parent 89fb2d451f
commit d648fe467f
3 changed files with 19 additions and 0 deletions

View File

@ -335,7 +335,15 @@ AnimationPlayer::IsRunning() const
void
AnimationPlayer::UpdateRelevance()
{
bool wasRelevant = mIsRelevant;
mIsRelevant = HasCurrentSource() || HasInEffectSource();
// Notify animation observers.
if (wasRelevant && !mIsRelevant) {
nsNodeUtils::AnimationRemoved(this);
} else if (!wasRelevant && mIsRelevant) {
nsNodeUtils::AnimationAdded(this);
}
}
bool

View File

@ -18,6 +18,7 @@
#include "nsLayoutUtils.h"
#include "nsIFrame.h"
#include "nsIDocument.h"
#include "nsDOMMutationObserver.h"
#include <math.h>
using namespace mozilla;
@ -260,6 +261,8 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
return nullptr;
}
nsAutoAnimationMutationBatch mb(aElement);
// build the animations list
dom::AnimationTimeline* timeline = aElement->OwnerDoc()->Timeline();
AnimationPlayerPtrArray newPlayers;
@ -714,6 +717,9 @@ nsAnimationManager::FlushAnimations(FlushFlags aFlags)
l = PR_NEXT_LINK(l)) {
AnimationPlayerCollection* collection =
static_cast<AnimationPlayerCollection*>(l);
nsAutoAnimationMutationBatch mb(collection->mElement);
collection->Tick();
bool canThrottleTick = aFlags == Can_Throttle &&
collection->CanPerformOnCompositorThread(

View File

@ -28,6 +28,7 @@
#include "nsStyleChangeList.h"
#include "nsStyleSet.h"
#include "RestyleManager.h"
#include "nsDOMMutationObserver.h"
using mozilla::TimeStamp;
using mozilla::TimeDuration;
@ -218,6 +219,8 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
afterChangeStyle = newStyleContext;
}
nsAutoAnimationMutationBatch mb(aElement);
// Per http://lists.w3.org/Archives/Public/www-style/2009Aug/0109.html
// I'll consider only the transitions from the number of items in
// 'transition-property' on down, and later ones will override earlier
@ -676,6 +679,8 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
static_cast<AnimationPlayerCollection*>(next);
next = PR_NEXT_LINK(next);
nsAutoAnimationMutationBatch mb(collection->mElement);
collection->Tick();
bool canThrottleTick = aFlags == Can_Throttle &&
collection->CanPerformOnCompositorThread(