SVGAttributeAnimator.cpp [plain text]
#include "config.h"
#include "SVGAttributeAnimator.h"
#include "CSSComputedStyleDeclaration.h"
#include "CSSPropertyParser.h"
#include "SVGElement.h"
namespace WebCore {
bool SVGAttributeAnimator::isAnimatedStylePropertyAniamtor(const SVGElement* targetElement) const
{
return targetElement->isAnimatedStyleAttribute(m_attributeName);
}
void SVGAttributeAnimator::invalidateStyle(SVGElement* targetElement)
{
SVGElement::InstanceInvalidationGuard guard(*targetElement);
targetElement->invalidateSVGPresentationAttributeStyle();
}
void SVGAttributeAnimator::applyAnimatedStylePropertyChange(SVGElement* element, CSSPropertyID id, const String& value)
{
ASSERT(element);
ASSERT(!element->m_deletionHasBegun);
ASSERT(id != CSSPropertyInvalid);
if (!element->ensureAnimatedSMILStyleProperties().setProperty(id, value, false))
return;
element->invalidateStyle();
}
void SVGAttributeAnimator::applyAnimatedStylePropertyChange(SVGElement* targetElement, const String& value)
{
ASSERT(targetElement);
ASSERT(m_attributeName != anyQName());
if (!targetElement->isConnected() || !targetElement->parentNode())
return;
CSSPropertyID id = cssPropertyID(m_attributeName.localName());
SVGElement::InstanceUpdateBlocker blocker(*targetElement);
applyAnimatedStylePropertyChange(targetElement, id, value);
for (auto* instance : targetElement->instances())
applyAnimatedStylePropertyChange(instance, id, value);
}
void SVGAttributeAnimator::removeAnimatedStyleProperty(SVGElement* element, CSSPropertyID id)
{
ASSERT(element);
ASSERT(!element->m_deletionHasBegun);
ASSERT(id != CSSPropertyInvalid);
element->ensureAnimatedSMILStyleProperties().removeProperty(id);
element->invalidateStyle();
}
void SVGAttributeAnimator::removeAnimatedStyleProperty(SVGElement* targetElement)
{
ASSERT(targetElement);
ASSERT(m_attributeName != anyQName());
if (!targetElement->isConnected() || !targetElement->parentNode())
return;
CSSPropertyID id = cssPropertyID(m_attributeName.localName());
SVGElement::InstanceUpdateBlocker blocker(*targetElement);
removeAnimatedStyleProperty(targetElement, id);
for (auto* instance : targetElement->instances())
removeAnimatedStyleProperty(instance, id);
}
void SVGAttributeAnimator::applyAnimatedPropertyChange(SVGElement* element, const QualifiedName& attributeName)
{
ASSERT(!element->m_deletionHasBegun);
element->svgAttributeChanged(attributeName);
}
void SVGAttributeAnimator::applyAnimatedPropertyChange(SVGElement* targetElement)
{
ASSERT(targetElement);
ASSERT(m_attributeName != anyQName());
if (!targetElement->isConnected() || !targetElement->parentNode())
return;
SVGElement::InstanceUpdateBlocker blocker(*targetElement);
applyAnimatedPropertyChange(targetElement, m_attributeName);
for (auto* instance : targetElement->instances())
applyAnimatedPropertyChange(instance, m_attributeName);
}
}