| 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 "JSAudioTrack.h" |
| 26 | |
| 27 | #include "Element.h" |
| 28 | #include "JSDOMAttribute.h" |
| 29 | #include "JSDOMBinding.h" |
| 30 | #include "JSDOMConstructorNotConstructable.h" |
| 31 | #include "JSDOMConvertBoolean.h" |
| 32 | #include "JSDOMConvertStrings.h" |
| 33 | #include "JSDOMExceptionHandling.h" |
| 34 | #include "JSDOMWrapperCache.h" |
| 35 | #include "JSNodeCustom.h" |
| 36 | #include "ScriptExecutionContext.h" |
| 37 | #include <JavaScriptCore/FunctionPrototype.h> |
| 38 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 39 | #include <JavaScriptCore/JSCInlines.h> |
| 40 | #include <wtf/GetPtr.h> |
| 41 | #include <wtf/PointerPreparations.h> |
| 42 | #include <wtf/URL.h> |
| 43 | |
| 44 | #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK) |
| 45 | #include "AudioTrackMediaSource.h" |
| 46 | #include "JSDOMConvertInterface.h" |
| 47 | #include "JSDOMConvertNullable.h" |
| 48 | #include "JSDOMGlobalObject.h" |
| 49 | #include "JSSourceBuffer.h" |
| 50 | #endif |
| 51 | |
| 52 | |
| 53 | namespace WebCore { |
| 54 | using namespace JSC; |
| 55 | |
| 56 | // Attributes |
| 57 | |
| 58 | JSC::EncodedJSValue jsAudioTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 59 | bool setJSAudioTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 60 | JSC::EncodedJSValue jsAudioTrackId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 61 | JSC::EncodedJSValue jsAudioTrackKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 62 | #if ENABLE(MEDIA_SOURCE) |
| 63 | bool setJSAudioTrackKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 64 | #endif |
| 65 | JSC::EncodedJSValue jsAudioTrackLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 66 | JSC::EncodedJSValue jsAudioTrackLanguage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 67 | #if ENABLE(MEDIA_SOURCE) |
| 68 | bool setJSAudioTrackLanguage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 69 | #endif |
| 70 | JSC::EncodedJSValue jsAudioTrackEnabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 71 | bool setJSAudioTrackEnabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 72 | #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK) |
| 73 | JSC::EncodedJSValue jsAudioTrackSourceBuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 74 | #endif |
| 75 | |
| 76 | class JSAudioTrackPrototype : public JSC::JSNonFinalObject { |
| 77 | public: |
| 78 | using Base = JSC::JSNonFinalObject; |
| 79 | static JSAudioTrackPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 80 | { |
| 81 | JSAudioTrackPrototype* ptr = new (NotNull, JSC::allocateCell<JSAudioTrackPrototype>(vm.heap)) JSAudioTrackPrototype(vm, globalObject, structure); |
| 82 | ptr->finishCreation(vm); |
| 83 | return ptr; |
| 84 | } |
| 85 | |
| 86 | DECLARE_INFO; |
| 87 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 88 | { |
| 89 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 90 | } |
| 91 | |
| 92 | private: |
| 93 | JSAudioTrackPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 94 | : JSC::JSNonFinalObject(vm, structure) |
| 95 | { |
| 96 | } |
| 97 | |
| 98 | void finishCreation(JSC::VM&); |
| 99 | }; |
| 100 | |
| 101 | using JSAudioTrackConstructor = JSDOMConstructorNotConstructable<JSAudioTrack>; |
| 102 | |
| 103 | template<> JSValue JSAudioTrackConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 104 | { |
| 105 | UNUSED_PARAM(vm); |
| 106 | return globalObject.functionPrototype(); |
| 107 | } |
| 108 | |
| 109 | template<> void JSAudioTrackConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 110 | { |
| 111 | putDirect(vm, vm.propertyNames->prototype, JSAudioTrack::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 112 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("AudioTrack"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 113 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 114 | } |
| 115 | |
| 116 | template<> const ClassInfo JSAudioTrackConstructor::s_info = { "AudioTrack" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAudioTrackConstructor) }; |
| 117 | |
| 118 | /* Hash table for prototype */ |
| 119 | |
| 120 | static const HashTableValue JSAudioTrackPrototypeTableValues[] = |
| 121 | { |
| 122 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAudioTrackConstructor) } }, |
| 123 | { "id" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 124 | #if ENABLE(MEDIA_SOURCE) |
| 125 | { "kind" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackKind), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAudioTrackKind) } }, |
| 126 | #else |
| 127 | { "kind" , JSC::PropertyAttribute::ReadOnly | static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackKind), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 128 | #endif |
| 129 | { "label" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackLabel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 130 | #if ENABLE(MEDIA_SOURCE) |
| 131 | { "language" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackLanguage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAudioTrackLanguage) } }, |
| 132 | #else |
| 133 | { "language" , JSC::PropertyAttribute::ReadOnly | static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackLanguage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 134 | #endif |
| 135 | { "enabled" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackEnabled), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAudioTrackEnabled) } }, |
| 136 | #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK) |
| 137 | { "sourceBuffer" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioTrackSourceBuffer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 138 | #else |
| 139 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
| 140 | #endif |
| 141 | }; |
| 142 | |
| 143 | const ClassInfo JSAudioTrackPrototype::s_info = { "AudioTrackPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAudioTrackPrototype) }; |
| 144 | |
| 145 | void JSAudioTrackPrototype::finishCreation(VM& vm) |
| 146 | { |
| 147 | Base::finishCreation(vm); |
| 148 | reifyStaticProperties(vm, JSAudioTrack::info(), JSAudioTrackPrototypeTableValues, *this); |
| 149 | } |
| 150 | |
| 151 | const ClassInfo JSAudioTrack::s_info = { "AudioTrack" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAudioTrack) }; |
| 152 | |
| 153 | JSAudioTrack::JSAudioTrack(Structure* structure, JSDOMGlobalObject& globalObject, Ref<AudioTrack>&& impl) |
| 154 | : JSDOMWrapper<AudioTrack>(structure, globalObject, WTFMove(impl)) |
| 155 | { |
| 156 | } |
| 157 | |
| 158 | void JSAudioTrack::finishCreation(VM& vm) |
| 159 | { |
| 160 | Base::finishCreation(vm); |
| 161 | ASSERT(inherits(vm, info())); |
| 162 | |
| 163 | } |
| 164 | |
| 165 | JSObject* JSAudioTrack::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 166 | { |
| 167 | return JSAudioTrackPrototype::create(vm, &globalObject, JSAudioTrackPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 168 | } |
| 169 | |
| 170 | JSObject* JSAudioTrack::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 171 | { |
| 172 | return getDOMPrototype<JSAudioTrack>(vm, globalObject); |
| 173 | } |
| 174 | |
| 175 | JSValue JSAudioTrack::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 176 | { |
| 177 | return getDOMConstructor<JSAudioTrackConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 178 | } |
| 179 | |
| 180 | void JSAudioTrack::destroy(JSC::JSCell* cell) |
| 181 | { |
| 182 | JSAudioTrack* thisObject = static_cast<JSAudioTrack*>(cell); |
| 183 | thisObject->JSAudioTrack::~JSAudioTrack(); |
| 184 | } |
| 185 | |
| 186 | template<> inline JSAudioTrack* IDLAttribute<JSAudioTrack>::cast(ExecState& state, EncodedJSValue thisValue) |
| 187 | { |
| 188 | return jsDynamicCast<JSAudioTrack*>(state.vm(), JSValue::decode(thisValue)); |
| 189 | } |
| 190 | |
| 191 | EncodedJSValue jsAudioTrackConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 192 | { |
| 193 | VM& vm = state->vm(); |
| 194 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 195 | auto* prototype = jsDynamicCast<JSAudioTrackPrototype*>(vm, JSValue::decode(thisValue)); |
| 196 | if (UNLIKELY(!prototype)) |
| 197 | return throwVMTypeError(state, throwScope); |
| 198 | return JSValue::encode(JSAudioTrack::getConstructor(state->vm(), prototype->globalObject())); |
| 199 | } |
| 200 | |
| 201 | bool setJSAudioTrackConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 202 | { |
| 203 | VM& vm = state->vm(); |
| 204 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 205 | auto* prototype = jsDynamicCast<JSAudioTrackPrototype*>(vm, JSValue::decode(thisValue)); |
| 206 | if (UNLIKELY(!prototype)) { |
| 207 | throwVMTypeError(state, throwScope); |
| 208 | return false; |
| 209 | } |
| 210 | // Shadowing a built-in constructor |
| 211 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 212 | } |
| 213 | |
| 214 | static inline JSValue jsAudioTrackIdGetter(ExecState& state, JSAudioTrack& thisObject, ThrowScope& throwScope) |
| 215 | { |
| 216 | UNUSED_PARAM(throwScope); |
| 217 | UNUSED_PARAM(state); |
| 218 | auto& impl = thisObject.wrapped(); |
| 219 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.id()); |
| 220 | return result; |
| 221 | } |
| 222 | |
| 223 | EncodedJSValue jsAudioTrackId(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 224 | { |
| 225 | return IDLAttribute<JSAudioTrack>::get<jsAudioTrackIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "id" ); |
| 226 | } |
| 227 | |
| 228 | static inline JSValue jsAudioTrackKindGetter(ExecState& state, JSAudioTrack& thisObject, ThrowScope& throwScope) |
| 229 | { |
| 230 | UNUSED_PARAM(throwScope); |
| 231 | UNUSED_PARAM(state); |
| 232 | auto& impl = thisObject.wrapped(); |
| 233 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.kind()); |
| 234 | return result; |
| 235 | } |
| 236 | |
| 237 | EncodedJSValue jsAudioTrackKind(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 238 | { |
| 239 | return IDLAttribute<JSAudioTrack>::get<jsAudioTrackKindGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "kind" ); |
| 240 | } |
| 241 | |
| 242 | #if ENABLE(MEDIA_SOURCE) |
| 243 | static inline bool setJSAudioTrackKindSetter(ExecState& state, JSAudioTrack& thisObject, JSValue value, ThrowScope& throwScope) |
| 244 | { |
| 245 | UNUSED_PARAM(throwScope); |
| 246 | auto& impl = thisObject.wrapped(); |
| 247 | auto nativeValue = convert<IDLDOMString>(state, value); |
| 248 | RETURN_IF_EXCEPTION(throwScope, false); |
| 249 | AttributeSetter::call(state, throwScope, [&] { |
| 250 | return impl.setKind(WTFMove(nativeValue)); |
| 251 | }); |
| 252 | return true; |
| 253 | } |
| 254 | |
| 255 | bool setJSAudioTrackKind(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 256 | { |
| 257 | return IDLAttribute<JSAudioTrack>::set<setJSAudioTrackKindSetter>(*state, thisValue, encodedValue, "kind" ); |
| 258 | } |
| 259 | |
| 260 | #endif |
| 261 | |
| 262 | static inline JSValue jsAudioTrackLabelGetter(ExecState& state, JSAudioTrack& thisObject, ThrowScope& throwScope) |
| 263 | { |
| 264 | UNUSED_PARAM(throwScope); |
| 265 | UNUSED_PARAM(state); |
| 266 | auto& impl = thisObject.wrapped(); |
| 267 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.label()); |
| 268 | return result; |
| 269 | } |
| 270 | |
| 271 | EncodedJSValue jsAudioTrackLabel(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 272 | { |
| 273 | return IDLAttribute<JSAudioTrack>::get<jsAudioTrackLabelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "label" ); |
| 274 | } |
| 275 | |
| 276 | static inline JSValue jsAudioTrackLanguageGetter(ExecState& state, JSAudioTrack& thisObject, ThrowScope& throwScope) |
| 277 | { |
| 278 | UNUSED_PARAM(throwScope); |
| 279 | UNUSED_PARAM(state); |
| 280 | auto& impl = thisObject.wrapped(); |
| 281 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.language()); |
| 282 | return result; |
| 283 | } |
| 284 | |
| 285 | EncodedJSValue jsAudioTrackLanguage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 286 | { |
| 287 | return IDLAttribute<JSAudioTrack>::get<jsAudioTrackLanguageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "language" ); |
| 288 | } |
| 289 | |
| 290 | #if ENABLE(MEDIA_SOURCE) |
| 291 | static inline bool setJSAudioTrackLanguageSetter(ExecState& state, JSAudioTrack& thisObject, JSValue value, ThrowScope& throwScope) |
| 292 | { |
| 293 | UNUSED_PARAM(throwScope); |
| 294 | auto& impl = thisObject.wrapped(); |
| 295 | auto nativeValue = convert<IDLDOMString>(state, value); |
| 296 | RETURN_IF_EXCEPTION(throwScope, false); |
| 297 | AttributeSetter::call(state, throwScope, [&] { |
| 298 | return impl.setLanguage(WTFMove(nativeValue)); |
| 299 | }); |
| 300 | return true; |
| 301 | } |
| 302 | |
| 303 | bool setJSAudioTrackLanguage(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 304 | { |
| 305 | return IDLAttribute<JSAudioTrack>::set<setJSAudioTrackLanguageSetter>(*state, thisValue, encodedValue, "language" ); |
| 306 | } |
| 307 | |
| 308 | #endif |
| 309 | |
| 310 | static inline JSValue jsAudioTrackEnabledGetter(ExecState& state, JSAudioTrack& thisObject, ThrowScope& throwScope) |
| 311 | { |
| 312 | UNUSED_PARAM(throwScope); |
| 313 | UNUSED_PARAM(state); |
| 314 | auto& impl = thisObject.wrapped(); |
| 315 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.enabled()); |
| 316 | return result; |
| 317 | } |
| 318 | |
| 319 | EncodedJSValue jsAudioTrackEnabled(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 320 | { |
| 321 | return IDLAttribute<JSAudioTrack>::get<jsAudioTrackEnabledGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "enabled" ); |
| 322 | } |
| 323 | |
| 324 | static inline bool setJSAudioTrackEnabledSetter(ExecState& state, JSAudioTrack& thisObject, JSValue value, ThrowScope& throwScope) |
| 325 | { |
| 326 | UNUSED_PARAM(throwScope); |
| 327 | auto& impl = thisObject.wrapped(); |
| 328 | auto nativeValue = convert<IDLBoolean>(state, value); |
| 329 | RETURN_IF_EXCEPTION(throwScope, false); |
| 330 | AttributeSetter::call(state, throwScope, [&] { |
| 331 | return impl.setEnabled(WTFMove(nativeValue)); |
| 332 | }); |
| 333 | return true; |
| 334 | } |
| 335 | |
| 336 | bool setJSAudioTrackEnabled(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 337 | { |
| 338 | return IDLAttribute<JSAudioTrack>::set<setJSAudioTrackEnabledSetter>(*state, thisValue, encodedValue, "enabled" ); |
| 339 | } |
| 340 | |
| 341 | #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK) |
| 342 | static inline JSValue jsAudioTrackSourceBufferGetter(ExecState& state, JSAudioTrack& thisObject, ThrowScope& throwScope) |
| 343 | { |
| 344 | UNUSED_PARAM(throwScope); |
| 345 | UNUSED_PARAM(state); |
| 346 | auto& impl = thisObject.wrapped(); |
| 347 | JSValue result = toJS<IDLNullable<IDLInterface<SourceBuffer>>>(state, *thisObject.globalObject(), throwScope, WebCore::AudioTrackMediaSource::sourceBuffer(impl)); |
| 348 | return result; |
| 349 | } |
| 350 | |
| 351 | EncodedJSValue jsAudioTrackSourceBuffer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 352 | { |
| 353 | return IDLAttribute<JSAudioTrack>::get<jsAudioTrackSourceBufferGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sourceBuffer" ); |
| 354 | } |
| 355 | |
| 356 | #endif |
| 357 | |
| 358 | void JSAudioTrack::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 359 | { |
| 360 | auto* thisObject = jsCast<JSAudioTrack*>(cell); |
| 361 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 362 | Base::visitChildren(thisObject, visitor); |
| 363 | thisObject->visitAdditionalChildren(visitor); |
| 364 | } |
| 365 | |
| 366 | void JSAudioTrack::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 367 | { |
| 368 | auto* thisObject = jsCast<JSAudioTrack*>(cell); |
| 369 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 370 | Base::visitOutputConstraints(thisObject, visitor); |
| 371 | thisObject->visitAdditionalChildren(visitor); |
| 372 | } |
| 373 | |
| 374 | void JSAudioTrack::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 375 | { |
| 376 | auto* thisObject = jsCast<JSAudioTrack*>(cell); |
| 377 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 378 | if (thisObject->scriptExecutionContext()) |
| 379 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 380 | Base::heapSnapshot(cell, builder); |
| 381 | } |
| 382 | |
| 383 | bool JSAudioTrackOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 384 | { |
| 385 | auto* jsAudioTrack = jsCast<JSAudioTrack*>(handle.slot()->asCell()); |
| 386 | Element* element = WTF::getPtr(jsAudioTrack->wrapped().element()); |
| 387 | if (!element) |
| 388 | return false; |
| 389 | if (UNLIKELY(reason)) |
| 390 | *reason = "Reachable from AudioTrackOwner" ; |
| 391 | void* root = WebCore::root(element); |
| 392 | return visitor.containsOpaqueRoot(root); |
| 393 | } |
| 394 | |
| 395 | void JSAudioTrackOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 396 | { |
| 397 | auto* jsAudioTrack = static_cast<JSAudioTrack*>(handle.slot()->asCell()); |
| 398 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 399 | uncacheWrapper(world, &jsAudioTrack->wrapped(), jsAudioTrack); |
| 400 | } |
| 401 | |
| 402 | #if ENABLE(BINDING_INTEGRITY) |
| 403 | #if PLATFORM(WIN) |
| 404 | #pragma warning(disable: 4483) |
| 405 | extern "C" { extern void (*const __identifier("??_7AudioTrack@WebCore@@6B@" )[])(); } |
| 406 | #else |
| 407 | extern "C" { extern void* _ZTVN7WebCore10AudioTrackE[]; } |
| 408 | #endif |
| 409 | #endif |
| 410 | |
| 411 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<AudioTrack>&& impl) |
| 412 | { |
| 413 | |
| 414 | #if ENABLE(BINDING_INTEGRITY) |
| 415 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 416 | #if PLATFORM(WIN) |
| 417 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7AudioTrack@WebCore@@6B@" )); |
| 418 | #else |
| 419 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore10AudioTrackE[2]); |
| 420 | #endif |
| 421 | |
| 422 | // If this fails AudioTrack does not have a vtable, so you need to add the |
| 423 | // ImplementationLacksVTable attribute to the interface definition |
| 424 | static_assert(std::is_polymorphic<AudioTrack>::value, "AudioTrack is not polymorphic" ); |
| 425 | |
| 426 | // If you hit this assertion you either have a use after free bug, or |
| 427 | // AudioTrack has subclasses. If AudioTrack has subclasses that get passed |
| 428 | // to toJS() we currently require AudioTrack you to opt out of binding hardening |
| 429 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 430 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 431 | #endif |
| 432 | return createWrapper<AudioTrack>(globalObject, WTFMove(impl)); |
| 433 | } |
| 434 | |
| 435 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, AudioTrack& impl) |
| 436 | { |
| 437 | return wrap(state, globalObject, impl); |
| 438 | } |
| 439 | |
| 440 | AudioTrack* JSAudioTrack::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 441 | { |
| 442 | if (auto* wrapper = jsDynamicCast<JSAudioTrack*>(vm, value)) |
| 443 | return &wrapper->wrapped(); |
| 444 | return nullptr; |
| 445 | } |
| 446 | |
| 447 | } |
| 448 | |
| 449 | #endif // ENABLE(VIDEO_TRACK) |
| 450 | |