This source file includes following definitions.
- neutralValue
- interpolate
- add
- addWith
- distance
- distanceTo
#include "config.h"
#include "core/animation/AnimatableValue.h"
#include "core/animation/AnimatableNeutral.h"
#include "wtf/StdLibExtras.h"
#include <algorithm>
namespace {
const double defaultDistance = 1;
}
namespace WebCore {
const AnimatableValue* AnimatableValue::neutralValue()
{
#if ENABLE_OILPAN
DEFINE_STATIC_LOCAL(Persistent<AnimatableNeutral>, neutralSentinelValue, (AnimatableNeutral::create()));
return neutralSentinelValue.get();
#else
DEFINE_STATIC_REF(AnimatableNeutral, neutralSentinelValue, (AnimatableNeutral::create()));
return neutralSentinelValue;
#endif
}
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableValue::interpolate(const AnimatableValue* left, const AnimatableValue* right, double fraction)
{
ASSERT(left);
ASSERT(right);
ASSERT(!left->isNeutral());
ASSERT(!right->isNeutral());
if (fraction && fraction != 1 && left->isSameType(right))
return left->interpolateTo(right, fraction);
return defaultInterpolateTo(left, right, fraction);
}
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableValue::add(const AnimatableValue* left, const AnimatableValue* right)
{
ASSERT(left);
ASSERT(right);
if (left->isNeutral())
return takeConstRef(right);
if (right->isNeutral())
return takeConstRef(left);
if (left->isSameType(right))
return left->addWith(right);
return defaultAddWith(left, right);
}
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableValue::addWith(const AnimatableValue* value) const
{
return defaultAddWith(this, value);
}
double AnimatableValue::distance(const AnimatableValue* left, const AnimatableValue* right)
{
ASSERT(left);
ASSERT(right);
if (left->isSameType(right))
return left->distanceTo(right);
return defaultDistance;
}
double AnimatableValue::distanceTo(const AnimatableValue*) const
{
return defaultDistance;
}
}