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 "JSTextTrackList.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 "JSDOMConvertNumbers.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 "JSTextTrack.h" |
42 | #include "ScriptExecutionContext.h" |
43 | #include <JavaScriptCore/ArrayPrototype.h> |
44 | #include <JavaScriptCore/BuiltinNames.h> |
45 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
46 | #include <JavaScriptCore/JSCInlines.h> |
47 | #include <JavaScriptCore/PropertyNameArray.h> |
48 | #include <wtf/GetPtr.h> |
49 | #include <wtf/PointerPreparations.h> |
50 | #include <wtf/URL.h> |
51 | |
52 | |
53 | namespace WebCore { |
54 | using namespace JSC; |
55 | |
56 | // Functions |
57 | |
58 | JSC::EncodedJSValue JSC_HOST_CALL jsTextTrackListPrototypeFunctionItem(JSC::ExecState*); |
59 | JSC::EncodedJSValue JSC_HOST_CALL jsTextTrackListPrototypeFunctionGetTrackById(JSC::ExecState*); |
60 | |
61 | // Attributes |
62 | |
63 | JSC::EncodedJSValue jsTextTrackListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
64 | bool setJSTextTrackListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
65 | JSC::EncodedJSValue jsTextTrackListLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
66 | JSC::EncodedJSValue jsTextTrackListOnaddtrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
67 | bool setJSTextTrackListOnaddtrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
68 | JSC::EncodedJSValue jsTextTrackListOnchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
69 | bool setJSTextTrackListOnchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
70 | JSC::EncodedJSValue jsTextTrackListOnremovetrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
71 | bool setJSTextTrackListOnremovetrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
72 | |
73 | class JSTextTrackListPrototype : public JSC::JSNonFinalObject { |
74 | public: |
75 | using Base = JSC::JSNonFinalObject; |
76 | static JSTextTrackListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
77 | { |
78 | JSTextTrackListPrototype* ptr = new (NotNull, JSC::allocateCell<JSTextTrackListPrototype>(vm.heap)) JSTextTrackListPrototype(vm, globalObject, structure); |
79 | ptr->finishCreation(vm); |
80 | return ptr; |
81 | } |
82 | |
83 | DECLARE_INFO; |
84 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
85 | { |
86 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
87 | } |
88 | |
89 | private: |
90 | JSTextTrackListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
91 | : JSC::JSNonFinalObject(vm, structure) |
92 | { |
93 | } |
94 | |
95 | void finishCreation(JSC::VM&); |
96 | }; |
97 | |
98 | using JSTextTrackListConstructor = JSDOMConstructorNotConstructable<JSTextTrackList>; |
99 | |
100 | template<> JSValue JSTextTrackListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
101 | { |
102 | return JSEventTarget::getConstructor(vm, &globalObject); |
103 | } |
104 | |
105 | template<> void JSTextTrackListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
106 | { |
107 | putDirect(vm, vm.propertyNames->prototype, JSTextTrackList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
108 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TextTrackList"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
109 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
110 | } |
111 | |
112 | template<> const ClassInfo JSTextTrackListConstructor::s_info = { "TextTrackList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextTrackListConstructor) }; |
113 | |
114 | /* Hash table for prototype */ |
115 | |
116 | static const HashTableValue JSTextTrackListPrototypeTableValues[] = |
117 | { |
118 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackListConstructor) } }, |
119 | { "length" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackListLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
120 | { "onaddtrack" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackListOnaddtrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackListOnaddtrack) } }, |
121 | { "onchange" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackListOnchange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackListOnchange) } }, |
122 | { "onremovetrack" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackListOnremovetrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackListOnremovetrack) } }, |
123 | { "item" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTextTrackListPrototypeFunctionItem), (intptr_t) (1) } }, |
124 | { "getTrackById" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTextTrackListPrototypeFunctionGetTrackById), (intptr_t) (1) } }, |
125 | }; |
126 | |
127 | const ClassInfo JSTextTrackListPrototype::s_info = { "TextTrackListPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextTrackListPrototype) }; |
128 | |
129 | void JSTextTrackListPrototype::finishCreation(VM& vm) |
130 | { |
131 | Base::finishCreation(vm); |
132 | reifyStaticProperties(vm, JSTextTrackList::info(), JSTextTrackListPrototypeTableValues, *this); |
133 | putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
134 | } |
135 | |
136 | const ClassInfo JSTextTrackList::s_info = { "TextTrackList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextTrackList) }; |
137 | |
138 | JSTextTrackList::JSTextTrackList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TextTrackList>&& impl) |
139 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
140 | { |
141 | } |
142 | |
143 | void JSTextTrackList::finishCreation(VM& vm) |
144 | { |
145 | Base::finishCreation(vm); |
146 | ASSERT(inherits(vm, info())); |
147 | |
148 | } |
149 | |
150 | JSObject* JSTextTrackList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
151 | { |
152 | return JSTextTrackListPrototype::create(vm, &globalObject, JSTextTrackListPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
153 | } |
154 | |
155 | JSObject* JSTextTrackList::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
156 | { |
157 | return getDOMPrototype<JSTextTrackList>(vm, globalObject); |
158 | } |
159 | |
160 | JSValue JSTextTrackList::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
161 | { |
162 | return getDOMConstructor<JSTextTrackListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
163 | } |
164 | |
165 | bool JSTextTrackList::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot) |
166 | { |
167 | auto* thisObject = jsCast<JSTextTrackList*>(object); |
168 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
169 | if (auto index = parseIndex(propertyName)) { |
170 | if (index.value() < thisObject->wrapped().length()) { |
171 | auto value = toJS<IDLInterface<TextTrack>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value())); |
172 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
173 | return true; |
174 | } |
175 | } |
176 | return JSObject::getOwnPropertySlot(object, state, propertyName, slot); |
177 | } |
178 | |
179 | bool JSTextTrackList::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot) |
180 | { |
181 | auto* thisObject = jsCast<JSTextTrackList*>(object); |
182 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
183 | if (LIKELY(index <= MAX_ARRAY_INDEX)) { |
184 | if (index < thisObject->wrapped().length()) { |
185 | auto value = toJS<IDLInterface<TextTrack>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index)); |
186 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
187 | return true; |
188 | } |
189 | } |
190 | return JSObject::getOwnPropertySlotByIndex(object, state, index, slot); |
191 | } |
192 | |
193 | void JSTextTrackList::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode) |
194 | { |
195 | auto* thisObject = jsCast<JSTextTrackList*>(object); |
196 | ASSERT_GC_OBJECT_INHERITS(object, info()); |
197 | for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i) |
198 | propertyNames.add(Identifier::from(state, i)); |
199 | JSObject::getOwnPropertyNames(object, state, propertyNames, mode); |
200 | } |
201 | |
202 | template<> inline JSTextTrackList* IDLAttribute<JSTextTrackList>::cast(ExecState& state, EncodedJSValue thisValue) |
203 | { |
204 | return jsDynamicCast<JSTextTrackList*>(state.vm(), JSValue::decode(thisValue)); |
205 | } |
206 | |
207 | template<> inline JSTextTrackList* IDLOperation<JSTextTrackList>::cast(ExecState& state) |
208 | { |
209 | return jsDynamicCast<JSTextTrackList*>(state.vm(), state.thisValue()); |
210 | } |
211 | |
212 | EncodedJSValue jsTextTrackListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
213 | { |
214 | VM& vm = state->vm(); |
215 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
216 | auto* prototype = jsDynamicCast<JSTextTrackListPrototype*>(vm, JSValue::decode(thisValue)); |
217 | if (UNLIKELY(!prototype)) |
218 | return throwVMTypeError(state, throwScope); |
219 | return JSValue::encode(JSTextTrackList::getConstructor(state->vm(), prototype->globalObject())); |
220 | } |
221 | |
222 | bool setJSTextTrackListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
223 | { |
224 | VM& vm = state->vm(); |
225 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
226 | auto* prototype = jsDynamicCast<JSTextTrackListPrototype*>(vm, JSValue::decode(thisValue)); |
227 | if (UNLIKELY(!prototype)) { |
228 | throwVMTypeError(state, throwScope); |
229 | return false; |
230 | } |
231 | // Shadowing a built-in constructor |
232 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
233 | } |
234 | |
235 | static inline JSValue jsTextTrackListLengthGetter(ExecState& state, JSTextTrackList& thisObject, ThrowScope& throwScope) |
236 | { |
237 | UNUSED_PARAM(throwScope); |
238 | UNUSED_PARAM(state); |
239 | auto& impl = thisObject.wrapped(); |
240 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length()); |
241 | return result; |
242 | } |
243 | |
244 | EncodedJSValue jsTextTrackListLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
245 | { |
246 | return IDLAttribute<JSTextTrackList>::get<jsTextTrackListLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length" ); |
247 | } |
248 | |
249 | static inline JSValue jsTextTrackListOnaddtrackGetter(ExecState& state, JSTextTrackList& thisObject, ThrowScope& throwScope) |
250 | { |
251 | UNUSED_PARAM(throwScope); |
252 | UNUSED_PARAM(state); |
253 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().addtrackEvent, worldForDOMObject(thisObject)); |
254 | } |
255 | |
256 | EncodedJSValue jsTextTrackListOnaddtrack(ExecState* state, EncodedJSValue thisValue, PropertyName) |
257 | { |
258 | return IDLAttribute<JSTextTrackList>::get<jsTextTrackListOnaddtrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onaddtrack" ); |
259 | } |
260 | |
261 | static inline bool setJSTextTrackListOnaddtrackSetter(ExecState& state, JSTextTrackList& thisObject, JSValue value, ThrowScope& throwScope) |
262 | { |
263 | UNUSED_PARAM(throwScope); |
264 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().addtrackEvent, value); |
265 | return true; |
266 | } |
267 | |
268 | bool setJSTextTrackListOnaddtrack(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
269 | { |
270 | return IDLAttribute<JSTextTrackList>::set<setJSTextTrackListOnaddtrackSetter>(*state, thisValue, encodedValue, "onaddtrack" ); |
271 | } |
272 | |
273 | static inline JSValue jsTextTrackListOnchangeGetter(ExecState& state, JSTextTrackList& thisObject, ThrowScope& throwScope) |
274 | { |
275 | UNUSED_PARAM(throwScope); |
276 | UNUSED_PARAM(state); |
277 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().changeEvent, worldForDOMObject(thisObject)); |
278 | } |
279 | |
280 | EncodedJSValue jsTextTrackListOnchange(ExecState* state, EncodedJSValue thisValue, PropertyName) |
281 | { |
282 | return IDLAttribute<JSTextTrackList>::get<jsTextTrackListOnchangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onchange" ); |
283 | } |
284 | |
285 | static inline bool setJSTextTrackListOnchangeSetter(ExecState& state, JSTextTrackList& thisObject, JSValue value, ThrowScope& throwScope) |
286 | { |
287 | UNUSED_PARAM(throwScope); |
288 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().changeEvent, value); |
289 | return true; |
290 | } |
291 | |
292 | bool setJSTextTrackListOnchange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
293 | { |
294 | return IDLAttribute<JSTextTrackList>::set<setJSTextTrackListOnchangeSetter>(*state, thisValue, encodedValue, "onchange" ); |
295 | } |
296 | |
297 | static inline JSValue jsTextTrackListOnremovetrackGetter(ExecState& state, JSTextTrackList& thisObject, ThrowScope& throwScope) |
298 | { |
299 | UNUSED_PARAM(throwScope); |
300 | UNUSED_PARAM(state); |
301 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().removetrackEvent, worldForDOMObject(thisObject)); |
302 | } |
303 | |
304 | EncodedJSValue jsTextTrackListOnremovetrack(ExecState* state, EncodedJSValue thisValue, PropertyName) |
305 | { |
306 | return IDLAttribute<JSTextTrackList>::get<jsTextTrackListOnremovetrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onremovetrack" ); |
307 | } |
308 | |
309 | static inline bool setJSTextTrackListOnremovetrackSetter(ExecState& state, JSTextTrackList& thisObject, JSValue value, ThrowScope& throwScope) |
310 | { |
311 | UNUSED_PARAM(throwScope); |
312 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().removetrackEvent, value); |
313 | return true; |
314 | } |
315 | |
316 | bool setJSTextTrackListOnremovetrack(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
317 | { |
318 | return IDLAttribute<JSTextTrackList>::set<setJSTextTrackListOnremovetrackSetter>(*state, thisValue, encodedValue, "onremovetrack" ); |
319 | } |
320 | |
321 | static inline JSC::EncodedJSValue jsTextTrackListPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSTextTrackList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
322 | { |
323 | UNUSED_PARAM(state); |
324 | UNUSED_PARAM(throwScope); |
325 | auto& impl = castedThis->wrapped(); |
326 | if (UNLIKELY(state->argumentCount() < 1)) |
327 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
328 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
329 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
330 | return JSValue::encode(toJS<IDLInterface<TextTrack>>(*state, *castedThis->globalObject(), impl.item(WTFMove(index)))); |
331 | } |
332 | |
333 | EncodedJSValue JSC_HOST_CALL jsTextTrackListPrototypeFunctionItem(ExecState* state) |
334 | { |
335 | return IDLOperation<JSTextTrackList>::call<jsTextTrackListPrototypeFunctionItemBody>(*state, "item" ); |
336 | } |
337 | |
338 | static inline JSC::EncodedJSValue jsTextTrackListPrototypeFunctionGetTrackByIdBody(JSC::ExecState* state, typename IDLOperation<JSTextTrackList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
339 | { |
340 | UNUSED_PARAM(state); |
341 | UNUSED_PARAM(throwScope); |
342 | auto& impl = castedThis->wrapped(); |
343 | if (UNLIKELY(state->argumentCount() < 1)) |
344 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
345 | auto id = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
346 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
347 | return JSValue::encode(toJS<IDLInterface<TextTrack>>(*state, *castedThis->globalObject(), impl.getTrackById(WTFMove(id)))); |
348 | } |
349 | |
350 | EncodedJSValue JSC_HOST_CALL jsTextTrackListPrototypeFunctionGetTrackById(ExecState* state) |
351 | { |
352 | return IDLOperation<JSTextTrackList>::call<jsTextTrackListPrototypeFunctionGetTrackByIdBody>(*state, "getTrackById" ); |
353 | } |
354 | |
355 | void JSTextTrackList::visitChildren(JSCell* cell, SlotVisitor& visitor) |
356 | { |
357 | auto* thisObject = jsCast<JSTextTrackList*>(cell); |
358 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
359 | Base::visitChildren(thisObject, visitor); |
360 | thisObject->visitAdditionalChildren(visitor); |
361 | } |
362 | |
363 | void JSTextTrackList::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
364 | { |
365 | auto* thisObject = jsCast<JSTextTrackList*>(cell); |
366 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
367 | Base::visitOutputConstraints(thisObject, visitor); |
368 | thisObject->visitAdditionalChildren(visitor); |
369 | } |
370 | |
371 | void JSTextTrackList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
372 | { |
373 | auto* thisObject = jsCast<JSTextTrackList*>(cell); |
374 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
375 | if (thisObject->scriptExecutionContext()) |
376 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
377 | Base::heapSnapshot(cell, builder); |
378 | } |
379 | |
380 | bool JSTextTrackListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
381 | { |
382 | auto* jsTextTrackList = jsCast<JSTextTrackList*>(handle.slot()->asCell()); |
383 | if (jsTextTrackList->wrapped().hasPendingActivity()) { |
384 | if (UNLIKELY(reason)) |
385 | *reason = "ActiveDOMObject with pending activity" ; |
386 | return true; |
387 | } |
388 | if (jsTextTrackList->wrapped().isFiringEventListeners()) { |
389 | if (UNLIKELY(reason)) |
390 | *reason = "EventTarget firing event listeners" ; |
391 | return true; |
392 | } |
393 | Element* element = WTF::getPtr(jsTextTrackList->wrapped().element()); |
394 | if (!element) |
395 | return false; |
396 | if (UNLIKELY(reason)) |
397 | *reason = "Reachable from TextTrackListOwner" ; |
398 | void* root = WebCore::root(element); |
399 | return visitor.containsOpaqueRoot(root); |
400 | } |
401 | |
402 | void JSTextTrackListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
403 | { |
404 | auto* jsTextTrackList = static_cast<JSTextTrackList*>(handle.slot()->asCell()); |
405 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
406 | uncacheWrapper(world, &jsTextTrackList->wrapped(), jsTextTrackList); |
407 | } |
408 | |
409 | #if ENABLE(BINDING_INTEGRITY) |
410 | #if PLATFORM(WIN) |
411 | #pragma warning(disable: 4483) |
412 | extern "C" { extern void (*const __identifier("??_7TextTrackList@WebCore@@6B@" )[])(); } |
413 | #else |
414 | extern "C" { extern void* _ZTVN7WebCore13TextTrackListE[]; } |
415 | #endif |
416 | #endif |
417 | |
418 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TextTrackList>&& impl) |
419 | { |
420 | |
421 | #if ENABLE(BINDING_INTEGRITY) |
422 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
423 | #if PLATFORM(WIN) |
424 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TextTrackList@WebCore@@6B@" )); |
425 | #else |
426 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore13TextTrackListE[2]); |
427 | #endif |
428 | |
429 | // If this fails TextTrackList does not have a vtable, so you need to add the |
430 | // ImplementationLacksVTable attribute to the interface definition |
431 | static_assert(std::is_polymorphic<TextTrackList>::value, "TextTrackList is not polymorphic" ); |
432 | |
433 | // If you hit this assertion you either have a use after free bug, or |
434 | // TextTrackList has subclasses. If TextTrackList has subclasses that get passed |
435 | // to toJS() we currently require TextTrackList you to opt out of binding hardening |
436 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
437 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
438 | #endif |
439 | return createWrapper<TextTrackList>(globalObject, WTFMove(impl)); |
440 | } |
441 | |
442 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TextTrackList& impl) |
443 | { |
444 | return wrap(state, globalObject, impl); |
445 | } |
446 | |
447 | TextTrackList* JSTextTrackList::toWrapped(JSC::VM& vm, JSC::JSValue value) |
448 | { |
449 | if (auto* wrapper = jsDynamicCast<JSTextTrackList*>(vm, value)) |
450 | return &wrapper->wrapped(); |
451 | return nullptr; |
452 | } |
453 | |
454 | } |
455 | |
456 | #endif // ENABLE(VIDEO_TRACK) |
457 | |