• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 
5     This file is part of the KDE project
6 
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.
11 
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.
16 
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.
21 */
22 
23 #include "config.h"
24 
25 #if ENABLE(SVG)
26 #include "SVGStopElement.h"
27 
28 #include "Document.h"
29 #include "MappedAttribute.h"
30 #include "RenderSVGGradientStop.h"
31 #include "SVGGradientElement.h"
32 #include "SVGNames.h"
33 
34 namespace WebCore {
35 
SVGStopElement(const QualifiedName & tagName,Document * doc)36 SVGStopElement::SVGStopElement(const QualifiedName& tagName, Document* doc)
37     : SVGStyledElement(tagName, doc)
38     , m_offset(this, SVGNames::offsetAttr, 0.0f)
39 {
40 }
41 
~SVGStopElement()42 SVGStopElement::~SVGStopElement()
43 {
44 }
45 
parseMappedAttribute(MappedAttribute * attr)46 void SVGStopElement::parseMappedAttribute(MappedAttribute* attr)
47 {
48     if (attr->name() == SVGNames::offsetAttr) {
49         const String& value = attr->value();
50         if (value.endsWith("%"))
51             setOffsetBaseValue(value.left(value.length() - 1).toFloat() / 100.0f);
52         else
53             setOffsetBaseValue(value.toFloat());
54 
55         setNeedsStyleRecalc();
56     } else
57         SVGStyledElement::parseMappedAttribute(attr);
58 }
59 
createRenderer(RenderArena * arena,RenderStyle *)60 RenderObject* SVGStopElement::createRenderer(RenderArena* arena, RenderStyle*)
61 {
62     return new (arena) RenderSVGGradientStop(this);
63 }
64 
65 }
66 
67 #endif // ENABLE(SVG)
68