Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGMarkerElement.h
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/core/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 blink {
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     DEFINE_WRAPPERTYPEINFO();
44 public:
45     // Forward declare enumerations in the W3C naming scheme, for IDL generation.
46     enum {
47         SVG_MARKERUNITS_UNKNOWN = SVGMarkerUnitsUnknown,
48         SVG_MARKERUNITS_USERSPACEONUSE = SVGMarkerUnitsUserSpaceOnUse,
49         SVG_MARKERUNITS_STROKEWIDTH = SVGMarkerUnitsStrokeWidth
50     };
51
52     enum {
53         SVG_MARKER_ORIENT_UNKNOWN = SVGMarkerOrientUnknown,
54         SVG_MARKER_ORIENT_AUTO = SVGMarkerOrientAuto,
55         SVG_MARKER_ORIENT_ANGLE = SVGMarkerOrientAngle
56     };
57
58     DECLARE_NODE_FACTORY(SVGMarkerElement);
59
60     AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const;
61
62     void setOrientToAuto();
63     void setOrientToAngle(PassRefPtr<SVGAngleTearOff>);
64
65     SVGAnimatedLength* refX() const { return m_refX.get(); }
66     SVGAnimatedLength* refY() const { return m_refY.get(); }
67     SVGAnimatedLength* markerWidth() const { return m_markerWidth.get(); }
68     SVGAnimatedLength* markerHeight() const { return m_markerHeight.get(); }
69     SVGAnimatedEnumeration<SVGMarkerUnitsType>* markerUnits() { return m_markerUnits.get(); }
70     SVGAnimatedAngle* orientAngle() { return m_orientAngle.get(); }
71     SVGAnimatedEnumeration<SVGMarkerOrientType>* orientType() { return m_orientAngle->orientType(); }
72
73 private:
74     explicit SVGMarkerElement(Document&);
75
76     virtual bool needsPendingResourceHandling() const OVERRIDE { return false; }
77
78     bool isSupportedAttribute(const QualifiedName&);
79     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
80     virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE;
81     virtual void childrenChanged(const ChildrenChange&) OVERRIDE;
82
83     virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
84     virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE { return true; }
85
86     virtual bool selfHasRelativeLengths() const OVERRIDE;
87
88     RefPtr<SVGAnimatedLength> m_refX;
89     RefPtr<SVGAnimatedLength> m_refY;
90     RefPtr<SVGAnimatedLength> m_markerWidth;
91     RefPtr<SVGAnimatedLength> m_markerHeight;
92     RefPtr<SVGAnimatedAngle> m_orientAngle;
93     RefPtr<SVGAnimatedEnumeration<SVGMarkerUnitsType> > m_markerUnits;
94 };
95
96 } // namespace blink
97
98 #endif // SVGMarkerElement_h