| 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(MEDIA_SOURCE) |
| 24 | |
| 25 | #include "JSSourceBufferList.h" |
| 26 | |
| 27 | #include "EventNames.h" |
| 28 | #include "JSDOMAttribute.h" |
| 29 | #include "JSDOMBinding.h" |
| 30 | #include "JSDOMConstructorNotConstructable.h" |
| 31 | #include "JSDOMConvertInterface.h" |
| 32 | #include "JSDOMConvertNumbers.h" |
| 33 | #include "JSDOMExceptionHandling.h" |
| 34 | #include "JSDOMGlobalObject.h" |
| 35 | #include "JSDOMOperation.h" |
| 36 | #include "JSDOMWrapperCache.h" |
| 37 | #include "JSEventListener.h" |
| 38 | #include "JSSourceBuffer.h" |
| 39 | #include "ScriptExecutionContext.h" |
| 40 | #include <JavaScriptCore/ArrayPrototype.h> |
| 41 | #include <JavaScriptCore/BuiltinNames.h> |
| 42 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 43 | #include <JavaScriptCore/JSCInlines.h> |
| 44 | #include <JavaScriptCore/PropertyNameArray.h> |
| 45 | #include <wtf/GetPtr.h> |
| 46 | #include <wtf/PointerPreparations.h> |
| 47 | #include <wtf/URL.h> |
| 48 | |
| 49 | |
| 50 | namespace WebCore { |
| 51 | using namespace JSC; |
| 52 | |
| 53 | // Functions |
| 54 | |
| 55 | JSC::EncodedJSValue JSC_HOST_CALL jsSourceBufferListPrototypeFunctionItem(JSC::ExecState*); |
| 56 | |
| 57 | // Attributes |
| 58 | |
| 59 | JSC::EncodedJSValue jsSourceBufferListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 60 | bool setJSSourceBufferListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 61 | JSC::EncodedJSValue jsSourceBufferListLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 62 | JSC::EncodedJSValue jsSourceBufferListOnaddsourcebuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 63 | bool setJSSourceBufferListOnaddsourcebuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 64 | JSC::EncodedJSValue jsSourceBufferListOnremovesourcebuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 65 | bool setJSSourceBufferListOnremovesourcebuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 66 | |
| 67 | class JSSourceBufferListPrototype : public JSC::JSNonFinalObject { |
| 68 | public: |
| 69 | using Base = JSC::JSNonFinalObject; |
| 70 | static JSSourceBufferListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 71 | { |
| 72 | JSSourceBufferListPrototype* ptr = new (NotNull, JSC::allocateCell<JSSourceBufferListPrototype>(vm.heap)) JSSourceBufferListPrototype(vm, globalObject, structure); |
| 73 | ptr->finishCreation(vm); |
| 74 | return ptr; |
| 75 | } |
| 76 | |
| 77 | DECLARE_INFO; |
| 78 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 79 | { |
| 80 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 81 | } |
| 82 | |
| 83 | private: |
| 84 | JSSourceBufferListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 85 | : JSC::JSNonFinalObject(vm, structure) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | void finishCreation(JSC::VM&); |
| 90 | }; |
| 91 | |
| 92 | using JSSourceBufferListConstructor = JSDOMConstructorNotConstructable<JSSourceBufferList>; |
| 93 | |
| 94 | template<> JSValue JSSourceBufferListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 95 | { |
| 96 | return JSEventTarget::getConstructor(vm, &globalObject); |
| 97 | } |
| 98 | |
| 99 | template<> void JSSourceBufferListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 100 | { |
| 101 | putDirect(vm, vm.propertyNames->prototype, JSSourceBufferList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 102 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SourceBufferList"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 103 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 104 | } |
| 105 | |
| 106 | template<> const ClassInfo JSSourceBufferListConstructor::s_info = { "SourceBufferList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSourceBufferListConstructor) }; |
| 107 | |
| 108 | /* Hash table for prototype */ |
| 109 | |
| 110 | static const HashTableValue JSSourceBufferListPrototypeTableValues[] = |
| 111 | { |
| 112 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferListConstructor) } }, |
| 113 | { "length" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferListLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 114 | { "onaddsourcebuffer" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferListOnaddsourcebuffer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferListOnaddsourcebuffer) } }, |
| 115 | { "onremovesourcebuffer" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferListOnremovesourcebuffer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferListOnremovesourcebuffer) } }, |
| 116 | { "item" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSourceBufferListPrototypeFunctionItem), (intptr_t) (1) } }, |
| 117 | }; |
| 118 | |
| 119 | const ClassInfo JSSourceBufferListPrototype::s_info = { "SourceBufferListPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSourceBufferListPrototype) }; |
| 120 | |
| 121 | void JSSourceBufferListPrototype::finishCreation(VM& vm) |
| 122 | { |
| 123 | Base::finishCreation(vm); |
| 124 | reifyStaticProperties(vm, JSSourceBufferList::info(), JSSourceBufferListPrototypeTableValues, *this); |
| 125 | putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
| 126 | } |
| 127 | |
| 128 | const ClassInfo JSSourceBufferList::s_info = { "SourceBufferList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSourceBufferList) }; |
| 129 | |
| 130 | JSSourceBufferList::JSSourceBufferList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SourceBufferList>&& impl) |
| 131 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| 132 | { |
| 133 | } |
| 134 | |
| 135 | void JSSourceBufferList::finishCreation(VM& vm) |
| 136 | { |
| 137 | Base::finishCreation(vm); |
| 138 | ASSERT(inherits(vm, info())); |
| 139 | |
| 140 | } |
| 141 | |
| 142 | JSObject* JSSourceBufferList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 143 | { |
| 144 | return JSSourceBufferListPrototype::create(vm, &globalObject, JSSourceBufferListPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
| 145 | } |
| 146 | |
| 147 | JSObject* JSSourceBufferList::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 148 | { |
| 149 | return getDOMPrototype<JSSourceBufferList>(vm, globalObject); |
| 150 | } |
| 151 | |
| 152 | JSValue JSSourceBufferList::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 153 | { |
| 154 | return getDOMConstructor<JSSourceBufferListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 155 | } |
| 156 | |
| 157 | bool JSSourceBufferList::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot) |
| 158 | { |
| 159 | auto* thisObject = jsCast<JSSourceBufferList*>(object); |
| 160 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 161 | if (auto index = parseIndex(propertyName)) { |
| 162 | if (index.value() < thisObject->wrapped().length()) { |
| 163 | auto value = toJS<IDLInterface<SourceBuffer>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value())); |
| 164 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
| 165 | return true; |
| 166 | } |
| 167 | } |
| 168 | return JSObject::getOwnPropertySlot(object, state, propertyName, slot); |
| 169 | } |
| 170 | |
| 171 | bool JSSourceBufferList::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot) |
| 172 | { |
| 173 | auto* thisObject = jsCast<JSSourceBufferList*>(object); |
| 174 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 175 | if (LIKELY(index <= MAX_ARRAY_INDEX)) { |
| 176 | if (index < thisObject->wrapped().length()) { |
| 177 | auto value = toJS<IDLInterface<SourceBuffer>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index)); |
| 178 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
| 179 | return true; |
| 180 | } |
| 181 | } |
| 182 | return JSObject::getOwnPropertySlotByIndex(object, state, index, slot); |
| 183 | } |
| 184 | |
| 185 | void JSSourceBufferList::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode) |
| 186 | { |
| 187 | auto* thisObject = jsCast<JSSourceBufferList*>(object); |
| 188 | ASSERT_GC_OBJECT_INHERITS(object, info()); |
| 189 | for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i) |
| 190 | propertyNames.add(Identifier::from(state, i)); |
| 191 | JSObject::getOwnPropertyNames(object, state, propertyNames, mode); |
| 192 | } |
| 193 | |
| 194 | template<> inline JSSourceBufferList* IDLAttribute<JSSourceBufferList>::cast(ExecState& state, EncodedJSValue thisValue) |
| 195 | { |
| 196 | return jsDynamicCast<JSSourceBufferList*>(state.vm(), JSValue::decode(thisValue)); |
| 197 | } |
| 198 | |
| 199 | template<> inline JSSourceBufferList* IDLOperation<JSSourceBufferList>::cast(ExecState& state) |
| 200 | { |
| 201 | return jsDynamicCast<JSSourceBufferList*>(state.vm(), state.thisValue()); |
| 202 | } |
| 203 | |
| 204 | EncodedJSValue jsSourceBufferListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 205 | { |
| 206 | VM& vm = state->vm(); |
| 207 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 208 | auto* prototype = jsDynamicCast<JSSourceBufferListPrototype*>(vm, JSValue::decode(thisValue)); |
| 209 | if (UNLIKELY(!prototype)) |
| 210 | return throwVMTypeError(state, throwScope); |
| 211 | return JSValue::encode(JSSourceBufferList::getConstructor(state->vm(), prototype->globalObject())); |
| 212 | } |
| 213 | |
| 214 | bool setJSSourceBufferListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 215 | { |
| 216 | VM& vm = state->vm(); |
| 217 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 218 | auto* prototype = jsDynamicCast<JSSourceBufferListPrototype*>(vm, JSValue::decode(thisValue)); |
| 219 | if (UNLIKELY(!prototype)) { |
| 220 | throwVMTypeError(state, throwScope); |
| 221 | return false; |
| 222 | } |
| 223 | // Shadowing a built-in constructor |
| 224 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 225 | } |
| 226 | |
| 227 | static inline JSValue jsSourceBufferListLengthGetter(ExecState& state, JSSourceBufferList& thisObject, ThrowScope& throwScope) |
| 228 | { |
| 229 | UNUSED_PARAM(throwScope); |
| 230 | UNUSED_PARAM(state); |
| 231 | auto& impl = thisObject.wrapped(); |
| 232 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length()); |
| 233 | return result; |
| 234 | } |
| 235 | |
| 236 | EncodedJSValue jsSourceBufferListLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 237 | { |
| 238 | return IDLAttribute<JSSourceBufferList>::get<jsSourceBufferListLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length" ); |
| 239 | } |
| 240 | |
| 241 | static inline JSValue jsSourceBufferListOnaddsourcebufferGetter(ExecState& state, JSSourceBufferList& thisObject, ThrowScope& throwScope) |
| 242 | { |
| 243 | UNUSED_PARAM(throwScope); |
| 244 | UNUSED_PARAM(state); |
| 245 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().addsourcebufferEvent, worldForDOMObject(thisObject)); |
| 246 | } |
| 247 | |
| 248 | EncodedJSValue jsSourceBufferListOnaddsourcebuffer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 249 | { |
| 250 | return IDLAttribute<JSSourceBufferList>::get<jsSourceBufferListOnaddsourcebufferGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onaddsourcebuffer" ); |
| 251 | } |
| 252 | |
| 253 | static inline bool setJSSourceBufferListOnaddsourcebufferSetter(ExecState& state, JSSourceBufferList& thisObject, JSValue value, ThrowScope& throwScope) |
| 254 | { |
| 255 | UNUSED_PARAM(throwScope); |
| 256 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().addsourcebufferEvent, value); |
| 257 | return true; |
| 258 | } |
| 259 | |
| 260 | bool setJSSourceBufferListOnaddsourcebuffer(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 261 | { |
| 262 | return IDLAttribute<JSSourceBufferList>::set<setJSSourceBufferListOnaddsourcebufferSetter>(*state, thisValue, encodedValue, "onaddsourcebuffer" ); |
| 263 | } |
| 264 | |
| 265 | static inline JSValue jsSourceBufferListOnremovesourcebufferGetter(ExecState& state, JSSourceBufferList& thisObject, ThrowScope& throwScope) |
| 266 | { |
| 267 | UNUSED_PARAM(throwScope); |
| 268 | UNUSED_PARAM(state); |
| 269 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().removesourcebufferEvent, worldForDOMObject(thisObject)); |
| 270 | } |
| 271 | |
| 272 | EncodedJSValue jsSourceBufferListOnremovesourcebuffer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 273 | { |
| 274 | return IDLAttribute<JSSourceBufferList>::get<jsSourceBufferListOnremovesourcebufferGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onremovesourcebuffer" ); |
| 275 | } |
| 276 | |
| 277 | static inline bool setJSSourceBufferListOnremovesourcebufferSetter(ExecState& state, JSSourceBufferList& thisObject, JSValue value, ThrowScope& throwScope) |
| 278 | { |
| 279 | UNUSED_PARAM(throwScope); |
| 280 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().removesourcebufferEvent, value); |
| 281 | return true; |
| 282 | } |
| 283 | |
| 284 | bool setJSSourceBufferListOnremovesourcebuffer(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 285 | { |
| 286 | return IDLAttribute<JSSourceBufferList>::set<setJSSourceBufferListOnremovesourcebufferSetter>(*state, thisValue, encodedValue, "onremovesourcebuffer" ); |
| 287 | } |
| 288 | |
| 289 | static inline JSC::EncodedJSValue jsSourceBufferListPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSSourceBufferList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 290 | { |
| 291 | UNUSED_PARAM(state); |
| 292 | UNUSED_PARAM(throwScope); |
| 293 | auto& impl = castedThis->wrapped(); |
| 294 | if (UNLIKELY(state->argumentCount() < 1)) |
| 295 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 296 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
| 297 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 298 | return JSValue::encode(toJS<IDLInterface<SourceBuffer>>(*state, *castedThis->globalObject(), impl.item(WTFMove(index)))); |
| 299 | } |
| 300 | |
| 301 | EncodedJSValue JSC_HOST_CALL jsSourceBufferListPrototypeFunctionItem(ExecState* state) |
| 302 | { |
| 303 | return IDLOperation<JSSourceBufferList>::call<jsSourceBufferListPrototypeFunctionItemBody>(*state, "item" ); |
| 304 | } |
| 305 | |
| 306 | void JSSourceBufferList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 307 | { |
| 308 | auto* thisObject = jsCast<JSSourceBufferList*>(cell); |
| 309 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 310 | if (thisObject->scriptExecutionContext()) |
| 311 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 312 | Base::heapSnapshot(cell, builder); |
| 313 | } |
| 314 | |
| 315 | bool JSSourceBufferListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 316 | { |
| 317 | auto* jsSourceBufferList = jsCast<JSSourceBufferList*>(handle.slot()->asCell()); |
| 318 | if (jsSourceBufferList->wrapped().hasPendingActivity()) { |
| 319 | if (UNLIKELY(reason)) |
| 320 | *reason = "ActiveDOMObject with pending activity" ; |
| 321 | return true; |
| 322 | } |
| 323 | if (jsSourceBufferList->wrapped().isFiringEventListeners()) { |
| 324 | if (UNLIKELY(reason)) |
| 325 | *reason = "EventTarget firing event listeners" ; |
| 326 | return true; |
| 327 | } |
| 328 | SourceBufferList* root = &jsSourceBufferList->wrapped(); |
| 329 | if (UNLIKELY(reason)) |
| 330 | *reason = "Reachable from SourceBufferList" ; |
| 331 | return visitor.containsOpaqueRoot(root); |
| 332 | } |
| 333 | |
| 334 | void JSSourceBufferListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 335 | { |
| 336 | auto* jsSourceBufferList = static_cast<JSSourceBufferList*>(handle.slot()->asCell()); |
| 337 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 338 | uncacheWrapper(world, &jsSourceBufferList->wrapped(), jsSourceBufferList); |
| 339 | } |
| 340 | |
| 341 | #if ENABLE(BINDING_INTEGRITY) |
| 342 | #if PLATFORM(WIN) |
| 343 | #pragma warning(disable: 4483) |
| 344 | extern "C" { extern void (*const __identifier("??_7SourceBufferList@WebCore@@6B@" )[])(); } |
| 345 | #else |
| 346 | extern "C" { extern void* _ZTVN7WebCore16SourceBufferListE[]; } |
| 347 | #endif |
| 348 | #endif |
| 349 | |
| 350 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SourceBufferList>&& impl) |
| 351 | { |
| 352 | |
| 353 | #if ENABLE(BINDING_INTEGRITY) |
| 354 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 355 | #if PLATFORM(WIN) |
| 356 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7SourceBufferList@WebCore@@6B@" )); |
| 357 | #else |
| 358 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore16SourceBufferListE[2]); |
| 359 | #endif |
| 360 | |
| 361 | // If this fails SourceBufferList does not have a vtable, so you need to add the |
| 362 | // ImplementationLacksVTable attribute to the interface definition |
| 363 | static_assert(std::is_polymorphic<SourceBufferList>::value, "SourceBufferList is not polymorphic" ); |
| 364 | |
| 365 | // If you hit this assertion you either have a use after free bug, or |
| 366 | // SourceBufferList has subclasses. If SourceBufferList has subclasses that get passed |
| 367 | // to toJS() we currently require SourceBufferList you to opt out of binding hardening |
| 368 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 369 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 370 | #endif |
| 371 | return createWrapper<SourceBufferList>(globalObject, WTFMove(impl)); |
| 372 | } |
| 373 | |
| 374 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SourceBufferList& impl) |
| 375 | { |
| 376 | return wrap(state, globalObject, impl); |
| 377 | } |
| 378 | |
| 379 | SourceBufferList* JSSourceBufferList::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 380 | { |
| 381 | if (auto* wrapper = jsDynamicCast<JSSourceBufferList*>(vm, value)) |
| 382 | return &wrapper->wrapped(); |
| 383 | return nullptr; |
| 384 | } |
| 385 | |
| 386 | } |
| 387 | |
| 388 | #endif // ENABLE(MEDIA_SOURCE) |
| 389 | |