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 "JSTextTrackCue.h"
26
27#include "EventNames.h"
28#include "JSDOMAttribute.h"
29#include "JSDOMBinding.h"
30#include "JSDOMConstructorNotConstructable.h"
31#include "JSDOMConvertBoolean.h"
32#include "JSDOMConvertInterface.h"
33#include "JSDOMConvertNumbers.h"
34#include "JSDOMConvertStrings.h"
35#include "JSDOMExceptionHandling.h"
36#include "JSDOMGlobalObject.h"
37#include "JSDOMWrapperCache.h"
38#include "JSEventListener.h"
39#include "JSTextTrack.h"
40#include "ScriptExecutionContext.h"
41#include <JavaScriptCore/HeapSnapshotBuilder.h>
42#include <JavaScriptCore/JSCInlines.h>
43#include <wtf/GetPtr.h>
44#include <wtf/PointerPreparations.h>
45#include <wtf/URL.h>
46
47
48namespace WebCore {
49using namespace JSC;
50
51// Attributes
52
53JSC::EncodedJSValue jsTextTrackCueConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54bool setJSTextTrackCueConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
55JSC::EncodedJSValue jsTextTrackCueTrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
56JSC::EncodedJSValue jsTextTrackCueId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
57bool setJSTextTrackCueId(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
58JSC::EncodedJSValue jsTextTrackCueStartTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
59bool setJSTextTrackCueStartTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
60JSC::EncodedJSValue jsTextTrackCueEndTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
61bool setJSTextTrackCueEndTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
62JSC::EncodedJSValue jsTextTrackCuePauseOnExit(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
63bool setJSTextTrackCuePauseOnExit(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
64JSC::EncodedJSValue jsTextTrackCueOnenter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
65bool setJSTextTrackCueOnenter(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
66JSC::EncodedJSValue jsTextTrackCueOnexit(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
67bool setJSTextTrackCueOnexit(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
68
69class JSTextTrackCuePrototype : public JSC::JSNonFinalObject {
70public:
71 using Base = JSC::JSNonFinalObject;
72 static JSTextTrackCuePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
73 {
74 JSTextTrackCuePrototype* ptr = new (NotNull, JSC::allocateCell<JSTextTrackCuePrototype>(vm.heap)) JSTextTrackCuePrototype(vm, globalObject, structure);
75 ptr->finishCreation(vm);
76 return ptr;
77 }
78
79 DECLARE_INFO;
80 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
81 {
82 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
83 }
84
85private:
86 JSTextTrackCuePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
87 : JSC::JSNonFinalObject(vm, structure)
88 {
89 }
90
91 void finishCreation(JSC::VM&);
92};
93
94using JSTextTrackCueConstructor = JSDOMConstructorNotConstructable<JSTextTrackCue>;
95
96template<> JSValue JSTextTrackCueConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
97{
98 return JSEventTarget::getConstructor(vm, &globalObject);
99}
100
101template<> void JSTextTrackCueConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
102{
103 putDirect(vm, vm.propertyNames->prototype, JSTextTrackCue::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
104 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TextTrackCue"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
105 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
106}
107
108template<> const ClassInfo JSTextTrackCueConstructor::s_info = { "TextTrackCue", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextTrackCueConstructor) };
109
110/* Hash table for prototype */
111
112static const HashTableValue JSTextTrackCuePrototypeTableValues[] =
113{
114 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCueConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackCueConstructor) } },
115 { "track", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCueTrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
116 { "id", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCueId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackCueId) } },
117 { "startTime", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCueStartTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackCueStartTime) } },
118 { "endTime", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCueEndTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackCueEndTime) } },
119 { "pauseOnExit", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCuePauseOnExit), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackCuePauseOnExit) } },
120 { "onenter", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCueOnenter), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackCueOnenter) } },
121 { "onexit", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCueOnexit), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackCueOnexit) } },
122};
123
124const ClassInfo JSTextTrackCuePrototype::s_info = { "TextTrackCuePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextTrackCuePrototype) };
125
126void JSTextTrackCuePrototype::finishCreation(VM& vm)
127{
128 Base::finishCreation(vm);
129 reifyStaticProperties(vm, JSTextTrackCue::info(), JSTextTrackCuePrototypeTableValues, *this);
130}
131
132const ClassInfo JSTextTrackCue::s_info = { "TextTrackCue", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextTrackCue) };
133
134JSTextTrackCue::JSTextTrackCue(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TextTrackCue>&& impl)
135 : JSEventTarget(structure, globalObject, WTFMove(impl))
136{
137}
138
139void JSTextTrackCue::finishCreation(VM& vm)
140{
141 Base::finishCreation(vm);
142 ASSERT(inherits(vm, info()));
143
144}
145
146JSObject* JSTextTrackCue::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
147{
148 return JSTextTrackCuePrototype::create(vm, &globalObject, JSTextTrackCuePrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject)));
149}
150
151JSObject* JSTextTrackCue::prototype(VM& vm, JSDOMGlobalObject& globalObject)
152{
153 return getDOMPrototype<JSTextTrackCue>(vm, globalObject);
154}
155
156JSValue JSTextTrackCue::getConstructor(VM& vm, const JSGlobalObject* globalObject)
157{
158 return getDOMConstructor<JSTextTrackCueConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
159}
160
161template<> inline JSTextTrackCue* IDLAttribute<JSTextTrackCue>::cast(ExecState& state, EncodedJSValue thisValue)
162{
163 return jsDynamicCast<JSTextTrackCue*>(state.vm(), JSValue::decode(thisValue));
164}
165
166EncodedJSValue jsTextTrackCueConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
167{
168 VM& vm = state->vm();
169 auto throwScope = DECLARE_THROW_SCOPE(vm);
170 auto* prototype = jsDynamicCast<JSTextTrackCuePrototype*>(vm, JSValue::decode(thisValue));
171 if (UNLIKELY(!prototype))
172 return throwVMTypeError(state, throwScope);
173 return JSValue::encode(JSTextTrackCue::getConstructor(state->vm(), prototype->globalObject()));
174}
175
176bool setJSTextTrackCueConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
177{
178 VM& vm = state->vm();
179 auto throwScope = DECLARE_THROW_SCOPE(vm);
180 auto* prototype = jsDynamicCast<JSTextTrackCuePrototype*>(vm, JSValue::decode(thisValue));
181 if (UNLIKELY(!prototype)) {
182 throwVMTypeError(state, throwScope);
183 return false;
184 }
185 // Shadowing a built-in constructor
186 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
187}
188
189static inline JSValue jsTextTrackCueTrackGetter(ExecState& state, JSTextTrackCue& thisObject, ThrowScope& throwScope)
190{
191 UNUSED_PARAM(throwScope);
192 UNUSED_PARAM(state);
193 auto& impl = thisObject.wrapped();
194 JSValue result = toJS<IDLInterface<TextTrack>>(state, *thisObject.globalObject(), throwScope, impl.track());
195 return result;
196}
197
198EncodedJSValue jsTextTrackCueTrack(ExecState* state, EncodedJSValue thisValue, PropertyName)
199{
200 return IDLAttribute<JSTextTrackCue>::get<jsTextTrackCueTrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "track");
201}
202
203static inline JSValue jsTextTrackCueIdGetter(ExecState& state, JSTextTrackCue& thisObject, ThrowScope& throwScope)
204{
205 UNUSED_PARAM(throwScope);
206 UNUSED_PARAM(state);
207 auto& impl = thisObject.wrapped();
208 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.id());
209 return result;
210}
211
212EncodedJSValue jsTextTrackCueId(ExecState* state, EncodedJSValue thisValue, PropertyName)
213{
214 return IDLAttribute<JSTextTrackCue>::get<jsTextTrackCueIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "id");
215}
216
217static inline bool setJSTextTrackCueIdSetter(ExecState& state, JSTextTrackCue& thisObject, JSValue value, ThrowScope& throwScope)
218{
219 UNUSED_PARAM(throwScope);
220 auto& impl = thisObject.wrapped();
221 auto nativeValue = convert<IDLDOMString>(state, value);
222 RETURN_IF_EXCEPTION(throwScope, false);
223 AttributeSetter::call(state, throwScope, [&] {
224 return impl.setId(WTFMove(nativeValue));
225 });
226 return true;
227}
228
229bool setJSTextTrackCueId(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
230{
231 return IDLAttribute<JSTextTrackCue>::set<setJSTextTrackCueIdSetter>(*state, thisValue, encodedValue, "id");
232}
233
234static inline JSValue jsTextTrackCueStartTimeGetter(ExecState& state, JSTextTrackCue& thisObject, ThrowScope& throwScope)
235{
236 UNUSED_PARAM(throwScope);
237 UNUSED_PARAM(state);
238 auto& impl = thisObject.wrapped();
239 JSValue result = toJS<IDLDouble>(state, throwScope, impl.startTime());
240 return result;
241}
242
243EncodedJSValue jsTextTrackCueStartTime(ExecState* state, EncodedJSValue thisValue, PropertyName)
244{
245 return IDLAttribute<JSTextTrackCue>::get<jsTextTrackCueStartTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "startTime");
246}
247
248static inline bool setJSTextTrackCueStartTimeSetter(ExecState& state, JSTextTrackCue& thisObject, JSValue value, ThrowScope& throwScope)
249{
250 UNUSED_PARAM(throwScope);
251 auto& impl = thisObject.wrapped();
252 auto nativeValue = convert<IDLDouble>(state, value);
253 RETURN_IF_EXCEPTION(throwScope, false);
254 AttributeSetter::call(state, throwScope, [&] {
255 return impl.setStartTime(WTFMove(nativeValue));
256 });
257 return true;
258}
259
260bool setJSTextTrackCueStartTime(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
261{
262 return IDLAttribute<JSTextTrackCue>::set<setJSTextTrackCueStartTimeSetter>(*state, thisValue, encodedValue, "startTime");
263}
264
265static inline JSValue jsTextTrackCueEndTimeGetter(ExecState& state, JSTextTrackCue& thisObject, ThrowScope& throwScope)
266{
267 UNUSED_PARAM(throwScope);
268 UNUSED_PARAM(state);
269 auto& impl = thisObject.wrapped();
270 JSValue result = toJS<IDLDouble>(state, throwScope, impl.endTime());
271 return result;
272}
273
274EncodedJSValue jsTextTrackCueEndTime(ExecState* state, EncodedJSValue thisValue, PropertyName)
275{
276 return IDLAttribute<JSTextTrackCue>::get<jsTextTrackCueEndTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "endTime");
277}
278
279static inline bool setJSTextTrackCueEndTimeSetter(ExecState& state, JSTextTrackCue& thisObject, JSValue value, ThrowScope& throwScope)
280{
281 UNUSED_PARAM(throwScope);
282 auto& impl = thisObject.wrapped();
283 auto nativeValue = convert<IDLDouble>(state, value);
284 RETURN_IF_EXCEPTION(throwScope, false);
285 AttributeSetter::call(state, throwScope, [&] {
286 return impl.setEndTime(WTFMove(nativeValue));
287 });
288 return true;
289}
290
291bool setJSTextTrackCueEndTime(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
292{
293 return IDLAttribute<JSTextTrackCue>::set<setJSTextTrackCueEndTimeSetter>(*state, thisValue, encodedValue, "endTime");
294}
295
296static inline JSValue jsTextTrackCuePauseOnExitGetter(ExecState& state, JSTextTrackCue& thisObject, ThrowScope& throwScope)
297{
298 UNUSED_PARAM(throwScope);
299 UNUSED_PARAM(state);
300 auto& impl = thisObject.wrapped();
301 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.pauseOnExit());
302 return result;
303}
304
305EncodedJSValue jsTextTrackCuePauseOnExit(ExecState* state, EncodedJSValue thisValue, PropertyName)
306{
307 return IDLAttribute<JSTextTrackCue>::get<jsTextTrackCuePauseOnExitGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pauseOnExit");
308}
309
310static inline bool setJSTextTrackCuePauseOnExitSetter(ExecState& state, JSTextTrackCue& thisObject, JSValue value, ThrowScope& throwScope)
311{
312 UNUSED_PARAM(throwScope);
313 auto& impl = thisObject.wrapped();
314 auto nativeValue = convert<IDLBoolean>(state, value);
315 RETURN_IF_EXCEPTION(throwScope, false);
316 AttributeSetter::call(state, throwScope, [&] {
317 return impl.setPauseOnExit(WTFMove(nativeValue));
318 });
319 return true;
320}
321
322bool setJSTextTrackCuePauseOnExit(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
323{
324 return IDLAttribute<JSTextTrackCue>::set<setJSTextTrackCuePauseOnExitSetter>(*state, thisValue, encodedValue, "pauseOnExit");
325}
326
327static inline JSValue jsTextTrackCueOnenterGetter(ExecState& state, JSTextTrackCue& thisObject, ThrowScope& throwScope)
328{
329 UNUSED_PARAM(throwScope);
330 UNUSED_PARAM(state);
331 return eventHandlerAttribute(thisObject.wrapped(), eventNames().enterEvent, worldForDOMObject(thisObject));
332}
333
334EncodedJSValue jsTextTrackCueOnenter(ExecState* state, EncodedJSValue thisValue, PropertyName)
335{
336 return IDLAttribute<JSTextTrackCue>::get<jsTextTrackCueOnenterGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onenter");
337}
338
339static inline bool setJSTextTrackCueOnenterSetter(ExecState& state, JSTextTrackCue& thisObject, JSValue value, ThrowScope& throwScope)
340{
341 UNUSED_PARAM(throwScope);
342 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().enterEvent, value);
343 return true;
344}
345
346bool setJSTextTrackCueOnenter(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
347{
348 return IDLAttribute<JSTextTrackCue>::set<setJSTextTrackCueOnenterSetter>(*state, thisValue, encodedValue, "onenter");
349}
350
351static inline JSValue jsTextTrackCueOnexitGetter(ExecState& state, JSTextTrackCue& thisObject, ThrowScope& throwScope)
352{
353 UNUSED_PARAM(throwScope);
354 UNUSED_PARAM(state);
355 return eventHandlerAttribute(thisObject.wrapped(), eventNames().exitEvent, worldForDOMObject(thisObject));
356}
357
358EncodedJSValue jsTextTrackCueOnexit(ExecState* state, EncodedJSValue thisValue, PropertyName)
359{
360 return IDLAttribute<JSTextTrackCue>::get<jsTextTrackCueOnexitGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onexit");
361}
362
363static inline bool setJSTextTrackCueOnexitSetter(ExecState& state, JSTextTrackCue& thisObject, JSValue value, ThrowScope& throwScope)
364{
365 UNUSED_PARAM(throwScope);
366 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().exitEvent, value);
367 return true;
368}
369
370bool setJSTextTrackCueOnexit(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
371{
372 return IDLAttribute<JSTextTrackCue>::set<setJSTextTrackCueOnexitSetter>(*state, thisValue, encodedValue, "onexit");
373}
374
375void JSTextTrackCue::visitChildren(JSCell* cell, SlotVisitor& visitor)
376{
377 auto* thisObject = jsCast<JSTextTrackCue*>(cell);
378 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
379 Base::visitChildren(thisObject, visitor);
380 thisObject->visitAdditionalChildren(visitor);
381}
382
383void JSTextTrackCue::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor)
384{
385 auto* thisObject = jsCast<JSTextTrackCue*>(cell);
386 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
387 Base::visitOutputConstraints(thisObject, visitor);
388 thisObject->visitAdditionalChildren(visitor);
389}
390
391void JSTextTrackCue::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
392{
393 auto* thisObject = jsCast<JSTextTrackCue*>(cell);
394 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
395 if (thisObject->scriptExecutionContext())
396 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
397 Base::heapSnapshot(cell, builder);
398}
399
400void JSTextTrackCueOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
401{
402 auto* jsTextTrackCue = static_cast<JSTextTrackCue*>(handle.slot()->asCell());
403 auto& world = *static_cast<DOMWrapperWorld*>(context);
404 uncacheWrapper(world, &jsTextTrackCue->wrapped(), jsTextTrackCue);
405}
406
407TextTrackCue* JSTextTrackCue::toWrapped(JSC::VM& vm, JSC::JSValue value)
408{
409 if (auto* wrapper = jsDynamicCast<JSTextTrackCue*>(vm, value))
410 return &wrapper->wrapped();
411 return nullptr;
412}
413
414}
415
416#endif // ENABLE(VIDEO_TRACK)
417