SVGStyledTransformableElement.cpp [plain text]
#include "config.h"
#if ENABLE(SVG)
#include "SVGStyledTransformableElement.h"
#include "AffineTransform.h"
#include "Attribute.h"
#include "RenderSVGPath.h"
#include "RenderSVGResource.h"
#include "SVGNames.h"
namespace WebCore {
DEFINE_ANIMATED_TRANSFORM_LIST(SVGStyledTransformableElement, SVGNames::transformAttr, Transform, transform)
SVGStyledTransformableElement::SVGStyledTransformableElement(const QualifiedName& tagName, Document* document)
: SVGStyledLocatableElement(tagName, document)
{
}
SVGStyledTransformableElement::~SVGStyledTransformableElement()
{
}
AffineTransform SVGStyledTransformableElement::getCTM(StyleUpdateStrategy styleUpdateStrategy) const
{
return SVGLocatable::computeCTM(this, SVGLocatable::NearestViewportScope, styleUpdateStrategy);
}
AffineTransform SVGStyledTransformableElement::getScreenCTM(StyleUpdateStrategy styleUpdateStrategy) const
{
return SVGLocatable::computeCTM(this, SVGLocatable::ScreenScope, styleUpdateStrategy);
}
AffineTransform SVGStyledTransformableElement::animatedLocalTransform() const
{
AffineTransform matrix;
transform().concatenate(matrix);
if (m_supplementalTransform)
matrix *= *m_supplementalTransform;
return matrix;
}
AffineTransform* SVGStyledTransformableElement::supplementalTransform()
{
if (!m_supplementalTransform)
m_supplementalTransform = adoptPtr(new AffineTransform);
return m_supplementalTransform.get();
}
void SVGStyledTransformableElement::parseMappedAttribute(Attribute* attr)
{
if (SVGTransformable::isKnownAttribute(attr->name())) {
SVGTransformList newList;
if (!SVGTransformable::parseTransformAttribute(newList, attr->value()))
newList.clear();
detachAnimatedTransformListWrappers(newList.size());
setTransformBaseValue(newList);
} else
SVGStyledLocatableElement::parseMappedAttribute(attr);
}
void SVGStyledTransformableElement::svgAttributeChanged(const QualifiedName& attrName)
{
SVGStyledLocatableElement::svgAttributeChanged(attrName);
if (!SVGStyledTransformableElement::isKnownAttribute(attrName))
return;
RenderObject* object = renderer();
if (!object)
return;
object->setNeedsTransformUpdate();
RenderSVGResource::markForLayoutAndParentResourceInvalidation(object);
}
void SVGStyledTransformableElement::synchronizeProperty(const QualifiedName& attrName)
{
SVGStyledLocatableElement::synchronizeProperty(attrName);
if (attrName == anyQName() || SVGTransformable::isKnownAttribute(attrName))
synchronizeTransform();
}
bool SVGStyledTransformableElement::isKnownAttribute(const QualifiedName& attrName)
{
return SVGTransformable::isKnownAttribute(attrName) || SVGStyledLocatableElement::isKnownAttribute(attrName);
}
SVGElement* SVGStyledTransformableElement::nearestViewportElement() const
{
return SVGTransformable::nearestViewportElement(this);
}
SVGElement* SVGStyledTransformableElement::farthestViewportElement() const
{
return SVGTransformable::farthestViewportElement(this);
}
FloatRect SVGStyledTransformableElement::getBBox(StyleUpdateStrategy styleUpdateStrategy) const
{
return SVGTransformable::getBBox(this, styleUpdateStrategy);
}
RenderObject* SVGStyledTransformableElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderSVGPath(this);
}
void SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap& attributeToPropertyTypeMap)
{
SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap);
attributeToPropertyTypeMap.set(SVGNames::transformAttr, AnimatedTransformList);
}
void SVGStyledTransformableElement::toClipPath(Path& path) const
{
toPathData(path);
path.transform(animatedLocalTransform());
}
}
#endif // ENABLE(SVG)