|
1 /* |
|
2 This file is part of the WebKit open source project. |
|
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
|
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 #include "config.h" |
|
22 |
|
23 |
|
24 #if ENABLE(SVG) |
|
25 |
|
26 #include "Document.h" |
|
27 #include "Frame.h" |
|
28 #include "SVGDocumentExtensions.h" |
|
29 #include "SVGElement.h" |
|
30 #include "SVGAnimatedTemplate.h" |
|
31 #include "JSSVGTransform.h" |
|
32 |
|
33 #include <wtf/GetPtr.h> |
|
34 |
|
35 #include "JSSVGMatrix.h" |
|
36 #include "SVGTransform.h" |
|
37 |
|
38 using namespace KJS; |
|
39 |
|
40 namespace WebCore { |
|
41 |
|
42 /* Hash table */ |
|
43 |
|
44 static const HashEntry JSSVGTransformTableEntries[] = |
|
45 { |
|
46 { "angle", JSSVGTransform::AngleAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
47 { "matrix", JSSVGTransform::MatrixAttrNum, DontDelete|ReadOnly, 0, &JSSVGTransformTableEntries[4] }, |
|
48 { 0, 0, 0, 0, 0 }, |
|
49 { "type", JSSVGTransform::TypeAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
50 { "constructor", JSSVGTransform::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 } |
|
51 }; |
|
52 |
|
53 static const HashTable JSSVGTransformTable = |
|
54 { |
|
55 2, 5, JSSVGTransformTableEntries, 4 |
|
56 }; |
|
57 |
|
58 /* Hash table for constructor */ |
|
59 |
|
60 static const HashEntry JSSVGTransformConstructorTableEntries[] = |
|
61 { |
|
62 { "SVG_TRANSFORM_SCALE", SVGTransform::SVG_TRANSFORM_SCALE, DontDelete|ReadOnly, 0, 0 }, |
|
63 { 0, 0, 0, 0, 0 }, |
|
64 { 0, 0, 0, 0, 0 }, |
|
65 { 0, 0, 0, 0, 0 }, |
|
66 { "SVG_TRANSFORM_UNKNOWN", SVGTransform::SVG_TRANSFORM_UNKNOWN, DontDelete|ReadOnly, 0, &JSSVGTransformConstructorTableEntries[7] }, |
|
67 { "SVG_TRANSFORM_ROTATE", SVGTransform::SVG_TRANSFORM_ROTATE, DontDelete|ReadOnly, 0, &JSSVGTransformConstructorTableEntries[9] }, |
|
68 { "SVG_TRANSFORM_SKEWY", SVGTransform::SVG_TRANSFORM_SKEWY, DontDelete|ReadOnly, 0, 0 }, |
|
69 { "SVG_TRANSFORM_MATRIX", SVGTransform::SVG_TRANSFORM_MATRIX, DontDelete|ReadOnly, 0, &JSSVGTransformConstructorTableEntries[8] }, |
|
70 { "SVG_TRANSFORM_TRANSLATE", SVGTransform::SVG_TRANSFORM_TRANSLATE, DontDelete|ReadOnly, 0, 0 }, |
|
71 { "SVG_TRANSFORM_SKEWX", SVGTransform::SVG_TRANSFORM_SKEWX, DontDelete|ReadOnly, 0, 0 } |
|
72 }; |
|
73 |
|
74 static const HashTable JSSVGTransformConstructorTable = |
|
75 { |
|
76 2, 10, JSSVGTransformConstructorTableEntries, 7 |
|
77 }; |
|
78 |
|
79 class JSSVGTransformConstructor : public DOMObject { |
|
80 public: |
|
81 JSSVGTransformConstructor(ExecState* exec) |
|
82 { |
|
83 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); |
|
84 putDirect(exec->propertyNames().prototype, JSSVGTransformPrototype::self(exec), None); |
|
85 } |
|
86 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); |
|
87 JSValue* getValueProperty(ExecState*, int token) const; |
|
88 virtual const ClassInfo* classInfo() const { return &info; } |
|
89 static const ClassInfo info; |
|
90 |
|
91 virtual bool implementsHasInstance() const { return true; } |
|
92 }; |
|
93 |
|
94 const ClassInfo JSSVGTransformConstructor::info = { "SVGTransformConstructor", 0, &JSSVGTransformConstructorTable, 0 }; |
|
95 |
|
96 bool JSSVGTransformConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
97 { |
|
98 return getStaticValueSlot<JSSVGTransformConstructor, DOMObject>(exec, &JSSVGTransformConstructorTable, this, propertyName, slot); |
|
99 } |
|
100 |
|
101 JSValue* JSSVGTransformConstructor::getValueProperty(ExecState*, int token) const |
|
102 { |
|
103 // The token is the numeric value of its associated constant |
|
104 return jsNumber(token); |
|
105 } |
|
106 |
|
107 /* Hash table for prototype */ |
|
108 |
|
109 static const HashEntry JSSVGTransformPrototypeTableEntries[] = |
|
110 { |
|
111 { "SVG_TRANSFORM_MATRIX", SVGTransform::SVG_TRANSFORM_MATRIX, DontDelete|ReadOnly, 0, 0 }, |
|
112 { 0, 0, 0, 0, 0 }, |
|
113 { "setTranslate", JSSVGTransform::SetTranslateFuncNum, DontDelete|Function, 2, 0 }, |
|
114 { "SVG_TRANSFORM_UNKNOWN", SVGTransform::SVG_TRANSFORM_UNKNOWN, DontDelete|ReadOnly, 0, &JSSVGTransformPrototypeTableEntries[15] }, |
|
115 { 0, 0, 0, 0, 0 }, |
|
116 { "setMatrix", JSSVGTransform::SetMatrixFuncNum, DontDelete|Function, 1, 0 }, |
|
117 { "setSkewY", JSSVGTransform::SetSkewYFuncNum, DontDelete|Function, 1, 0 }, |
|
118 { "SVG_TRANSFORM_SCALE", SVGTransform::SVG_TRANSFORM_SCALE, DontDelete|ReadOnly, 0, &JSSVGTransformPrototypeTableEntries[14] }, |
|
119 { "SVG_TRANSFORM_ROTATE", SVGTransform::SVG_TRANSFORM_ROTATE, DontDelete|ReadOnly, 0, &JSSVGTransformPrototypeTableEntries[13] }, |
|
120 { 0, 0, 0, 0, 0 }, |
|
121 { "SVG_TRANSFORM_TRANSLATE", SVGTransform::SVG_TRANSFORM_TRANSLATE, DontDelete|ReadOnly, 0, 0 }, |
|
122 { "setRotate", JSSVGTransform::SetRotateFuncNum, DontDelete|Function, 3, 0 }, |
|
123 { "setSkewX", JSSVGTransform::SetSkewXFuncNum, DontDelete|Function, 1, 0 }, |
|
124 { "SVG_TRANSFORM_SKEWX", SVGTransform::SVG_TRANSFORM_SKEWX, DontDelete|ReadOnly, 0, 0 }, |
|
125 { "SVG_TRANSFORM_SKEWY", SVGTransform::SVG_TRANSFORM_SKEWY, DontDelete|ReadOnly, 0, 0 }, |
|
126 { "setScale", JSSVGTransform::SetScaleFuncNum, DontDelete|Function, 2, 0 } |
|
127 }; |
|
128 |
|
129 static const HashTable JSSVGTransformPrototypeTable = |
|
130 { |
|
131 2, 16, JSSVGTransformPrototypeTableEntries, 13 |
|
132 }; |
|
133 |
|
134 const ClassInfo JSSVGTransformPrototype::info = { "SVGTransformPrototype", 0, &JSSVGTransformPrototypeTable, 0 }; |
|
135 |
|
136 JSObject* JSSVGTransformPrototype::self(ExecState* exec) |
|
137 { |
|
138 return KJS::cacheGlobalObject<JSSVGTransformPrototype>(exec, "[[JSSVGTransform.prototype]]"); |
|
139 } |
|
140 |
|
141 bool JSSVGTransformPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
142 { |
|
143 return getStaticPropertySlot<JSSVGTransformPrototypeFunction, JSSVGTransformPrototype, JSObject>(exec, &JSSVGTransformPrototypeTable, this, propertyName, slot); |
|
144 } |
|
145 |
|
146 JSValue* JSSVGTransformPrototype::getValueProperty(ExecState*, int token) const |
|
147 { |
|
148 // The token is the numeric value of its associated constant |
|
149 return jsNumber(token); |
|
150 } |
|
151 |
|
152 const ClassInfo JSSVGTransform::info = { "SVGTransform", 0, &JSSVGTransformTable, 0 }; |
|
153 |
|
154 JSSVGTransform::JSSVGTransform(ExecState* exec, JSSVGPODTypeWrapper<SVGTransform>* impl) |
|
155 : m_impl(impl) |
|
156 { |
|
157 setPrototype(JSSVGTransformPrototype::self(exec)); |
|
158 } |
|
159 |
|
160 JSSVGTransform::~JSSVGTransform() |
|
161 { |
|
162 ScriptInterpreter::forgetDOMObject(m_impl.get()); |
|
163 } |
|
164 |
|
165 bool JSSVGTransform::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
166 { |
|
167 return getStaticValueSlot<JSSVGTransform, KJS::DOMObject>(exec, &JSSVGTransformTable, this, propertyName, slot); |
|
168 } |
|
169 |
|
170 JSValue* JSSVGTransform::getValueProperty(ExecState* exec, int token) const |
|
171 { |
|
172 switch (token) { |
|
173 case TypeAttrNum: { |
|
174 SVGTransform& imp(*impl()); |
|
175 |
|
176 return jsNumber(imp.type()); |
|
177 } |
|
178 case MatrixAttrNum: { |
|
179 SVGTransform& imp(*impl()); |
|
180 |
|
181 return toJS(exec, new JSSVGPODTypeWrapper<AffineTransform>(imp.matrix())); |
|
182 } |
|
183 case AngleAttrNum: { |
|
184 SVGTransform& imp(*impl()); |
|
185 |
|
186 return jsNumber(imp.angle()); |
|
187 } |
|
188 case ConstructorAttrNum: |
|
189 return getConstructor(exec); |
|
190 } |
|
191 return 0; |
|
192 } |
|
193 |
|
194 JSValue* JSSVGTransform::getConstructor(ExecState* exec) |
|
195 { |
|
196 return KJS::cacheGlobalObject<JSSVGTransformConstructor>(exec, "[[SVGTransform.constructor]]"); |
|
197 } |
|
198 JSValue* JSSVGTransformPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
199 { |
|
200 if (!thisObj->inherits(&JSSVGTransform::info)) |
|
201 return throwError(exec, TypeError); |
|
202 |
|
203 JSSVGPODTypeWrapper<SVGTransform>* wrapper = static_cast<JSSVGTransform*>(thisObj)->impl(); |
|
204 SVGTransform& imp(*wrapper); |
|
205 |
|
206 switch (id) { |
|
207 case JSSVGTransform::SetMatrixFuncNum: { |
|
208 AffineTransform matrix = toSVGMatrix(args[0]); |
|
209 |
|
210 imp.setMatrix(matrix); |
|
211 wrapper->commitChange(exec); |
|
212 return jsUndefined(); |
|
213 } |
|
214 case JSSVGTransform::SetTranslateFuncNum: { |
|
215 float tx = args[0]->toFloat(exec); |
|
216 float ty = args[1]->toFloat(exec); |
|
217 |
|
218 imp.setTranslate(tx, ty); |
|
219 wrapper->commitChange(exec); |
|
220 return jsUndefined(); |
|
221 } |
|
222 case JSSVGTransform::SetScaleFuncNum: { |
|
223 float sx = args[0]->toFloat(exec); |
|
224 float sy = args[1]->toFloat(exec); |
|
225 |
|
226 imp.setScale(sx, sy); |
|
227 wrapper->commitChange(exec); |
|
228 return jsUndefined(); |
|
229 } |
|
230 case JSSVGTransform::SetRotateFuncNum: { |
|
231 float angle = args[0]->toFloat(exec); |
|
232 float cx = args[1]->toFloat(exec); |
|
233 float cy = args[2]->toFloat(exec); |
|
234 |
|
235 imp.setRotate(angle, cx, cy); |
|
236 wrapper->commitChange(exec); |
|
237 return jsUndefined(); |
|
238 } |
|
239 case JSSVGTransform::SetSkewXFuncNum: { |
|
240 float angle = args[0]->toFloat(exec); |
|
241 |
|
242 imp.setSkewX(angle); |
|
243 wrapper->commitChange(exec); |
|
244 return jsUndefined(); |
|
245 } |
|
246 case JSSVGTransform::SetSkewYFuncNum: { |
|
247 float angle = args[0]->toFloat(exec); |
|
248 |
|
249 imp.setSkewY(angle); |
|
250 wrapper->commitChange(exec); |
|
251 return jsUndefined(); |
|
252 } |
|
253 } |
|
254 return 0; |
|
255 } |
|
256 KJS::JSValue* toJS(KJS::ExecState* exec, JSSVGPODTypeWrapper<SVGTransform>* obj) |
|
257 { |
|
258 return KJS::cacheDOMObject<JSSVGPODTypeWrapper<SVGTransform>, JSSVGTransform>(exec, obj); |
|
259 } |
|
260 SVGTransform toSVGTransform(KJS::JSValue* val) |
|
261 { |
|
262 return val->isObject(&JSSVGTransform::info) ? (SVGTransform) *static_cast<JSSVGTransform*>(val)->impl() : SVGTransform(); |
|
263 } |
|
264 |
|
265 } |
|
266 |
|
267 #endif // ENABLE(SVG) |