|
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 "JSSVGTextContentElement.h" |
|
32 |
|
33 #include <wtf/GetPtr.h> |
|
34 |
|
35 #include "CSSMutableStyleDeclaration.h" |
|
36 #include "CSSStyleDeclaration.h" |
|
37 #include "ExceptionCode.h" |
|
38 #include "FloatPoint.h" |
|
39 #include "JSCSSStyleDeclaration.h" |
|
40 #include "JSSVGAnimatedBoolean.h" |
|
41 #include "JSSVGAnimatedEnumeration.h" |
|
42 #include "JSSVGAnimatedLength.h" |
|
43 #include "JSSVGAnimatedString.h" |
|
44 #include "JSSVGPoint.h" |
|
45 #include "JSSVGRect.h" |
|
46 #include "JSSVGStringList.h" |
|
47 #include "PlatformString.h" |
|
48 #include "SVGStringList.h" |
|
49 #include "SVGTextContentElement.h" |
|
50 |
|
51 using namespace KJS; |
|
52 |
|
53 namespace WebCore { |
|
54 |
|
55 /* Hash table */ |
|
56 |
|
57 static const HashEntry JSSVGTextContentElementTableEntries[] = |
|
58 { |
|
59 { "xmllang", JSSVGTextContentElement::XmllangAttrNum, DontDelete, 0, 0 }, |
|
60 { 0, 0, 0, 0, 0 }, |
|
61 { "xmlspace", JSSVGTextContentElement::XmlspaceAttrNum, DontDelete, 0, 0 }, |
|
62 { "requiredExtensions", JSSVGTextContentElement::RequiredExtensionsAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
63 { "systemLanguage", JSSVGTextContentElement::SystemLanguageAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
64 { "lengthAdjust", JSSVGTextContentElement::LengthAdjustAttrNum, DontDelete|ReadOnly, 0, &JSSVGTextContentElementTableEntries[10] }, |
|
65 { "className", JSSVGTextContentElement::ClassNameAttrNum, DontDelete|ReadOnly, 0, &JSSVGTextContentElementTableEntries[11] }, |
|
66 { 0, 0, 0, 0, 0 }, |
|
67 { "textLength", JSSVGTextContentElement::TextLengthAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
68 { "requiredFeatures", JSSVGTextContentElement::RequiredFeaturesAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
69 { "externalResourcesRequired", JSSVGTextContentElement::ExternalResourcesRequiredAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
70 { "style", JSSVGTextContentElement::StyleAttrNum, DontDelete|ReadOnly, 0, 0 } |
|
71 }; |
|
72 |
|
73 static const HashTable JSSVGTextContentElementTable = |
|
74 { |
|
75 2, 12, JSSVGTextContentElementTableEntries, 10 |
|
76 }; |
|
77 |
|
78 /* Hash table for prototype */ |
|
79 |
|
80 static const HashEntry JSSVGTextContentElementPrototypeTableEntries[] = |
|
81 { |
|
82 { "getNumberOfChars", JSSVGTextContentElement::GetNumberOfCharsFuncNum, DontDelete|Function, 0, &JSSVGTextContentElementPrototypeTableEntries[15] }, |
|
83 { "getExtentOfChar", JSSVGTextContentElement::GetExtentOfCharFuncNum, DontDelete|Function, 1, 0 }, |
|
84 { 0, 0, 0, 0, 0 }, |
|
85 { 0, 0, 0, 0, 0 }, |
|
86 { "getRotationOfChar", JSSVGTextContentElement::GetRotationOfCharFuncNum, DontDelete|Function, 1, 0 }, |
|
87 { "getStartPositionOfChar", JSSVGTextContentElement::GetStartPositionOfCharFuncNum, DontDelete|Function, 1, 0 }, |
|
88 { "getComputedTextLength", JSSVGTextContentElement::GetComputedTextLengthFuncNum, DontDelete|Function, 0, &JSSVGTextContentElementPrototypeTableEntries[14] }, |
|
89 { 0, 0, 0, 0, 0 }, |
|
90 { "getEndPositionOfChar", JSSVGTextContentElement::GetEndPositionOfCharFuncNum, DontDelete|Function, 1, 0 }, |
|
91 { "hasExtension", JSSVGTextContentElement::HasExtensionFuncNum, DontDelete|Function, 1, 0 }, |
|
92 { "LENGTHADJUST_SPACING", SVGTextContentElement::LENGTHADJUST_SPACING, DontDelete|ReadOnly, 0, &JSSVGTextContentElementPrototypeTableEntries[13] }, |
|
93 { 0, 0, 0, 0, 0 }, |
|
94 { "LENGTHADJUST_UNKNOWN", SVGTextContentElement::LENGTHADJUST_UNKNOWN, DontDelete|ReadOnly, 0, 0 }, |
|
95 { "LENGTHADJUST_SPACINGANDGLYPHS", SVGTextContentElement::LENGTHADJUST_SPACINGANDGLYPHS, DontDelete|ReadOnly, 0, &JSSVGTextContentElementPrototypeTableEntries[16] }, |
|
96 { "getSubStringLength", JSSVGTextContentElement::GetSubStringLengthFuncNum, DontDelete|Function, 2, 0 }, |
|
97 { "getCharNumAtPosition", JSSVGTextContentElement::GetCharNumAtPositionFuncNum, DontDelete|Function, 1, 0 }, |
|
98 { "selectSubString", JSSVGTextContentElement::SelectSubStringFuncNum, DontDelete|Function, 2, 0 } |
|
99 }; |
|
100 |
|
101 static const HashTable JSSVGTextContentElementPrototypeTable = |
|
102 { |
|
103 2, 17, JSSVGTextContentElementPrototypeTableEntries, 13 |
|
104 }; |
|
105 |
|
106 const ClassInfo JSSVGTextContentElementPrototype::info = { "SVGTextContentElementPrototype", 0, &JSSVGTextContentElementPrototypeTable, 0 }; |
|
107 |
|
108 JSObject* JSSVGTextContentElementPrototype::self(ExecState* exec) |
|
109 { |
|
110 return KJS::cacheGlobalObject<JSSVGTextContentElementPrototype>(exec, "[[JSSVGTextContentElement.prototype]]"); |
|
111 } |
|
112 |
|
113 bool JSSVGTextContentElementPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
114 { |
|
115 return getStaticPropertySlot<JSSVGTextContentElementPrototypeFunction, JSSVGTextContentElementPrototype, JSObject>(exec, &JSSVGTextContentElementPrototypeTable, this, propertyName, slot); |
|
116 } |
|
117 |
|
118 JSValue* JSSVGTextContentElementPrototype::getValueProperty(ExecState*, int token) const |
|
119 { |
|
120 // The token is the numeric value of its associated constant |
|
121 return jsNumber(token); |
|
122 } |
|
123 |
|
124 const ClassInfo JSSVGTextContentElement::info = { "SVGTextContentElement", &JSSVGElement::info, &JSSVGTextContentElementTable, 0 }; |
|
125 |
|
126 JSSVGTextContentElement::JSSVGTextContentElement(ExecState* exec, SVGTextContentElement* impl) |
|
127 : JSSVGElement(exec, impl) |
|
128 { |
|
129 setPrototype(JSSVGTextContentElementPrototype::self(exec)); |
|
130 } |
|
131 |
|
132 bool JSSVGTextContentElement::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
133 { |
|
134 return getStaticValueSlot<JSSVGTextContentElement, JSSVGElement>(exec, &JSSVGTextContentElementTable, this, propertyName, slot); |
|
135 } |
|
136 |
|
137 JSValue* JSSVGTextContentElement::getValueProperty(ExecState* exec, int token) const |
|
138 { |
|
139 switch (token) { |
|
140 case TextLengthAttrNum: { |
|
141 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
142 |
|
143 ASSERT(exec && exec->dynamicInterpreter()); |
|
144 |
|
145 RefPtr<SVGAnimatedLength> obj = imp->textLengthAnimated(); |
|
146 Frame* activeFrame = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->frame(); |
|
147 if (activeFrame) { |
|
148 SVGDocumentExtensions* extensions = (activeFrame->document() ? activeFrame->document()->accessSVGExtensions() : 0); |
|
149 if (extensions) { |
|
150 if (extensions->hasGenericContext<SVGAnimatedLength>(obj.get())) |
|
151 ASSERT(extensions->genericContext<SVGAnimatedLength>(obj.get()) == imp); |
|
152 else |
|
153 extensions->setGenericContext<SVGAnimatedLength>(obj.get(), imp); |
|
154 } |
|
155 } |
|
156 |
|
157 return toJS(exec, obj.get()); |
|
158 } |
|
159 case LengthAdjustAttrNum: { |
|
160 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
161 |
|
162 ASSERT(exec && exec->dynamicInterpreter()); |
|
163 |
|
164 RefPtr<SVGAnimatedEnumeration> obj = imp->lengthAdjustAnimated(); |
|
165 Frame* activeFrame = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->frame(); |
|
166 if (activeFrame) { |
|
167 SVGDocumentExtensions* extensions = (activeFrame->document() ? activeFrame->document()->accessSVGExtensions() : 0); |
|
168 if (extensions) { |
|
169 if (extensions->hasGenericContext<SVGAnimatedEnumeration>(obj.get())) |
|
170 ASSERT(extensions->genericContext<SVGAnimatedEnumeration>(obj.get()) == imp); |
|
171 else |
|
172 extensions->setGenericContext<SVGAnimatedEnumeration>(obj.get(), imp); |
|
173 } |
|
174 } |
|
175 |
|
176 return toJS(exec, obj.get()); |
|
177 } |
|
178 case RequiredFeaturesAttrNum: { |
|
179 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
180 |
|
181 return toJS(exec, WTF::getPtr(imp->requiredFeatures())); |
|
182 } |
|
183 case RequiredExtensionsAttrNum: { |
|
184 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
185 |
|
186 return toJS(exec, WTF::getPtr(imp->requiredExtensions())); |
|
187 } |
|
188 case SystemLanguageAttrNum: { |
|
189 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
190 |
|
191 return toJS(exec, WTF::getPtr(imp->systemLanguage())); |
|
192 } |
|
193 case XmllangAttrNum: { |
|
194 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
195 |
|
196 return jsString(imp->xmllang()); |
|
197 } |
|
198 case XmlspaceAttrNum: { |
|
199 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
200 |
|
201 return jsString(imp->xmlspace()); |
|
202 } |
|
203 case ExternalResourcesRequiredAttrNum: { |
|
204 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
205 |
|
206 ASSERT(exec && exec->dynamicInterpreter()); |
|
207 |
|
208 RefPtr<SVGAnimatedBoolean> obj = imp->externalResourcesRequiredAnimated(); |
|
209 Frame* activeFrame = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->frame(); |
|
210 if (activeFrame) { |
|
211 SVGDocumentExtensions* extensions = (activeFrame->document() ? activeFrame->document()->accessSVGExtensions() : 0); |
|
212 if (extensions) { |
|
213 if (extensions->hasGenericContext<SVGAnimatedBoolean>(obj.get())) |
|
214 ASSERT(extensions->genericContext<SVGAnimatedBoolean>(obj.get()) == imp); |
|
215 else |
|
216 extensions->setGenericContext<SVGAnimatedBoolean>(obj.get(), imp); |
|
217 } |
|
218 } |
|
219 |
|
220 return toJS(exec, obj.get()); |
|
221 } |
|
222 case ClassNameAttrNum: { |
|
223 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
224 |
|
225 ASSERT(exec && exec->dynamicInterpreter()); |
|
226 |
|
227 RefPtr<SVGAnimatedString> obj = imp->classNameAnimated(); |
|
228 Frame* activeFrame = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->frame(); |
|
229 if (activeFrame) { |
|
230 SVGDocumentExtensions* extensions = (activeFrame->document() ? activeFrame->document()->accessSVGExtensions() : 0); |
|
231 if (extensions) { |
|
232 if (extensions->hasGenericContext<SVGAnimatedString>(obj.get())) |
|
233 ASSERT(extensions->genericContext<SVGAnimatedString>(obj.get()) == imp); |
|
234 else |
|
235 extensions->setGenericContext<SVGAnimatedString>(obj.get(), imp); |
|
236 } |
|
237 } |
|
238 |
|
239 return toJS(exec, obj.get()); |
|
240 } |
|
241 case StyleAttrNum: { |
|
242 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
243 |
|
244 return toJS(exec, WTF::getPtr(imp->style())); |
|
245 } |
|
246 } |
|
247 return 0; |
|
248 } |
|
249 |
|
250 void JSSVGTextContentElement::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) |
|
251 { |
|
252 lookupPut<JSSVGTextContentElement, JSSVGElement>(exec, propertyName, value, attr, &JSSVGTextContentElementTable, this); |
|
253 } |
|
254 |
|
255 void JSSVGTextContentElement::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/) |
|
256 { |
|
257 switch (token) { |
|
258 case XmllangAttrNum: { |
|
259 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
260 |
|
261 imp->setXmllang(value->toString(exec)); |
|
262 break; |
|
263 } |
|
264 case XmlspaceAttrNum: { |
|
265 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(impl()); |
|
266 |
|
267 imp->setXmlspace(value->toString(exec)); |
|
268 break; |
|
269 } |
|
270 } |
|
271 } |
|
272 |
|
273 JSValue* JSSVGTextContentElementPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
274 { |
|
275 if (!thisObj->inherits(&JSSVGTextContentElement::info)) |
|
276 return throwError(exec, TypeError); |
|
277 |
|
278 SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(static_cast<JSSVGTextContentElement*>(thisObj)->impl()); |
|
279 |
|
280 switch (id) { |
|
281 case JSSVGTextContentElement::GetNumberOfCharsFuncNum: { |
|
282 |
|
283 |
|
284 KJS::JSValue* result = jsNumber(imp->getNumberOfChars()); |
|
285 return result; |
|
286 } |
|
287 case JSSVGTextContentElement::GetComputedTextLengthFuncNum: { |
|
288 |
|
289 |
|
290 KJS::JSValue* result = jsNumber(imp->getComputedTextLength()); |
|
291 return result; |
|
292 } |
|
293 case JSSVGTextContentElement::GetSubStringLengthFuncNum: { |
|
294 ExceptionCode ec = 0; |
|
295 bool offsetOk; |
|
296 unsigned offset = args[0]->toInt32(exec, offsetOk); |
|
297 if (!offsetOk) { |
|
298 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
299 return jsUndefined(); |
|
300 } |
|
301 bool lengthOk; |
|
302 unsigned length = args[1]->toInt32(exec, lengthOk); |
|
303 if (!lengthOk) { |
|
304 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
305 return jsUndefined(); |
|
306 } |
|
307 |
|
308 |
|
309 KJS::JSValue* result = jsNumber(imp->getSubStringLength(offset, length, ec)); |
|
310 setDOMException(exec, ec); |
|
311 return result; |
|
312 } |
|
313 case JSSVGTextContentElement::GetStartPositionOfCharFuncNum: { |
|
314 ExceptionCode ec = 0; |
|
315 bool offsetOk; |
|
316 unsigned offset = args[0]->toInt32(exec, offsetOk); |
|
317 if (!offsetOk) { |
|
318 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
319 return jsUndefined(); |
|
320 } |
|
321 |
|
322 |
|
323 KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<FloatPoint>(imp->getStartPositionOfChar(offset, ec))); |
|
324 setDOMException(exec, ec); |
|
325 return result; |
|
326 } |
|
327 case JSSVGTextContentElement::GetEndPositionOfCharFuncNum: { |
|
328 ExceptionCode ec = 0; |
|
329 bool offsetOk; |
|
330 unsigned offset = args[0]->toInt32(exec, offsetOk); |
|
331 if (!offsetOk) { |
|
332 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
333 return jsUndefined(); |
|
334 } |
|
335 |
|
336 |
|
337 KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<FloatPoint>(imp->getEndPositionOfChar(offset, ec))); |
|
338 setDOMException(exec, ec); |
|
339 return result; |
|
340 } |
|
341 case JSSVGTextContentElement::GetExtentOfCharFuncNum: { |
|
342 ExceptionCode ec = 0; |
|
343 bool offsetOk; |
|
344 unsigned offset = args[0]->toInt32(exec, offsetOk); |
|
345 if (!offsetOk) { |
|
346 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
347 return jsUndefined(); |
|
348 } |
|
349 |
|
350 |
|
351 KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<FloatRect>(imp->getExtentOfChar(offset, ec))); |
|
352 setDOMException(exec, ec); |
|
353 return result; |
|
354 } |
|
355 case JSSVGTextContentElement::GetRotationOfCharFuncNum: { |
|
356 ExceptionCode ec = 0; |
|
357 bool offsetOk; |
|
358 unsigned offset = args[0]->toInt32(exec, offsetOk); |
|
359 if (!offsetOk) { |
|
360 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
361 return jsUndefined(); |
|
362 } |
|
363 |
|
364 |
|
365 KJS::JSValue* result = jsNumber(imp->getRotationOfChar(offset, ec)); |
|
366 setDOMException(exec, ec); |
|
367 return result; |
|
368 } |
|
369 case JSSVGTextContentElement::GetCharNumAtPositionFuncNum: { |
|
370 FloatPoint point = toSVGPoint(args[0]); |
|
371 |
|
372 |
|
373 KJS::JSValue* result = jsNumber(imp->getCharNumAtPosition(point)); |
|
374 return result; |
|
375 } |
|
376 case JSSVGTextContentElement::SelectSubStringFuncNum: { |
|
377 ExceptionCode ec = 0; |
|
378 bool offsetOk; |
|
379 unsigned offset = args[0]->toInt32(exec, offsetOk); |
|
380 if (!offsetOk) { |
|
381 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
382 return jsUndefined(); |
|
383 } |
|
384 bool lengthOk; |
|
385 unsigned length = args[1]->toInt32(exec, lengthOk); |
|
386 if (!lengthOk) { |
|
387 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
388 return jsUndefined(); |
|
389 } |
|
390 |
|
391 imp->selectSubString(offset, length, ec); |
|
392 setDOMException(exec, ec); |
|
393 return jsUndefined(); |
|
394 } |
|
395 case JSSVGTextContentElement::HasExtensionFuncNum: { |
|
396 String extension = args[0]->toString(exec); |
|
397 |
|
398 |
|
399 KJS::JSValue* result = jsBoolean(imp->hasExtension(extension)); |
|
400 return result; |
|
401 } |
|
402 } |
|
403 return 0; |
|
404 } |
|
405 |
|
406 } |
|
407 |
|
408 #endif // ENABLE(SVG) |