| 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_SESSION) |
| 24 | |
| 25 | #include "JSMediaSession.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructor.h" |
| 30 | #include "JSDOMConvertInterface.h" |
| 31 | #include "JSDOMConvertNullable.h" |
| 32 | #include "JSDOMConvertStrings.h" |
| 33 | #include "JSDOMExceptionHandling.h" |
| 34 | #include "JSDOMGlobalObject.h" |
| 35 | #include "JSDOMOperation.h" |
| 36 | #include "JSDOMWrapperCache.h" |
| 37 | #include "JSMediaRemoteControls.h" |
| 38 | #include "ScriptExecutionContext.h" |
| 39 | #include <JavaScriptCore/FunctionPrototype.h> |
| 40 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 41 | #include <JavaScriptCore/JSCInlines.h> |
| 42 | #include <JavaScriptCore/JSString.h> |
| 43 | #include <wtf/GetPtr.h> |
| 44 | #include <wtf/PointerPreparations.h> |
| 45 | #include <wtf/URL.h> |
| 46 | |
| 47 | |
| 48 | namespace WebCore { |
| 49 | using namespace JSC; |
| 50 | |
| 51 | String convertEnumerationToString(MediaSession::Kind enumerationValue) |
| 52 | { |
| 53 | static const NeverDestroyed<String> values[] = { |
| 54 | MAKE_STATIC_STRING_IMPL("content" ), |
| 55 | MAKE_STATIC_STRING_IMPL("transient" ), |
| 56 | MAKE_STATIC_STRING_IMPL("transient-solo" ), |
| 57 | MAKE_STATIC_STRING_IMPL("ambient" ), |
| 58 | }; |
| 59 | static_assert(static_cast<size_t>(MediaSession::Kind::Content) == 0, "MediaSession::Kind::Content is not 0 as expected" ); |
| 60 | static_assert(static_cast<size_t>(MediaSession::Kind::Transient) == 1, "MediaSession::Kind::Transient is not 1 as expected" ); |
| 61 | static_assert(static_cast<size_t>(MediaSession::Kind::TransientSolo) == 2, "MediaSession::Kind::TransientSolo is not 2 as expected" ); |
| 62 | static_assert(static_cast<size_t>(MediaSession::Kind::Ambient) == 3, "MediaSession::Kind::Ambient is not 3 as expected" ); |
| 63 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| 64 | return values[static_cast<size_t>(enumerationValue)]; |
| 65 | } |
| 66 | |
| 67 | template<> JSString* convertEnumerationToJS(ExecState& state, MediaSession::Kind enumerationValue) |
| 68 | { |
| 69 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
| 70 | } |
| 71 | |
| 72 | template<> Optional<MediaSession::Kind> parseEnumeration<MediaSession::Kind>(ExecState& state, JSValue value) |
| 73 | { |
| 74 | auto stringValue = value.toWTFString(&state); |
| 75 | if (stringValue == "content" ) |
| 76 | return MediaSession::Kind::Content; |
| 77 | if (stringValue == "transient" ) |
| 78 | return MediaSession::Kind::Transient; |
| 79 | if (stringValue == "transient-solo" ) |
| 80 | return MediaSession::Kind::TransientSolo; |
| 81 | if (stringValue == "ambient" ) |
| 82 | return MediaSession::Kind::Ambient; |
| 83 | return WTF::nullopt; |
| 84 | } |
| 85 | |
| 86 | template<> const char* expectedEnumerationValues<MediaSession::Kind>() |
| 87 | { |
| 88 | return "\"content\", \"transient\", \"transient-solo\", \"ambient\"" ; |
| 89 | } |
| 90 | |
| 91 | template<> MediaSession::Metadata convertDictionary<MediaSession::Metadata>(ExecState& state, JSValue value) |
| 92 | { |
| 93 | VM& vm = state.vm(); |
| 94 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 95 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 96 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 97 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 98 | throwTypeError(&state, throwScope); |
| 99 | return { }; |
| 100 | } |
| 101 | MediaSession::Metadata result; |
| 102 | JSValue albumValue; |
| 103 | if (isNullOrUndefined) |
| 104 | albumValue = jsUndefined(); |
| 105 | else { |
| 106 | albumValue = object->get(&state, Identifier::fromString(&state, "album" )); |
| 107 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 108 | } |
| 109 | if (!albumValue.isUndefined()) { |
| 110 | result.album = convert<IDLDOMString>(state, albumValue); |
| 111 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 112 | } |
| 113 | JSValue artistValue; |
| 114 | if (isNullOrUndefined) |
| 115 | artistValue = jsUndefined(); |
| 116 | else { |
| 117 | artistValue = object->get(&state, Identifier::fromString(&state, "artist" )); |
| 118 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 119 | } |
| 120 | if (!artistValue.isUndefined()) { |
| 121 | result.artist = convert<IDLDOMString>(state, artistValue); |
| 122 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 123 | } |
| 124 | JSValue artworkValue; |
| 125 | if (isNullOrUndefined) |
| 126 | artworkValue = jsUndefined(); |
| 127 | else { |
| 128 | artworkValue = object->get(&state, Identifier::fromString(&state, "artwork" )); |
| 129 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 130 | } |
| 131 | if (!artworkValue.isUndefined()) { |
| 132 | result.artwork = convert<IDLUSVString>(state, artworkValue); |
| 133 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 134 | } |
| 135 | JSValue titleValue; |
| 136 | if (isNullOrUndefined) |
| 137 | titleValue = jsUndefined(); |
| 138 | else { |
| 139 | titleValue = object->get(&state, Identifier::fromString(&state, "title" )); |
| 140 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 141 | } |
| 142 | if (!titleValue.isUndefined()) { |
| 143 | result.title = convert<IDLDOMString>(state, titleValue); |
| 144 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 145 | } |
| 146 | return result; |
| 147 | } |
| 148 | |
| 149 | // Functions |
| 150 | |
| 151 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaSessionPrototypeFunctionSetMetadata(JSC::ExecState*); |
| 152 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaSessionPrototypeFunctionDeactivate(JSC::ExecState*); |
| 153 | |
| 154 | // Attributes |
| 155 | |
| 156 | JSC::EncodedJSValue jsMediaSessionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 157 | bool setJSMediaSessionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 158 | JSC::EncodedJSValue jsMediaSessionKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 159 | JSC::EncodedJSValue jsMediaSessionControls(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 160 | |
| 161 | class JSMediaSessionPrototype : public JSC::JSNonFinalObject { |
| 162 | public: |
| 163 | using Base = JSC::JSNonFinalObject; |
| 164 | static JSMediaSessionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 165 | { |
| 166 | JSMediaSessionPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaSessionPrototype>(vm.heap)) JSMediaSessionPrototype(vm, globalObject, structure); |
| 167 | ptr->finishCreation(vm); |
| 168 | return ptr; |
| 169 | } |
| 170 | |
| 171 | DECLARE_INFO; |
| 172 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 173 | { |
| 174 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 175 | } |
| 176 | |
| 177 | private: |
| 178 | JSMediaSessionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 179 | : JSC::JSNonFinalObject(vm, structure) |
| 180 | { |
| 181 | } |
| 182 | |
| 183 | void finishCreation(JSC::VM&); |
| 184 | }; |
| 185 | |
| 186 | using JSMediaSessionConstructor = JSDOMConstructor<JSMediaSession>; |
| 187 | |
| 188 | template<> JSC::EncodedJSValue JSC_HOST_CALL JSMediaSessionConstructor::construct(JSC::ExecState* exec) |
| 189 | { |
| 190 | ASSERT(exec); |
| 191 | return constructJSMediaSession(*exec); |
| 192 | } |
| 193 | |
| 194 | template<> JSValue JSMediaSessionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 195 | { |
| 196 | UNUSED_PARAM(vm); |
| 197 | return globalObject.functionPrototype(); |
| 198 | } |
| 199 | |
| 200 | template<> void JSMediaSessionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 201 | { |
| 202 | putDirect(vm, vm.propertyNames->prototype, JSMediaSession::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 203 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MediaSession"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 204 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 205 | } |
| 206 | |
| 207 | template<> const ClassInfo JSMediaSessionConstructor::s_info = { "MediaSession" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaSessionConstructor) }; |
| 208 | |
| 209 | /* Hash table for prototype */ |
| 210 | |
| 211 | static const HashTableValue JSMediaSessionPrototypeTableValues[] = |
| 212 | { |
| 213 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSessionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaSessionConstructor) } }, |
| 214 | { "kind" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSessionKind), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 215 | { "controls" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSessionControls), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 216 | { "setMetadata" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaSessionPrototypeFunctionSetMetadata), (intptr_t) (1) } }, |
| 217 | { "deactivate" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaSessionPrototypeFunctionDeactivate), (intptr_t) (0) } }, |
| 218 | }; |
| 219 | |
| 220 | const ClassInfo JSMediaSessionPrototype::s_info = { "MediaSessionPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaSessionPrototype) }; |
| 221 | |
| 222 | void JSMediaSessionPrototype::finishCreation(VM& vm) |
| 223 | { |
| 224 | Base::finishCreation(vm); |
| 225 | reifyStaticProperties(vm, JSMediaSession::info(), JSMediaSessionPrototypeTableValues, *this); |
| 226 | } |
| 227 | |
| 228 | const ClassInfo JSMediaSession::s_info = { "MediaSession" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaSession) }; |
| 229 | |
| 230 | JSMediaSession::JSMediaSession(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaSession>&& impl) |
| 231 | : JSDOMWrapper<MediaSession>(structure, globalObject, WTFMove(impl)) |
| 232 | { |
| 233 | } |
| 234 | |
| 235 | void JSMediaSession::finishCreation(VM& vm) |
| 236 | { |
| 237 | Base::finishCreation(vm); |
| 238 | ASSERT(inherits(vm, info())); |
| 239 | |
| 240 | } |
| 241 | |
| 242 | JSObject* JSMediaSession::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 243 | { |
| 244 | return JSMediaSessionPrototype::create(vm, &globalObject, JSMediaSessionPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 245 | } |
| 246 | |
| 247 | JSObject* JSMediaSession::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 248 | { |
| 249 | return getDOMPrototype<JSMediaSession>(vm, globalObject); |
| 250 | } |
| 251 | |
| 252 | JSValue JSMediaSession::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 253 | { |
| 254 | return getDOMConstructor<JSMediaSessionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 255 | } |
| 256 | |
| 257 | void JSMediaSession::destroy(JSC::JSCell* cell) |
| 258 | { |
| 259 | JSMediaSession* thisObject = static_cast<JSMediaSession*>(cell); |
| 260 | thisObject->JSMediaSession::~JSMediaSession(); |
| 261 | } |
| 262 | |
| 263 | template<> inline JSMediaSession* IDLAttribute<JSMediaSession>::cast(ExecState& state, EncodedJSValue thisValue) |
| 264 | { |
| 265 | return jsDynamicCast<JSMediaSession*>(state.vm(), JSValue::decode(thisValue)); |
| 266 | } |
| 267 | |
| 268 | template<> inline JSMediaSession* IDLOperation<JSMediaSession>::cast(ExecState& state) |
| 269 | { |
| 270 | return jsDynamicCast<JSMediaSession*>(state.vm(), state.thisValue()); |
| 271 | } |
| 272 | |
| 273 | EncodedJSValue jsMediaSessionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 274 | { |
| 275 | VM& vm = state->vm(); |
| 276 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 277 | auto* prototype = jsDynamicCast<JSMediaSessionPrototype*>(vm, JSValue::decode(thisValue)); |
| 278 | if (UNLIKELY(!prototype)) |
| 279 | return throwVMTypeError(state, throwScope); |
| 280 | return JSValue::encode(JSMediaSession::getConstructor(state->vm(), prototype->globalObject())); |
| 281 | } |
| 282 | |
| 283 | bool setJSMediaSessionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 284 | { |
| 285 | VM& vm = state->vm(); |
| 286 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 287 | auto* prototype = jsDynamicCast<JSMediaSessionPrototype*>(vm, JSValue::decode(thisValue)); |
| 288 | if (UNLIKELY(!prototype)) { |
| 289 | throwVMTypeError(state, throwScope); |
| 290 | return false; |
| 291 | } |
| 292 | // Shadowing a built-in constructor |
| 293 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 294 | } |
| 295 | |
| 296 | static inline JSValue jsMediaSessionKindGetter(ExecState& state, JSMediaSession& thisObject, ThrowScope& throwScope) |
| 297 | { |
| 298 | UNUSED_PARAM(throwScope); |
| 299 | UNUSED_PARAM(state); |
| 300 | auto& impl = thisObject.wrapped(); |
| 301 | JSValue result = toJS<IDLEnumeration<MediaSession::Kind>>(state, throwScope, impl.kind()); |
| 302 | return result; |
| 303 | } |
| 304 | |
| 305 | EncodedJSValue jsMediaSessionKind(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 306 | { |
| 307 | return IDLAttribute<JSMediaSession>::get<jsMediaSessionKindGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "kind" ); |
| 308 | } |
| 309 | |
| 310 | static inline JSValue jsMediaSessionControlsGetter(ExecState& state, JSMediaSession& thisObject, ThrowScope& throwScope) |
| 311 | { |
| 312 | UNUSED_PARAM(throwScope); |
| 313 | UNUSED_PARAM(state); |
| 314 | auto& impl = thisObject.wrapped(); |
| 315 | JSValue result = toJS<IDLNullable<IDLInterface<MediaRemoteControls>>>(state, *thisObject.globalObject(), throwScope, impl.controls()); |
| 316 | return result; |
| 317 | } |
| 318 | |
| 319 | EncodedJSValue jsMediaSessionControls(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 320 | { |
| 321 | return IDLAttribute<JSMediaSession>::get<jsMediaSessionControlsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "controls" ); |
| 322 | } |
| 323 | |
| 324 | static inline JSC::EncodedJSValue jsMediaSessionPrototypeFunctionSetMetadataBody(JSC::ExecState* state, typename IDLOperation<JSMediaSession>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 325 | { |
| 326 | UNUSED_PARAM(state); |
| 327 | UNUSED_PARAM(throwScope); |
| 328 | auto& impl = castedThis->wrapped(); |
| 329 | if (UNLIKELY(state->argumentCount() < 1)) |
| 330 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 331 | auto metadata = convert<IDLNullable<IDLDictionary<MediaSession::Metadata>>>(*state, state->uncheckedArgument(0)); |
| 332 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 333 | impl.setMetadata(WTFMove(metadata)); |
| 334 | return JSValue::encode(jsUndefined()); |
| 335 | } |
| 336 | |
| 337 | EncodedJSValue JSC_HOST_CALL jsMediaSessionPrototypeFunctionSetMetadata(ExecState* state) |
| 338 | { |
| 339 | return IDLOperation<JSMediaSession>::call<jsMediaSessionPrototypeFunctionSetMetadataBody>(*state, "setMetadata" ); |
| 340 | } |
| 341 | |
| 342 | static inline JSC::EncodedJSValue jsMediaSessionPrototypeFunctionDeactivateBody(JSC::ExecState* state, typename IDLOperation<JSMediaSession>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 343 | { |
| 344 | UNUSED_PARAM(state); |
| 345 | UNUSED_PARAM(throwScope); |
| 346 | auto& impl = castedThis->wrapped(); |
| 347 | impl.deactivate(); |
| 348 | return JSValue::encode(jsUndefined()); |
| 349 | } |
| 350 | |
| 351 | EncodedJSValue JSC_HOST_CALL jsMediaSessionPrototypeFunctionDeactivate(ExecState* state) |
| 352 | { |
| 353 | return IDLOperation<JSMediaSession>::call<jsMediaSessionPrototypeFunctionDeactivateBody>(*state, "deactivate" ); |
| 354 | } |
| 355 | |
| 356 | void JSMediaSession::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 357 | { |
| 358 | auto* thisObject = jsCast<JSMediaSession*>(cell); |
| 359 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 360 | if (thisObject->scriptExecutionContext()) |
| 361 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 362 | Base::heapSnapshot(cell, builder); |
| 363 | } |
| 364 | |
| 365 | bool JSMediaSessionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 366 | { |
| 367 | UNUSED_PARAM(handle); |
| 368 | UNUSED_PARAM(visitor); |
| 369 | UNUSED_PARAM(reason); |
| 370 | return false; |
| 371 | } |
| 372 | |
| 373 | void JSMediaSessionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 374 | { |
| 375 | auto* jsMediaSession = static_cast<JSMediaSession*>(handle.slot()->asCell()); |
| 376 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 377 | uncacheWrapper(world, &jsMediaSession->wrapped(), jsMediaSession); |
| 378 | } |
| 379 | |
| 380 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaSession>&& impl) |
| 381 | { |
| 382 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 383 | // attribute. You should remove that attribute. If the class has subclasses |
| 384 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 385 | // attribute to MediaSession. |
| 386 | static_assert(!std::is_polymorphic<MediaSession>::value, "MediaSession is polymorphic but the IDL claims it is not" ); |
| 387 | return createWrapper<MediaSession>(globalObject, WTFMove(impl)); |
| 388 | } |
| 389 | |
| 390 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaSession& impl) |
| 391 | { |
| 392 | return wrap(state, globalObject, impl); |
| 393 | } |
| 394 | |
| 395 | MediaSession* JSMediaSession::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 396 | { |
| 397 | if (auto* wrapper = jsDynamicCast<JSMediaSession*>(vm, value)) |
| 398 | return &wrapper->wrapped(); |
| 399 | return nullptr; |
| 400 | } |
| 401 | |
| 402 | } |
| 403 | |
| 404 | #endif // ENABLE(MEDIA_SESSION) |
| 405 | |