SVGAnimatedRect.cpp [plain text]
#include "config.h"
#include "SVGAnimatedRect.h"
#include "SVGAnimateElement.h"
#include "SVGParserUtilities.h"
namespace WebCore {
SVGAnimatedRectAnimator::SVGAnimatedRectAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
: SVGAnimatedTypeAnimator(AnimatedRect, animationElement, contextElement)
{
}
std::unique_ptr<SVGAnimatedType> SVGAnimatedRectAnimator::constructFromString(const String& string)
{
auto animatedType = SVGAnimatedType::createRect(std::make_unique<FloatRect>());
parseRect(string, animatedType->rect());
return animatedType;
}
std::unique_ptr<SVGAnimatedType> SVGAnimatedRectAnimator::startAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
{
return SVGAnimatedType::createRect(constructFromBaseValue<SVGAnimatedRect>(animatedTypes));
}
void SVGAnimatedRectAnimator::stopAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
{
stopAnimValAnimationForType<SVGAnimatedRect>(animatedTypes);
}
void SVGAnimatedRectAnimator::resetAnimValToBaseVal(const SVGElementAnimatedPropertyList& animatedTypes, SVGAnimatedType* type)
{
resetFromBaseValue<SVGAnimatedRect>(animatedTypes, type, &SVGAnimatedType::rect);
}
void SVGAnimatedRectAnimator::animValWillChange(const SVGElementAnimatedPropertyList& animatedTypes)
{
animValWillChangeForType<SVGAnimatedRect>(animatedTypes);
}
void SVGAnimatedRectAnimator::animValDidChange(const SVGElementAnimatedPropertyList& animatedTypes)
{
animValDidChangeForType<SVGAnimatedRect>(animatedTypes);
}
void SVGAnimatedRectAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnimatedType* to)
{
ASSERT(from->type() == AnimatedRect);
ASSERT(from->type() == to->type());
to->rect() += from->rect();
}
void SVGAnimatedRectAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated)
{
ASSERT(m_animationElement);
ASSERT(m_contextElement);
const FloatRect& fromRect = m_animationElement->animationMode() == ToAnimation ? animated->rect() : from->rect();
const FloatRect& toRect = to->rect();
const FloatRect& toAtEndOfDurationRect = toAtEndOfDuration->rect();
FloatRect& animatedRect = animated->rect();
float animatedX = animatedRect.x();
float animatedY = animatedRect.y();
float animatedWidth = animatedRect.width();
float animatedHeight = animatedRect.height();
m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromRect.x(), toRect.x(), toAtEndOfDurationRect.x(), animatedX);
m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromRect.y(), toRect.y(), toAtEndOfDurationRect.y(), animatedY);
m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromRect.width(), toRect.width(), toAtEndOfDurationRect.width(), animatedWidth);
m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromRect.height(), toRect.height(), toAtEndOfDurationRect.height(), animatedHeight);
animatedRect = FloatRect(animatedX, animatedY, animatedWidth, animatedHeight);
}
float SVGAnimatedRectAnimator::calculateDistance(const String&, const String&)
{
return -1;
}
}