SVGAnimatedNumberList.cpp [plain text]
#include "config.h"
#include "SVGAnimatedNumberList.h"
#include "SVGAnimateElementBase.h"
#include "SVGAnimatedNumber.h"
namespace WebCore {
SVGAnimatedNumberListAnimator::SVGAnimatedNumberListAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
: SVGAnimatedTypeAnimator(AnimatedNumberList, animationElement, contextElement)
{
}
std::unique_ptr<SVGAnimatedType> SVGAnimatedNumberListAnimator::constructFromString(const String& string)
{
auto animatedType = SVGAnimatedType::createNumberList(std::make_unique<SVGNumberList>());
animatedType->numberList().parse(string);
return animatedType;
}
std::unique_ptr<SVGAnimatedType> SVGAnimatedNumberListAnimator::startAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
{
return SVGAnimatedType::createNumberList(constructFromBaseValue<SVGAnimatedNumberList>(animatedTypes));
}
void SVGAnimatedNumberListAnimator::stopAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
{
stopAnimValAnimationForType<SVGAnimatedNumberList>(animatedTypes);
}
void SVGAnimatedNumberListAnimator::resetAnimValToBaseVal(const SVGElementAnimatedPropertyList& animatedTypes, SVGAnimatedType* type)
{
resetFromBaseValue<SVGAnimatedNumberList>(animatedTypes, type, &SVGAnimatedType::numberList);
}
void SVGAnimatedNumberListAnimator::animValWillChange(const SVGElementAnimatedPropertyList& animatedTypes)
{
animValWillChangeForType<SVGAnimatedNumberList>(animatedTypes);
}
void SVGAnimatedNumberListAnimator::animValDidChange(const SVGElementAnimatedPropertyList& animatedTypes)
{
animValDidChangeForType<SVGAnimatedNumberList>(animatedTypes);
}
void SVGAnimatedNumberListAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnimatedType* to)
{
ASSERT(from->type() == AnimatedNumberList);
ASSERT(from->type() == to->type());
const SVGNumberList& fromNumberList = from->numberList();
SVGNumberList& toNumberList = to->numberList();
unsigned fromNumberListSize = fromNumberList.size();
if (!fromNumberListSize || fromNumberListSize != toNumberList.size())
return;
for (unsigned i = 0; i < fromNumberListSize; ++i)
toNumberList[i] += fromNumberList[i];
}
void SVGAnimatedNumberListAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated)
{
ASSERT(m_animationElement);
const SVGNumberList& fromNumberList = m_animationElement->animationMode() == ToAnimation ? animated->numberList() : from->numberList();
const SVGNumberList& toNumberList = to->numberList();
const SVGNumberList& toAtEndOfDurationNumberList = toAtEndOfDuration->numberList();
SVGNumberList& animatedNumberList = animated->numberList();
if (!m_animationElement->adjustFromToListValues<SVGNumberList>(fromNumberList, toNumberList, animatedNumberList, percentage))
return;
unsigned fromNumberListSize = fromNumberList.size();
unsigned toNumberListSize = toNumberList.size();
unsigned toAtEndOfDurationSize = toAtEndOfDurationNumberList.size();
for (unsigned i = 0; i < toNumberListSize; ++i) {
float effectiveFrom = fromNumberListSize ? fromNumberList[i] : 0;
float effectiveToAtEnd = i < toAtEndOfDurationSize ? toAtEndOfDurationNumberList[i] : 0;
m_animationElement->animateAdditiveNumber(percentage, repeatCount, effectiveFrom, toNumberList[i], effectiveToAtEnd, animatedNumberList[i]);
}
}
float SVGAnimatedNumberListAnimator::calculateDistance(const String&, const String&)
{
return -1;
}
}