1 | /* |
2 | * Copyright (C) 2006-2018 Apple Inc. All rights reserved. |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public License |
15 | * along with this library; see the file COPYING.LIB. If not, write to |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #pragma once |
21 | |
22 | #include "SVGExternalResourcesRequired.h" |
23 | #include "SVGGraphicsElement.h" |
24 | #include "SVGNames.h" |
25 | #include "SVGURIReference.h" |
26 | |
27 | namespace WebCore { |
28 | |
29 | class SVGForeignObjectElement final : public SVGGraphicsElement, public SVGExternalResourcesRequired { |
30 | WTF_MAKE_ISO_ALLOCATED(SVGForeignObjectElement); |
31 | public: |
32 | static Ref<SVGForeignObjectElement> create(const QualifiedName&, Document&); |
33 | |
34 | const SVGLengthValue& x() const { return m_x->currentValue(); } |
35 | const SVGLengthValue& y() const { return m_y->currentValue(); } |
36 | const SVGLengthValue& width() const { return m_width->currentValue(); } |
37 | const SVGLengthValue& height() const { return m_height->currentValue(); } |
38 | |
39 | SVGAnimatedLength& xAnimated() { return m_x; } |
40 | SVGAnimatedLength& yAnimated() { return m_y; } |
41 | SVGAnimatedLength& widthAnimated() { return m_width; } |
42 | SVGAnimatedLength& heightAnimated() { return m_height; } |
43 | |
44 | private: |
45 | SVGForeignObjectElement(const QualifiedName&, Document&); |
46 | |
47 | using PropertyRegistry = SVGPropertyOwnerRegistry<SVGForeignObjectElement, SVGGraphicsElement, SVGExternalResourcesRequired>; |
48 | const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; } |
49 | |
50 | void parseAttribute(const QualifiedName&, const AtomicString&) final; |
51 | void svgAttributeChanged(const QualifiedName&) final; |
52 | |
53 | bool rendererIsNeeded(const RenderStyle&) final; |
54 | bool childShouldCreateRenderer(const Node&) const final; |
55 | RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final; |
56 | |
57 | bool isValid() const final { return SVGTests::isValid(); } |
58 | bool selfHasRelativeLengths() const final { return true; } |
59 | |
60 | PropertyRegistry m_propertyRegistry { *this }; |
61 | Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth) }; |
62 | Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight) }; |
63 | Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth) }; |
64 | Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight) }; |
65 | }; |
66 | |
67 | } // namespace WebCore |
68 | |