diff --git a/content/smil/nsSMILAnimationFunction.cpp b/content/smil/nsSMILAnimationFunction.cpp index 5611b17a9131..aad2ca3c2822 100644 --- a/content/smil/nsSMILAnimationFunction.cpp +++ b/content/smil/nsSMILAnimationFunction.cpp @@ -248,8 +248,7 @@ nsSMILAnimationFunction::ComposeResult(const nsISMILAttr& aSMILAttr, nsSMILValue result(aResult.mType); if (mSimpleDuration.IsIndefinite() || - (HasAttr(nsGkAtoms::values) && values.Length() == 1)) { - + (values.Length() == 1 && TreatSingleValueAsStatic())) { // Indefinite duration or only one value set: Always set the first value result = values[0]; diff --git a/content/smil/nsSMILAnimationFunction.h b/content/smil/nsSMILAnimationFunction.h index 86ebcb207f9f..7f9db251fe33 100644 --- a/content/smil/nsSMILAnimationFunction.h +++ b/content/smil/nsSMILAnimationFunction.h @@ -327,6 +327,13 @@ protected: void CheckKeyTimes(PRUint32 aNumValues); void CheckKeySplines(PRUint32 aNumValues); + // When GetValues() returns a single-value array, this method indicates + // whether that single value can be understood to be a static value, to be + // set for the full animation duration. + virtual PRBool TreatSingleValueAsStatic() const { + return HasAttr(nsGkAtoms::values); + } + inline PRBool IsToAnimation() const { return !HasAttr(nsGkAtoms::values) && HasAttr(nsGkAtoms::to) && diff --git a/content/smil/nsSMILSetAnimationFunction.cpp b/content/smil/nsSMILSetAnimationFunction.cpp index 71d56c728423..4efe1faa82e8 100644 --- a/content/smil/nsSMILSetAnimationFunction.cpp +++ b/content/smil/nsSMILSetAnimationFunction.cpp @@ -97,32 +97,6 @@ nsSMILSetAnimationFunction::UnsetAttr(nsIAtom* aAttribute) return nsSMILAnimationFunction::UnsetAttr(aAttribute); } -nsresult -nsSMILSetAnimationFunction::InterpolateResult(const nsSMILValueArray& aValues, - nsSMILValue& aResult, - nsSMILValue& aBaseValue) -{ - // Sanity Checks - const nsSMILTime& dur = mSimpleDuration.GetMillis(); - NS_ABORT_IF_FALSE(mSampleTime >= 0.0f, "Sample time should not be negative"); - NS_ABORT_IF_FALSE(dur >= 0.0f, "Simple duration should not be negative"); - NS_ABORT_IF_FALSE(IsToAnimation(), "Set element only supports to-animation"); - - if (mSampleTime >= dur || mSampleTime < 0) { - NS_ERROR("Animation sampled outside interval"); - return NS_ERROR_FAILURE; - } - if (aValues.Length() != 1) { - NS_ERROR("Unexpected number of values"); - return NS_ERROR_FAILURE; - } - // End Sanity Checks - - // Always use the 'to' value (which should be first & only elem in |aValues|) - aResult = aValues[0]; - return NS_OK; -} - PRBool nsSMILSetAnimationFunction::HasAttr(nsIAtom* aAttName) const { diff --git a/content/smil/nsSMILSetAnimationFunction.h b/content/smil/nsSMILSetAnimationFunction.h index 49ad514ad2da..b06c8a7f60f4 100644 --- a/content/smil/nsSMILSetAnimationFunction.h +++ b/content/smil/nsSMILSetAnimationFunction.h @@ -71,17 +71,19 @@ public: * @returns PR_TRUE if aAttribute is a recognized animation-related * attribute; PR_FALSE otherwise. */ - virtual PRBool UnsetAttr(nsIAtom* aAttribute); + NS_OVERRIDE virtual PRBool UnsetAttr(nsIAtom* aAttribute); protected: - NS_OVERRIDE virtual nsresult - InterpolateResult(const nsSMILValueArray& aValues, - nsSMILValue& aResult, nsSMILValue& aBaseValue); - - virtual PRBool HasAttr(nsIAtom* aAttName) const; - virtual const nsAttrValue* GetAttr(nsIAtom* aAttName) const; - virtual PRBool GetAttr(nsIAtom* aAttName, - nsAString& aResult) const; + // uses the "to" attribute as its only source of animation values + // (which gives us a single value in our values array), and we want to use + // that value whenever the animation is active (no interpolation or anything). + NS_OVERRIDE virtual PRBool TreatSingleValueAsStatic() const { + return PR_TRUE; + } + NS_OVERRIDE virtual PRBool HasAttr(nsIAtom* aAttName) const; + NS_OVERRIDE virtual const nsAttrValue* GetAttr(nsIAtom* aAttName) const; + NS_OVERRIDE virtual PRBool GetAttr(nsIAtom* aAttName, + nsAString& aResult) const; PRBool IsDisallowedAttribute(const nsIAtom* aAttribute) const; };