tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / JSTextTrack.cpp
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 #if ENABLE(VIDEO_TRACK)
24
25 #include "JSTextTrack.h"
26
27 #include "Event.h"
28 #include "EventListener.h"
29 #include "ExceptionCode.h"
30 #include "JSDOMBinding.h"
31 #include "JSEvent.h"
32 #include "JSEventListener.h"
33 #include "JSTextTrackCue.h"
34 #include "JSTextTrackCueList.h"
35 #include "KURL.h"
36 #include "TextTrack.h"
37 #include "TextTrackCueList.h"
38 #include <runtime/Error.h>
39 #include <runtime/JSString.h>
40 #include <wtf/GetPtr.h>
41
42 using namespace JSC;
43
44 namespace WebCore {
45
46 ASSERT_CLASS_FITS_IN_CELL(JSTextTrack);
47
48 /* Hash table */
49 #if ENABLE(JIT)
50 #define THUNK_GENERATOR(generator) , generator
51 #else
52 #define THUNK_GENERATOR(generator)
53 #endif
54 #if ENABLE(DFG_JIT)
55 #define INTRINSIC(intrinsic) , intrinsic
56 #else
57 #define INTRINSIC(intrinsic)
58 #endif
59
60 static const HashTableValue JSTextTrackTableValues[] =
61 {
62     { "kind", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackKind), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
63     { "label", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackLabel), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
64     { "language", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackLanguage), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
65     { "mode", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackMode), (intptr_t)setJSTextTrackMode THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
66     { "cues", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCues), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
67     { "activeCues", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackActiveCues), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
68     { "oncuechange", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackOncuechange), (intptr_t)setJSTextTrackOncuechange THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
69     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
70     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
71 };
72
73 #undef THUNK_GENERATOR
74 static const HashTable JSTextTrackTable = { 18, 15, JSTextTrackTableValues, 0 };
75 /* Hash table for constructor */
76 #if ENABLE(JIT)
77 #define THUNK_GENERATOR(generator) , generator
78 #else
79 #define THUNK_GENERATOR(generator)
80 #endif
81 #if ENABLE(DFG_JIT)
82 #define INTRINSIC(intrinsic) , intrinsic
83 #else
84 #define INTRINSIC(intrinsic)
85 #endif
86
87 static const HashTableValue JSTextTrackConstructorTableValues[] =
88 {
89     { "DISABLED", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackDISABLED), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
90     { "HIDDEN", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackHIDDEN), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
91     { "SHOWING", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackSHOWING), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
92     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
93 };
94
95 #undef THUNK_GENERATOR
96 static const HashTable JSTextTrackConstructorTable = { 8, 7, JSTextTrackConstructorTableValues, 0 };
97
98 COMPILE_ASSERT(0 == TextTrack::DISABLED, TextTrackEnumDISABLEDIsWrongUseDontCheckEnums);
99 COMPILE_ASSERT(1 == TextTrack::HIDDEN, TextTrackEnumHIDDENIsWrongUseDontCheckEnums);
100 COMPILE_ASSERT(2 == TextTrack::SHOWING, TextTrackEnumSHOWINGIsWrongUseDontCheckEnums);
101
102 const ClassInfo JSTextTrackConstructor::s_info = { "TextTrackConstructor", &DOMConstructorObject::s_info, &JSTextTrackConstructorTable, 0, CREATE_METHOD_TABLE(JSTextTrackConstructor) };
103
104 JSTextTrackConstructor::JSTextTrackConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
105     : DOMConstructorObject(structure, globalObject)
106 {
107 }
108
109 void JSTextTrackConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
110 {
111     Base::finishCreation(exec->globalData());
112     ASSERT(inherits(&s_info));
113     putDirect(exec->globalData(), exec->propertyNames().prototype, JSTextTrackPrototype::self(exec, globalObject), DontDelete | ReadOnly);
114 }
115
116 bool JSTextTrackConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
117 {
118     return getStaticValueSlot<JSTextTrackConstructor, JSDOMWrapper>(exec, &JSTextTrackConstructorTable, static_cast<JSTextTrackConstructor*>(cell), propertyName, slot);
119 }
120
121 bool JSTextTrackConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
122 {
123     return getStaticValueDescriptor<JSTextTrackConstructor, JSDOMWrapper>(exec, &JSTextTrackConstructorTable, static_cast<JSTextTrackConstructor*>(object), propertyName, descriptor);
124 }
125
126 /* Hash table for prototype */
127 #if ENABLE(JIT)
128 #define THUNK_GENERATOR(generator) , generator
129 #else
130 #define THUNK_GENERATOR(generator)
131 #endif
132 #if ENABLE(DFG_JIT)
133 #define INTRINSIC(intrinsic) , intrinsic
134 #else
135 #define INTRINSIC(intrinsic)
136 #endif
137
138 static const HashTableValue JSTextTrackPrototypeTableValues[] =
139 {
140     { "DISABLED", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackDISABLED), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
141     { "HIDDEN", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackHIDDEN), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
142     { "SHOWING", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackSHOWING), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
143     { "addCue", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTextTrackPrototypeFunctionAddCue), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
144     { "removeCue", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTextTrackPrototypeFunctionRemoveCue), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
145     { "addEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTextTrackPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
146     { "removeEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTextTrackPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
147     { "dispatchEvent", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTextTrackPrototypeFunctionDispatchEvent), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
148     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
149 };
150
151 #undef THUNK_GENERATOR
152 static const HashTable JSTextTrackPrototypeTable = { 18, 15, JSTextTrackPrototypeTableValues, 0 };
153 const ClassInfo JSTextTrackPrototype::s_info = { "TextTrackPrototype", &JSC::JSNonFinalObject::s_info, &JSTextTrackPrototypeTable, 0, CREATE_METHOD_TABLE(JSTextTrackPrototype) };
154
155 JSObject* JSTextTrackPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
156 {
157     return getDOMPrototype<JSTextTrack>(exec, globalObject);
158 }
159
160 bool JSTextTrackPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
161 {
162     JSTextTrackPrototype* thisObject = jsCast<JSTextTrackPrototype*>(cell);
163     return getStaticPropertySlot<JSTextTrackPrototype, JSObject>(exec, &JSTextTrackPrototypeTable, thisObject, propertyName, slot);
164 }
165
166 bool JSTextTrackPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
167 {
168     JSTextTrackPrototype* thisObject = jsCast<JSTextTrackPrototype*>(object);
169     return getStaticPropertyDescriptor<JSTextTrackPrototype, JSObject>(exec, &JSTextTrackPrototypeTable, thisObject, propertyName, descriptor);
170 }
171
172 const ClassInfo JSTextTrack::s_info = { "TextTrack", &JSDOMWrapper::s_info, &JSTextTrackTable, 0 , CREATE_METHOD_TABLE(JSTextTrack) };
173
174 JSTextTrack::JSTextTrack(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TextTrack> impl)
175     : JSDOMWrapper(structure, globalObject)
176     , m_impl(impl.leakRef())
177 {
178 }
179
180 void JSTextTrack::finishCreation(JSGlobalData& globalData)
181 {
182     Base::finishCreation(globalData);
183     ASSERT(inherits(&s_info));
184 }
185
186 JSObject* JSTextTrack::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
187 {
188     return JSTextTrackPrototype::create(exec->globalData(), globalObject, JSTextTrackPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
189 }
190
191 bool JSTextTrack::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
192 {
193     JSTextTrack* thisObject = jsCast<JSTextTrack*>(cell);
194     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
195     return getStaticValueSlot<JSTextTrack, Base>(exec, &JSTextTrackTable, thisObject, propertyName, slot);
196 }
197
198 bool JSTextTrack::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
199 {
200     JSTextTrack* thisObject = jsCast<JSTextTrack*>(object);
201     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
202     return getStaticValueDescriptor<JSTextTrack, Base>(exec, &JSTextTrackTable, thisObject, propertyName, descriptor);
203 }
204
205 JSValue jsTextTrackKind(ExecState* exec, JSValue slotBase, const Identifier&)
206 {
207     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(slotBase));
208     UNUSED_PARAM(exec);
209     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
210     JSValue result = jsString(exec, imp->kind());
211     return result;
212 }
213
214
215 JSValue jsTextTrackLabel(ExecState* exec, JSValue slotBase, const Identifier&)
216 {
217     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(slotBase));
218     UNUSED_PARAM(exec);
219     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
220     JSValue result = jsString(exec, imp->label());
221     return result;
222 }
223
224
225 JSValue jsTextTrackLanguage(ExecState* exec, JSValue slotBase, const Identifier&)
226 {
227     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(slotBase));
228     UNUSED_PARAM(exec);
229     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
230     JSValue result = jsString(exec, imp->language());
231     return result;
232 }
233
234
235 JSValue jsTextTrackMode(ExecState* exec, JSValue slotBase, const Identifier&)
236 {
237     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(slotBase));
238     UNUSED_PARAM(exec);
239     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
240     JSValue result = jsNumber(imp->mode());
241     return result;
242 }
243
244
245 JSValue jsTextTrackCues(ExecState* exec, JSValue slotBase, const Identifier&)
246 {
247     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(slotBase));
248     UNUSED_PARAM(exec);
249     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
250     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->cues()));
251     return result;
252 }
253
254
255 JSValue jsTextTrackActiveCues(ExecState* exec, JSValue slotBase, const Identifier&)
256 {
257     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(slotBase));
258     UNUSED_PARAM(exec);
259     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
260     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->activeCues()));
261     return result;
262 }
263
264
265 JSValue jsTextTrackOncuechange(ExecState* exec, JSValue slotBase, const Identifier&)
266 {
267     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(slotBase));
268     UNUSED_PARAM(exec);
269     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
270     if (EventListener* listener = imp->oncuechange()) {
271         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
272             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
273                 return jsFunction;
274         }
275     }
276     return jsNull();
277 }
278
279
280 JSValue jsTextTrackConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
281 {
282     JSTextTrack* domObject = static_cast<JSTextTrack*>(asObject(slotBase));
283     return JSTextTrack::getConstructor(exec, domObject->globalObject());
284 }
285
286 void JSTextTrack::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
287 {
288     JSTextTrack* thisObject = jsCast<JSTextTrack*>(cell);
289     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
290     lookupPut<JSTextTrack, Base>(exec, propertyName, value, &JSTextTrackTable, thisObject, slot);
291 }
292
293 void setJSTextTrackMode(ExecState* exec, JSObject* thisObject, JSValue value)
294 {
295     JSTextTrack* castedThis = static_cast<JSTextTrack*>(thisObject);
296     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
297     ExceptionCode ec = 0;
298     imp->setMode(value.toUInt32(exec), ec);
299     setDOMException(exec, ec);
300 }
301
302
303 void setJSTextTrackOncuechange(ExecState* exec, JSObject* thisObject, JSValue value)
304 {
305     UNUSED_PARAM(exec);
306     JSTextTrack* castedThis = static_cast<JSTextTrack*>(thisObject);
307     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
308     imp->setOncuechange(createJSAttributeEventListener(exec, value, thisObject));
309 }
310
311
312 JSValue JSTextTrack::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
313 {
314     return getDOMConstructor<JSTextTrackConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
315 }
316
317 EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionAddCue(ExecState* exec)
318 {
319     JSValue thisValue = exec->hostThisValue();
320     if (!thisValue.inherits(&JSTextTrack::s_info))
321         return throwVMTypeError(exec);
322     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(thisValue));
323     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTextTrack::s_info);
324     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
325     if (exec->argumentCount() < 1)
326         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
327     ExceptionCode ec = 0;
328     TextTrackCue* cue(toTextTrackCue(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
329     if (exec->hadException())
330         return JSValue::encode(jsUndefined());
331     imp->addCue(cue, ec);
332     setDOMException(exec, ec);
333     return JSValue::encode(jsUndefined());
334 }
335
336 EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionRemoveCue(ExecState* exec)
337 {
338     JSValue thisValue = exec->hostThisValue();
339     if (!thisValue.inherits(&JSTextTrack::s_info))
340         return throwVMTypeError(exec);
341     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(thisValue));
342     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTextTrack::s_info);
343     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
344     if (exec->argumentCount() < 1)
345         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
346     ExceptionCode ec = 0;
347     TextTrackCue* cue(toTextTrackCue(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
348     if (exec->hadException())
349         return JSValue::encode(jsUndefined());
350     imp->removeCue(cue, ec);
351     setDOMException(exec, ec);
352     return JSValue::encode(jsUndefined());
353 }
354
355 EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionAddEventListener(ExecState* exec)
356 {
357     JSValue thisValue = exec->hostThisValue();
358     if (!thisValue.inherits(&JSTextTrack::s_info))
359         return throwVMTypeError(exec);
360     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(thisValue));
361     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTextTrack::s_info);
362     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
363     if (exec->argumentCount() < 2)
364         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
365     JSValue listener = exec->argument(1);
366     if (!listener.isObject())
367         return JSValue::encode(jsUndefined());
368     imp->addEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), exec->argument(2).toBoolean(exec));
369     return JSValue::encode(jsUndefined());
370 }
371
372 EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionRemoveEventListener(ExecState* exec)
373 {
374     JSValue thisValue = exec->hostThisValue();
375     if (!thisValue.inherits(&JSTextTrack::s_info))
376         return throwVMTypeError(exec);
377     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(thisValue));
378     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTextTrack::s_info);
379     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
380     if (exec->argumentCount() < 2)
381         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
382     JSValue listener = exec->argument(1);
383     if (!listener.isObject())
384         return JSValue::encode(jsUndefined());
385     imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec));
386     return JSValue::encode(jsUndefined());
387 }
388
389 EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionDispatchEvent(ExecState* exec)
390 {
391     JSValue thisValue = exec->hostThisValue();
392     if (!thisValue.inherits(&JSTextTrack::s_info))
393         return throwVMTypeError(exec);
394     JSTextTrack* castedThis = static_cast<JSTextTrack*>(asObject(thisValue));
395     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTextTrack::s_info);
396     TextTrack* imp = static_cast<TextTrack*>(castedThis->impl());
397     if (exec->argumentCount() < 1)
398         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
399     ExceptionCode ec = 0;
400     Event* evt(toEvent(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
401     if (exec->hadException())
402         return JSValue::encode(jsUndefined());
403
404     JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec));
405     setDOMException(exec, ec);
406     return JSValue::encode(result);
407 }
408
409 void JSTextTrack::visitChildren(JSCell* cell, SlotVisitor& visitor)
410 {
411     JSTextTrack* thisObject = jsCast<JSTextTrack*>(cell);
412     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
413     COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
414     ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
415     Base::visitChildren(thisObject, visitor);
416     thisObject->impl()->visitJSEventListeners(visitor);
417 }
418
419 // Constant getters
420
421 JSValue jsTextTrackDISABLED(ExecState* exec, JSValue, const Identifier&)
422 {
423     UNUSED_PARAM(exec);
424     return jsNumber(static_cast<int>(0));
425 }
426
427 JSValue jsTextTrackHIDDEN(ExecState* exec, JSValue, const Identifier&)
428 {
429     UNUSED_PARAM(exec);
430     return jsNumber(static_cast<int>(1));
431 }
432
433 JSValue jsTextTrackSHOWING(ExecState* exec, JSValue, const Identifier&)
434 {
435     UNUSED_PARAM(exec);
436     return jsNumber(static_cast<int>(2));
437 }
438
439 static inline bool isObservable(JSTextTrack* jsTextTrack)
440 {
441     if (jsTextTrack->hasCustomProperties())
442         return true;
443     if (jsTextTrack->impl()->hasEventListeners())
444         return true;
445     return false;
446 }
447
448 bool JSTextTrackOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
449 {
450     JSTextTrack* jsTextTrack = static_cast<JSTextTrack*>(handle.get().asCell());
451     if (!isObservable(jsTextTrack))
452         return false;
453     UNUSED_PARAM(visitor);
454     return false;
455 }
456
457 void JSTextTrackOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
458 {
459     JSTextTrack* jsTextTrack = static_cast<JSTextTrack*>(handle.get().asCell());
460     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
461     uncacheWrapper(world, jsTextTrack->impl(), jsTextTrack);
462     jsTextTrack->releaseImpl();
463 }
464
465 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TextTrack* impl)
466 {
467     return wrap<JSTextTrack>(exec, globalObject, impl);
468 }
469
470 TextTrack* toTextTrack(JSC::JSValue value)
471 {
472     return value.inherits(&JSTextTrack::s_info) ? static_cast<JSTextTrack*>(asObject(value))->impl() : 0;
473 }
474
475 }
476
477 #endif // ENABLE(VIDEO_TRACK)