1 /*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "config.h"
21
22 #if ENABLE(SVG)
23 #include "JSSVGPathSeg.h"
24 #include "JSSVGPathSegArcAbs.h"
25 #include "JSSVGPathSegArcRel.h"
26 #include "JSSVGPathSegClosePath.h"
27 #include "JSSVGPathSegCurvetoCubicAbs.h"
28 #include "JSSVGPathSegCurvetoCubicRel.h"
29 #include "JSSVGPathSegCurvetoCubicSmoothAbs.h"
30 #include "JSSVGPathSegCurvetoCubicSmoothRel.h"
31 #include "JSSVGPathSegCurvetoQuadraticAbs.h"
32 #include "JSSVGPathSegCurvetoQuadraticRel.h"
33 #include "JSSVGPathSegCurvetoQuadraticSmoothAbs.h"
34 #include "JSSVGPathSegCurvetoQuadraticSmoothRel.h"
35 #include "JSSVGPathSegLinetoAbs.h"
36 #include "JSSVGPathSegLinetoRel.h"
37 #include "JSSVGPathSegLinetoHorizontalAbs.h"
38 #include "JSSVGPathSegLinetoHorizontalRel.h"
39 #include "JSSVGPathSegLinetoVerticalAbs.h"
40 #include "JSSVGPathSegLinetoVerticalRel.h"
41 #include "JSSVGPathSegMovetoAbs.h"
42 #include "JSSVGPathSegMovetoRel.h"
43
44 #include "JSDOMBinding.h"
45
46 #include "SVGPathSeg.h"
47 #include "SVGPathSegArc.h"
48 #include "SVGPathSegClosePath.h"
49 #include "SVGPathSegCurvetoCubic.h"
50 #include "SVGPathSegCurvetoCubicSmooth.h"
51 #include "SVGPathSegCurvetoQuadratic.h"
52 #include "SVGPathSegCurvetoQuadraticSmooth.h"
53 #include "SVGPathSegLineto.h"
54 #include "SVGPathSegLinetoHorizontal.h"
55 #include "SVGPathSegLinetoVertical.h"
56 #include "SVGPathSegMoveto.h"
57
58 using namespace JSC;
59
60 namespace WebCore {
61
toJS(ExecState * exec,JSDOMGlobalObject * globalObject,SVGPathSeg * object,SVGElement * context)62 JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, SVGPathSeg* object, SVGElement* context)
63 {
64 if (!object)
65 return jsNull();
66
67 if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), object))
68 return wrapper;
69
70 switch (object->pathSegType()) {
71 case SVGPathSeg::PATHSEG_CLOSEPATH:
72 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegClosePath, object, context);
73 case SVGPathSeg::PATHSEG_MOVETO_ABS:
74 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegMovetoAbs, object, context);
75 case SVGPathSeg::PATHSEG_MOVETO_REL:
76 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegMovetoRel, object, context);
77 case SVGPathSeg::PATHSEG_LINETO_ABS:
78 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoAbs, object, context);
79 case SVGPathSeg::PATHSEG_LINETO_REL:
80 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoRel, object, context);
81 case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:
82 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicAbs, object, context);
83 case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL:
84 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicRel, object, context);
85 case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS:
86 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticAbs, object, context);
87 case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL:
88 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticRel, object, context);
89 case SVGPathSeg::PATHSEG_ARC_ABS:
90 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegArcAbs, object, context);
91 case SVGPathSeg::PATHSEG_ARC_REL:
92 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegArcRel, object, context);
93 case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS:
94 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoHorizontalAbs, object, context);
95 case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL:
96 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoHorizontalRel, object, context);
97 case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS:
98 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoVerticalAbs, object, context);
99 case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL:
100 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoVerticalRel, object, context);
101 case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
102 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicSmoothAbs, object, context);
103 case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
104 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicSmoothRel, object, context);
105 case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
106 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticSmoothAbs, object, context);
107 case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
108 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticSmoothRel, object, context);
109 case SVGPathSeg::PATHSEG_UNKNOWN:
110 default:
111 return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSeg, object, context);
112 }
113 }
114
115 }
116
117 #endif // ENABLE(SVG)
118
119 // vim:ts=4:noet
120