This source file includes following definitions.
- toCSSValue
- usesDefaultInterpolationWith
- interpolateTo
- addWith
- equalTo
- distanceTo
#include "config.h"
#include "core/animation/AnimatableDouble.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSValuePool.h"
#include "platform/animation/AnimationUtilities.h"
#include <math.h>
namespace WebCore {
PassRefPtrWillBeRawPtr<CSSValue> AnimatableDouble::toCSSValue() const
{
return cssValuePool().createValue(m_number, CSSPrimitiveValue::CSS_NUMBER);
}
bool AnimatableDouble::usesDefaultInterpolationWith(const AnimatableValue* value) const
{
const AnimatableDouble* other = toAnimatableDouble(value);
return (m_constraint == InterpolationIsNonContinuousWithZero) && (!m_number || !other->m_number);
}
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableDouble::interpolateTo(const AnimatableValue* value, double fraction) const
{
const AnimatableDouble* other = toAnimatableDouble(value);
ASSERT(m_constraint == other->m_constraint);
if ((m_constraint == InterpolationIsNonContinuousWithZero) && (!m_number || !other->m_number))
return defaultInterpolateTo(this, value, fraction);
return AnimatableDouble::create(blend(m_number, other->m_number, fraction));
}
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableDouble::addWith(const AnimatableValue* value) const
{
if (!m_number)
return takeConstRef(value);
const AnimatableDouble* other = toAnimatableDouble(value);
if (!other->m_number)
return takeConstRef(this);
return AnimatableDouble::create(m_number + other->m_number);
}
bool AnimatableDouble::equalTo(const AnimatableValue* value) const
{
return m_number == toAnimatableDouble(value)->m_number;
}
double AnimatableDouble::distanceTo(const AnimatableValue* value) const
{
const AnimatableDouble* other = toAnimatableDouble(value);
return fabs(m_number - other->m_number);
}
}