| 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 "JSVideoTrack.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 "JSDOMConvertInterface.h" |
| 46 | #include "JSDOMConvertNullable.h" |
| 47 | #include "JSDOMGlobalObject.h" |
| 48 | #include "JSSourceBuffer.h" |
| 49 | #include "VideoTrackMediaSource.h" |
| 50 | #endif |
| 51 | |
| 52 | |
| 53 | namespace WebCore { |
| 54 | using namespace JSC; |
| 55 | |
| 56 | // Attributes |
| 57 | |
| 58 | JSC::EncodedJSValue jsVideoTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 59 | bool setJSVideoTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 60 | JSC::EncodedJSValue jsVideoTrackId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 61 | JSC::EncodedJSValue jsVideoTrackKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 62 | #if ENABLE(MEDIA_SOURCE) |
| 63 | bool setJSVideoTrackKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 64 | #endif |
| 65 | JSC::EncodedJSValue jsVideoTrackLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 66 | JSC::EncodedJSValue jsVideoTrackLanguage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 67 | #if ENABLE(MEDIA_SOURCE) |
| 68 | bool setJSVideoTrackLanguage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 69 | #endif |
| 70 | JSC::EncodedJSValue jsVideoTrackSelected(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 71 | bool setJSVideoTrackSelected(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 72 | #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK) |
| 73 | JSC::EncodedJSValue jsVideoTrackSourceBuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 74 | #endif |
| 75 | |
| 76 | class JSVideoTrackPrototype : public JSC::JSNonFinalObject { |
| 77 | public: |
| 78 | using Base = JSC::JSNonFinalObject; |
| 79 | static JSVideoTrackPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 80 | { |
| 81 | JSVideoTrackPrototype* ptr = new (NotNull, JSC::allocateCell<JSVideoTrackPrototype>(vm.heap)) JSVideoTrackPrototype(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 | JSVideoTrackPrototype(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 JSVideoTrackConstructor = JSDOMConstructorNotConstructable<JSVideoTrack>; |
| 102 | |
| 103 | template<> JSValue JSVideoTrackConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 104 | { |
| 105 | UNUSED_PARAM(vm); |
| 106 | return globalObject.functionPrototype(); |
| 107 | } |
| 108 | |
| 109 | template<> void JSVideoTrackConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 110 | { |
| 111 | putDirect(vm, vm.propertyNames->prototype, JSVideoTrack::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 112 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("VideoTrack"_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 JSVideoTrackConstructor::s_info = { "VideoTrack" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVideoTrackConstructor) }; |
| 117 | |
| 118 | /* Hash table for prototype */ |
| 119 | |
| 120 | static const HashTableValue JSVideoTrackPrototypeTableValues[] = |
| 121 | { |
| 122 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVideoTrackConstructor) } }, |
| 123 | { "id" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackId), (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>(jsVideoTrackKind), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVideoTrackKind) } }, |
| 126 | #else |
| 127 | { "kind" , JSC::PropertyAttribute::ReadOnly | static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackKind), (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>(jsVideoTrackLabel), (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>(jsVideoTrackLanguage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVideoTrackLanguage) } }, |
| 132 | #else |
| 133 | { "language" , JSC::PropertyAttribute::ReadOnly | static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackLanguage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 134 | #endif |
| 135 | { "selected" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackSelected), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVideoTrackSelected) } }, |
| 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>(jsVideoTrackSourceBuffer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 138 | #else |
| 139 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
| 140 | #endif |
| 141 | }; |
| 142 | |
| 143 | const ClassInfo JSVideoTrackPrototype::s_info = { "VideoTrackPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVideoTrackPrototype) }; |
| 144 | |
| 145 | void JSVideoTrackPrototype::finishCreation(VM& vm) |
| 146 | { |
| 147 | Base::finishCreation(vm); |
| 148 | reifyStaticProperties(vm, JSVideoTrack::info(), JSVideoTrackPrototypeTableValues, *this); |
| 149 | } |
| 150 | |
| 151 | const ClassInfo JSVideoTrack::s_info = { "VideoTrack" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVideoTrack) }; |
| 152 | |
| 153 | JSVideoTrack::JSVideoTrack(Structure* structure, JSDOMGlobalObject& globalObject, Ref<VideoTrack>&& impl) |
| 154 | : JSDOMWrapper<VideoTrack>(structure, globalObject, WTFMove(impl)) |
| 155 | { |
| 156 | } |
| 157 | |
| 158 | void JSVideoTrack::finishCreation(VM& vm) |
| 159 | { |
| 160 | Base::finishCreation(vm); |
| 161 | ASSERT(inherits(vm, info())); |
| 162 | |
| 163 | } |
| 164 | |
| 165 | JSObject* JSVideoTrack::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 166 | { |
| 167 | return JSVideoTrackPrototype::create(vm, &globalObject, JSVideoTrackPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 168 | } |
| 169 | |
| 170 | JSObject* JSVideoTrack::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 171 | { |
| 172 | return getDOMPrototype<JSVideoTrack>(vm, globalObject); |
| 173 | } |
| 174 | |
| 175 | JSValue JSVideoTrack::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 176 | { |
| 177 | return getDOMConstructor<JSVideoTrackConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 178 | } |
| 179 | |
| 180 | void JSVideoTrack::destroy(JSC::JSCell* cell) |
| 181 | { |
| 182 | JSVideoTrack* thisObject = static_cast<JSVideoTrack*>(cell); |
| 183 | thisObject->JSVideoTrack::~JSVideoTrack(); |
| 184 | } |
| 185 | |
| 186 | template<> inline JSVideoTrack* IDLAttribute<JSVideoTrack>::cast(ExecState& state, EncodedJSValue thisValue) |
| 187 | { |
| 188 | return jsDynamicCast<JSVideoTrack*>(state.vm(), JSValue::decode(thisValue)); |
| 189 | } |
| 190 | |
| 191 | EncodedJSValue jsVideoTrackConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 192 | { |
| 193 | VM& vm = state->vm(); |
| 194 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 195 | auto* prototype = jsDynamicCast<JSVideoTrackPrototype*>(vm, JSValue::decode(thisValue)); |
| 196 | if (UNLIKELY(!prototype)) |
| 197 | return throwVMTypeError(state, throwScope); |
| 198 | return JSValue::encode(JSVideoTrack::getConstructor(state->vm(), prototype->globalObject())); |
| 199 | } |
| 200 | |
| 201 | bool setJSVideoTrackConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 202 | { |
| 203 | VM& vm = state->vm(); |
| 204 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 205 | auto* prototype = jsDynamicCast<JSVideoTrackPrototype*>(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 jsVideoTrackIdGetter(ExecState& state, JSVideoTrack& 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 jsVideoTrackId(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 224 | { |
| 225 | return IDLAttribute<JSVideoTrack>::get<jsVideoTrackIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "id" ); |
| 226 | } |
| 227 | |
| 228 | static inline JSValue jsVideoTrackKindGetter(ExecState& state, JSVideoTrack& 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 jsVideoTrackKind(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 238 | { |
| 239 | return IDLAttribute<JSVideoTrack>::get<jsVideoTrackKindGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "kind" ); |
| 240 | } |
| 241 | |
| 242 | #if ENABLE(MEDIA_SOURCE) |
| 243 | static inline bool setJSVideoTrackKindSetter(ExecState& state, JSVideoTrack& 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 setJSVideoTrackKind(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 256 | { |
| 257 | return IDLAttribute<JSVideoTrack>::set<setJSVideoTrackKindSetter>(*state, thisValue, encodedValue, "kind" ); |
| 258 | } |
| 259 | |
| 260 | #endif |
| 261 | |
| 262 | static inline JSValue jsVideoTrackLabelGetter(ExecState& state, JSVideoTrack& 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 jsVideoTrackLabel(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 272 | { |
| 273 | return IDLAttribute<JSVideoTrack>::get<jsVideoTrackLabelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "label" ); |
| 274 | } |
| 275 | |
| 276 | static inline JSValue jsVideoTrackLanguageGetter(ExecState& state, JSVideoTrack& 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 jsVideoTrackLanguage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 286 | { |
| 287 | return IDLAttribute<JSVideoTrack>::get<jsVideoTrackLanguageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "language" ); |
| 288 | } |
| 289 | |
| 290 | #if ENABLE(MEDIA_SOURCE) |
| 291 | static inline bool setJSVideoTrackLanguageSetter(ExecState& state, JSVideoTrack& 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 setJSVideoTrackLanguage(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 304 | { |
| 305 | return IDLAttribute<JSVideoTrack>::set<setJSVideoTrackLanguageSetter>(*state, thisValue, encodedValue, "language" ); |
| 306 | } |
| 307 | |
| 308 | #endif |
| 309 | |
| 310 | static inline JSValue jsVideoTrackSelectedGetter(ExecState& state, JSVideoTrack& 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.selected()); |
| 316 | return result; |
| 317 | } |
| 318 | |
| 319 | EncodedJSValue jsVideoTrackSelected(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 320 | { |
| 321 | return IDLAttribute<JSVideoTrack>::get<jsVideoTrackSelectedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "selected" ); |
| 322 | } |
| 323 | |
| 324 | static inline bool setJSVideoTrackSelectedSetter(ExecState& state, JSVideoTrack& 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.setSelected(WTFMove(nativeValue)); |
| 332 | }); |
| 333 | return true; |
| 334 | } |
| 335 | |
| 336 | bool setJSVideoTrackSelected(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 337 | { |
| 338 | return IDLAttribute<JSVideoTrack>::set<setJSVideoTrackSelectedSetter>(*state, thisValue, encodedValue, "selected" ); |
| 339 | } |
| 340 | |
| 341 | #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK) |
| 342 | static inline JSValue jsVideoTrackSourceBufferGetter(ExecState& state, JSVideoTrack& 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::VideoTrackMediaSource::sourceBuffer(impl)); |
| 348 | return result; |
| 349 | } |
| 350 | |
| 351 | EncodedJSValue jsVideoTrackSourceBuffer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 352 | { |
| 353 | return IDLAttribute<JSVideoTrack>::get<jsVideoTrackSourceBufferGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sourceBuffer" ); |
| 354 | } |
| 355 | |
| 356 | #endif |
| 357 | |
| 358 | void JSVideoTrack::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 359 | { |
| 360 | auto* thisObject = jsCast<JSVideoTrack*>(cell); |
| 361 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 362 | Base::visitChildren(thisObject, visitor); |
| 363 | thisObject->visitAdditionalChildren(visitor); |
| 364 | } |
| 365 | |
| 366 | void JSVideoTrack::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 367 | { |
| 368 | auto* thisObject = jsCast<JSVideoTrack*>(cell); |
| 369 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 370 | Base::visitOutputConstraints(thisObject, visitor); |
| 371 | thisObject->visitAdditionalChildren(visitor); |
| 372 | } |
| 373 | |
| 374 | void JSVideoTrack::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 375 | { |
| 376 | auto* thisObject = jsCast<JSVideoTrack*>(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 JSVideoTrackOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 384 | { |
| 385 | auto* jsVideoTrack = jsCast<JSVideoTrack*>(handle.slot()->asCell()); |
| 386 | Element* element = WTF::getPtr(jsVideoTrack->wrapped().element()); |
| 387 | if (!element) |
| 388 | return false; |
| 389 | if (UNLIKELY(reason)) |
| 390 | *reason = "Reachable from VideoTrackOwner" ; |
| 391 | void* root = WebCore::root(element); |
| 392 | return visitor.containsOpaqueRoot(root); |
| 393 | } |
| 394 | |
| 395 | void JSVideoTrackOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 396 | { |
| 397 | auto* jsVideoTrack = static_cast<JSVideoTrack*>(handle.slot()->asCell()); |
| 398 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 399 | uncacheWrapper(world, &jsVideoTrack->wrapped(), jsVideoTrack); |
| 400 | } |
| 401 | |
| 402 | #if ENABLE(BINDING_INTEGRITY) |
| 403 | #if PLATFORM(WIN) |
| 404 | #pragma warning(disable: 4483) |
| 405 | extern "C" { extern void (*const __identifier("??_7VideoTrack@WebCore@@6B@" )[])(); } |
| 406 | #else |
| 407 | extern "C" { extern void* _ZTVN7WebCore10VideoTrackE[]; } |
| 408 | #endif |
| 409 | #endif |
| 410 | |
| 411 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<VideoTrack>&& 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("??_7VideoTrack@WebCore@@6B@" )); |
| 418 | #else |
| 419 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore10VideoTrackE[2]); |
| 420 | #endif |
| 421 | |
| 422 | // If this fails VideoTrack does not have a vtable, so you need to add the |
| 423 | // ImplementationLacksVTable attribute to the interface definition |
| 424 | static_assert(std::is_polymorphic<VideoTrack>::value, "VideoTrack is not polymorphic" ); |
| 425 | |
| 426 | // If you hit this assertion you either have a use after free bug, or |
| 427 | // VideoTrack has subclasses. If VideoTrack has subclasses that get passed |
| 428 | // to toJS() we currently require VideoTrack 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<VideoTrack>(globalObject, WTFMove(impl)); |
| 433 | } |
| 434 | |
| 435 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, VideoTrack& impl) |
| 436 | { |
| 437 | return wrap(state, globalObject, impl); |
| 438 | } |
| 439 | |
| 440 | VideoTrack* JSVideoTrack::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 441 | { |
| 442 | if (auto* wrapper = jsDynamicCast<JSVideoTrack*>(vm, value)) |
| 443 | return &wrapper->wrapped(); |
| 444 | return nullptr; |
| 445 | } |
| 446 | |
| 447 | } |
| 448 | |
| 449 | #endif // ENABLE(VIDEO_TRACK) |
| 450 | |