blob: 945a9dab795b0c812734832886a20216014c98e0 [file] [log] [blame]
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -08001/*
2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005 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
Feng Qian5f1ab042009-06-17 12:12:20 -070025#if ENABLE(SVG) && ENABLE(FILTERS)
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080026#include "SVGFEOffsetElement.h"
27
28#include "Attr.h"
Feng Qian5f1ab042009-06-17 12:12:20 -070029#include "MappedAttribute.h"
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080030#include "SVGResourceFilter.h"
31
32namespace WebCore {
33
34SVGFEOffsetElement::SVGFEOffsetElement(const QualifiedName& tagName, Document* doc)
35 : SVGFilterPrimitiveStandardAttributes(tagName, doc)
36 , m_in1(this, SVGNames::inAttr)
37 , m_dx(this, SVGNames::dxAttr)
38 , m_dy(this, SVGNames::dyAttr)
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080039{
40}
41
42SVGFEOffsetElement::~SVGFEOffsetElement()
43{
44}
45
46void SVGFEOffsetElement::parseMappedAttribute(MappedAttribute* attr)
47{
48 const String& value = attr->value();
49 if (attr->name() == SVGNames::dxAttr)
50 setDxBaseValue(value.toFloat());
51 else if (attr->name() == SVGNames::dyAttr)
52 setDyBaseValue(value.toFloat());
53 else if (attr->name() == SVGNames::inAttr)
54 setIn1BaseValue(value);
55 else
56 SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
57}
58
Feng Qian5f1ab042009-06-17 12:12:20 -070059bool SVGFEOffsetElement::build(SVGResourceFilter* filterResource)
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080060{
Feng Qian5f1ab042009-06-17 12:12:20 -070061 FilterEffect* input1 = filterResource->builder()->getEffectById(in1());
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080062
Ben Murdoch0bf48ef2009-08-11 17:01:47 +010063 if (!input1)
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080064 return false;
65
Feng Qian5f1ab042009-06-17 12:12:20 -070066 RefPtr<FilterEffect> effect = FEOffset::create(input1, dx(), dy());
67 filterResource->addFilterEffect(this, effect.release());
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080068
69 return true;
70}
71
72}
73
74#endif // ENABLE(SVG)