bug 520710: SVG/SMIL: Make <set> element apply its 'to' value for whole duration. r=birtles sr=roc

This commit is contained in:
Daniel Holbert 2009-10-22 15:15:44 -07:00
parent a0d87ac241
commit cf8e774a99
5 changed files with 35 additions and 11 deletions

View File

@ -365,10 +365,10 @@ nsSMILAnimationFunction::InterpolateResult(const nsSMILValueArray& aValues,
const nsSMILTime& dur = mSimpleDuration.GetMillis();
// Sanity Checks
NS_ASSERTION(mSampleTime >= 0.0f, "Sample time should not be negative...");
NS_ASSERTION(dur >= 0.0f, "Simple duration should not be negative...");
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");
if (mSampleTime >= dur || mSampleTime < 0) {
if (mSampleTime >= dur || mSampleTime < 0.0f) {
NS_ERROR("Animation sampled outside interval.");
return NS_ERROR_FAILURE;
}

View File

@ -263,9 +263,9 @@ protected:
void UnsetKeySplines();
// Helpers
nsresult InterpolateResult(const nsSMILValueArray& aValues,
nsSMILValue& aResult,
nsSMILValue& aBaseValue);
virtual nsresult InterpolateResult(const nsSMILValueArray& aValues,
nsSMILValue& aResult,
nsSMILValue& aBaseValue);
nsresult AccumulateResult(const nsSMILValueArray& aValues,
nsSMILValue& aResult);

View File

@ -97,10 +97,30 @@ nsSMILSetAnimationFunction::UnsetAttr(nsIAtom* aAttribute)
return nsSMILAnimationFunction::UnsetAttr(aAttribute);
}
nsSMILAnimationFunction::nsSMILCalcMode
nsSMILSetAnimationFunction::GetCalcMode() const
nsresult
nsSMILSetAnimationFunction::InterpolateResult(const nsSMILValueArray& aValues,
nsSMILValue& aResult,
nsSMILValue& aBaseValue)
{
return CALC_DISCRETE;
// 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

View File

@ -74,7 +74,9 @@ public:
virtual PRBool UnsetAttr(nsIAtom* aAttribute);
protected:
virtual nsSMILAnimationFunction::nsSMILCalcMode GetCalcMode() const;
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;

View File

@ -4,7 +4,6 @@
# - Stacking of additive=[sum|replace] animations
# - Stacking of additive animations, w/ "hybrid case of to-animation"
# - Repeating animations, w/ & w/out accumulate=sum
# - <set>
# - Interpolation between different units (e.g. font-size attr, 3em to 50px)
# - Correct behavior for em/ex font-size animations, when context changes
# (with change happening 1. when completed/frozen and 2. when animating)
@ -18,6 +17,9 @@
# animation sort-order tests
include sort/reftest.list
# set tests
include set/reftest.list
# style tests
include style/reftest.list