2 Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2006 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
24 #include "wtf/Platform.h"
27 #include "SVGStyledTransformableElement.h"
30 #include "RegularExpression.h"*/
31 #include "RenderPath.h"
32 #include "SVGDocument.h"
33 #include "AffineTransform.h"
34 #include "SVGStyledElement.h"
35 #include "SVGTransformList.h"
39 SVGStyledTransformableElement::SVGStyledTransformableElement(const QualifiedName
& tagName
, Document
* doc
)
40 : SVGStyledLocatableElement(tagName
, doc
)
42 , m_transform(SVGTransformList::create(SVGNames::transformAttr
))
46 SVGStyledTransformableElement::~SVGStyledTransformableElement()
50 ANIMATED_PROPERTY_DEFINITIONS(SVGStyledTransformableElement
, SVGTransformList
*, TransformList
, transformList
, Transform
, transform
, SVGNames::transformAttr
, m_transform
.get())
52 AffineTransform
SVGStyledTransformableElement::getCTM() const
54 return SVGTransformable::getCTM(this);
57 AffineTransform
SVGStyledTransformableElement::getScreenCTM() const
59 return SVGTransformable::getScreenCTM(this);
62 AffineTransform
SVGStyledTransformableElement::animatedLocalTransform() const
64 return m_supplementalTransform
? transform()->concatenate().matrix() * *m_supplementalTransform
: transform()->concatenate().matrix();
67 AffineTransform
* SVGStyledTransformableElement::supplementalTransform()
69 if (!m_supplementalTransform
)
70 m_supplementalTransform
.set(new AffineTransform());
71 return m_supplementalTransform
.get();
74 void SVGStyledTransformableElement::parseMappedAttribute(MappedAttribute
* attr
)
76 if (attr
->name() == SVGNames::transformAttr
) {
77 SVGTransformList
* localTransforms
= transformBaseValue();
80 localTransforms
->clear(ec
);
82 if (!SVGTransformable::parseTransformAttribute(localTransforms
, attr
->value()))
83 localTransforms
->clear(ec
);
85 setTransformBaseValue(localTransforms
);
87 SVGStyledLocatableElement::parseMappedAttribute(attr
);
90 bool SVGStyledTransformableElement::isKnownAttribute(const QualifiedName
& attrName
)
92 return SVGTransformable::isKnownAttribute(attrName
) ||
93 SVGStyledLocatableElement::isKnownAttribute(attrName
);
96 SVGElement
* SVGStyledTransformableElement::nearestViewportElement() const
98 return SVGTransformable::nearestViewportElement(this);
101 SVGElement
* SVGStyledTransformableElement::farthestViewportElement() const
103 return SVGTransformable::farthestViewportElement(this);
106 FloatRect
SVGStyledTransformableElement::getBBox() const
108 return SVGTransformable::getBBox(this);
111 RenderObject
* SVGStyledTransformableElement::createRenderer(RenderArena
* arena
, RenderStyle
* style
)
113 // By default, any subclass is expected to do path-based drawing
114 return new (arena
) RenderPath(style
, this);
119 #endif // ENABLE(SVG)