| 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 "JSVideoTrackList.h" |
| 26 | |
| 27 | #include "Element.h" |
| 28 | #include "EventNames.h" |
| 29 | #include "JSDOMAttribute.h" |
| 30 | #include "JSDOMBinding.h" |
| 31 | #include "JSDOMConstructorNotConstructable.h" |
| 32 | #include "JSDOMConvertInterface.h" |
| 33 | #include "JSDOMConvertNumbers.h" |
| 34 | #include "JSDOMConvertStrings.h" |
| 35 | #include "JSDOMExceptionHandling.h" |
| 36 | #include "JSDOMGlobalObject.h" |
| 37 | #include "JSDOMOperation.h" |
| 38 | #include "JSDOMWrapperCache.h" |
| 39 | #include "JSEventListener.h" |
| 40 | #include "JSNodeCustom.h" |
| 41 | #include "JSVideoTrack.h" |
| 42 | #include "ScriptExecutionContext.h" |
| 43 | #include <JavaScriptCore/ArrayPrototype.h> |
| 44 | #include <JavaScriptCore/BuiltinNames.h> |
| 45 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 46 | #include <JavaScriptCore/JSCInlines.h> |
| 47 | #include <JavaScriptCore/PropertyNameArray.h> |
| 48 | #include <wtf/GetPtr.h> |
| 49 | #include <wtf/PointerPreparations.h> |
| 50 | #include <wtf/URL.h> |
| 51 | |
| 52 | |
| 53 | namespace WebCore { |
| 54 | using namespace JSC; |
| 55 | |
| 56 | // Functions |
| 57 | |
| 58 | JSC::EncodedJSValue JSC_HOST_CALL jsVideoTrackListPrototypeFunctionItem(JSC::ExecState*); |
| 59 | JSC::EncodedJSValue JSC_HOST_CALL jsVideoTrackListPrototypeFunctionGetTrackById(JSC::ExecState*); |
| 60 | |
| 61 | // Attributes |
| 62 | |
| 63 | JSC::EncodedJSValue jsVideoTrackListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 64 | bool setJSVideoTrackListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 65 | JSC::EncodedJSValue jsVideoTrackListLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 66 | JSC::EncodedJSValue jsVideoTrackListSelectedIndex(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 67 | JSC::EncodedJSValue jsVideoTrackListOnchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 68 | bool setJSVideoTrackListOnchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 69 | JSC::EncodedJSValue jsVideoTrackListOnaddtrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 70 | bool setJSVideoTrackListOnaddtrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 71 | JSC::EncodedJSValue jsVideoTrackListOnremovetrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 72 | bool setJSVideoTrackListOnremovetrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 73 | |
| 74 | class JSVideoTrackListPrototype : public JSC::JSNonFinalObject { |
| 75 | public: |
| 76 | using Base = JSC::JSNonFinalObject; |
| 77 | static JSVideoTrackListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 78 | { |
| 79 | JSVideoTrackListPrototype* ptr = new (NotNull, JSC::allocateCell<JSVideoTrackListPrototype>(vm.heap)) JSVideoTrackListPrototype(vm, globalObject, structure); |
| 80 | ptr->finishCreation(vm); |
| 81 | return ptr; |
| 82 | } |
| 83 | |
| 84 | DECLARE_INFO; |
| 85 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 86 | { |
| 87 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 88 | } |
| 89 | |
| 90 | private: |
| 91 | JSVideoTrackListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 92 | : JSC::JSNonFinalObject(vm, structure) |
| 93 | { |
| 94 | } |
| 95 | |
| 96 | void finishCreation(JSC::VM&); |
| 97 | }; |
| 98 | |
| 99 | using JSVideoTrackListConstructor = JSDOMConstructorNotConstructable<JSVideoTrackList>; |
| 100 | |
| 101 | template<> JSValue JSVideoTrackListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 102 | { |
| 103 | return JSEventTarget::getConstructor(vm, &globalObject); |
| 104 | } |
| 105 | |
| 106 | template<> void JSVideoTrackListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 107 | { |
| 108 | putDirect(vm, vm.propertyNames->prototype, JSVideoTrackList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 109 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("VideoTrackList"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 110 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 111 | } |
| 112 | |
| 113 | template<> const ClassInfo JSVideoTrackListConstructor::s_info = { "VideoTrackList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVideoTrackListConstructor) }; |
| 114 | |
| 115 | /* Hash table for prototype */ |
| 116 | |
| 117 | static const HashTableValue JSVideoTrackListPrototypeTableValues[] = |
| 118 | { |
| 119 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVideoTrackListConstructor) } }, |
| 120 | { "length" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackListLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 121 | { "selectedIndex" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackListSelectedIndex), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 122 | { "onchange" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackListOnchange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVideoTrackListOnchange) } }, |
| 123 | { "onaddtrack" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackListOnaddtrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVideoTrackListOnaddtrack) } }, |
| 124 | { "onremovetrack" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVideoTrackListOnremovetrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVideoTrackListOnremovetrack) } }, |
| 125 | { "item" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVideoTrackListPrototypeFunctionItem), (intptr_t) (1) } }, |
| 126 | { "getTrackById" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVideoTrackListPrototypeFunctionGetTrackById), (intptr_t) (1) } }, |
| 127 | }; |
| 128 | |
| 129 | const ClassInfo JSVideoTrackListPrototype::s_info = { "VideoTrackListPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVideoTrackListPrototype) }; |
| 130 | |
| 131 | void JSVideoTrackListPrototype::finishCreation(VM& vm) |
| 132 | { |
| 133 | Base::finishCreation(vm); |
| 134 | reifyStaticProperties(vm, JSVideoTrackList::info(), JSVideoTrackListPrototypeTableValues, *this); |
| 135 | putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
| 136 | } |
| 137 | |
| 138 | const ClassInfo JSVideoTrackList::s_info = { "VideoTrackList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVideoTrackList) }; |
| 139 | |
| 140 | JSVideoTrackList::JSVideoTrackList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<VideoTrackList>&& impl) |
| 141 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| 142 | { |
| 143 | } |
| 144 | |
| 145 | void JSVideoTrackList::finishCreation(VM& vm) |
| 146 | { |
| 147 | Base::finishCreation(vm); |
| 148 | ASSERT(inherits(vm, info())); |
| 149 | |
| 150 | } |
| 151 | |
| 152 | JSObject* JSVideoTrackList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 153 | { |
| 154 | return JSVideoTrackListPrototype::create(vm, &globalObject, JSVideoTrackListPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
| 155 | } |
| 156 | |
| 157 | JSObject* JSVideoTrackList::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 158 | { |
| 159 | return getDOMPrototype<JSVideoTrackList>(vm, globalObject); |
| 160 | } |
| 161 | |
| 162 | JSValue JSVideoTrackList::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 163 | { |
| 164 | return getDOMConstructor<JSVideoTrackListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 165 | } |
| 166 | |
| 167 | bool JSVideoTrackList::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot) |
| 168 | { |
| 169 | auto* thisObject = jsCast<JSVideoTrackList*>(object); |
| 170 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 171 | if (auto index = parseIndex(propertyName)) { |
| 172 | if (index.value() < thisObject->wrapped().length()) { |
| 173 | auto value = toJS<IDLInterface<VideoTrack>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value())); |
| 174 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
| 175 | return true; |
| 176 | } |
| 177 | } |
| 178 | return JSObject::getOwnPropertySlot(object, state, propertyName, slot); |
| 179 | } |
| 180 | |
| 181 | bool JSVideoTrackList::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot) |
| 182 | { |
| 183 | auto* thisObject = jsCast<JSVideoTrackList*>(object); |
| 184 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 185 | if (LIKELY(index <= MAX_ARRAY_INDEX)) { |
| 186 | if (index < thisObject->wrapped().length()) { |
| 187 | auto value = toJS<IDLInterface<VideoTrack>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index)); |
| 188 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
| 189 | return true; |
| 190 | } |
| 191 | } |
| 192 | return JSObject::getOwnPropertySlotByIndex(object, state, index, slot); |
| 193 | } |
| 194 | |
| 195 | void JSVideoTrackList::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode) |
| 196 | { |
| 197 | auto* thisObject = jsCast<JSVideoTrackList*>(object); |
| 198 | ASSERT_GC_OBJECT_INHERITS(object, info()); |
| 199 | for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i) |
| 200 | propertyNames.add(Identifier::from(state, i)); |
| 201 | JSObject::getOwnPropertyNames(object, state, propertyNames, mode); |
| 202 | } |
| 203 | |
| 204 | template<> inline JSVideoTrackList* IDLAttribute<JSVideoTrackList>::cast(ExecState& state, EncodedJSValue thisValue) |
| 205 | { |
| 206 | return jsDynamicCast<JSVideoTrackList*>(state.vm(), JSValue::decode(thisValue)); |
| 207 | } |
| 208 | |
| 209 | template<> inline JSVideoTrackList* IDLOperation<JSVideoTrackList>::cast(ExecState& state) |
| 210 | { |
| 211 | return jsDynamicCast<JSVideoTrackList*>(state.vm(), state.thisValue()); |
| 212 | } |
| 213 | |
| 214 | EncodedJSValue jsVideoTrackListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 215 | { |
| 216 | VM& vm = state->vm(); |
| 217 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 218 | auto* prototype = jsDynamicCast<JSVideoTrackListPrototype*>(vm, JSValue::decode(thisValue)); |
| 219 | if (UNLIKELY(!prototype)) |
| 220 | return throwVMTypeError(state, throwScope); |
| 221 | return JSValue::encode(JSVideoTrackList::getConstructor(state->vm(), prototype->globalObject())); |
| 222 | } |
| 223 | |
| 224 | bool setJSVideoTrackListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 225 | { |
| 226 | VM& vm = state->vm(); |
| 227 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 228 | auto* prototype = jsDynamicCast<JSVideoTrackListPrototype*>(vm, JSValue::decode(thisValue)); |
| 229 | if (UNLIKELY(!prototype)) { |
| 230 | throwVMTypeError(state, throwScope); |
| 231 | return false; |
| 232 | } |
| 233 | // Shadowing a built-in constructor |
| 234 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 235 | } |
| 236 | |
| 237 | static inline JSValue jsVideoTrackListLengthGetter(ExecState& state, JSVideoTrackList& thisObject, ThrowScope& throwScope) |
| 238 | { |
| 239 | UNUSED_PARAM(throwScope); |
| 240 | UNUSED_PARAM(state); |
| 241 | auto& impl = thisObject.wrapped(); |
| 242 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length()); |
| 243 | return result; |
| 244 | } |
| 245 | |
| 246 | EncodedJSValue jsVideoTrackListLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 247 | { |
| 248 | return IDLAttribute<JSVideoTrackList>::get<jsVideoTrackListLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length" ); |
| 249 | } |
| 250 | |
| 251 | static inline JSValue jsVideoTrackListSelectedIndexGetter(ExecState& state, JSVideoTrackList& thisObject, ThrowScope& throwScope) |
| 252 | { |
| 253 | UNUSED_PARAM(throwScope); |
| 254 | UNUSED_PARAM(state); |
| 255 | auto& impl = thisObject.wrapped(); |
| 256 | JSValue result = toJS<IDLLong>(state, throwScope, impl.selectedIndex()); |
| 257 | return result; |
| 258 | } |
| 259 | |
| 260 | EncodedJSValue jsVideoTrackListSelectedIndex(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 261 | { |
| 262 | return IDLAttribute<JSVideoTrackList>::get<jsVideoTrackListSelectedIndexGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "selectedIndex" ); |
| 263 | } |
| 264 | |
| 265 | static inline JSValue jsVideoTrackListOnchangeGetter(ExecState& state, JSVideoTrackList& thisObject, ThrowScope& throwScope) |
| 266 | { |
| 267 | UNUSED_PARAM(throwScope); |
| 268 | UNUSED_PARAM(state); |
| 269 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().changeEvent, worldForDOMObject(thisObject)); |
| 270 | } |
| 271 | |
| 272 | EncodedJSValue jsVideoTrackListOnchange(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 273 | { |
| 274 | return IDLAttribute<JSVideoTrackList>::get<jsVideoTrackListOnchangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onchange" ); |
| 275 | } |
| 276 | |
| 277 | static inline bool setJSVideoTrackListOnchangeSetter(ExecState& state, JSVideoTrackList& thisObject, JSValue value, ThrowScope& throwScope) |
| 278 | { |
| 279 | UNUSED_PARAM(throwScope); |
| 280 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().changeEvent, value); |
| 281 | return true; |
| 282 | } |
| 283 | |
| 284 | bool setJSVideoTrackListOnchange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 285 | { |
| 286 | return IDLAttribute<JSVideoTrackList>::set<setJSVideoTrackListOnchangeSetter>(*state, thisValue, encodedValue, "onchange" ); |
| 287 | } |
| 288 | |
| 289 | static inline JSValue jsVideoTrackListOnaddtrackGetter(ExecState& state, JSVideoTrackList& thisObject, ThrowScope& throwScope) |
| 290 | { |
| 291 | UNUSED_PARAM(throwScope); |
| 292 | UNUSED_PARAM(state); |
| 293 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().addtrackEvent, worldForDOMObject(thisObject)); |
| 294 | } |
| 295 | |
| 296 | EncodedJSValue jsVideoTrackListOnaddtrack(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 297 | { |
| 298 | return IDLAttribute<JSVideoTrackList>::get<jsVideoTrackListOnaddtrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onaddtrack" ); |
| 299 | } |
| 300 | |
| 301 | static inline bool setJSVideoTrackListOnaddtrackSetter(ExecState& state, JSVideoTrackList& thisObject, JSValue value, ThrowScope& throwScope) |
| 302 | { |
| 303 | UNUSED_PARAM(throwScope); |
| 304 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().addtrackEvent, value); |
| 305 | return true; |
| 306 | } |
| 307 | |
| 308 | bool setJSVideoTrackListOnaddtrack(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 309 | { |
| 310 | return IDLAttribute<JSVideoTrackList>::set<setJSVideoTrackListOnaddtrackSetter>(*state, thisValue, encodedValue, "onaddtrack" ); |
| 311 | } |
| 312 | |
| 313 | static inline JSValue jsVideoTrackListOnremovetrackGetter(ExecState& state, JSVideoTrackList& thisObject, ThrowScope& throwScope) |
| 314 | { |
| 315 | UNUSED_PARAM(throwScope); |
| 316 | UNUSED_PARAM(state); |
| 317 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().removetrackEvent, worldForDOMObject(thisObject)); |
| 318 | } |
| 319 | |
| 320 | EncodedJSValue jsVideoTrackListOnremovetrack(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 321 | { |
| 322 | return IDLAttribute<JSVideoTrackList>::get<jsVideoTrackListOnremovetrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onremovetrack" ); |
| 323 | } |
| 324 | |
| 325 | static inline bool setJSVideoTrackListOnremovetrackSetter(ExecState& state, JSVideoTrackList& thisObject, JSValue value, ThrowScope& throwScope) |
| 326 | { |
| 327 | UNUSED_PARAM(throwScope); |
| 328 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().removetrackEvent, value); |
| 329 | return true; |
| 330 | } |
| 331 | |
| 332 | bool setJSVideoTrackListOnremovetrack(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 333 | { |
| 334 | return IDLAttribute<JSVideoTrackList>::set<setJSVideoTrackListOnremovetrackSetter>(*state, thisValue, encodedValue, "onremovetrack" ); |
| 335 | } |
| 336 | |
| 337 | static inline JSC::EncodedJSValue jsVideoTrackListPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSVideoTrackList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 338 | { |
| 339 | UNUSED_PARAM(state); |
| 340 | UNUSED_PARAM(throwScope); |
| 341 | auto& impl = castedThis->wrapped(); |
| 342 | if (UNLIKELY(state->argumentCount() < 1)) |
| 343 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 344 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
| 345 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 346 | return JSValue::encode(toJS<IDLInterface<VideoTrack>>(*state, *castedThis->globalObject(), impl.item(WTFMove(index)))); |
| 347 | } |
| 348 | |
| 349 | EncodedJSValue JSC_HOST_CALL jsVideoTrackListPrototypeFunctionItem(ExecState* state) |
| 350 | { |
| 351 | return IDLOperation<JSVideoTrackList>::call<jsVideoTrackListPrototypeFunctionItemBody>(*state, "item" ); |
| 352 | } |
| 353 | |
| 354 | static inline JSC::EncodedJSValue jsVideoTrackListPrototypeFunctionGetTrackByIdBody(JSC::ExecState* state, typename IDLOperation<JSVideoTrackList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 355 | { |
| 356 | UNUSED_PARAM(state); |
| 357 | UNUSED_PARAM(throwScope); |
| 358 | auto& impl = castedThis->wrapped(); |
| 359 | if (UNLIKELY(state->argumentCount() < 1)) |
| 360 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 361 | auto id = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 362 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 363 | return JSValue::encode(toJS<IDLInterface<VideoTrack>>(*state, *castedThis->globalObject(), impl.getTrackById(WTFMove(id)))); |
| 364 | } |
| 365 | |
| 366 | EncodedJSValue JSC_HOST_CALL jsVideoTrackListPrototypeFunctionGetTrackById(ExecState* state) |
| 367 | { |
| 368 | return IDLOperation<JSVideoTrackList>::call<jsVideoTrackListPrototypeFunctionGetTrackByIdBody>(*state, "getTrackById" ); |
| 369 | } |
| 370 | |
| 371 | void JSVideoTrackList::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 372 | { |
| 373 | auto* thisObject = jsCast<JSVideoTrackList*>(cell); |
| 374 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 375 | Base::visitChildren(thisObject, visitor); |
| 376 | thisObject->visitAdditionalChildren(visitor); |
| 377 | } |
| 378 | |
| 379 | void JSVideoTrackList::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 380 | { |
| 381 | auto* thisObject = jsCast<JSVideoTrackList*>(cell); |
| 382 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 383 | Base::visitOutputConstraints(thisObject, visitor); |
| 384 | thisObject->visitAdditionalChildren(visitor); |
| 385 | } |
| 386 | |
| 387 | void JSVideoTrackList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 388 | { |
| 389 | auto* thisObject = jsCast<JSVideoTrackList*>(cell); |
| 390 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 391 | if (thisObject->scriptExecutionContext()) |
| 392 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 393 | Base::heapSnapshot(cell, builder); |
| 394 | } |
| 395 | |
| 396 | bool JSVideoTrackListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 397 | { |
| 398 | auto* jsVideoTrackList = jsCast<JSVideoTrackList*>(handle.slot()->asCell()); |
| 399 | if (jsVideoTrackList->wrapped().hasPendingActivity()) { |
| 400 | if (UNLIKELY(reason)) |
| 401 | *reason = "ActiveDOMObject with pending activity" ; |
| 402 | return true; |
| 403 | } |
| 404 | if (jsVideoTrackList->wrapped().isFiringEventListeners()) { |
| 405 | if (UNLIKELY(reason)) |
| 406 | *reason = "EventTarget firing event listeners" ; |
| 407 | return true; |
| 408 | } |
| 409 | Element* element = WTF::getPtr(jsVideoTrackList->wrapped().element()); |
| 410 | if (!element) |
| 411 | return false; |
| 412 | if (UNLIKELY(reason)) |
| 413 | *reason = "Reachable from VideoTrackListOwner" ; |
| 414 | void* root = WebCore::root(element); |
| 415 | return visitor.containsOpaqueRoot(root); |
| 416 | } |
| 417 | |
| 418 | void JSVideoTrackListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 419 | { |
| 420 | auto* jsVideoTrackList = static_cast<JSVideoTrackList*>(handle.slot()->asCell()); |
| 421 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 422 | uncacheWrapper(world, &jsVideoTrackList->wrapped(), jsVideoTrackList); |
| 423 | } |
| 424 | |
| 425 | #if ENABLE(BINDING_INTEGRITY) |
| 426 | #if PLATFORM(WIN) |
| 427 | #pragma warning(disable: 4483) |
| 428 | extern "C" { extern void (*const __identifier("??_7VideoTrackList@WebCore@@6B@" )[])(); } |
| 429 | #else |
| 430 | extern "C" { extern void* _ZTVN7WebCore14VideoTrackListE[]; } |
| 431 | #endif |
| 432 | #endif |
| 433 | |
| 434 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<VideoTrackList>&& impl) |
| 435 | { |
| 436 | |
| 437 | #if ENABLE(BINDING_INTEGRITY) |
| 438 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 439 | #if PLATFORM(WIN) |
| 440 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7VideoTrackList@WebCore@@6B@" )); |
| 441 | #else |
| 442 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore14VideoTrackListE[2]); |
| 443 | #endif |
| 444 | |
| 445 | // If this fails VideoTrackList does not have a vtable, so you need to add the |
| 446 | // ImplementationLacksVTable attribute to the interface definition |
| 447 | static_assert(std::is_polymorphic<VideoTrackList>::value, "VideoTrackList is not polymorphic" ); |
| 448 | |
| 449 | // If you hit this assertion you either have a use after free bug, or |
| 450 | // VideoTrackList has subclasses. If VideoTrackList has subclasses that get passed |
| 451 | // to toJS() we currently require VideoTrackList you to opt out of binding hardening |
| 452 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 453 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 454 | #endif |
| 455 | return createWrapper<VideoTrackList>(globalObject, WTFMove(impl)); |
| 456 | } |
| 457 | |
| 458 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, VideoTrackList& impl) |
| 459 | { |
| 460 | return wrap(state, globalObject, impl); |
| 461 | } |
| 462 | |
| 463 | VideoTrackList* JSVideoTrackList::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 464 | { |
| 465 | if (auto* wrapper = jsDynamicCast<JSVideoTrackList*>(vm, value)) |
| 466 | return &wrapper->wrapped(); |
| 467 | return nullptr; |
| 468 | } |
| 469 | |
| 470 | } |
| 471 | |
| 472 | #endif // ENABLE(VIDEO_TRACK) |
| 473 | |