• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
25 #include "JSDOMBinding.h"
26 #include "JSSVGPathSegArcAbs.h"
27 #include "JSSVGPathSegArcRel.h"
28 #include "JSSVGPathSegClosePath.h"
29 #include "JSSVGPathSegCurvetoCubicAbs.h"
30 #include "JSSVGPathSegCurvetoCubicRel.h"
31 #include "JSSVGPathSegCurvetoCubicSmoothAbs.h"
32 #include "JSSVGPathSegCurvetoCubicSmoothRel.h"
33 #include "JSSVGPathSegCurvetoQuadraticAbs.h"
34 #include "JSSVGPathSegCurvetoQuadraticRel.h"
35 #include "JSSVGPathSegCurvetoQuadraticSmoothAbs.h"
36 #include "JSSVGPathSegCurvetoQuadraticSmoothRel.h"
37 #include "JSSVGPathSegLinetoAbs.h"
38 #include "JSSVGPathSegLinetoRel.h"
39 #include "JSSVGPathSegLinetoHorizontalAbs.h"
40 #include "JSSVGPathSegLinetoHorizontalRel.h"
41 #include "JSSVGPathSegLinetoVerticalAbs.h"
42 #include "JSSVGPathSegLinetoVerticalRel.h"
43 #include "JSSVGPathSegMovetoAbs.h"
44 #include "JSSVGPathSegMovetoRel.h"
45 #include "SVGPathSeg.h"
46 #include "SVGPathSegArc.h"
47 #include "SVGPathSegClosePath.h"
48 #include "SVGPathSegCurvetoCubic.h"
49 #include "SVGPathSegCurvetoCubicSmooth.h"
50 #include "SVGPathSegCurvetoQuadratic.h"
51 #include "SVGPathSegCurvetoQuadraticSmooth.h"
52 #include "SVGPathSegLineto.h"
53 #include "SVGPathSegLinetoHorizontal.h"
54 #include "SVGPathSegLinetoVertical.h"
55 #include "SVGPathSegMoveto.h"
56 
57 using namespace JSC;
58 
59 namespace WebCore {
60 
toJS(ExecState * exec,JSDOMGlobalObject * globalObject,SVGPathSeg * object)61 JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, SVGPathSeg* object)
62 {
63     if (!object)
64         return jsNull();
65 
66     if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), object))
67         return wrapper;
68 
69     switch (object->pathSegType()) {
70     case SVGPathSeg::PATHSEG_CLOSEPATH:
71         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegClosePath, object);
72     case SVGPathSeg::PATHSEG_MOVETO_ABS:
73         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegMovetoAbs, object);
74     case SVGPathSeg::PATHSEG_MOVETO_REL:
75         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegMovetoRel, object);
76     case SVGPathSeg::PATHSEG_LINETO_ABS:
77         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoAbs, object);
78     case SVGPathSeg::PATHSEG_LINETO_REL:
79         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoRel, object);
80     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:
81         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicAbs, object);
82     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL:
83         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicRel, object);
84     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS:
85         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticAbs, object);
86     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL:
87         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticRel, object);
88     case SVGPathSeg::PATHSEG_ARC_ABS:
89         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegArcAbs, object);
90     case SVGPathSeg::PATHSEG_ARC_REL:
91         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegArcRel, object);
92     case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS:
93         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoHorizontalAbs, object);
94     case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL:
95         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoHorizontalRel, object);
96     case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS:
97         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoVerticalAbs, object);
98     case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL:
99         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoVerticalRel, object);
100     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
101         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicSmoothAbs, object);
102     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
103         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicSmoothRel, object);
104     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
105         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticSmoothAbs, object);
106     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
107         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticSmoothRel, object);
108     case SVGPathSeg::PATHSEG_UNKNOWN:
109     default:
110         return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSeg, object);
111     }
112 }
113 
114 }
115 
116 #endif // ENABLE(SVG)
117