File indexing completed on 2024-04-28 15:24:42
0001 /* 0002 Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 0003 2004, 2005, 2006, 2007, 2008 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 "SVGTextPositioningElement.h" 0027 0028 #include "SVGLengthList.h" 0029 #include "SVGNames.h" 0030 #include "SVGNumberList.h" 0031 0032 namespace WebCore 0033 { 0034 0035 SVGTextPositioningElement::SVGTextPositioningElement(const QualifiedName &tagName, Document *doc) 0036 : SVGTextContentElement(tagName, doc) 0037 , m_x(SVGLengthList::create(SVGNames::xAttr)) 0038 , m_y(SVGLengthList::create(SVGNames::yAttr)) 0039 , m_dx(SVGLengthList::create(SVGNames::dxAttr)) 0040 , m_dy(SVGLengthList::create(SVGNames::dyAttr)) 0041 , m_rotate(SVGNumberList::create(SVGNames::rotateAttr)) 0042 { 0043 } 0044 0045 SVGTextPositioningElement::~SVGTextPositioningElement() 0046 { 0047 } 0048 0049 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPositioningElement, SVGLengthList *, LengthList, lengthList, X, x, SVGNames::xAttr, m_x.get()) 0050 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPositioningElement, SVGLengthList *, LengthList, lengthList, Y, y, SVGNames::yAttr, m_y.get()) 0051 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPositioningElement, SVGLengthList *, LengthList, lengthList, Dx, dx, SVGNames::dxAttr, m_dx.get()) 0052 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPositioningElement, SVGLengthList *, LengthList, lengthList, Dy, dy, SVGNames::dyAttr, m_dy.get()) 0053 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPositioningElement, SVGNumberList *, NumberList, numberList, Rotate, rotate, SVGNames::rotateAttr, m_rotate.get()) 0054 0055 void SVGTextPositioningElement::parseMappedAttribute(MappedAttribute *attr) 0056 { 0057 // qCDebug(KHTML_LOG) << "parse:" << attr->localName() << attr->value(); 0058 if (attr->name() == SVGNames::xAttr) { 0059 xBaseValue()->parse(attr->value(), this, LengthModeWidth); 0060 } else if (attr->name() == SVGNames::yAttr) { 0061 yBaseValue()->parse(attr->value(), this, LengthModeHeight); 0062 } else if (attr->name() == SVGNames::dxAttr) { 0063 dxBaseValue()->parse(attr->value(), this, LengthModeWidth); 0064 } else if (attr->name() == SVGNames::dyAttr) { 0065 dyBaseValue()->parse(attr->value(), this, LengthModeHeight); 0066 } else if (attr->name() == SVGNames::rotateAttr) { 0067 rotateBaseValue()->parse(attr->value()); 0068 } else { 0069 SVGTextContentElement::parseMappedAttribute(attr); 0070 } 0071 } 0072 0073 bool SVGTextPositioningElement::isKnownAttribute(const QualifiedName &attrName) 0074 { 0075 return (attrName.matches(SVGNames::xAttr) || 0076 attrName.matches(SVGNames::yAttr) || 0077 attrName.matches(SVGNames::dxAttr) || 0078 attrName.matches(SVGNames::dyAttr) || 0079 attrName.matches(SVGNames::rotateAttr) || 0080 SVGTextContentElement::isKnownAttribute(attrName)); 0081 } 0082 0083 } 0084 0085 #endif // ENABLE(SVG)