| 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(WEB_RTC) |
| 24 | |
| 25 | #include "JSRTCTrackEvent.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructor.h" |
| 30 | #include "JSDOMConvertBoolean.h" |
| 31 | #include "JSDOMConvertInterface.h" |
| 32 | #include "JSDOMConvertSequences.h" |
| 33 | #include "JSDOMExceptionHandling.h" |
| 34 | #include "JSDOMGlobalObject.h" |
| 35 | #include "JSDOMWrapperCache.h" |
| 36 | #include "JSMediaStream.h" |
| 37 | #include "JSMediaStreamTrack.h" |
| 38 | #include "JSRTCRtpReceiver.h" |
| 39 | #include "JSRTCRtpTransceiver.h" |
| 40 | #include "ScriptExecutionContext.h" |
| 41 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 42 | #include <JavaScriptCore/JSArray.h> |
| 43 | #include <JavaScriptCore/JSCInlines.h> |
| 44 | #include <wtf/GetPtr.h> |
| 45 | #include <wtf/PointerPreparations.h> |
| 46 | #include <wtf/URL.h> |
| 47 | |
| 48 | #if ENABLE(WEB_RTC) |
| 49 | #include "JSDOMConvertStrings.h" |
| 50 | #endif |
| 51 | |
| 52 | |
| 53 | namespace WebCore { |
| 54 | using namespace JSC; |
| 55 | |
| 56 | template<> RTCTrackEvent::Init convertDictionary<RTCTrackEvent::Init>(ExecState& state, JSValue value) |
| 57 | { |
| 58 | VM& vm = state.vm(); |
| 59 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 60 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 61 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 62 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 63 | throwTypeError(&state, throwScope); |
| 64 | return { }; |
| 65 | } |
| 66 | RTCTrackEvent::Init result; |
| 67 | JSValue bubblesValue; |
| 68 | if (isNullOrUndefined) |
| 69 | bubblesValue = jsUndefined(); |
| 70 | else { |
| 71 | bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles" )); |
| 72 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 73 | } |
| 74 | if (!bubblesValue.isUndefined()) { |
| 75 | result.bubbles = convert<IDLBoolean>(state, bubblesValue); |
| 76 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 77 | } else |
| 78 | result.bubbles = false; |
| 79 | JSValue cancelableValue; |
| 80 | if (isNullOrUndefined) |
| 81 | cancelableValue = jsUndefined(); |
| 82 | else { |
| 83 | cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable" )); |
| 84 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 85 | } |
| 86 | if (!cancelableValue.isUndefined()) { |
| 87 | result.cancelable = convert<IDLBoolean>(state, cancelableValue); |
| 88 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 89 | } else |
| 90 | result.cancelable = false; |
| 91 | JSValue composedValue; |
| 92 | if (isNullOrUndefined) |
| 93 | composedValue = jsUndefined(); |
| 94 | else { |
| 95 | composedValue = object->get(&state, Identifier::fromString(&state, "composed" )); |
| 96 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 97 | } |
| 98 | if (!composedValue.isUndefined()) { |
| 99 | result.composed = convert<IDLBoolean>(state, composedValue); |
| 100 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 101 | } else |
| 102 | result.composed = false; |
| 103 | JSValue receiverValue; |
| 104 | if (isNullOrUndefined) |
| 105 | receiverValue = jsUndefined(); |
| 106 | else { |
| 107 | receiverValue = object->get(&state, Identifier::fromString(&state, "receiver" )); |
| 108 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 109 | } |
| 110 | if (!receiverValue.isUndefined()) { |
| 111 | result.receiver = convert<IDLInterface<RTCRtpReceiver>>(state, receiverValue); |
| 112 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 113 | } else { |
| 114 | throwRequiredMemberTypeError(state, throwScope, "receiver" , "RTCTrackEventInit" , "RTCRtpReceiver" ); |
| 115 | return { }; |
| 116 | } |
| 117 | JSValue streamsValue; |
| 118 | if (isNullOrUndefined) |
| 119 | streamsValue = jsUndefined(); |
| 120 | else { |
| 121 | streamsValue = object->get(&state, Identifier::fromString(&state, "streams" )); |
| 122 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 123 | } |
| 124 | if (!streamsValue.isUndefined()) { |
| 125 | result.streams = convert<IDLSequence<IDLInterface<MediaStream>>>(state, streamsValue); |
| 126 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 127 | } else |
| 128 | result.streams = Converter<IDLSequence<IDLInterface<MediaStream>>>::ReturnType{ }; |
| 129 | JSValue trackValue; |
| 130 | if (isNullOrUndefined) |
| 131 | trackValue = jsUndefined(); |
| 132 | else { |
| 133 | trackValue = object->get(&state, Identifier::fromString(&state, "track" )); |
| 134 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 135 | } |
| 136 | if (!trackValue.isUndefined()) { |
| 137 | result.track = convert<IDLInterface<MediaStreamTrack>>(state, trackValue); |
| 138 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 139 | } else { |
| 140 | throwRequiredMemberTypeError(state, throwScope, "track" , "RTCTrackEventInit" , "MediaStreamTrack" ); |
| 141 | return { }; |
| 142 | } |
| 143 | JSValue transceiverValue; |
| 144 | if (isNullOrUndefined) |
| 145 | transceiverValue = jsUndefined(); |
| 146 | else { |
| 147 | transceiverValue = object->get(&state, Identifier::fromString(&state, "transceiver" )); |
| 148 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 149 | } |
| 150 | if (!transceiverValue.isUndefined()) { |
| 151 | result.transceiver = convert<IDLInterface<RTCRtpTransceiver>>(state, transceiverValue); |
| 152 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 153 | } else { |
| 154 | throwRequiredMemberTypeError(state, throwScope, "transceiver" , "RTCTrackEventInit" , "RTCRtpTransceiver" ); |
| 155 | return { }; |
| 156 | } |
| 157 | return result; |
| 158 | } |
| 159 | |
| 160 | // Attributes |
| 161 | |
| 162 | JSC::EncodedJSValue jsRTCTrackEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 163 | bool setJSRTCTrackEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 164 | JSC::EncodedJSValue jsRTCTrackEventReceiver(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 165 | JSC::EncodedJSValue jsRTCTrackEventTrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 166 | JSC::EncodedJSValue jsRTCTrackEventStreams(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 167 | JSC::EncodedJSValue jsRTCTrackEventTransceiver(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 168 | |
| 169 | class JSRTCTrackEventPrototype : public JSC::JSNonFinalObject { |
| 170 | public: |
| 171 | using Base = JSC::JSNonFinalObject; |
| 172 | static JSRTCTrackEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 173 | { |
| 174 | JSRTCTrackEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCTrackEventPrototype>(vm.heap)) JSRTCTrackEventPrototype(vm, globalObject, structure); |
| 175 | ptr->finishCreation(vm); |
| 176 | return ptr; |
| 177 | } |
| 178 | |
| 179 | DECLARE_INFO; |
| 180 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 181 | { |
| 182 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 183 | } |
| 184 | |
| 185 | private: |
| 186 | JSRTCTrackEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 187 | : JSC::JSNonFinalObject(vm, structure) |
| 188 | { |
| 189 | } |
| 190 | |
| 191 | void finishCreation(JSC::VM&); |
| 192 | }; |
| 193 | |
| 194 | using JSRTCTrackEventConstructor = JSDOMConstructor<JSRTCTrackEvent>; |
| 195 | |
| 196 | template<> EncodedJSValue JSC_HOST_CALL JSRTCTrackEventConstructor::construct(ExecState* state) |
| 197 | { |
| 198 | VM& vm = state->vm(); |
| 199 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 200 | UNUSED_PARAM(throwScope); |
| 201 | auto* castedThis = jsCast<JSRTCTrackEventConstructor*>(state->jsCallee()); |
| 202 | ASSERT(castedThis); |
| 203 | if (UNLIKELY(state->argumentCount() < 2)) |
| 204 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 205 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 206 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 207 | auto eventInitDict = convert<IDLDictionary<RTCTrackEvent::Init>>(*state, state->uncheckedArgument(1)); |
| 208 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 209 | auto object = RTCTrackEvent::create(WTFMove(type), WTFMove(eventInitDict)); |
| 210 | return JSValue::encode(toJSNewlyCreated<IDLInterface<RTCTrackEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 211 | } |
| 212 | |
| 213 | template<> JSValue JSRTCTrackEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 214 | { |
| 215 | return JSEvent::getConstructor(vm, &globalObject); |
| 216 | } |
| 217 | |
| 218 | template<> void JSRTCTrackEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 219 | { |
| 220 | putDirect(vm, vm.propertyNames->prototype, JSRTCTrackEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 221 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("RTCTrackEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 222 | putDirect(vm, vm.propertyNames->length, jsNumber(2), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 223 | } |
| 224 | |
| 225 | template<> const ClassInfo JSRTCTrackEventConstructor::s_info = { "RTCTrackEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCTrackEventConstructor) }; |
| 226 | |
| 227 | /* Hash table for prototype */ |
| 228 | |
| 229 | static const HashTableValue JSRTCTrackEventPrototypeTableValues[] = |
| 230 | { |
| 231 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCTrackEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCTrackEventConstructor) } }, |
| 232 | { "receiver" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCTrackEventReceiver), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 233 | { "track" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCTrackEventTrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 234 | { "streams" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCTrackEventStreams), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 235 | { "transceiver" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCTrackEventTransceiver), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 236 | }; |
| 237 | |
| 238 | const ClassInfo JSRTCTrackEventPrototype::s_info = { "RTCTrackEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCTrackEventPrototype) }; |
| 239 | |
| 240 | void JSRTCTrackEventPrototype::finishCreation(VM& vm) |
| 241 | { |
| 242 | Base::finishCreation(vm); |
| 243 | reifyStaticProperties(vm, JSRTCTrackEvent::info(), JSRTCTrackEventPrototypeTableValues, *this); |
| 244 | } |
| 245 | |
| 246 | const ClassInfo JSRTCTrackEvent::s_info = { "RTCTrackEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCTrackEvent) }; |
| 247 | |
| 248 | JSRTCTrackEvent::JSRTCTrackEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCTrackEvent>&& impl) |
| 249 | : JSEvent(structure, globalObject, WTFMove(impl)) |
| 250 | { |
| 251 | } |
| 252 | |
| 253 | void JSRTCTrackEvent::finishCreation(VM& vm) |
| 254 | { |
| 255 | Base::finishCreation(vm); |
| 256 | ASSERT(inherits(vm, info())); |
| 257 | |
| 258 | } |
| 259 | |
| 260 | JSObject* JSRTCTrackEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 261 | { |
| 262 | return JSRTCTrackEventPrototype::create(vm, &globalObject, JSRTCTrackEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
| 263 | } |
| 264 | |
| 265 | JSObject* JSRTCTrackEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 266 | { |
| 267 | return getDOMPrototype<JSRTCTrackEvent>(vm, globalObject); |
| 268 | } |
| 269 | |
| 270 | JSValue JSRTCTrackEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 271 | { |
| 272 | return getDOMConstructor<JSRTCTrackEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 273 | } |
| 274 | |
| 275 | template<> inline JSRTCTrackEvent* IDLAttribute<JSRTCTrackEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
| 276 | { |
| 277 | return jsDynamicCast<JSRTCTrackEvent*>(state.vm(), JSValue::decode(thisValue)); |
| 278 | } |
| 279 | |
| 280 | EncodedJSValue jsRTCTrackEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 281 | { |
| 282 | VM& vm = state->vm(); |
| 283 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 284 | auto* prototype = jsDynamicCast<JSRTCTrackEventPrototype*>(vm, JSValue::decode(thisValue)); |
| 285 | if (UNLIKELY(!prototype)) |
| 286 | return throwVMTypeError(state, throwScope); |
| 287 | return JSValue::encode(JSRTCTrackEvent::getConstructor(state->vm(), prototype->globalObject())); |
| 288 | } |
| 289 | |
| 290 | bool setJSRTCTrackEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 291 | { |
| 292 | VM& vm = state->vm(); |
| 293 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 294 | auto* prototype = jsDynamicCast<JSRTCTrackEventPrototype*>(vm, JSValue::decode(thisValue)); |
| 295 | if (UNLIKELY(!prototype)) { |
| 296 | throwVMTypeError(state, throwScope); |
| 297 | return false; |
| 298 | } |
| 299 | // Shadowing a built-in constructor |
| 300 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 301 | } |
| 302 | |
| 303 | static inline JSValue jsRTCTrackEventReceiverGetter(ExecState& state, JSRTCTrackEvent& thisObject, ThrowScope& throwScope) |
| 304 | { |
| 305 | UNUSED_PARAM(throwScope); |
| 306 | UNUSED_PARAM(state); |
| 307 | auto& impl = thisObject.wrapped(); |
| 308 | JSValue result = toJS<IDLInterface<RTCRtpReceiver>>(state, *thisObject.globalObject(), throwScope, impl.receiver()); |
| 309 | return result; |
| 310 | } |
| 311 | |
| 312 | EncodedJSValue jsRTCTrackEventReceiver(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 313 | { |
| 314 | return IDLAttribute<JSRTCTrackEvent>::get<jsRTCTrackEventReceiverGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "receiver" ); |
| 315 | } |
| 316 | |
| 317 | static inline JSValue jsRTCTrackEventTrackGetter(ExecState& state, JSRTCTrackEvent& thisObject, ThrowScope& throwScope) |
| 318 | { |
| 319 | UNUSED_PARAM(throwScope); |
| 320 | UNUSED_PARAM(state); |
| 321 | auto& impl = thisObject.wrapped(); |
| 322 | JSValue result = toJS<IDLInterface<MediaStreamTrack>>(state, *thisObject.globalObject(), throwScope, impl.track()); |
| 323 | return result; |
| 324 | } |
| 325 | |
| 326 | EncodedJSValue jsRTCTrackEventTrack(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 327 | { |
| 328 | return IDLAttribute<JSRTCTrackEvent>::get<jsRTCTrackEventTrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "track" ); |
| 329 | } |
| 330 | |
| 331 | static inline JSValue jsRTCTrackEventStreamsGetter(ExecState& state, JSRTCTrackEvent& thisObject, ThrowScope& throwScope) |
| 332 | { |
| 333 | UNUSED_PARAM(throwScope); |
| 334 | UNUSED_PARAM(state); |
| 335 | if (JSValue cachedValue = thisObject.m_streams.get()) |
| 336 | return cachedValue; |
| 337 | auto& impl = thisObject.wrapped(); |
| 338 | JSValue result = toJS<IDLFrozenArray<IDLInterface<MediaStream>>>(state, *thisObject.globalObject(), throwScope, impl.streams()); |
| 339 | thisObject.m_streams.set(state.vm(), &thisObject, result); |
| 340 | return result; |
| 341 | } |
| 342 | |
| 343 | EncodedJSValue jsRTCTrackEventStreams(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 344 | { |
| 345 | return IDLAttribute<JSRTCTrackEvent>::get<jsRTCTrackEventStreamsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "streams" ); |
| 346 | } |
| 347 | |
| 348 | static inline JSValue jsRTCTrackEventTransceiverGetter(ExecState& state, JSRTCTrackEvent& thisObject, ThrowScope& throwScope) |
| 349 | { |
| 350 | UNUSED_PARAM(throwScope); |
| 351 | UNUSED_PARAM(state); |
| 352 | auto& impl = thisObject.wrapped(); |
| 353 | JSValue result = toJS<IDLInterface<RTCRtpTransceiver>>(state, *thisObject.globalObject(), throwScope, impl.transceiver()); |
| 354 | return result; |
| 355 | } |
| 356 | |
| 357 | EncodedJSValue jsRTCTrackEventTransceiver(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 358 | { |
| 359 | return IDLAttribute<JSRTCTrackEvent>::get<jsRTCTrackEventTransceiverGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "transceiver" ); |
| 360 | } |
| 361 | |
| 362 | void JSRTCTrackEvent::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 363 | { |
| 364 | auto* thisObject = jsCast<JSRTCTrackEvent*>(cell); |
| 365 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 366 | Base::visitChildren(thisObject, visitor); |
| 367 | visitor.append(thisObject->m_streams); |
| 368 | } |
| 369 | |
| 370 | void JSRTCTrackEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 371 | { |
| 372 | auto* thisObject = jsCast<JSRTCTrackEvent*>(cell); |
| 373 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 374 | if (thisObject->scriptExecutionContext()) |
| 375 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 376 | Base::heapSnapshot(cell, builder); |
| 377 | } |
| 378 | |
| 379 | #if ENABLE(BINDING_INTEGRITY) |
| 380 | #if PLATFORM(WIN) |
| 381 | #pragma warning(disable: 4483) |
| 382 | extern "C" { extern void (*const __identifier("??_7RTCTrackEvent@WebCore@@6B@" )[])(); } |
| 383 | #else |
| 384 | extern "C" { extern void* _ZTVN7WebCore13RTCTrackEventE[]; } |
| 385 | #endif |
| 386 | #endif |
| 387 | |
| 388 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCTrackEvent>&& impl) |
| 389 | { |
| 390 | |
| 391 | #if ENABLE(BINDING_INTEGRITY) |
| 392 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 393 | #if PLATFORM(WIN) |
| 394 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7RTCTrackEvent@WebCore@@6B@" )); |
| 395 | #else |
| 396 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore13RTCTrackEventE[2]); |
| 397 | #endif |
| 398 | |
| 399 | // If this fails RTCTrackEvent does not have a vtable, so you need to add the |
| 400 | // ImplementationLacksVTable attribute to the interface definition |
| 401 | static_assert(std::is_polymorphic<RTCTrackEvent>::value, "RTCTrackEvent is not polymorphic" ); |
| 402 | |
| 403 | // If you hit this assertion you either have a use after free bug, or |
| 404 | // RTCTrackEvent has subclasses. If RTCTrackEvent has subclasses that get passed |
| 405 | // to toJS() we currently require RTCTrackEvent you to opt out of binding hardening |
| 406 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 407 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 408 | #endif |
| 409 | return createWrapper<RTCTrackEvent>(globalObject, WTFMove(impl)); |
| 410 | } |
| 411 | |
| 412 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCTrackEvent& impl) |
| 413 | { |
| 414 | return wrap(state, globalObject, impl); |
| 415 | } |
| 416 | |
| 417 | |
| 418 | } |
| 419 | |
| 420 | #endif // ENABLE(WEB_RTC) |
| 421 | |