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