SVGAnimationAdditiveListFunction.h [plain text]
#pragma once
#include "SVGAnimationAdditiveFunction.h"
namespace WebCore {
template<typename ListType>
class SVGAnimationAdditiveListFunction : public SVGAnimationAdditiveFunction {
public:
template<typename... Arguments>
SVGAnimationAdditiveListFunction(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive, Arguments&&... arguments)
: SVGAnimationAdditiveFunction(animationMode, calcMode, isAccumulated, isAdditive)
, m_from(ListType::create(std::forward<Arguments>(arguments)...))
, m_to(ListType::create(std::forward<Arguments>(arguments)...))
, m_toAtEndOfDuration(ListType::create(std::forward<Arguments>(arguments)...))
{
}
protected:
const Ref<ListType>& toAtEndOfDuration() const { return !m_toAtEndOfDuration->isEmpty() ? m_toAtEndOfDuration : m_to; }
bool adjustAnimatedList(AnimationMode animationMode, float percentage, RefPtr<ListType>& animated, bool resizeAnimatedIfNeeded = true)
{
if (!m_to->numberOfItems())
return false;
if (m_from->numberOfItems() && m_from->size() != m_to->size()) {
if (percentage >= 0.5)
*animated = m_to;
else if (animationMode != AnimationMode::To)
*animated = m_from;
return false;
}
if (resizeAnimatedIfNeeded && animated->size() < m_to->size())
animated->resize(m_to->size());
return true;
}
Ref<ListType> m_from;
Ref<ListType> m_to;
Ref<ListType> m_toAtEndOfDuration;
};
}