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 Adobe Systems Incorporated. All rights reserved. |
5 | * Copyright (C) 2018-2019 Apple Inc. All rights reserved. |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. |
11 | * |
12 | * This library is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Library General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Library General Public License |
18 | * along with this library; see the file COPYING.LIB. If not, write to |
19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | * Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #pragma once |
24 | |
25 | #include "Path.h" |
26 | #include "SVGGraphicsElement.h" |
27 | #include "SVGNames.h" |
28 | |
29 | namespace WebCore { |
30 | |
31 | struct DOMPointInit; |
32 | class SVGPoint; |
33 | |
34 | class SVGGeometryElement : public SVGGraphicsElement { |
35 | WTF_MAKE_ISO_ALLOCATED(SVGGeometryElement); |
36 | public: |
37 | virtual float getTotalLength() const; |
38 | virtual Ref<SVGPoint> getPointAtLength(float distance) const; |
39 | |
40 | bool isPointInFill(DOMPointInit&&); |
41 | bool isPointInStroke(DOMPointInit&&); |
42 | |
43 | using PropertyRegistry = SVGPropertyOwnerRegistry<SVGGeometryElement, SVGGraphicsElement>; |
44 | |
45 | float pathLength() const { return m_pathLength->currentValue(); } |
46 | SVGAnimatedNumber& pathLengthAnimated() { return m_pathLength; } |
47 | |
48 | protected: |
49 | SVGGeometryElement(const QualifiedName&, Document&); |
50 | |
51 | void parseAttribute(const QualifiedName&, const AtomicString&) override; |
52 | void svgAttributeChanged(const QualifiedName&) override; |
53 | |
54 | private: |
55 | bool isSVGGeometryElement() const override { return true; } |
56 | |
57 | Ref<SVGAnimatedNumber> m_pathLength { SVGAnimatedNumber::create(this) }; |
58 | }; |
59 | |
60 | } // namespace WebCore |
61 | |
62 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGGeometryElement) |
63 | static bool isType(const WebCore::SVGElement& element) { return element.isSVGGeometryElement(); } |
64 | static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); } |
65 | SPECIALIZE_TYPE_TRAITS_END() |
66 | |