Bug 510139. Remove no-longer-animated attributes from the set of attributes that are animated. r=roc
--- a/content/smil/nsSMILAnimationController.cpp
+++ b/content/smil/nsSMILAnimationController.cpp
@@ -435,21 +435,28 @@ nsSMILAnimationController::AddAnimationT
nsISMILAnimationElement* aElement, nsSMILCompositorTable* aCompositorTable)
{
// Add a compositor to the hash table if there's not already one there
nsSMILCompositorKey key;
if (!GetCompositorKeyForAnimation(aElement, key))
// Something's wrong/missing about animation's target; skip this animation
return;
- nsSMILCompositor* result = aCompositorTable->PutEntry(key);
+ nsSMILAnimationFunction& func = aElement->AnimationFunction();
- // Add this animationElement's animation function to the compositor's list of
- // animation functions.
- result->AddAnimationFunction(&aElement->AnimationFunction());
+ // Only add active animation functions. If there are no active animations
+ // targetting an attribute, no compositor will be created and any previously
+ // applied animations will be cleared.
+ if (func.IsActiveOrFrozen()) {
+ nsSMILCompositor* result = aCompositorTable->PutEntry(key);
+
+ // Add this animationElement's animation function to the compositor's list
+ // of animation functions.
+ result->AddAnimationFunction(&func);
+ }
}
// Helper function that, given a nsISMILAnimationElement, looks up its target
// element & target attribute and returns a newly-constructed nsSMILCompositor
// for this target.
/*static*/ PRBool
nsSMILAnimationController::GetCompositorKeyForAnimation(
nsISMILAnimationElement* aAnimElem, nsSMILCompositorKey& aResult)
--- a/content/smil/nsSMILAnimationFunction.cpp
+++ b/content/smil/nsSMILAnimationFunction.cpp
@@ -231,17 +231,17 @@ nsSMILAnimationFunction::Inactivate(PRBo
void
nsSMILAnimationFunction::ComposeResult(const nsISMILAttr& aSMILAttr,
nsSMILValue& aResult)
{
mHasChanged = PR_FALSE;
// Skip animations that are inactive or in error
- if (!IsActive() || mErrorFlags != 0)
+ if (!IsActiveOrFrozen() || mErrorFlags != 0)
return;
// Get the animation values
nsSMILValueArray values;
nsresult rv = GetValues(aSMILAttr, values);
if (NS_FAILED(rv))
return;
@@ -304,20 +304,20 @@ nsSMILAnimationFunction::ComposeResult(c
PRInt8
nsSMILAnimationFunction::CompareTo(const nsSMILAnimationFunction* aOther) const
{
NS_ENSURE_TRUE(aOther, 0);
NS_ASSERTION(aOther != this, "Trying to compare to self.");
// Inactive animations sort first
- if (!IsActive() && aOther->IsActive())
+ if (!IsActiveOrFrozen() && aOther->IsActiveOrFrozen())
return -1;
- if (IsActive() && !aOther->IsActive())
+ if (IsActiveOrFrozen() && !aOther->IsActiveOrFrozen())
return 1;
// Sort based on begin time
if (mBeginTime != aOther->GetBeginTime())
return mBeginTime > aOther->GetBeginTime() ? 1 : -1;
// XXX When syncbase timing is implemented, we next need to sort based on
// dependencies
--- a/content/smil/nsSMILAnimationFunction.h
+++ b/content/smil/nsSMILAnimationFunction.h
@@ -171,22 +171,22 @@ public:
/*
* The following methods are provided so that the compositor can optimize its
* operations by only composing those animation that will affect the final
* result.
*/
/**
- * Indicates if the animation is currently active. Inactive animations will
- * not contribute to the composed result.
+ * Indicates if the animation is currently active or frozen. Inactive
+ * animations will not contribute to the composed result.
*
- * @return True if the animation active, false otherwise.
+ * @return True if the animation is active or frozen, false otherwise.
*/
- PRBool IsActive() const
+ PRBool IsActiveOrFrozen() const
{
/*
* - Frozen animations should be considered active for the purposes of
* compositing.
* - This function does not assume that our nsSMILValues (by/from/to/values)
* have already been parsed.
*/
return (mIsActive || mIsFrozen);