1/*
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 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#ifndef SVGPatternElement_h
22#define SVGPatternElement_h
23
24#include "SVGAnimatedBoolean.h"
25#include "SVGAnimatedEnumeration.h"
26#include "SVGAnimatedLength.h"
27#include "SVGAnimatedPreserveAspectRatio.h"
28#include "SVGAnimatedRect.h"
29#include "SVGAnimatedTransformList.h"
30#include "SVGElement.h"
31#include "SVGExternalResourcesRequired.h"
32#include "SVGFitToViewBox.h"
33#include "SVGNames.h"
34#include "SVGTests.h"
35#include "SVGURIReference.h"
36#include "SVGUnitTypes.h"
37
38namespace WebCore {
39
40struct PatternAttributes;
41
42class SVGPatternElement final : public SVGElement,
43                                public SVGURIReference,
44                                public SVGTests,
45                                public SVGExternalResourcesRequired,
46                                public SVGFitToViewBox {
47public:
48    static PassRefPtr<SVGPatternElement> create(const QualifiedName&, Document&);
49
50    void collectPatternAttributes(PatternAttributes&) const;
51
52    virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const override;
53
54private:
55    SVGPatternElement(const QualifiedName&, Document&);
56
57    virtual bool isValid() const override { return SVGTests::isValid(); }
58    virtual bool needsPendingResourceHandling() const override { return false; }
59
60    bool isSupportedAttribute(const QualifiedName&);
61    virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
62    virtual void svgAttributeChanged(const QualifiedName&) override;
63    virtual void childrenChanged(const ChildChange&) override;
64
65    virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
66
67    virtual bool selfHasRelativeLengths() const override;
68
69    BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGPatternElement)
70        DECLARE_ANIMATED_LENGTH(X, x)
71        DECLARE_ANIMATED_LENGTH(Y, y)
72        DECLARE_ANIMATED_LENGTH(Width, width)
73        DECLARE_ANIMATED_LENGTH(Height, height)
74        DECLARE_ANIMATED_ENUMERATION(PatternUnits, patternUnits, SVGUnitTypes::SVGUnitType)
75        DECLARE_ANIMATED_ENUMERATION(PatternContentUnits, patternContentUnits, SVGUnitTypes::SVGUnitType)
76        DECLARE_ANIMATED_TRANSFORM_LIST(PatternTransform, patternTransform)
77        DECLARE_ANIMATED_STRING(Href, href)
78        DECLARE_ANIMATED_BOOLEAN(ExternalResourcesRequired, externalResourcesRequired)
79        DECLARE_ANIMATED_RECT(ViewBox, viewBox)
80        DECLARE_ANIMATED_PRESERVEASPECTRATIO(PreserveAspectRatio, preserveAspectRatio)
81    END_DECLARE_ANIMATED_PROPERTIES
82
83    // SVGTests
84    virtual void synchronizeRequiredFeatures() override { SVGTests::synchronizeRequiredFeatures(this); }
85    virtual void synchronizeRequiredExtensions() override { SVGTests::synchronizeRequiredExtensions(this); }
86    virtual void synchronizeSystemLanguage() override { SVGTests::synchronizeSystemLanguage(this); }
87};
88
89NODE_TYPE_CASTS(SVGPatternElement)
90
91} // namespace WebCore
92
93#endif
94