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 | #include "config.h" |
23 | #include "SVGEllipseElement.h" |
24 | |
25 | #include "RenderSVGEllipse.h" |
26 | #include "RenderSVGResource.h" |
27 | #include <wtf/IsoMallocInlines.h> |
28 | |
29 | namespace WebCore { |
30 | |
31 | WTF_MAKE_ISO_ALLOCATED_IMPL(SVGEllipseElement); |
32 | |
33 | inline SVGEllipseElement::SVGEllipseElement(const QualifiedName& tagName, Document& document) |
34 | : SVGGeometryElement(tagName, document) |
35 | , SVGExternalResourcesRequired(this) |
36 | { |
37 | ASSERT(hasTagName(SVGNames::ellipseTag)); |
38 | |
39 | static std::once_flag onceFlag; |
40 | std::call_once(onceFlag, [] { |
41 | PropertyRegistry::registerProperty<SVGNames::cxAttr, &SVGEllipseElement::m_cx>(); |
42 | PropertyRegistry::registerProperty<SVGNames::cyAttr, &SVGEllipseElement::m_cy>(); |
43 | PropertyRegistry::registerProperty<SVGNames::rxAttr, &SVGEllipseElement::m_rx>(); |
44 | PropertyRegistry::registerProperty<SVGNames::ryAttr, &SVGEllipseElement::m_ry>(); |
45 | }); |
46 | } |
47 | |
48 | Ref<SVGEllipseElement> SVGEllipseElement::create(const QualifiedName& tagName, Document& document) |
49 | { |
50 | return adoptRef(*new SVGEllipseElement(tagName, document)); |
51 | } |
52 | |
53 | void SVGEllipseElement::parseAttribute(const QualifiedName& name, const AtomicString& value) |
54 | { |
55 | SVGParsingError parseError = NoError; |
56 | |
57 | if (name == SVGNames::cxAttr) |
58 | m_cx->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError)); |
59 | else if (name == SVGNames::cyAttr) |
60 | m_cy->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError)); |
61 | else if (name == SVGNames::rxAttr) |
62 | m_rx->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths)); |
63 | else if (name == SVGNames::ryAttr) |
64 | m_ry->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths)); |
65 | |
66 | reportAttributeParsingError(parseError, name, value); |
67 | |
68 | SVGGeometryElement::parseAttribute(name, value); |
69 | SVGExternalResourcesRequired::parseAttribute(name, value); |
70 | } |
71 | |
72 | void SVGEllipseElement::svgAttributeChanged(const QualifiedName& attrName) |
73 | { |
74 | if (PropertyRegistry::isKnownAttribute(attrName)) { |
75 | InstanceInvalidationGuard guard(*this); |
76 | invalidateSVGPresentationAttributeStyle(); |
77 | return; |
78 | } |
79 | |
80 | SVGGeometryElement::svgAttributeChanged(attrName); |
81 | SVGExternalResourcesRequired::svgAttributeChanged(attrName); |
82 | } |
83 | |
84 | RenderPtr<RenderElement> SVGEllipseElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&) |
85 | { |
86 | return createRenderer<RenderSVGEllipse>(*this, WTFMove(style)); |
87 | } |
88 | |
89 | } |
90 | |