The Android Open Source Project | 8e35f3c | 2009-03-03 19:30:52 -0800 | [diff] [blame] | 1 | /* |
| 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 Qian | 5f1ab04 | 2009-06-17 12:12:20 -0700 | [diff] [blame] | 25 | #if ENABLE(SVG) && ENABLE(FILTERS) |
The Android Open Source Project | 8e35f3c | 2009-03-03 19:30:52 -0800 | [diff] [blame] | 26 | #include "SVGFEOffsetElement.h" |
| 27 | |
| 28 | #include "Attr.h" |
Feng Qian | 5f1ab04 | 2009-06-17 12:12:20 -0700 | [diff] [blame] | 29 | #include "MappedAttribute.h" |
The Android Open Source Project | 8e35f3c | 2009-03-03 19:30:52 -0800 | [diff] [blame] | 30 | #include "SVGResourceFilter.h" |
| 31 | |
| 32 | namespace WebCore { |
| 33 | |
| 34 | SVGFEOffsetElement::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 Project | 8e35f3c | 2009-03-03 19:30:52 -0800 | [diff] [blame] | 39 | { |
| 40 | } |
| 41 | |
| 42 | SVGFEOffsetElement::~SVGFEOffsetElement() |
| 43 | { |
| 44 | } |
| 45 | |
| 46 | void 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 Qian | 5f1ab04 | 2009-06-17 12:12:20 -0700 | [diff] [blame] | 59 | bool SVGFEOffsetElement::build(SVGResourceFilter* filterResource) |
The Android Open Source Project | 8e35f3c | 2009-03-03 19:30:52 -0800 | [diff] [blame] | 60 | { |
Feng Qian | 5f1ab04 | 2009-06-17 12:12:20 -0700 | [diff] [blame] | 61 | FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); |
The Android Open Source Project | 8e35f3c | 2009-03-03 19:30:52 -0800 | [diff] [blame] | 62 | |
Ben Murdoch | 0bf48ef | 2009-08-11 17:01:47 +0100 | [diff] [blame] | 63 | if (!input1) |
The Android Open Source Project | 8e35f3c | 2009-03-03 19:30:52 -0800 | [diff] [blame] | 64 | return false; |
| 65 | |
Feng Qian | 5f1ab04 | 2009-06-17 12:12:20 -0700 | [diff] [blame] | 66 | RefPtr<FilterEffect> effect = FEOffset::create(input1, dx(), dy()); |
| 67 | filterResource->addFilterEffect(this, effect.release()); |
The Android Open Source Project | 8e35f3c | 2009-03-03 19:30:52 -0800 | [diff] [blame] | 68 | |
| 69 | return true; |
| 70 | } |
| 71 | |
| 72 | } |
| 73 | |
| 74 | #endif // ENABLE(SVG) |