1/*
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4 * Copyright (C) 2018 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#include "config.h"
23#include "SVGFETileElement.h"
24
25#include "FETile.h"
26#include "FilterEffect.h"
27#include "SVGFilterBuilder.h"
28#include "SVGNames.h"
29#include "SVGRenderStyle.h"
30#include <wtf/IsoMallocInlines.h>
31
32namespace WebCore {
33
34WTF_MAKE_ISO_ALLOCATED_IMPL(SVGFETileElement);
35
36inline SVGFETileElement::SVGFETileElement(const QualifiedName& tagName, Document& document)
37 : SVGFilterPrimitiveStandardAttributes(tagName, document)
38{
39 ASSERT(hasTagName(SVGNames::feTileTag));
40
41 static std::once_flag onceFlag;
42 std::call_once(onceFlag, [] {
43 PropertyRegistry::registerProperty<SVGNames::inAttr, &SVGFETileElement::m_in1>();
44 });
45}
46
47Ref<SVGFETileElement> SVGFETileElement::create(const QualifiedName& tagName, Document& document)
48{
49 return adoptRef(*new SVGFETileElement(tagName, document));
50}
51
52void SVGFETileElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
53{
54 if (name == SVGNames::inAttr) {
55 m_in1->setBaseValInternal(value);
56 return;
57 }
58
59 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value);
60}
61
62void SVGFETileElement::svgAttributeChanged(const QualifiedName& attrName)
63{
64 if (attrName == SVGNames::inAttr) {
65 InstanceInvalidationGuard guard(*this);
66 invalidate();
67 return;
68 }
69
70 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
71}
72
73RefPtr<FilterEffect> SVGFETileElement::build(SVGFilterBuilder* filterBuilder, Filter& filter) const
74{
75 auto input1 = filterBuilder->getEffectById(in1());
76
77 if (!input1)
78 return nullptr;
79
80 auto effect = FETile::create(filter);
81 effect->inputEffects().append(input1);
82 return effect;
83}
84
85}
86