1 | /* |
2 | * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 | * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
4 | * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> |
5 | * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
6 | * Copyright (C) 2018-2019 Apple Inc. All rights reserved. |
7 | * |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; either |
11 | * version 2 of the License, or (at your option) any later version. |
12 | * |
13 | * This library is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Library General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU Library General Public License |
19 | * along with this library; see the file COPYING.LIB. If not, write to |
20 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 | * Boston, MA 02110-1301, USA. |
22 | */ |
23 | |
24 | #pragma once |
25 | |
26 | #include "SVGElement.h" |
27 | #include "SVGExternalResourcesRequired.h" |
28 | #include "SVGURIReference.h" |
29 | #include "SVGUnitTypes.h" |
30 | |
31 | namespace WebCore { |
32 | |
33 | class SVGFilterElement final : public SVGElement, public SVGExternalResourcesRequired, public SVGURIReference { |
34 | WTF_MAKE_ISO_ALLOCATED(SVGFilterElement); |
35 | public: |
36 | static Ref<SVGFilterElement> create(const QualifiedName&, Document&); |
37 | |
38 | SVGUnitTypes::SVGUnitType filterUnits() const { return m_filterUnits->currentValue<SVGUnitTypes::SVGUnitType>(); } |
39 | SVGUnitTypes::SVGUnitType primitiveUnits() const { return m_primitiveUnits->currentValue<SVGUnitTypes::SVGUnitType>(); } |
40 | const SVGLengthValue& x() const { return m_x->currentValue(); } |
41 | const SVGLengthValue& y() const { return m_y->currentValue(); } |
42 | const SVGLengthValue& width() const { return m_width->currentValue(); } |
43 | const SVGLengthValue& height() const { return m_height->currentValue(); } |
44 | |
45 | SVGAnimatedEnumeration& filterUnitsAnimated() { return m_filterUnits; } |
46 | SVGAnimatedEnumeration& primitiveUnitsAnimated() { return m_primitiveUnits; } |
47 | SVGAnimatedLength& xAnimated() { return m_x; } |
48 | SVGAnimatedLength& yAnimated() { return m_y; } |
49 | SVGAnimatedLength& widthAnimated() { return m_width; } |
50 | SVGAnimatedLength& heightAnimated() { return m_height; } |
51 | |
52 | private: |
53 | SVGFilterElement(const QualifiedName&, Document&); |
54 | |
55 | using PropertyRegistry = SVGPropertyOwnerRegistry<SVGFilterElement, SVGElement, SVGExternalResourcesRequired, SVGURIReference>; |
56 | const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; } |
57 | |
58 | void parseAttribute(const QualifiedName&, const AtomicString&) final; |
59 | void svgAttributeChanged(const QualifiedName&) final; |
60 | void childrenChanged(const ChildChange&) final; |
61 | |
62 | bool needsPendingResourceHandling() const final { return false; } |
63 | |
64 | RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final; |
65 | bool childShouldCreateRenderer(const Node&) const final; |
66 | |
67 | bool selfHasRelativeLengths() const final { return true; } |
68 | |
69 | PropertyRegistry m_propertyRegistry { *this }; |
70 | Ref<SVGAnimatedEnumeration> m_filterUnits { SVGAnimatedEnumeration::create(this, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) }; |
71 | Ref<SVGAnimatedEnumeration> m_primitiveUnits { SVGAnimatedEnumeration::create(this, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) }; |
72 | Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth, "-10%" ) }; |
73 | Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight, "-10%" ) }; |
74 | Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth, "120%" ) }; |
75 | Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight, "120%" ) }; |
76 | }; |
77 | |
78 | } // namespace WebCore |
79 | |