| 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 "JSAudioTrackList.h" |
| 26 | |
| 27 | #include "Element.h" |
| 28 | #include "EventNames.h" |
| 29 | #include "JSAudioTrack.h" |
| 30 | #include "JSDOMAttribute.h" |
| 31 | #include "JSDOMBinding.h" |
| 32 | #include "JSDOMConstructorNotConstructable.h" |
| 33 | #include "JSDOMConvertInterface.h" |
| 34 | #include "JSDOMConvertNumbers.h" |
| 35 | #include "JSDOMConvertStrings.h" |
| 36 | #include "JSDOMExceptionHandling.h" |
| 37 | #include "JSDOMGlobalObject.h" |
| 38 | #include "JSDOMOperation.h" |
| 39 | #include "JSDOMWrapperCache.h" |
| 40 | #include "JSEventListener.h" |
| 41 | #include "JSNodeCustom.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 jsAudioTrackListPrototypeFunctionItem(JSC::ExecState*); |
| 59 | JSC::EncodedJSValue JSC_HOST_CALL jsAudioTrackListPrototypeFunctionGetTrackById(JSC::ExecState*); |
| 60 | |
| 61 | // Attributes |
| 62 | |
| 63 | JSC::EncodedJSValue jsAudioTrackListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 64 | bool setJSAudioTrackListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 65 | JSC::EncodedJSValue jsAudioTrackListLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 66 | JSC::EncodedJSValue jsAudioTrackListOnchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 67 | bool setJSAudioTrackListOnchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 68 | JSC::EncodedJSValue jsAudioTrackListOnaddtrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 69 | bool setJSAudioTrackListOnaddtrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 70 | JSC::EncodedJSValue jsAudioTrackListOnremovetrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 71 | bool setJSAudioTrackListOnremovetrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 72 | |
| 73 | class JSAudioTrackListPrototype : public JSC::JSNonFinalObject { |
| 74 | public: |
| 75 | using Base = JSC::JSNonFinalObject; |
| 76 | static JSAudioTrackListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 77 | { |
| 78 | JSAudioTrackListPrototype* ptr = new (NotNull, JSC::allocateCell<JSAudioTrackListPrototype>(vm.heap)) JSAudioTrackListPrototype(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 | JSAudioTrackListPrototype(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 JSAudioTrackListConstructor = JSDOMConstructorNotConstructable<JSAudioTrackList>; |
| 99 | |
| 100 | template<> JSValue JSAudioTrackListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 101 | { |
| 102 | return JSEventTarget::getConstructor(vm, &globalObject); |
| 103 | } |
| 104 | |
| 105 | template<> void JSAudioTrackListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 106 | { |
| 107 | putDirect(vm, vm.propertyNames->prototype, JSAudioTrackList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 108 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("AudioTrackList"_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 JSAudioTrackListConstructor::s_info = { "AudioTrackList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAudioTrackListConstructor) }; |
| 113 | |
| 114 | /* Hash table for prototype */ |
| 115 | |
| 116 | static const HashTableValue JSAudioTrackListPrototypeTableValues[] = |
| 117 | { |
| 118 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAudioTrackListConstructor) } }, |
| 119 | { "length" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackListLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 120 | { "onchange" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackListOnchange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAudioTrackListOnchange) } }, |
| 121 | { "onaddtrack" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackListOnaddtrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAudioTrackListOnaddtrack) } }, |
| 122 | { "onremovetrack" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackListOnremovetrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAudioTrackListOnremovetrack) } }, |
| 123 | { "item" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsAudioTrackListPrototypeFunctionItem), (intptr_t) (1) } }, |
| 124 | { "getTrackById" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsAudioTrackListPrototypeFunctionGetTrackById), (intptr_t) (1) } }, |
| 125 | }; |
| 126 | |
| 127 | const ClassInfo JSAudioTrackListPrototype::s_info = { "AudioTrackListPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAudioTrackListPrototype) }; |
| 128 | |
| 129 | void JSAudioTrackListPrototype::finishCreation(VM& vm) |
| 130 | { |
| 131 | Base::finishCreation(vm); |
| 132 | reifyStaticProperties(vm, JSAudioTrackList::info(), JSAudioTrackListPrototypeTableValues, *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 JSAudioTrackList::s_info = { "AudioTrackList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAudioTrackList) }; |
| 137 | |
| 138 | JSAudioTrackList::JSAudioTrackList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<AudioTrackList>&& impl) |
| 139 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| 140 | { |
| 141 | } |
| 142 | |
| 143 | void JSAudioTrackList::finishCreation(VM& vm) |
| 144 | { |
| 145 | Base::finishCreation(vm); |
| 146 | ASSERT(inherits(vm, info())); |
| 147 | |
| 148 | } |
| 149 | |
| 150 | JSObject* JSAudioTrackList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 151 | { |
| 152 | return JSAudioTrackListPrototype::create(vm, &globalObject, JSAudioTrackListPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
| 153 | } |
| 154 | |
| 155 | JSObject* JSAudioTrackList::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 156 | { |
| 157 | return getDOMPrototype<JSAudioTrackList>(vm, globalObject); |
| 158 | } |
| 159 | |
| 160 | JSValue JSAudioTrackList::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 161 | { |
| 162 | return getDOMConstructor<JSAudioTrackListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 163 | } |
| 164 | |
| 165 | bool JSAudioTrackList::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot) |
| 166 | { |
| 167 | auto* thisObject = jsCast<JSAudioTrackList*>(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<AudioTrack>>(*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 JSAudioTrackList::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot) |
| 180 | { |
| 181 | auto* thisObject = jsCast<JSAudioTrackList*>(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<AudioTrack>>(*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 JSAudioTrackList::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode) |
| 194 | { |
| 195 | auto* thisObject = jsCast<JSAudioTrackList*>(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 JSAudioTrackList* IDLAttribute<JSAudioTrackList>::cast(ExecState& state, EncodedJSValue thisValue) |
| 203 | { |
| 204 | return jsDynamicCast<JSAudioTrackList*>(state.vm(), JSValue::decode(thisValue)); |
| 205 | } |
| 206 | |
| 207 | template<> inline JSAudioTrackList* IDLOperation<JSAudioTrackList>::cast(ExecState& state) |
| 208 | { |
| 209 | return jsDynamicCast<JSAudioTrackList*>(state.vm(), state.thisValue()); |
| 210 | } |
| 211 | |
| 212 | EncodedJSValue jsAudioTrackListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 213 | { |
| 214 | VM& vm = state->vm(); |
| 215 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 216 | auto* prototype = jsDynamicCast<JSAudioTrackListPrototype*>(vm, JSValue::decode(thisValue)); |
| 217 | if (UNLIKELY(!prototype)) |
| 218 | return throwVMTypeError(state, throwScope); |
| 219 | return JSValue::encode(JSAudioTrackList::getConstructor(state->vm(), prototype->globalObject())); |
| 220 | } |
| 221 | |
| 222 | bool setJSAudioTrackListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 223 | { |
| 224 | VM& vm = state->vm(); |
| 225 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 226 | auto* prototype = jsDynamicCast<JSAudioTrackListPrototype*>(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 jsAudioTrackListLengthGetter(ExecState& state, JSAudioTrackList& 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 jsAudioTrackListLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 245 | { |
| 246 | return IDLAttribute<JSAudioTrackList>::get<jsAudioTrackListLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length" ); |
| 247 | } |
| 248 | |
| 249 | static inline JSValue jsAudioTrackListOnchangeGetter(ExecState& state, JSAudioTrackList& thisObject, ThrowScope& throwScope) |
| 250 | { |
| 251 | UNUSED_PARAM(throwScope); |
| 252 | UNUSED_PARAM(state); |
| 253 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().changeEvent, worldForDOMObject(thisObject)); |
| 254 | } |
| 255 | |
| 256 | EncodedJSValue jsAudioTrackListOnchange(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 257 | { |
| 258 | return IDLAttribute<JSAudioTrackList>::get<jsAudioTrackListOnchangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onchange" ); |
| 259 | } |
| 260 | |
| 261 | static inline bool setJSAudioTrackListOnchangeSetter(ExecState& state, JSAudioTrackList& thisObject, JSValue value, ThrowScope& throwScope) |
| 262 | { |
| 263 | UNUSED_PARAM(throwScope); |
| 264 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().changeEvent, value); |
| 265 | return true; |
| 266 | } |
| 267 | |
| 268 | bool setJSAudioTrackListOnchange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 269 | { |
| 270 | return IDLAttribute<JSAudioTrackList>::set<setJSAudioTrackListOnchangeSetter>(*state, thisValue, encodedValue, "onchange" ); |
| 271 | } |
| 272 | |
| 273 | static inline JSValue jsAudioTrackListOnaddtrackGetter(ExecState& state, JSAudioTrackList& thisObject, ThrowScope& throwScope) |
| 274 | { |
| 275 | UNUSED_PARAM(throwScope); |
| 276 | UNUSED_PARAM(state); |
| 277 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().addtrackEvent, worldForDOMObject(thisObject)); |
| 278 | } |
| 279 | |
| 280 | EncodedJSValue jsAudioTrackListOnaddtrack(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 281 | { |
| 282 | return IDLAttribute<JSAudioTrackList>::get<jsAudioTrackListOnaddtrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onaddtrack" ); |
| 283 | } |
| 284 | |
| 285 | static inline bool setJSAudioTrackListOnaddtrackSetter(ExecState& state, JSAudioTrackList& thisObject, JSValue value, ThrowScope& throwScope) |
| 286 | { |
| 287 | UNUSED_PARAM(throwScope); |
| 288 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().addtrackEvent, value); |
| 289 | return true; |
| 290 | } |
| 291 | |
| 292 | bool setJSAudioTrackListOnaddtrack(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 293 | { |
| 294 | return IDLAttribute<JSAudioTrackList>::set<setJSAudioTrackListOnaddtrackSetter>(*state, thisValue, encodedValue, "onaddtrack" ); |
| 295 | } |
| 296 | |
| 297 | static inline JSValue jsAudioTrackListOnremovetrackGetter(ExecState& state, JSAudioTrackList& 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 jsAudioTrackListOnremovetrack(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 305 | { |
| 306 | return IDLAttribute<JSAudioTrackList>::get<jsAudioTrackListOnremovetrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onremovetrack" ); |
| 307 | } |
| 308 | |
| 309 | static inline bool setJSAudioTrackListOnremovetrackSetter(ExecState& state, JSAudioTrackList& 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 setJSAudioTrackListOnremovetrack(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 317 | { |
| 318 | return IDLAttribute<JSAudioTrackList>::set<setJSAudioTrackListOnremovetrackSetter>(*state, thisValue, encodedValue, "onremovetrack" ); |
| 319 | } |
| 320 | |
| 321 | static inline JSC::EncodedJSValue jsAudioTrackListPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSAudioTrackList>::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<AudioTrack>>(*state, *castedThis->globalObject(), impl.item(WTFMove(index)))); |
| 331 | } |
| 332 | |
| 333 | EncodedJSValue JSC_HOST_CALL jsAudioTrackListPrototypeFunctionItem(ExecState* state) |
| 334 | { |
| 335 | return IDLOperation<JSAudioTrackList>::call<jsAudioTrackListPrototypeFunctionItemBody>(*state, "item" ); |
| 336 | } |
| 337 | |
| 338 | static inline JSC::EncodedJSValue jsAudioTrackListPrototypeFunctionGetTrackByIdBody(JSC::ExecState* state, typename IDLOperation<JSAudioTrackList>::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<AudioTrack>>(*state, *castedThis->globalObject(), impl.getTrackById(WTFMove(id)))); |
| 348 | } |
| 349 | |
| 350 | EncodedJSValue JSC_HOST_CALL jsAudioTrackListPrototypeFunctionGetTrackById(ExecState* state) |
| 351 | { |
| 352 | return IDLOperation<JSAudioTrackList>::call<jsAudioTrackListPrototypeFunctionGetTrackByIdBody>(*state, "getTrackById" ); |
| 353 | } |
| 354 | |
| 355 | void JSAudioTrackList::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 356 | { |
| 357 | auto* thisObject = jsCast<JSAudioTrackList*>(cell); |
| 358 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 359 | Base::visitChildren(thisObject, visitor); |
| 360 | thisObject->visitAdditionalChildren(visitor); |
| 361 | } |
| 362 | |
| 363 | void JSAudioTrackList::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 364 | { |
| 365 | auto* thisObject = jsCast<JSAudioTrackList*>(cell); |
| 366 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 367 | Base::visitOutputConstraints(thisObject, visitor); |
| 368 | thisObject->visitAdditionalChildren(visitor); |
| 369 | } |
| 370 | |
| 371 | void JSAudioTrackList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 372 | { |
| 373 | auto* thisObject = jsCast<JSAudioTrackList*>(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 JSAudioTrackListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 381 | { |
| 382 | auto* jsAudioTrackList = jsCast<JSAudioTrackList*>(handle.slot()->asCell()); |
| 383 | if (jsAudioTrackList->wrapped().hasPendingActivity()) { |
| 384 | if (UNLIKELY(reason)) |
| 385 | *reason = "ActiveDOMObject with pending activity" ; |
| 386 | return true; |
| 387 | } |
| 388 | if (jsAudioTrackList->wrapped().isFiringEventListeners()) { |
| 389 | if (UNLIKELY(reason)) |
| 390 | *reason = "EventTarget firing event listeners" ; |
| 391 | return true; |
| 392 | } |
| 393 | Element* element = WTF::getPtr(jsAudioTrackList->wrapped().element()); |
| 394 | if (!element) |
| 395 | return false; |
| 396 | if (UNLIKELY(reason)) |
| 397 | *reason = "Reachable from AudioTrackListOwner" ; |
| 398 | void* root = WebCore::root(element); |
| 399 | return visitor.containsOpaqueRoot(root); |
| 400 | } |
| 401 | |
| 402 | void JSAudioTrackListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 403 | { |
| 404 | auto* jsAudioTrackList = static_cast<JSAudioTrackList*>(handle.slot()->asCell()); |
| 405 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 406 | uncacheWrapper(world, &jsAudioTrackList->wrapped(), jsAudioTrackList); |
| 407 | } |
| 408 | |
| 409 | #if ENABLE(BINDING_INTEGRITY) |
| 410 | #if PLATFORM(WIN) |
| 411 | #pragma warning(disable: 4483) |
| 412 | extern "C" { extern void (*const __identifier("??_7AudioTrackList@WebCore@@6B@" )[])(); } |
| 413 | #else |
| 414 | extern "C" { extern void* _ZTVN7WebCore14AudioTrackListE[]; } |
| 415 | #endif |
| 416 | #endif |
| 417 | |
| 418 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<AudioTrackList>&& 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("??_7AudioTrackList@WebCore@@6B@" )); |
| 425 | #else |
| 426 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore14AudioTrackListE[2]); |
| 427 | #endif |
| 428 | |
| 429 | // If this fails AudioTrackList does not have a vtable, so you need to add the |
| 430 | // ImplementationLacksVTable attribute to the interface definition |
| 431 | static_assert(std::is_polymorphic<AudioTrackList>::value, "AudioTrackList is not polymorphic" ); |
| 432 | |
| 433 | // If you hit this assertion you either have a use after free bug, or |
| 434 | // AudioTrackList has subclasses. If AudioTrackList has subclasses that get passed |
| 435 | // to toJS() we currently require AudioTrackList 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<AudioTrackList>(globalObject, WTFMove(impl)); |
| 440 | } |
| 441 | |
| 442 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, AudioTrackList& impl) |
| 443 | { |
| 444 | return wrap(state, globalObject, impl); |
| 445 | } |
| 446 | |
| 447 | AudioTrackList* JSAudioTrackList::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 448 | { |
| 449 | if (auto* wrapper = jsDynamicCast<JSAudioTrackList*>(vm, value)) |
| 450 | return &wrapper->wrapped(); |
| 451 | return nullptr; |
| 452 | } |
| 453 | |
| 454 | } |
| 455 | |
| 456 | #endif // ENABLE(VIDEO_TRACK) |
| 457 | |