File indexing completed on 2024-04-28 11:39:21
0001 /* 0002 Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 0003 2004, 2005, 2006 Rob Buis <buis@kde.org> 0004 0005 This file is part of the KDE project 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 Boston, MA 02110-1301, USA. 0021 */ 0022 0023 #include "wtf/Platform.h" 0024 0025 #if ENABLE(SVG) 0026 #include "SVGStyledTransformableElement.h" 0027 0028 /*#include "Attr.h" 0029 #include "RegularExpression.h"*/ 0030 #include "RenderPath.h" 0031 #include "SVGDocument.h" 0032 #include "AffineTransform.h" 0033 #include "SVGStyledElement.h" 0034 #include "SVGTransformList.h" 0035 0036 namespace WebCore 0037 { 0038 0039 SVGStyledTransformableElement::SVGStyledTransformableElement(const QualifiedName &tagName, Document *doc) 0040 : SVGStyledLocatableElement(tagName, doc) 0041 , SVGTransformable() 0042 , m_transform(SVGTransformList::create(SVGNames::transformAttr)) 0043 { 0044 } 0045 0046 SVGStyledTransformableElement::~SVGStyledTransformableElement() 0047 { 0048 } 0049 0050 ANIMATED_PROPERTY_DEFINITIONS(SVGStyledTransformableElement, SVGTransformList *, TransformList, transformList, Transform, transform, SVGNames::transformAttr, m_transform.get()) 0051 0052 AffineTransform SVGStyledTransformableElement::getCTM() const 0053 { 0054 return SVGTransformable::getCTM(this); 0055 } 0056 0057 AffineTransform SVGStyledTransformableElement::getScreenCTM() const 0058 { 0059 return SVGTransformable::getScreenCTM(this); 0060 } 0061 0062 AffineTransform SVGStyledTransformableElement::animatedLocalTransform() const 0063 { 0064 return m_supplementalTransform ? transform()->concatenate().matrix() **m_supplementalTransform : transform()->concatenate().matrix(); 0065 } 0066 0067 AffineTransform *SVGStyledTransformableElement::supplementalTransform() 0068 { 0069 if (!m_supplementalTransform) { 0070 m_supplementalTransform.set(new AffineTransform()); 0071 } 0072 return m_supplementalTransform.get(); 0073 } 0074 0075 void SVGStyledTransformableElement::parseMappedAttribute(MappedAttribute *attr) 0076 { 0077 if (attr->name() == SVGNames::transformAttr) { 0078 SVGTransformList *localTransforms = transformBaseValue(); 0079 0080 ExceptionCode ec = 0; 0081 localTransforms->clear(ec); 0082 0083 if (!SVGTransformable::parseTransformAttribute(localTransforms, attr->value())) { 0084 localTransforms->clear(ec); 0085 } else { 0086 setTransformBaseValue(localTransforms); 0087 } 0088 } else { 0089 SVGStyledLocatableElement::parseMappedAttribute(attr); 0090 } 0091 } 0092 0093 bool SVGStyledTransformableElement::isKnownAttribute(const QualifiedName &attrName) 0094 { 0095 return SVGTransformable::isKnownAttribute(attrName) || 0096 SVGStyledLocatableElement::isKnownAttribute(attrName); 0097 } 0098 0099 SVGElement *SVGStyledTransformableElement::nearestViewportElement() const 0100 { 0101 return SVGTransformable::nearestViewportElement(this); 0102 } 0103 0104 SVGElement *SVGStyledTransformableElement::farthestViewportElement() const 0105 { 0106 return SVGTransformable::farthestViewportElement(this); 0107 } 0108 0109 FloatRect SVGStyledTransformableElement::getBBox() const 0110 { 0111 return SVGTransformable::getBBox(this); 0112 } 0113 0114 RenderObject *SVGStyledTransformableElement::createRenderer(RenderArena *arena, RenderStyle *style) 0115 { 0116 // By default, any subclass is expected to do path-based drawing 0117 return new(arena) RenderPath(style, this); 0118 } 0119 0120 } 0121 0122 #endif // ENABLE(SVG)