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 | * Copyright (C) 2018-2019 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 | #pragma once |
23 | |
24 | #include "SVGElement.h" |
25 | #include "SVGExternalResourcesRequired.h" |
26 | #include "SVGFitToViewBox.h" |
27 | #include "SVGNames.h" |
28 | #include "SVGTests.h" |
29 | #include "SVGURIReference.h" |
30 | #include "SVGUnitTypes.h" |
31 | |
32 | namespace WebCore { |
33 | |
34 | struct PatternAttributes; |
35 | |
36 | class SVGPatternElement final : public SVGElement, public SVGExternalResourcesRequired, public SVGFitToViewBox, public SVGTests, public SVGURIReference { |
37 | WTF_MAKE_ISO_ALLOCATED(SVGPatternElement); |
38 | public: |
39 | static Ref<SVGPatternElement> create(const QualifiedName&, Document&); |
40 | |
41 | void collectPatternAttributes(PatternAttributes&) const; |
42 | |
43 | AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const final; |
44 | |
45 | const SVGLengthValue& x() const { return m_x->currentValue(); } |
46 | const SVGLengthValue& y() const { return m_y->currentValue(); } |
47 | const SVGLengthValue& width() const { return m_width->currentValue(); } |
48 | const SVGLengthValue& height() const { return m_height->currentValue(); } |
49 | SVGUnitTypes::SVGUnitType patternUnits() const { return m_patternUnits->currentValue<SVGUnitTypes::SVGUnitType>(); } |
50 | SVGUnitTypes::SVGUnitType patternContentUnits() const { return m_patternContentUnits->currentValue<SVGUnitTypes::SVGUnitType>(); } |
51 | const SVGTransformList& patternTransform() const { return m_patternTransform->currentValue(); } |
52 | |
53 | SVGAnimatedLength& xAnimated() { return m_x; } |
54 | SVGAnimatedLength& yAnimated() { return m_y; } |
55 | SVGAnimatedLength& widthAnimated() { return m_width; } |
56 | SVGAnimatedLength& heightAnimated() { return m_height; } |
57 | SVGAnimatedEnumeration& patternUnitsAnimated() { return m_patternUnits; } |
58 | SVGAnimatedEnumeration& patternContentUnitsAnimated() { return m_patternContentUnits; } |
59 | SVGAnimatedTransformList& patternTransformAnimated() { return m_patternTransform; } |
60 | |
61 | private: |
62 | SVGPatternElement(const QualifiedName&, Document&); |
63 | |
64 | using PropertyRegistry = SVGPropertyOwnerRegistry<SVGPatternElement, SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGTests, SVGURIReference>; |
65 | const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; } |
66 | |
67 | void parseAttribute(const QualifiedName&, const AtomicString&) final; |
68 | void svgAttributeChanged(const QualifiedName&) final; |
69 | void childrenChanged(const ChildChange&) final; |
70 | |
71 | RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final; |
72 | |
73 | bool isValid() const final { return SVGTests::isValid(); } |
74 | bool needsPendingResourceHandling() const final { return false; } |
75 | bool selfHasRelativeLengths() const final { return true; } |
76 | |
77 | PropertyRegistry m_propertyRegistry { *this }; |
78 | Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth) }; |
79 | Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight) }; |
80 | Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth) }; |
81 | Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight) }; |
82 | Ref<SVGAnimatedEnumeration> m_patternUnits { SVGAnimatedEnumeration::create(this, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) }; |
83 | Ref<SVGAnimatedEnumeration> m_patternContentUnits { SVGAnimatedEnumeration::create(this, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) }; |
84 | Ref<SVGAnimatedTransformList> m_patternTransform { SVGAnimatedTransformList::create(this) }; |
85 | }; |
86 | |
87 | } // namespace WebCore |
88 | |