1 /* 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef SVGMarkerElement_h 22 #define SVGMarkerElement_h 23 24 #include "bindings/v8/ExceptionState.h" 25 #include "core/svg/SVGAnimatedAngle.h" 26 #include "core/svg/SVGAnimatedBoolean.h" 27 #include "core/svg/SVGAnimatedEnumeration.h" 28 #include "core/svg/SVGAnimatedLength.h" 29 #include "core/svg/SVGElement.h" 30 #include "core/svg/SVGFitToViewBox.h" 31 32 namespace WebCore { 33 34 enum SVGMarkerUnitsType { 35 SVGMarkerUnitsUnknown = 0, 36 SVGMarkerUnitsUserSpaceOnUse, 37 SVGMarkerUnitsStrokeWidth 38 }; 39 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGMarkerUnitsType>(); 40 41 class SVGMarkerElement FINAL : public SVGElement, 42 public SVGFitToViewBox { 43 public: 44 // Forward declare enumerations in the W3C naming scheme, for IDL generation. 45 enum { 46 SVG_MARKERUNITS_UNKNOWN = SVGMarkerUnitsUnknown, 47 SVG_MARKERUNITS_USERSPACEONUSE = SVGMarkerUnitsUserSpaceOnUse, 48 SVG_MARKERUNITS_STROKEWIDTH = SVGMarkerUnitsStrokeWidth 49 }; 50 51 enum { 52 SVG_MARKER_ORIENT_UNKNOWN = SVGMarkerOrientUnknown, 53 SVG_MARKER_ORIENT_AUTO = SVGMarkerOrientAuto, 54 SVG_MARKER_ORIENT_ANGLE = SVGMarkerOrientAngle 55 }; 56 57 DECLARE_NODE_FACTORY(SVGMarkerElement); 58 59 AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const; 60 61 void setOrientToAuto(); 62 void setOrientToAngle(PassRefPtr<SVGAngleTearOff>); 63 refX()64 SVGAnimatedLength* refX() const { return m_refX.get(); } refY()65 SVGAnimatedLength* refY() const { return m_refY.get(); } markerWidth()66 SVGAnimatedLength* markerWidth() const { return m_markerWidth.get(); } markerHeight()67 SVGAnimatedLength* markerHeight() const { return m_markerHeight.get(); } markerUnits()68 SVGAnimatedEnumeration<SVGMarkerUnitsType>* markerUnits() { return m_markerUnits.get(); } orientAngle()69 SVGAnimatedAngle* orientAngle() { return m_orientAngle.get(); } orientType()70 SVGAnimatedEnumeration<SVGMarkerOrientType>* orientType() { return m_orientAngle->orientType(); } 71 72 private: 73 explicit SVGMarkerElement(Document&); 74 needsPendingResourceHandling()75 virtual bool needsPendingResourceHandling() const OVERRIDE { return false; } 76 77 bool isSupportedAttribute(const QualifiedName&); 78 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 79 virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE; 80 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE; 81 82 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; rendererIsNeeded(const RenderStyle &)83 virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE { return true; } 84 85 virtual bool selfHasRelativeLengths() const OVERRIDE; 86 87 RefPtr<SVGAnimatedLength> m_refX; 88 RefPtr<SVGAnimatedLength> m_refY; 89 RefPtr<SVGAnimatedLength> m_markerWidth; 90 RefPtr<SVGAnimatedLength> m_markerHeight; 91 RefPtr<SVGAnimatedAngle> m_orientAngle; 92 RefPtr<SVGAnimatedEnumeration<SVGMarkerUnitsType> > m_markerUnits; 93 }; 94 95 } 96 97 #endif 98