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 "Element.h" |
28 | #include "EventNames.h" |
29 | #include "JSDOMAttribute.h" |
30 | #include "JSDOMBinding.h" |
31 | #include "JSDOMConstructorNotConstructable.h" |
32 | #include "JSDOMConvertInterface.h" |
33 | #include "JSDOMConvertNullable.h" |
34 | #include "JSDOMConvertStrings.h" |
35 | #include "JSDOMExceptionHandling.h" |
36 | #include "JSDOMGlobalObject.h" |
37 | #include "JSDOMOperation.h" |
38 | #include "JSDOMWrapperCache.h" |
39 | #include "JSEventListener.h" |
40 | #include "JSNodeCustom.h" |
41 | #include "JSTextTrackCue.h" |
42 | #include "JSTextTrackCueList.h" |
43 | #include "JSVTTRegion.h" |
44 | #include "JSVTTRegionList.h" |
45 | #include "ScriptExecutionContext.h" |
46 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
47 | #include <JavaScriptCore/JSCInlines.h> |
48 | #include <JavaScriptCore/JSString.h> |
49 | #include <wtf/GetPtr.h> |
50 | #include <wtf/PointerPreparations.h> |
51 | #include <wtf/URL.h> |
52 | |
53 | #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK) |
54 | #include "JSSourceBuffer.h" |
55 | #include "TextTrackMediaSource.h" |
56 | #endif |
57 | |
58 | |
59 | namespace WebCore { |
60 | using namespace JSC; |
61 | |
62 | String convertEnumerationToString(TextTrack::Mode enumerationValue) |
63 | { |
64 | static const NeverDestroyed<String> values[] = { |
65 | MAKE_STATIC_STRING_IMPL("disabled" ), |
66 | MAKE_STATIC_STRING_IMPL("hidden" ), |
67 | MAKE_STATIC_STRING_IMPL("showing" ), |
68 | }; |
69 | static_assert(static_cast<size_t>(TextTrack::Mode::Disabled) == 0, "TextTrack::Mode::Disabled is not 0 as expected" ); |
70 | static_assert(static_cast<size_t>(TextTrack::Mode::Hidden) == 1, "TextTrack::Mode::Hidden is not 1 as expected" ); |
71 | static_assert(static_cast<size_t>(TextTrack::Mode::Showing) == 2, "TextTrack::Mode::Showing is not 2 as expected" ); |
72 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
73 | return values[static_cast<size_t>(enumerationValue)]; |
74 | } |
75 | |
76 | template<> JSString* convertEnumerationToJS(ExecState& state, TextTrack::Mode enumerationValue) |
77 | { |
78 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
79 | } |
80 | |
81 | template<> Optional<TextTrack::Mode> parseEnumeration<TextTrack::Mode>(ExecState& state, JSValue value) |
82 | { |
83 | auto stringValue = value.toWTFString(&state); |
84 | if (stringValue == "disabled" ) |
85 | return TextTrack::Mode::Disabled; |
86 | if (stringValue == "hidden" ) |
87 | return TextTrack::Mode::Hidden; |
88 | if (stringValue == "showing" ) |
89 | return TextTrack::Mode::Showing; |
90 | return WTF::nullopt; |
91 | } |
92 | |
93 | template<> const char* expectedEnumerationValues<TextTrack::Mode>() |
94 | { |
95 | return "\"disabled\", \"hidden\", \"showing\"" ; |
96 | } |
97 | |
98 | String convertEnumerationToString(TextTrack::Kind enumerationValue) |
99 | { |
100 | static const NeverDestroyed<String> values[] = { |
101 | MAKE_STATIC_STRING_IMPL("subtitles" ), |
102 | MAKE_STATIC_STRING_IMPL("captions" ), |
103 | MAKE_STATIC_STRING_IMPL("descriptions" ), |
104 | MAKE_STATIC_STRING_IMPL("chapters" ), |
105 | MAKE_STATIC_STRING_IMPL("metadata" ), |
106 | MAKE_STATIC_STRING_IMPL("forced" ), |
107 | }; |
108 | static_assert(static_cast<size_t>(TextTrack::Kind::Subtitles) == 0, "TextTrack::Kind::Subtitles is not 0 as expected" ); |
109 | static_assert(static_cast<size_t>(TextTrack::Kind::Captions) == 1, "TextTrack::Kind::Captions is not 1 as expected" ); |
110 | static_assert(static_cast<size_t>(TextTrack::Kind::Descriptions) == 2, "TextTrack::Kind::Descriptions is not 2 as expected" ); |
111 | static_assert(static_cast<size_t>(TextTrack::Kind::Chapters) == 3, "TextTrack::Kind::Chapters is not 3 as expected" ); |
112 | static_assert(static_cast<size_t>(TextTrack::Kind::Metadata) == 4, "TextTrack::Kind::Metadata is not 4 as expected" ); |
113 | static_assert(static_cast<size_t>(TextTrack::Kind::Forced) == 5, "TextTrack::Kind::Forced is not 5 as expected" ); |
114 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
115 | return values[static_cast<size_t>(enumerationValue)]; |
116 | } |
117 | |
118 | template<> JSString* convertEnumerationToJS(ExecState& state, TextTrack::Kind enumerationValue) |
119 | { |
120 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
121 | } |
122 | |
123 | template<> Optional<TextTrack::Kind> parseEnumeration<TextTrack::Kind>(ExecState& state, JSValue value) |
124 | { |
125 | auto stringValue = value.toWTFString(&state); |
126 | if (stringValue == "subtitles" ) |
127 | return TextTrack::Kind::Subtitles; |
128 | if (stringValue == "captions" ) |
129 | return TextTrack::Kind::Captions; |
130 | if (stringValue == "descriptions" ) |
131 | return TextTrack::Kind::Descriptions; |
132 | if (stringValue == "chapters" ) |
133 | return TextTrack::Kind::Chapters; |
134 | if (stringValue == "metadata" ) |
135 | return TextTrack::Kind::Metadata; |
136 | if (stringValue == "forced" ) |
137 | return TextTrack::Kind::Forced; |
138 | return WTF::nullopt; |
139 | } |
140 | |
141 | template<> const char* expectedEnumerationValues<TextTrack::Kind>() |
142 | { |
143 | return "\"subtitles\", \"captions\", \"descriptions\", \"chapters\", \"metadata\", \"forced\"" ; |
144 | } |
145 | |
146 | // Functions |
147 | |
148 | JSC::EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionAddCue(JSC::ExecState*); |
149 | JSC::EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionRemoveCue(JSC::ExecState*); |
150 | JSC::EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionAddRegion(JSC::ExecState*); |
151 | JSC::EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionRemoveRegion(JSC::ExecState*); |
152 | |
153 | // Attributes |
154 | |
155 | JSC::EncodedJSValue jsTextTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
156 | bool setJSTextTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
157 | JSC::EncodedJSValue jsTextTrackId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
158 | JSC::EncodedJSValue jsTextTrackKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
159 | bool setJSTextTrackKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
160 | JSC::EncodedJSValue jsTextTrackLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
161 | JSC::EncodedJSValue jsTextTrackLanguage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
162 | #if ENABLE(MEDIA_SOURCE) |
163 | bool setJSTextTrackLanguage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
164 | #endif |
165 | JSC::EncodedJSValue jsTextTrackInBandMetadataTrackDispatchType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
166 | JSC::EncodedJSValue jsTextTrackMode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
167 | bool setJSTextTrackMode(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
168 | JSC::EncodedJSValue jsTextTrackCues(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
169 | JSC::EncodedJSValue jsTextTrackActiveCues(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
170 | JSC::EncodedJSValue jsTextTrackOncuechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
171 | bool setJSTextTrackOncuechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
172 | JSC::EncodedJSValue jsTextTrackRegions(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
173 | #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK) |
174 | JSC::EncodedJSValue jsTextTrackSourceBuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
175 | #endif |
176 | |
177 | class JSTextTrackPrototype : public JSC::JSNonFinalObject { |
178 | public: |
179 | using Base = JSC::JSNonFinalObject; |
180 | static JSTextTrackPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
181 | { |
182 | JSTextTrackPrototype* ptr = new (NotNull, JSC::allocateCell<JSTextTrackPrototype>(vm.heap)) JSTextTrackPrototype(vm, globalObject, structure); |
183 | ptr->finishCreation(vm); |
184 | return ptr; |
185 | } |
186 | |
187 | DECLARE_INFO; |
188 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
189 | { |
190 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
191 | } |
192 | |
193 | private: |
194 | JSTextTrackPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
195 | : JSC::JSNonFinalObject(vm, structure) |
196 | { |
197 | } |
198 | |
199 | void finishCreation(JSC::VM&); |
200 | }; |
201 | |
202 | using JSTextTrackConstructor = JSDOMConstructorNotConstructable<JSTextTrack>; |
203 | |
204 | template<> JSValue JSTextTrackConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
205 | { |
206 | return JSEventTarget::getConstructor(vm, &globalObject); |
207 | } |
208 | |
209 | template<> void JSTextTrackConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
210 | { |
211 | putDirect(vm, vm.propertyNames->prototype, JSTextTrack::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
212 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TextTrack"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
213 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
214 | } |
215 | |
216 | template<> const ClassInfo JSTextTrackConstructor::s_info = { "TextTrack" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextTrackConstructor) }; |
217 | |
218 | /* Hash table for prototype */ |
219 | |
220 | static const HashTableValue JSTextTrackPrototypeTableValues[] = |
221 | { |
222 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackConstructor) } }, |
223 | { "id" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
224 | { "kind" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackKind), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackKind) } }, |
225 | { "label" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackLabel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
226 | #if ENABLE(MEDIA_SOURCE) |
227 | { "language" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackLanguage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackLanguage) } }, |
228 | #else |
229 | { "language" , JSC::PropertyAttribute::ReadOnly | static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackLanguage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
230 | #endif |
231 | { "inBandMetadataTrackDispatchType" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackInBandMetadataTrackDispatchType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
232 | { "mode" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackMode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackMode) } }, |
233 | { "cues" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCues), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
234 | { "activeCues" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackActiveCues), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
235 | { "oncuechange" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackOncuechange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackOncuechange) } }, |
236 | { "regions" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackRegions), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
237 | #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK) |
238 | { "sourceBuffer" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackSourceBuffer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
239 | #else |
240 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
241 | #endif |
242 | { "addCue" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTextTrackPrototypeFunctionAddCue), (intptr_t) (1) } }, |
243 | { "removeCue" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTextTrackPrototypeFunctionRemoveCue), (intptr_t) (1) } }, |
244 | { "addRegion" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTextTrackPrototypeFunctionAddRegion), (intptr_t) (1) } }, |
245 | { "removeRegion" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTextTrackPrototypeFunctionRemoveRegion), (intptr_t) (1) } }, |
246 | }; |
247 | |
248 | const ClassInfo JSTextTrackPrototype::s_info = { "TextTrackPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextTrackPrototype) }; |
249 | |
250 | void JSTextTrackPrototype::finishCreation(VM& vm) |
251 | { |
252 | Base::finishCreation(vm); |
253 | reifyStaticProperties(vm, JSTextTrack::info(), JSTextTrackPrototypeTableValues, *this); |
254 | } |
255 | |
256 | const ClassInfo JSTextTrack::s_info = { "TextTrack" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextTrack) }; |
257 | |
258 | JSTextTrack::JSTextTrack(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TextTrack>&& impl) |
259 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
260 | { |
261 | } |
262 | |
263 | void JSTextTrack::finishCreation(VM& vm) |
264 | { |
265 | Base::finishCreation(vm); |
266 | ASSERT(inherits(vm, info())); |
267 | |
268 | } |
269 | |
270 | JSObject* JSTextTrack::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
271 | { |
272 | return JSTextTrackPrototype::create(vm, &globalObject, JSTextTrackPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
273 | } |
274 | |
275 | JSObject* JSTextTrack::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
276 | { |
277 | return getDOMPrototype<JSTextTrack>(vm, globalObject); |
278 | } |
279 | |
280 | JSValue JSTextTrack::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
281 | { |
282 | return getDOMConstructor<JSTextTrackConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
283 | } |
284 | |
285 | template<> inline JSTextTrack* IDLAttribute<JSTextTrack>::cast(ExecState& state, EncodedJSValue thisValue) |
286 | { |
287 | return jsDynamicCast<JSTextTrack*>(state.vm(), JSValue::decode(thisValue)); |
288 | } |
289 | |
290 | template<> inline JSTextTrack* IDLOperation<JSTextTrack>::cast(ExecState& state) |
291 | { |
292 | return jsDynamicCast<JSTextTrack*>(state.vm(), state.thisValue()); |
293 | } |
294 | |
295 | EncodedJSValue jsTextTrackConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
296 | { |
297 | VM& vm = state->vm(); |
298 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
299 | auto* prototype = jsDynamicCast<JSTextTrackPrototype*>(vm, JSValue::decode(thisValue)); |
300 | if (UNLIKELY(!prototype)) |
301 | return throwVMTypeError(state, throwScope); |
302 | return JSValue::encode(JSTextTrack::getConstructor(state->vm(), prototype->globalObject())); |
303 | } |
304 | |
305 | bool setJSTextTrackConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
306 | { |
307 | VM& vm = state->vm(); |
308 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
309 | auto* prototype = jsDynamicCast<JSTextTrackPrototype*>(vm, JSValue::decode(thisValue)); |
310 | if (UNLIKELY(!prototype)) { |
311 | throwVMTypeError(state, throwScope); |
312 | return false; |
313 | } |
314 | // Shadowing a built-in constructor |
315 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
316 | } |
317 | |
318 | static inline JSValue jsTextTrackIdGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
319 | { |
320 | UNUSED_PARAM(throwScope); |
321 | UNUSED_PARAM(state); |
322 | auto& impl = thisObject.wrapped(); |
323 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.id()); |
324 | return result; |
325 | } |
326 | |
327 | EncodedJSValue jsTextTrackId(ExecState* state, EncodedJSValue thisValue, PropertyName) |
328 | { |
329 | return IDLAttribute<JSTextTrack>::get<jsTextTrackIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "id" ); |
330 | } |
331 | |
332 | static inline JSValue jsTextTrackKindGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
333 | { |
334 | UNUSED_PARAM(throwScope); |
335 | UNUSED_PARAM(state); |
336 | auto& impl = thisObject.wrapped(); |
337 | JSValue result = toJS<IDLEnumeration<TextTrack::Kind>>(state, throwScope, impl.kindForBindings()); |
338 | return result; |
339 | } |
340 | |
341 | EncodedJSValue jsTextTrackKind(ExecState* state, EncodedJSValue thisValue, PropertyName) |
342 | { |
343 | return IDLAttribute<JSTextTrack>::get<jsTextTrackKindGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "kind" ); |
344 | } |
345 | |
346 | static inline bool setJSTextTrackKindSetter(ExecState& state, JSTextTrack& thisObject, JSValue value, ThrowScope& throwScope) |
347 | { |
348 | UNUSED_PARAM(throwScope); |
349 | auto& impl = thisObject.wrapped(); |
350 | auto optionalNativeValue = parseEnumeration<TextTrack::Kind>(state, value); |
351 | RETURN_IF_EXCEPTION(throwScope, false); |
352 | if (UNLIKELY(!optionalNativeValue)) |
353 | return false; |
354 | auto nativeValue = optionalNativeValue.value(); |
355 | AttributeSetter::call(state, throwScope, [&] { |
356 | return impl.setKindForBindings(WTFMove(nativeValue)); |
357 | }); |
358 | return true; |
359 | } |
360 | |
361 | bool setJSTextTrackKind(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
362 | { |
363 | return IDLAttribute<JSTextTrack>::set<setJSTextTrackKindSetter>(*state, thisValue, encodedValue, "kind" ); |
364 | } |
365 | |
366 | static inline JSValue jsTextTrackLabelGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
367 | { |
368 | UNUSED_PARAM(throwScope); |
369 | UNUSED_PARAM(state); |
370 | auto& impl = thisObject.wrapped(); |
371 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.label()); |
372 | return result; |
373 | } |
374 | |
375 | EncodedJSValue jsTextTrackLabel(ExecState* state, EncodedJSValue thisValue, PropertyName) |
376 | { |
377 | return IDLAttribute<JSTextTrack>::get<jsTextTrackLabelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "label" ); |
378 | } |
379 | |
380 | static inline JSValue jsTextTrackLanguageGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
381 | { |
382 | UNUSED_PARAM(throwScope); |
383 | UNUSED_PARAM(state); |
384 | auto& impl = thisObject.wrapped(); |
385 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.language()); |
386 | return result; |
387 | } |
388 | |
389 | EncodedJSValue jsTextTrackLanguage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
390 | { |
391 | return IDLAttribute<JSTextTrack>::get<jsTextTrackLanguageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "language" ); |
392 | } |
393 | |
394 | #if ENABLE(MEDIA_SOURCE) |
395 | static inline bool setJSTextTrackLanguageSetter(ExecState& state, JSTextTrack& thisObject, JSValue value, ThrowScope& throwScope) |
396 | { |
397 | UNUSED_PARAM(throwScope); |
398 | auto& impl = thisObject.wrapped(); |
399 | auto nativeValue = convert<IDLDOMString>(state, value); |
400 | RETURN_IF_EXCEPTION(throwScope, false); |
401 | AttributeSetter::call(state, throwScope, [&] { |
402 | return impl.setLanguage(WTFMove(nativeValue)); |
403 | }); |
404 | return true; |
405 | } |
406 | |
407 | bool setJSTextTrackLanguage(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
408 | { |
409 | return IDLAttribute<JSTextTrack>::set<setJSTextTrackLanguageSetter>(*state, thisValue, encodedValue, "language" ); |
410 | } |
411 | |
412 | #endif |
413 | |
414 | static inline JSValue jsTextTrackInBandMetadataTrackDispatchTypeGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
415 | { |
416 | UNUSED_PARAM(throwScope); |
417 | UNUSED_PARAM(state); |
418 | auto& impl = thisObject.wrapped(); |
419 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.inBandMetadataTrackDispatchType()); |
420 | return result; |
421 | } |
422 | |
423 | EncodedJSValue jsTextTrackInBandMetadataTrackDispatchType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
424 | { |
425 | return IDLAttribute<JSTextTrack>::get<jsTextTrackInBandMetadataTrackDispatchTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "inBandMetadataTrackDispatchType" ); |
426 | } |
427 | |
428 | static inline JSValue jsTextTrackModeGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
429 | { |
430 | UNUSED_PARAM(throwScope); |
431 | UNUSED_PARAM(state); |
432 | auto& impl = thisObject.wrapped(); |
433 | JSValue result = toJS<IDLEnumeration<TextTrack::Mode>>(state, throwScope, impl.mode()); |
434 | return result; |
435 | } |
436 | |
437 | EncodedJSValue jsTextTrackMode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
438 | { |
439 | return IDLAttribute<JSTextTrack>::get<jsTextTrackModeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "mode" ); |
440 | } |
441 | |
442 | static inline bool setJSTextTrackModeSetter(ExecState& state, JSTextTrack& thisObject, JSValue value, ThrowScope& throwScope) |
443 | { |
444 | UNUSED_PARAM(throwScope); |
445 | auto& impl = thisObject.wrapped(); |
446 | auto optionalNativeValue = parseEnumeration<TextTrack::Mode>(state, value); |
447 | RETURN_IF_EXCEPTION(throwScope, false); |
448 | if (UNLIKELY(!optionalNativeValue)) |
449 | return false; |
450 | auto nativeValue = optionalNativeValue.value(); |
451 | AttributeSetter::call(state, throwScope, [&] { |
452 | return impl.setMode(WTFMove(nativeValue)); |
453 | }); |
454 | return true; |
455 | } |
456 | |
457 | bool setJSTextTrackMode(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
458 | { |
459 | return IDLAttribute<JSTextTrack>::set<setJSTextTrackModeSetter>(*state, thisValue, encodedValue, "mode" ); |
460 | } |
461 | |
462 | static inline JSValue jsTextTrackCuesGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
463 | { |
464 | UNUSED_PARAM(throwScope); |
465 | UNUSED_PARAM(state); |
466 | auto& impl = thisObject.wrapped(); |
467 | JSValue result = toJS<IDLNullable<IDLInterface<TextTrackCueList>>>(state, *thisObject.globalObject(), throwScope, impl.cues()); |
468 | return result; |
469 | } |
470 | |
471 | EncodedJSValue jsTextTrackCues(ExecState* state, EncodedJSValue thisValue, PropertyName) |
472 | { |
473 | return IDLAttribute<JSTextTrack>::get<jsTextTrackCuesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "cues" ); |
474 | } |
475 | |
476 | static inline JSValue jsTextTrackActiveCuesGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
477 | { |
478 | UNUSED_PARAM(throwScope); |
479 | UNUSED_PARAM(state); |
480 | auto& impl = thisObject.wrapped(); |
481 | JSValue result = toJS<IDLNullable<IDLInterface<TextTrackCueList>>>(state, *thisObject.globalObject(), throwScope, impl.activeCues()); |
482 | return result; |
483 | } |
484 | |
485 | EncodedJSValue jsTextTrackActiveCues(ExecState* state, EncodedJSValue thisValue, PropertyName) |
486 | { |
487 | return IDLAttribute<JSTextTrack>::get<jsTextTrackActiveCuesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "activeCues" ); |
488 | } |
489 | |
490 | static inline JSValue jsTextTrackOncuechangeGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
491 | { |
492 | UNUSED_PARAM(throwScope); |
493 | UNUSED_PARAM(state); |
494 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().cuechangeEvent, worldForDOMObject(thisObject)); |
495 | } |
496 | |
497 | EncodedJSValue jsTextTrackOncuechange(ExecState* state, EncodedJSValue thisValue, PropertyName) |
498 | { |
499 | return IDLAttribute<JSTextTrack>::get<jsTextTrackOncuechangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "oncuechange" ); |
500 | } |
501 | |
502 | static inline bool setJSTextTrackOncuechangeSetter(ExecState& state, JSTextTrack& thisObject, JSValue value, ThrowScope& throwScope) |
503 | { |
504 | UNUSED_PARAM(throwScope); |
505 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().cuechangeEvent, value); |
506 | return true; |
507 | } |
508 | |
509 | bool setJSTextTrackOncuechange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
510 | { |
511 | return IDLAttribute<JSTextTrack>::set<setJSTextTrackOncuechangeSetter>(*state, thisValue, encodedValue, "oncuechange" ); |
512 | } |
513 | |
514 | static inline JSValue jsTextTrackRegionsGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
515 | { |
516 | UNUSED_PARAM(throwScope); |
517 | UNUSED_PARAM(state); |
518 | auto& impl = thisObject.wrapped(); |
519 | JSValue result = toJS<IDLInterface<VTTRegionList>>(state, *thisObject.globalObject(), throwScope, impl.regions()); |
520 | return result; |
521 | } |
522 | |
523 | EncodedJSValue jsTextTrackRegions(ExecState* state, EncodedJSValue thisValue, PropertyName) |
524 | { |
525 | return IDLAttribute<JSTextTrack>::get<jsTextTrackRegionsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "regions" ); |
526 | } |
527 | |
528 | #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK) |
529 | static inline JSValue jsTextTrackSourceBufferGetter(ExecState& state, JSTextTrack& thisObject, ThrowScope& throwScope) |
530 | { |
531 | UNUSED_PARAM(throwScope); |
532 | UNUSED_PARAM(state); |
533 | auto& impl = thisObject.wrapped(); |
534 | JSValue result = toJS<IDLNullable<IDLInterface<SourceBuffer>>>(state, *thisObject.globalObject(), throwScope, WebCore::TextTrackMediaSource::sourceBuffer(impl)); |
535 | return result; |
536 | } |
537 | |
538 | EncodedJSValue jsTextTrackSourceBuffer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
539 | { |
540 | return IDLAttribute<JSTextTrack>::get<jsTextTrackSourceBufferGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sourceBuffer" ); |
541 | } |
542 | |
543 | #endif |
544 | |
545 | static inline JSC::EncodedJSValue jsTextTrackPrototypeFunctionAddCueBody(JSC::ExecState* state, typename IDLOperation<JSTextTrack>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
546 | { |
547 | UNUSED_PARAM(state); |
548 | UNUSED_PARAM(throwScope); |
549 | auto& impl = castedThis->wrapped(); |
550 | if (UNLIKELY(state->argumentCount() < 1)) |
551 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
552 | auto cue = convert<IDLInterface<TextTrackCue>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "cue" , "TextTrack" , "addCue" , "TextTrackCue" ); }); |
553 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
554 | propagateException(*state, throwScope, impl.addCue(*cue)); |
555 | return JSValue::encode(jsUndefined()); |
556 | } |
557 | |
558 | EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionAddCue(ExecState* state) |
559 | { |
560 | return IDLOperation<JSTextTrack>::call<jsTextTrackPrototypeFunctionAddCueBody>(*state, "addCue" ); |
561 | } |
562 | |
563 | static inline JSC::EncodedJSValue jsTextTrackPrototypeFunctionRemoveCueBody(JSC::ExecState* state, typename IDLOperation<JSTextTrack>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
564 | { |
565 | UNUSED_PARAM(state); |
566 | UNUSED_PARAM(throwScope); |
567 | auto& impl = castedThis->wrapped(); |
568 | if (UNLIKELY(state->argumentCount() < 1)) |
569 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
570 | auto cue = convert<IDLInterface<TextTrackCue>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "cue" , "TextTrack" , "removeCue" , "TextTrackCue" ); }); |
571 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
572 | propagateException(*state, throwScope, impl.removeCue(*cue)); |
573 | return JSValue::encode(jsUndefined()); |
574 | } |
575 | |
576 | EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionRemoveCue(ExecState* state) |
577 | { |
578 | return IDLOperation<JSTextTrack>::call<jsTextTrackPrototypeFunctionRemoveCueBody>(*state, "removeCue" ); |
579 | } |
580 | |
581 | static inline JSC::EncodedJSValue jsTextTrackPrototypeFunctionAddRegionBody(JSC::ExecState* state, typename IDLOperation<JSTextTrack>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
582 | { |
583 | UNUSED_PARAM(state); |
584 | UNUSED_PARAM(throwScope); |
585 | auto& impl = castedThis->wrapped(); |
586 | if (UNLIKELY(state->argumentCount() < 1)) |
587 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
588 | auto region = convert<IDLNullable<IDLInterface<VTTRegion>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "region" , "TextTrack" , "addRegion" , "VTTRegion" ); }); |
589 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
590 | impl.addRegion(WTFMove(region)); |
591 | return JSValue::encode(jsUndefined()); |
592 | } |
593 | |
594 | EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionAddRegion(ExecState* state) |
595 | { |
596 | return IDLOperation<JSTextTrack>::call<jsTextTrackPrototypeFunctionAddRegionBody>(*state, "addRegion" ); |
597 | } |
598 | |
599 | static inline JSC::EncodedJSValue jsTextTrackPrototypeFunctionRemoveRegionBody(JSC::ExecState* state, typename IDLOperation<JSTextTrack>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
600 | { |
601 | UNUSED_PARAM(state); |
602 | UNUSED_PARAM(throwScope); |
603 | auto& impl = castedThis->wrapped(); |
604 | if (UNLIKELY(state->argumentCount() < 1)) |
605 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
606 | auto region = convert<IDLNullable<IDLInterface<VTTRegion>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "region" , "TextTrack" , "removeRegion" , "VTTRegion" ); }); |
607 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
608 | propagateException(*state, throwScope, impl.removeRegion(WTFMove(region))); |
609 | return JSValue::encode(jsUndefined()); |
610 | } |
611 | |
612 | EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionRemoveRegion(ExecState* state) |
613 | { |
614 | return IDLOperation<JSTextTrack>::call<jsTextTrackPrototypeFunctionRemoveRegionBody>(*state, "removeRegion" ); |
615 | } |
616 | |
617 | void JSTextTrack::visitChildren(JSCell* cell, SlotVisitor& visitor) |
618 | { |
619 | auto* thisObject = jsCast<JSTextTrack*>(cell); |
620 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
621 | Base::visitChildren(thisObject, visitor); |
622 | thisObject->visitAdditionalChildren(visitor); |
623 | } |
624 | |
625 | void JSTextTrack::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
626 | { |
627 | auto* thisObject = jsCast<JSTextTrack*>(cell); |
628 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
629 | Base::visitOutputConstraints(thisObject, visitor); |
630 | thisObject->visitAdditionalChildren(visitor); |
631 | } |
632 | |
633 | void JSTextTrack::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
634 | { |
635 | auto* thisObject = jsCast<JSTextTrack*>(cell); |
636 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
637 | if (thisObject->scriptExecutionContext()) |
638 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
639 | Base::heapSnapshot(cell, builder); |
640 | } |
641 | |
642 | bool JSTextTrackOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
643 | { |
644 | auto* jsTextTrack = jsCast<JSTextTrack*>(handle.slot()->asCell()); |
645 | if (jsTextTrack->wrapped().isFiringEventListeners()) { |
646 | if (UNLIKELY(reason)) |
647 | *reason = "EventTarget firing event listeners" ; |
648 | return true; |
649 | } |
650 | Element* element = WTF::getPtr(jsTextTrack->wrapped().element()); |
651 | if (!element) |
652 | return false; |
653 | if (UNLIKELY(reason)) |
654 | *reason = "Reachable from TextTrackOwner" ; |
655 | void* root = WebCore::root(element); |
656 | return visitor.containsOpaqueRoot(root); |
657 | } |
658 | |
659 | void JSTextTrackOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
660 | { |
661 | auto* jsTextTrack = static_cast<JSTextTrack*>(handle.slot()->asCell()); |
662 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
663 | uncacheWrapper(world, &jsTextTrack->wrapped(), jsTextTrack); |
664 | } |
665 | |
666 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TextTrack>&& impl) |
667 | { |
668 | return createWrapper<TextTrack>(globalObject, WTFMove(impl)); |
669 | } |
670 | |
671 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TextTrack& impl) |
672 | { |
673 | return wrap(state, globalObject, impl); |
674 | } |
675 | |
676 | TextTrack* JSTextTrack::toWrapped(JSC::VM& vm, JSC::JSValue value) |
677 | { |
678 | if (auto* wrapper = jsDynamicCast<JSTextTrack*>(vm, value)) |
679 | return &wrapper->wrapped(); |
680 | return nullptr; |
681 | } |
682 | |
683 | } |
684 | |
685 | #endif // ENABLE(VIDEO_TRACK) |
686 | |