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