1/*
2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 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 "SVGFEMergeNodeElement.h"
25
26#include "Attribute.h"
27#include "RenderObject.h"
28#include "RenderSVGResource.h"
29#include "SVGElementInstance.h"
30#include "SVGFilterElement.h"
31#include "SVGFilterPrimitiveStandardAttributes.h"
32#include "SVGNames.h"
33#include <wtf/NeverDestroyed.h>
34
35namespace WebCore {
36
37// Animated property definitions
38DEFINE_ANIMATED_STRING(SVGFEMergeNodeElement, SVGNames::inAttr, In1, in1)
39
40BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEMergeNodeElement)
41    REGISTER_LOCAL_ANIMATED_PROPERTY(in1)
42END_REGISTER_ANIMATED_PROPERTIES
43
44inline SVGFEMergeNodeElement::SVGFEMergeNodeElement(const QualifiedName& tagName, Document& document)
45    : SVGElement(tagName, document)
46{
47    ASSERT(hasTagName(SVGNames::feMergeNodeTag));
48    registerAnimatedPropertiesForSVGFEMergeNodeElement();
49}
50
51PassRefPtr<SVGFEMergeNodeElement> SVGFEMergeNodeElement::create(const QualifiedName& tagName, Document& document)
52{
53    return adoptRef(new SVGFEMergeNodeElement(tagName, document));
54}
55
56bool SVGFEMergeNodeElement::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 SVGFEMergeNodeElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
65{
66    if (!isSupportedAttribute(name)) {
67        SVGElement::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 SVGFEMergeNodeElement::svgAttributeChanged(const QualifiedName& attrName)
80{
81    if (!isSupportedAttribute(attrName)) {
82        SVGElement::svgAttributeChanged(attrName);
83        return;
84    }
85
86    SVGElementInstance::InvalidationGuard invalidationGuard(this);
87
88    if (attrName == SVGNames::inAttr) {
89        invalidateFilterPrimitiveParent(this);
90        return;
91    }
92
93    ASSERT_NOT_REACHED();
94}
95
96}
97
98#endif // ENABLE(FILTERS)
99