SVGAnimateTransformElement.cpp [plain text]
#include "config.h"
#include "SVGAnimateTransformElement.h"
#include "Attribute.h"
#include "SVGNames.h"
#include "SVGTransformable.h"
#include <wtf/NeverDestroyed.h>
namespace WebCore {
inline SVGAnimateTransformElement::SVGAnimateTransformElement(const QualifiedName& tagName, Document& document)
: SVGAnimateElement(tagName, document)
, m_type(SVGTransform::SVG_TRANSFORM_UNKNOWN)
{
ASSERT(hasTagName(SVGNames::animateTransformTag));
}
PassRefPtr<SVGAnimateTransformElement> SVGAnimateTransformElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(new SVGAnimateTransformElement(tagName, document));
}
bool SVGAnimateTransformElement::hasValidAttributeType()
{
SVGElement* targetElement = this->targetElement();
if (!targetElement)
return false;
if (attributeType() == AttributeTypeCSS)
return false;
return m_animatedPropertyType == AnimatedTransformList;
}
bool SVGAnimateTransformElement::isSupportedAttribute(const QualifiedName& attrName)
{
static NeverDestroyed<HashSet<QualifiedName>> supportedAttributes;
if (supportedAttributes.get().isEmpty())
supportedAttributes.get().add(SVGNames::typeAttr);
return supportedAttributes.get().contains<SVGAttributeHashTranslator>(attrName);
}
void SVGAnimateTransformElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (!isSupportedAttribute(name)) {
SVGAnimateElement::parseAttribute(name, value);
return;
}
if (name == SVGNames::typeAttr) {
m_type = SVGTransformable::parseTransformType(value);
if (m_type == SVGTransform::SVG_TRANSFORM_MATRIX)
m_type = SVGTransform::SVG_TRANSFORM_UNKNOWN;
return;
}
ASSERT_NOT_REACHED();
}
}