1/* 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 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 "SVGFETileElement.h" 25 26#include "Attribute.h" 27#include "FilterEffect.h" 28#include "SVGElementInstance.h" 29#include "SVGFilterBuilder.h" 30#include "SVGNames.h" 31#include "SVGRenderStyle.h" 32 33namespace WebCore { 34 35// Animated property definitions 36DEFINE_ANIMATED_STRING(SVGFETileElement, SVGNames::inAttr, In1, in1) 37 38BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFETileElement) 39 REGISTER_LOCAL_ANIMATED_PROPERTY(in1) 40 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) 41END_REGISTER_ANIMATED_PROPERTIES 42 43inline SVGFETileElement::SVGFETileElement(const QualifiedName& tagName, Document* document) 44 : SVGFilterPrimitiveStandardAttributes(tagName, document) 45{ 46 ASSERT(hasTagName(SVGNames::feTileTag)); 47 registerAnimatedPropertiesForSVGFETileElement(); 48} 49 50PassRefPtr<SVGFETileElement> SVGFETileElement::create(const QualifiedName& tagName, Document* document) 51{ 52 return adoptRef(new SVGFETileElement(tagName, document)); 53} 54 55bool SVGFETileElement::isSupportedAttribute(const QualifiedName& attrName) 56{ 57 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 58 if (supportedAttributes.isEmpty()) 59 supportedAttributes.add(SVGNames::inAttr); 60 return supportedAttributes.contains<QualifiedName, SVGAttributeHashTranslator>(attrName); 61} 62 63void SVGFETileElement::parseAttribute(const QualifiedName& name, const AtomicString& value) 64{ 65 if (!isSupportedAttribute(name)) { 66 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); 67 return; 68 } 69 70 if (name == SVGNames::inAttr) { 71 setIn1BaseValue(value); 72 return; 73 } 74 75 ASSERT_NOT_REACHED(); 76} 77 78void SVGFETileElement::svgAttributeChanged(const QualifiedName& attrName) 79{ 80 if (!isSupportedAttribute(attrName)) { 81 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); 82 return; 83 } 84 85 SVGElementInstance::InvalidationGuard invalidationGuard(this); 86 87 if (attrName == SVGNames::inAttr) { 88 invalidate(); 89 return; 90 } 91 92 ASSERT_NOT_REACHED(); 93} 94 95PassRefPtr<FilterEffect> SVGFETileElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) 96{ 97 FilterEffect* input1 = filterBuilder->getEffectById(in1()); 98 99 if (!input1) 100 return 0; 101 102 RefPtr<FilterEffect> effect = FETile::create(filter); 103 effect->inputEffects().append(input1); 104 return effect.release(); 105} 106 107} 108 109#endif // ENABLE(SVG) 110