mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 436418, patch C3: SVG/SMIL animateMotion - add "TreatSingleValueAsStatic" helper method, to assist nsSMILAnimationFunction subclasses in customizing animation behavior. r=roc
This commit is contained in:
parent
960e1b21ac
commit
9907d2d6ff
@ -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];
|
||||
|
||||
|
@ -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) &&
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
// <set> 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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user