File indexing completed on 2024-04-28 15:24:38
0001 /* 0002 Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 0003 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 0004 0005 This file is part of the KDE project 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 Boston, MA 02110-1301, USA. 0021 */ 0022 0023 #ifndef SVGPathElement_h 0024 #define SVGPathElement_h 0025 0026 #if ENABLE(SVG) 0027 #include "SVGAnimatedPathData.h" 0028 #include "SVGExternalResourcesRequired.h" 0029 #include "SVGLangSpace.h" 0030 #include "SVGStyledTransformableElement.h" 0031 #include "SVGTests.h" 0032 0033 namespace WebCore 0034 { 0035 0036 class SVGPathSeg; 0037 class SVGPathSegArcAbs; 0038 class SVGPathSegArcRel; 0039 class SVGPathSegClosePath; 0040 class SVGPathSegLinetoAbs; 0041 class SVGPathSegLinetoRel; 0042 class SVGPathSegMovetoAbs; 0043 class SVGPathSegMovetoRel; 0044 class SVGPathSegCurvetoCubicAbs; 0045 class SVGPathSegCurvetoCubicRel; 0046 class SVGPathSegLinetoVerticalAbs; 0047 class SVGPathSegLinetoVerticalRel; 0048 class SVGPathSegLinetoHorizontalAbs; 0049 class SVGPathSegLinetoHorizontalRel; 0050 class SVGPathSegCurvetoQuadraticAbs; 0051 class SVGPathSegCurvetoQuadraticRel; 0052 class SVGPathSegCurvetoCubicSmoothAbs; 0053 class SVGPathSegCurvetoCubicSmoothRel; 0054 class SVGPathSegCurvetoQuadraticSmoothAbs; 0055 class SVGPathSegCurvetoQuadraticSmoothRel; 0056 class SVGPathElement : public SVGStyledTransformableElement, 0057 public SVGTests, 0058 public SVGLangSpace, 0059 public SVGExternalResourcesRequired, 0060 public SVGAnimatedPathData 0061 { 0062 public: 0063 SVGPathElement(const QualifiedName &, Document *); 0064 virtual ~SVGPathElement(); 0065 0066 bool isValid() const override 0067 { 0068 return SVGTests::isValid(); 0069 } 0070 float getTotalLength(); 0071 FloatPoint getPointAtLength(float distance); 0072 unsigned long getPathSegAtLength(float distance); 0073 0074 static PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath(); 0075 static PassRefPtr<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y); 0076 static PassRefPtr<SVGPathSegMovetoRel> createSVGPathSegMovetoRel(float x, float y); 0077 static PassRefPtr<SVGPathSegLinetoAbs> createSVGPathSegLinetoAbs(float x, float y); 0078 static PassRefPtr<SVGPathSegLinetoRel> createSVGPathSegLinetoRel(float x, float y); 0079 static PassRefPtr<SVGPathSegCurvetoCubicAbs> createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2); 0080 static PassRefPtr<SVGPathSegCurvetoCubicRel> createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2); 0081 static PassRefPtr<SVGPathSegCurvetoQuadraticAbs> createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1); 0082 static PassRefPtr<SVGPathSegCurvetoQuadraticRel> createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1); 0083 static PassRefPtr<SVGPathSegArcAbs> createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag); 0084 static PassRefPtr<SVGPathSegArcRel> createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag); 0085 static PassRefPtr<SVGPathSegLinetoHorizontalAbs> createSVGPathSegLinetoHorizontalAbs(float x); 0086 static PassRefPtr<SVGPathSegLinetoHorizontalRel> createSVGPathSegLinetoHorizontalRel(float x); 0087 static PassRefPtr<SVGPathSegLinetoVerticalAbs> createSVGPathSegLinetoVerticalAbs(float y); 0088 static PassRefPtr<SVGPathSegLinetoVerticalRel> createSVGPathSegLinetoVerticalRel(float y); 0089 static PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2); 0090 static PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2); 0091 static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y); 0092 static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y); 0093 0094 // Derived from: 'SVGAnimatedPathData' 0095 SVGPathSegList *pathSegList() const override; 0096 SVGPathSegList *normalizedPathSegList() const override; 0097 SVGPathSegList *animatedPathSegList() const override; 0098 SVGPathSegList *animatedNormalizedPathSegList() const override; 0099 0100 void parseMappedAttribute(MappedAttribute *) override; 0101 void svgAttributeChanged(const QualifiedName &) override; 0102 0103 Path toPathData() const override; 0104 0105 bool supportsMarkers() const override 0106 { 0107 return true; 0108 } 0109 0110 // KHTML ElementImpl pure virtual method 0111 quint32 id() const override; 0112 protected: 0113 const SVGElement *contextElement() const override 0114 { 0115 return this; 0116 } 0117 0118 private: 0119 mutable RefPtr<SVGPathSegList> m_pathSegList; 0120 0121 ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired) 0122 0123 ANIMATED_PROPERTY_DECLARATIONS(SVGPathElement, float, float, PathLength, pathLength) 0124 }; 0125 0126 } // namespace WebCore 0127 0128 #endif // ENABLE(SVG) 0129 #endif