File indexing completed on 2024-04-28 11:39:21
0001 /* 0002 Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 0003 2004, 2005, 2006, 2007 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 "SVGStopElement.h" 0027 0028 #include "Document.h" 0029 #include "RenderSVGGradientStop.h" 0030 #include "SVGGradientElement.h" 0031 #include "SVGNames.h" 0032 0033 namespace WebCore 0034 { 0035 0036 SVGStopElement::SVGStopElement(const QualifiedName &tagName, Document *doc) 0037 : SVGStyledElement(tagName, doc) 0038 , m_offset(0.0f) 0039 { 0040 } 0041 0042 SVGStopElement::~SVGStopElement() 0043 { 0044 } 0045 0046 ANIMATED_PROPERTY_DEFINITIONS(SVGStopElement, float, Number, number, Offset, offset, SVGNames::offsetAttr, m_offset) 0047 0048 void SVGStopElement::parseMappedAttribute(MappedAttribute *attr) 0049 { 0050 if (attr->name() == SVGNames::offsetAttr) { 0051 const String &value = attr->value(); 0052 // qCDebug(KHTML_LOG) << "parse offset:" << value; 0053 if (value.endsWith("%")) { 0054 setOffsetBaseValue(value.substring(0, value.length() - 1).toFloat() / 100.0f); 0055 } else { 0056 setOffsetBaseValue(value.toFloat()); 0057 } 0058 0059 setChanged(); 0060 } else { 0061 SVGStyledElement::parseMappedAttribute(attr); 0062 } 0063 } 0064 0065 RenderObject *SVGStopElement::createRenderer(RenderArena *arena, RenderStyle *) 0066 { 0067 return new(arena) RenderSVGGradientStop(this); 0068 } 0069 0070 // KHTML ElementImpl pure virtual method 0071 quint32 SVGStopElement::id() const 0072 { 0073 return SVGNames::stopTag.id(); 0074 } 0075 0076 } 0077 0078 #endif // ENABLE(SVG)