1/* 2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 2004, 2005 Rob Buis <buis@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) && ENABLE(FILTERS) 24#include "SVGFEOffsetElement.h" 25 26#include "Attr.h" 27#include "MappedAttribute.h" 28#include "SVGResourceFilter.h" 29 30namespace WebCore { 31 32SVGFEOffsetElement::SVGFEOffsetElement(const QualifiedName& tagName, Document* doc) 33 : SVGFilterPrimitiveStandardAttributes(tagName, doc) 34{ 35} 36 37SVGFEOffsetElement::~SVGFEOffsetElement() 38{ 39} 40 41void SVGFEOffsetElement::parseMappedAttribute(MappedAttribute* attr) 42{ 43 const String& value = attr->value(); 44 if (attr->name() == SVGNames::dxAttr) 45 setDxBaseValue(value.toFloat()); 46 else if (attr->name() == SVGNames::dyAttr) 47 setDyBaseValue(value.toFloat()); 48 else if (attr->name() == SVGNames::inAttr) 49 setIn1BaseValue(value); 50 else 51 SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); 52} 53 54void SVGFEOffsetElement::synchronizeProperty(const QualifiedName& attrName) 55{ 56 SVGFilterPrimitiveStandardAttributes::synchronizeProperty(attrName); 57 58 if (attrName == anyQName()) { 59 synchronizeDx(); 60 synchronizeDy(); 61 synchronizeIn1(); 62 return; 63 } 64 65 if (attrName == SVGNames::dxAttr) 66 synchronizeDx(); 67 else if (attrName == SVGNames::dyAttr) 68 synchronizeDy(); 69 else if (attrName == SVGNames::inAttr) 70 synchronizeIn1(); 71} 72 73bool SVGFEOffsetElement::build(SVGResourceFilter* filterResource) 74{ 75 FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); 76 77 if (!input1) 78 return false; 79 80 RefPtr<FilterEffect> effect = FEOffset::create(input1, dx(), dy()); 81 filterResource->addFilterEffect(this, effect.release()); 82 83 return true; 84} 85 86} 87 88#endif // ENABLE(SVG) 89