1 /* 2 Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann (at) kde.org> 3 2004, 2005, 2006, 2007 Rob Buis <buis (at) kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public License 16 along with this library; see the file COPYING.LIB. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 21 #include "config.h" 22 23 #if ENABLE(SVG) 24 #include "SVGStopElement.h" 25 26 #include "Document.h" 27 #include "MappedAttribute.h" 28 #include "RenderSVGGradientStop.h" 29 #include "SVGGradientElement.h" 30 #include "SVGNames.h" 31 32 namespace WebCore { 33 34 SVGStopElement::SVGStopElement(const QualifiedName& tagName, Document* doc) 35 : SVGStyledElement(tagName, doc) 36 , m_offset(0.0f) 37 { 38 } 39 40 SVGStopElement::~SVGStopElement() 41 { 42 } 43 44 void SVGStopElement::parseMappedAttribute(MappedAttribute* attr) 45 { 46 if (attr->name() == SVGNames::offsetAttr) { 47 const String& value = attr->value(); 48 if (value.endsWith("%")) 49 setOffsetBaseValue(value.left(value.length() - 1).toFloat() / 100.0f); 50 else 51 setOffsetBaseValue(value.toFloat()); 52 53 setNeedsStyleRecalc(); 54 } else 55 SVGStyledElement::parseMappedAttribute(attr); 56 } 57 58 void SVGStopElement::synchronizeProperty(const QualifiedName& attrName) 59 { 60 SVGStyledElement::synchronizeProperty(attrName); 61 62 if (attrName == anyQName() || attrName == SVGNames::offsetAttr) 63 synchronizeOffset(); 64 } 65 66 RenderObject* SVGStopElement::createRenderer(RenderArena* arena, RenderStyle*) 67 { 68 return new (arena) RenderSVGGradientStop(this); 69 } 70 71 } 72 73 #endif // ENABLE(SVG) 74