Rubber-stamped by Brady Eidson.
[webbrowser.git] / WebCore / svg / SVGFEOffsetElement.cpp
blob95cbc8db3b546107b94ac9fdb91ec200c0a70625
1 /*
2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005 Rob Buis <buis@kde.org>
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.
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.
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.
21 #include "config.h"
23 #if ENABLE(SVG) && ENABLE(FILTERS)
24 #include "SVGFEOffsetElement.h"
26 #include "Attr.h"
27 #include "MappedAttribute.h"
28 #include "SVGResourceFilter.h"
30 namespace WebCore {
32 SVGFEOffsetElement::SVGFEOffsetElement(const QualifiedName& tagName, Document* doc)
33 : SVGFilterPrimitiveStandardAttributes(tagName, doc)
34 , m_in1(this, SVGNames::inAttr)
35 , m_dx(this, SVGNames::dxAttr)
36 , m_dy(this, SVGNames::dyAttr)
40 SVGFEOffsetElement::~SVGFEOffsetElement()
44 void SVGFEOffsetElement::parseMappedAttribute(MappedAttribute* attr)
46 const String& value = attr->value();
47 if (attr->name() == SVGNames::dxAttr)
48 setDxBaseValue(value.toFloat());
49 else if (attr->name() == SVGNames::dyAttr)
50 setDyBaseValue(value.toFloat());
51 else if (attr->name() == SVGNames::inAttr)
52 setIn1BaseValue(value);
53 else
54 SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
57 bool SVGFEOffsetElement::build(SVGResourceFilter* filterResource)
59 FilterEffect* input1 = filterResource->builder()->getEffectById(in1());
61 if (!input1)
62 return false;
64 RefPtr<FilterEffect> effect = FEOffset::create(input1, dx(), dy());
65 filterResource->addFilterEffect(this, effect.release());
67 return true;
72 #endif // ENABLE(SVG)