| 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) |
| 24 | |
| 25 | #include "JSMediaController.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructor.h" |
| 30 | #include "JSDOMConvertBoolean.h" |
| 31 | #include "JSDOMConvertInterface.h" |
| 32 | #include "JSDOMConvertNumbers.h" |
| 33 | #include "JSDOMConvertStrings.h" |
| 34 | #include "JSDOMExceptionHandling.h" |
| 35 | #include "JSDOMGlobalObject.h" |
| 36 | #include "JSDOMOperation.h" |
| 37 | #include "JSDOMWrapperCache.h" |
| 38 | #include "JSTimeRanges.h" |
| 39 | #include "ScriptExecutionContext.h" |
| 40 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 41 | #include <JavaScriptCore/JSCInlines.h> |
| 42 | #include <wtf/GetPtr.h> |
| 43 | #include <wtf/PointerPreparations.h> |
| 44 | #include <wtf/URL.h> |
| 45 | |
| 46 | |
| 47 | namespace WebCore { |
| 48 | using namespace JSC; |
| 49 | |
| 50 | // Functions |
| 51 | |
| 52 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaControllerPrototypeFunctionPlay(JSC::ExecState*); |
| 53 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaControllerPrototypeFunctionPause(JSC::ExecState*); |
| 54 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaControllerPrototypeFunctionUnpause(JSC::ExecState*); |
| 55 | |
| 56 | // Attributes |
| 57 | |
| 58 | JSC::EncodedJSValue jsMediaControllerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 59 | bool setJSMediaControllerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 60 | JSC::EncodedJSValue jsMediaControllerBuffered(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 61 | JSC::EncodedJSValue jsMediaControllerSeekable(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 62 | JSC::EncodedJSValue jsMediaControllerDuration(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 63 | JSC::EncodedJSValue jsMediaControllerCurrentTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 64 | bool setJSMediaControllerCurrentTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 65 | JSC::EncodedJSValue jsMediaControllerPaused(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 66 | JSC::EncodedJSValue jsMediaControllerPlayed(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 67 | JSC::EncodedJSValue jsMediaControllerPlaybackState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 68 | JSC::EncodedJSValue jsMediaControllerDefaultPlaybackRate(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 69 | bool setJSMediaControllerDefaultPlaybackRate(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 70 | JSC::EncodedJSValue jsMediaControllerPlaybackRate(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 71 | bool setJSMediaControllerPlaybackRate(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 72 | JSC::EncodedJSValue jsMediaControllerVolume(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 73 | bool setJSMediaControllerVolume(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 74 | JSC::EncodedJSValue jsMediaControllerMuted(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 75 | bool setJSMediaControllerMuted(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 76 | |
| 77 | class JSMediaControllerPrototype : public JSC::JSNonFinalObject { |
| 78 | public: |
| 79 | using Base = JSC::JSNonFinalObject; |
| 80 | static JSMediaControllerPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 81 | { |
| 82 | JSMediaControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaControllerPrototype>(vm.heap)) JSMediaControllerPrototype(vm, globalObject, structure); |
| 83 | ptr->finishCreation(vm); |
| 84 | return ptr; |
| 85 | } |
| 86 | |
| 87 | DECLARE_INFO; |
| 88 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 89 | { |
| 90 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 91 | } |
| 92 | |
| 93 | private: |
| 94 | JSMediaControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 95 | : JSC::JSNonFinalObject(vm, structure) |
| 96 | { |
| 97 | } |
| 98 | |
| 99 | void finishCreation(JSC::VM&); |
| 100 | }; |
| 101 | |
| 102 | using JSMediaControllerConstructor = JSDOMConstructor<JSMediaController>; |
| 103 | |
| 104 | template<> EncodedJSValue JSC_HOST_CALL JSMediaControllerConstructor::construct(ExecState* state) |
| 105 | { |
| 106 | VM& vm = state->vm(); |
| 107 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 108 | UNUSED_PARAM(throwScope); |
| 109 | auto* castedThis = jsCast<JSMediaControllerConstructor*>(state->jsCallee()); |
| 110 | ASSERT(castedThis); |
| 111 | auto* context = castedThis->scriptExecutionContext(); |
| 112 | if (UNLIKELY(!context)) |
| 113 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "MediaController" ); |
| 114 | auto object = MediaController::create(*context); |
| 115 | return JSValue::encode(toJSNewlyCreated<IDLInterface<MediaController>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 116 | } |
| 117 | |
| 118 | template<> JSValue JSMediaControllerConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 119 | { |
| 120 | return JSEventTarget::getConstructor(vm, &globalObject); |
| 121 | } |
| 122 | |
| 123 | template<> void JSMediaControllerConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 124 | { |
| 125 | putDirect(vm, vm.propertyNames->prototype, JSMediaController::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 126 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MediaController"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 127 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 128 | } |
| 129 | |
| 130 | template<> const ClassInfo JSMediaControllerConstructor::s_info = { "MediaController" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaControllerConstructor) }; |
| 131 | |
| 132 | /* Hash table for prototype */ |
| 133 | |
| 134 | static const HashTableValue JSMediaControllerPrototypeTableValues[] = |
| 135 | { |
| 136 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaControllerConstructor) } }, |
| 137 | { "buffered" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerBuffered), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 138 | { "seekable" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerSeekable), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 139 | { "duration" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerDuration), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 140 | { "currentTime" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerCurrentTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaControllerCurrentTime) } }, |
| 141 | { "paused" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerPaused), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 142 | { "played" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerPlayed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 143 | { "playbackState" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerPlaybackState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 144 | { "defaultPlaybackRate" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerDefaultPlaybackRate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaControllerDefaultPlaybackRate) } }, |
| 145 | { "playbackRate" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerPlaybackRate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaControllerPlaybackRate) } }, |
| 146 | { "volume" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerVolume), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaControllerVolume) } }, |
| 147 | { "muted" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaControllerMuted), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaControllerMuted) } }, |
| 148 | { "play" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaControllerPrototypeFunctionPlay), (intptr_t) (0) } }, |
| 149 | { "pause" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaControllerPrototypeFunctionPause), (intptr_t) (0) } }, |
| 150 | { "unpause" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaControllerPrototypeFunctionUnpause), (intptr_t) (0) } }, |
| 151 | }; |
| 152 | |
| 153 | const ClassInfo JSMediaControllerPrototype::s_info = { "MediaControllerPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaControllerPrototype) }; |
| 154 | |
| 155 | void JSMediaControllerPrototype::finishCreation(VM& vm) |
| 156 | { |
| 157 | Base::finishCreation(vm); |
| 158 | reifyStaticProperties(vm, JSMediaController::info(), JSMediaControllerPrototypeTableValues, *this); |
| 159 | } |
| 160 | |
| 161 | const ClassInfo JSMediaController::s_info = { "MediaController" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaController) }; |
| 162 | |
| 163 | JSMediaController::JSMediaController(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaController>&& impl) |
| 164 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| 165 | { |
| 166 | } |
| 167 | |
| 168 | void JSMediaController::finishCreation(VM& vm) |
| 169 | { |
| 170 | Base::finishCreation(vm); |
| 171 | ASSERT(inherits(vm, info())); |
| 172 | |
| 173 | } |
| 174 | |
| 175 | JSObject* JSMediaController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 176 | { |
| 177 | return JSMediaControllerPrototype::create(vm, &globalObject, JSMediaControllerPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
| 178 | } |
| 179 | |
| 180 | JSObject* JSMediaController::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 181 | { |
| 182 | return getDOMPrototype<JSMediaController>(vm, globalObject); |
| 183 | } |
| 184 | |
| 185 | JSValue JSMediaController::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 186 | { |
| 187 | return getDOMConstructor<JSMediaControllerConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 188 | } |
| 189 | |
| 190 | template<> inline JSMediaController* IDLAttribute<JSMediaController>::cast(ExecState& state, EncodedJSValue thisValue) |
| 191 | { |
| 192 | return jsDynamicCast<JSMediaController*>(state.vm(), JSValue::decode(thisValue)); |
| 193 | } |
| 194 | |
| 195 | template<> inline JSMediaController* IDLOperation<JSMediaController>::cast(ExecState& state) |
| 196 | { |
| 197 | return jsDynamicCast<JSMediaController*>(state.vm(), state.thisValue()); |
| 198 | } |
| 199 | |
| 200 | EncodedJSValue jsMediaControllerConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 201 | { |
| 202 | VM& vm = state->vm(); |
| 203 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 204 | auto* prototype = jsDynamicCast<JSMediaControllerPrototype*>(vm, JSValue::decode(thisValue)); |
| 205 | if (UNLIKELY(!prototype)) |
| 206 | return throwVMTypeError(state, throwScope); |
| 207 | return JSValue::encode(JSMediaController::getConstructor(state->vm(), prototype->globalObject())); |
| 208 | } |
| 209 | |
| 210 | bool setJSMediaControllerConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 211 | { |
| 212 | VM& vm = state->vm(); |
| 213 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 214 | auto* prototype = jsDynamicCast<JSMediaControllerPrototype*>(vm, JSValue::decode(thisValue)); |
| 215 | if (UNLIKELY(!prototype)) { |
| 216 | throwVMTypeError(state, throwScope); |
| 217 | return false; |
| 218 | } |
| 219 | // Shadowing a built-in constructor |
| 220 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 221 | } |
| 222 | |
| 223 | static inline JSValue jsMediaControllerBufferedGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 224 | { |
| 225 | UNUSED_PARAM(throwScope); |
| 226 | UNUSED_PARAM(state); |
| 227 | auto& impl = thisObject.wrapped(); |
| 228 | JSValue result = toJS<IDLInterface<TimeRanges>>(state, *thisObject.globalObject(), throwScope, impl.buffered()); |
| 229 | return result; |
| 230 | } |
| 231 | |
| 232 | EncodedJSValue jsMediaControllerBuffered(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 233 | { |
| 234 | return IDLAttribute<JSMediaController>::get<jsMediaControllerBufferedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "buffered" ); |
| 235 | } |
| 236 | |
| 237 | static inline JSValue jsMediaControllerSeekableGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 238 | { |
| 239 | UNUSED_PARAM(throwScope); |
| 240 | UNUSED_PARAM(state); |
| 241 | auto& impl = thisObject.wrapped(); |
| 242 | JSValue result = toJS<IDLInterface<TimeRanges>>(state, *thisObject.globalObject(), throwScope, impl.seekable()); |
| 243 | return result; |
| 244 | } |
| 245 | |
| 246 | EncodedJSValue jsMediaControllerSeekable(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 247 | { |
| 248 | return IDLAttribute<JSMediaController>::get<jsMediaControllerSeekableGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "seekable" ); |
| 249 | } |
| 250 | |
| 251 | static inline JSValue jsMediaControllerDurationGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 252 | { |
| 253 | UNUSED_PARAM(throwScope); |
| 254 | UNUSED_PARAM(state); |
| 255 | auto& impl = thisObject.wrapped(); |
| 256 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.duration()); |
| 257 | return result; |
| 258 | } |
| 259 | |
| 260 | EncodedJSValue jsMediaControllerDuration(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 261 | { |
| 262 | return IDLAttribute<JSMediaController>::get<jsMediaControllerDurationGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "duration" ); |
| 263 | } |
| 264 | |
| 265 | static inline JSValue jsMediaControllerCurrentTimeGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 266 | { |
| 267 | UNUSED_PARAM(throwScope); |
| 268 | UNUSED_PARAM(state); |
| 269 | auto& impl = thisObject.wrapped(); |
| 270 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.currentTime()); |
| 271 | return result; |
| 272 | } |
| 273 | |
| 274 | EncodedJSValue jsMediaControllerCurrentTime(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 275 | { |
| 276 | return IDLAttribute<JSMediaController>::get<jsMediaControllerCurrentTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "currentTime" ); |
| 277 | } |
| 278 | |
| 279 | static inline bool setJSMediaControllerCurrentTimeSetter(ExecState& state, JSMediaController& thisObject, JSValue value, ThrowScope& throwScope) |
| 280 | { |
| 281 | UNUSED_PARAM(throwScope); |
| 282 | auto& impl = thisObject.wrapped(); |
| 283 | auto nativeValue = convert<IDLUnrestrictedDouble>(state, value); |
| 284 | RETURN_IF_EXCEPTION(throwScope, false); |
| 285 | AttributeSetter::call(state, throwScope, [&] { |
| 286 | return impl.setCurrentTime(WTFMove(nativeValue)); |
| 287 | }); |
| 288 | return true; |
| 289 | } |
| 290 | |
| 291 | bool setJSMediaControllerCurrentTime(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 292 | { |
| 293 | return IDLAttribute<JSMediaController>::set<setJSMediaControllerCurrentTimeSetter>(*state, thisValue, encodedValue, "currentTime" ); |
| 294 | } |
| 295 | |
| 296 | static inline JSValue jsMediaControllerPausedGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 297 | { |
| 298 | UNUSED_PARAM(throwScope); |
| 299 | UNUSED_PARAM(state); |
| 300 | auto& impl = thisObject.wrapped(); |
| 301 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.paused()); |
| 302 | return result; |
| 303 | } |
| 304 | |
| 305 | EncodedJSValue jsMediaControllerPaused(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 306 | { |
| 307 | return IDLAttribute<JSMediaController>::get<jsMediaControllerPausedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "paused" ); |
| 308 | } |
| 309 | |
| 310 | static inline JSValue jsMediaControllerPlayedGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 311 | { |
| 312 | UNUSED_PARAM(throwScope); |
| 313 | UNUSED_PARAM(state); |
| 314 | auto& impl = thisObject.wrapped(); |
| 315 | JSValue result = toJS<IDLInterface<TimeRanges>>(state, *thisObject.globalObject(), throwScope, impl.played()); |
| 316 | return result; |
| 317 | } |
| 318 | |
| 319 | EncodedJSValue jsMediaControllerPlayed(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 320 | { |
| 321 | return IDLAttribute<JSMediaController>::get<jsMediaControllerPlayedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "played" ); |
| 322 | } |
| 323 | |
| 324 | static inline JSValue jsMediaControllerPlaybackStateGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 325 | { |
| 326 | UNUSED_PARAM(throwScope); |
| 327 | UNUSED_PARAM(state); |
| 328 | auto& impl = thisObject.wrapped(); |
| 329 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.playbackState()); |
| 330 | return result; |
| 331 | } |
| 332 | |
| 333 | EncodedJSValue jsMediaControllerPlaybackState(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 334 | { |
| 335 | return IDLAttribute<JSMediaController>::get<jsMediaControllerPlaybackStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "playbackState" ); |
| 336 | } |
| 337 | |
| 338 | static inline JSValue jsMediaControllerDefaultPlaybackRateGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 339 | { |
| 340 | UNUSED_PARAM(throwScope); |
| 341 | UNUSED_PARAM(state); |
| 342 | auto& impl = thisObject.wrapped(); |
| 343 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.defaultPlaybackRate()); |
| 344 | return result; |
| 345 | } |
| 346 | |
| 347 | EncodedJSValue jsMediaControllerDefaultPlaybackRate(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 348 | { |
| 349 | return IDLAttribute<JSMediaController>::get<jsMediaControllerDefaultPlaybackRateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "defaultPlaybackRate" ); |
| 350 | } |
| 351 | |
| 352 | static inline bool setJSMediaControllerDefaultPlaybackRateSetter(ExecState& state, JSMediaController& thisObject, JSValue value, ThrowScope& throwScope) |
| 353 | { |
| 354 | UNUSED_PARAM(throwScope); |
| 355 | auto& impl = thisObject.wrapped(); |
| 356 | auto nativeValue = convert<IDLUnrestrictedDouble>(state, value); |
| 357 | RETURN_IF_EXCEPTION(throwScope, false); |
| 358 | AttributeSetter::call(state, throwScope, [&] { |
| 359 | return impl.setDefaultPlaybackRate(WTFMove(nativeValue)); |
| 360 | }); |
| 361 | return true; |
| 362 | } |
| 363 | |
| 364 | bool setJSMediaControllerDefaultPlaybackRate(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 365 | { |
| 366 | return IDLAttribute<JSMediaController>::set<setJSMediaControllerDefaultPlaybackRateSetter>(*state, thisValue, encodedValue, "defaultPlaybackRate" ); |
| 367 | } |
| 368 | |
| 369 | static inline JSValue jsMediaControllerPlaybackRateGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 370 | { |
| 371 | UNUSED_PARAM(throwScope); |
| 372 | UNUSED_PARAM(state); |
| 373 | auto& impl = thisObject.wrapped(); |
| 374 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.playbackRate()); |
| 375 | return result; |
| 376 | } |
| 377 | |
| 378 | EncodedJSValue jsMediaControllerPlaybackRate(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 379 | { |
| 380 | return IDLAttribute<JSMediaController>::get<jsMediaControllerPlaybackRateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "playbackRate" ); |
| 381 | } |
| 382 | |
| 383 | static inline bool setJSMediaControllerPlaybackRateSetter(ExecState& state, JSMediaController& thisObject, JSValue value, ThrowScope& throwScope) |
| 384 | { |
| 385 | UNUSED_PARAM(throwScope); |
| 386 | auto& impl = thisObject.wrapped(); |
| 387 | auto nativeValue = convert<IDLUnrestrictedDouble>(state, value); |
| 388 | RETURN_IF_EXCEPTION(throwScope, false); |
| 389 | AttributeSetter::call(state, throwScope, [&] { |
| 390 | return impl.setPlaybackRate(WTFMove(nativeValue)); |
| 391 | }); |
| 392 | return true; |
| 393 | } |
| 394 | |
| 395 | bool setJSMediaControllerPlaybackRate(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 396 | { |
| 397 | return IDLAttribute<JSMediaController>::set<setJSMediaControllerPlaybackRateSetter>(*state, thisValue, encodedValue, "playbackRate" ); |
| 398 | } |
| 399 | |
| 400 | static inline JSValue jsMediaControllerVolumeGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 401 | { |
| 402 | UNUSED_PARAM(throwScope); |
| 403 | UNUSED_PARAM(state); |
| 404 | auto& impl = thisObject.wrapped(); |
| 405 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.volume()); |
| 406 | return result; |
| 407 | } |
| 408 | |
| 409 | EncodedJSValue jsMediaControllerVolume(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 410 | { |
| 411 | return IDLAttribute<JSMediaController>::get<jsMediaControllerVolumeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "volume" ); |
| 412 | } |
| 413 | |
| 414 | static inline bool setJSMediaControllerVolumeSetter(ExecState& state, JSMediaController& thisObject, JSValue value, ThrowScope& throwScope) |
| 415 | { |
| 416 | UNUSED_PARAM(throwScope); |
| 417 | auto& impl = thisObject.wrapped(); |
| 418 | auto nativeValue = convert<IDLUnrestrictedDouble>(state, value); |
| 419 | RETURN_IF_EXCEPTION(throwScope, false); |
| 420 | AttributeSetter::call(state, throwScope, [&] { |
| 421 | return impl.setVolume(WTFMove(nativeValue)); |
| 422 | }); |
| 423 | return true; |
| 424 | } |
| 425 | |
| 426 | bool setJSMediaControllerVolume(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 427 | { |
| 428 | return IDLAttribute<JSMediaController>::set<setJSMediaControllerVolumeSetter>(*state, thisValue, encodedValue, "volume" ); |
| 429 | } |
| 430 | |
| 431 | static inline JSValue jsMediaControllerMutedGetter(ExecState& state, JSMediaController& thisObject, ThrowScope& throwScope) |
| 432 | { |
| 433 | UNUSED_PARAM(throwScope); |
| 434 | UNUSED_PARAM(state); |
| 435 | auto& impl = thisObject.wrapped(); |
| 436 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.muted()); |
| 437 | return result; |
| 438 | } |
| 439 | |
| 440 | EncodedJSValue jsMediaControllerMuted(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 441 | { |
| 442 | return IDLAttribute<JSMediaController>::get<jsMediaControllerMutedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "muted" ); |
| 443 | } |
| 444 | |
| 445 | static inline bool setJSMediaControllerMutedSetter(ExecState& state, JSMediaController& thisObject, JSValue value, ThrowScope& throwScope) |
| 446 | { |
| 447 | UNUSED_PARAM(throwScope); |
| 448 | auto& impl = thisObject.wrapped(); |
| 449 | auto nativeValue = convert<IDLBoolean>(state, value); |
| 450 | RETURN_IF_EXCEPTION(throwScope, false); |
| 451 | AttributeSetter::call(state, throwScope, [&] { |
| 452 | return impl.setMuted(WTFMove(nativeValue)); |
| 453 | }); |
| 454 | return true; |
| 455 | } |
| 456 | |
| 457 | bool setJSMediaControllerMuted(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 458 | { |
| 459 | return IDLAttribute<JSMediaController>::set<setJSMediaControllerMutedSetter>(*state, thisValue, encodedValue, "muted" ); |
| 460 | } |
| 461 | |
| 462 | static inline JSC::EncodedJSValue jsMediaControllerPrototypeFunctionPlayBody(JSC::ExecState* state, typename IDLOperation<JSMediaController>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 463 | { |
| 464 | UNUSED_PARAM(state); |
| 465 | UNUSED_PARAM(throwScope); |
| 466 | auto& impl = castedThis->wrapped(); |
| 467 | impl.play(); |
| 468 | return JSValue::encode(jsUndefined()); |
| 469 | } |
| 470 | |
| 471 | EncodedJSValue JSC_HOST_CALL jsMediaControllerPrototypeFunctionPlay(ExecState* state) |
| 472 | { |
| 473 | return IDLOperation<JSMediaController>::call<jsMediaControllerPrototypeFunctionPlayBody>(*state, "play" ); |
| 474 | } |
| 475 | |
| 476 | static inline JSC::EncodedJSValue jsMediaControllerPrototypeFunctionPauseBody(JSC::ExecState* state, typename IDLOperation<JSMediaController>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 477 | { |
| 478 | UNUSED_PARAM(state); |
| 479 | UNUSED_PARAM(throwScope); |
| 480 | auto& impl = castedThis->wrapped(); |
| 481 | impl.pause(); |
| 482 | return JSValue::encode(jsUndefined()); |
| 483 | } |
| 484 | |
| 485 | EncodedJSValue JSC_HOST_CALL jsMediaControllerPrototypeFunctionPause(ExecState* state) |
| 486 | { |
| 487 | return IDLOperation<JSMediaController>::call<jsMediaControllerPrototypeFunctionPauseBody>(*state, "pause" ); |
| 488 | } |
| 489 | |
| 490 | static inline JSC::EncodedJSValue jsMediaControllerPrototypeFunctionUnpauseBody(JSC::ExecState* state, typename IDLOperation<JSMediaController>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 491 | { |
| 492 | UNUSED_PARAM(state); |
| 493 | UNUSED_PARAM(throwScope); |
| 494 | auto& impl = castedThis->wrapped(); |
| 495 | impl.unpause(); |
| 496 | return JSValue::encode(jsUndefined()); |
| 497 | } |
| 498 | |
| 499 | EncodedJSValue JSC_HOST_CALL jsMediaControllerPrototypeFunctionUnpause(ExecState* state) |
| 500 | { |
| 501 | return IDLOperation<JSMediaController>::call<jsMediaControllerPrototypeFunctionUnpauseBody>(*state, "unpause" ); |
| 502 | } |
| 503 | |
| 504 | void JSMediaController::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 505 | { |
| 506 | auto* thisObject = jsCast<JSMediaController*>(cell); |
| 507 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 508 | if (thisObject->scriptExecutionContext()) |
| 509 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 510 | Base::heapSnapshot(cell, builder); |
| 511 | } |
| 512 | |
| 513 | #if ENABLE(BINDING_INTEGRITY) |
| 514 | #if PLATFORM(WIN) |
| 515 | #pragma warning(disable: 4483) |
| 516 | extern "C" { extern void (*const __identifier("??_7MediaController@WebCore@@6B@" )[])(); } |
| 517 | #else |
| 518 | extern "C" { extern void* _ZTVN7WebCore15MediaControllerE[]; } |
| 519 | #endif |
| 520 | #endif |
| 521 | |
| 522 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaController>&& impl) |
| 523 | { |
| 524 | |
| 525 | #if ENABLE(BINDING_INTEGRITY) |
| 526 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 527 | #if PLATFORM(WIN) |
| 528 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7MediaController@WebCore@@6B@" )); |
| 529 | #else |
| 530 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore15MediaControllerE[2]); |
| 531 | #endif |
| 532 | |
| 533 | // If this fails MediaController does not have a vtable, so you need to add the |
| 534 | // ImplementationLacksVTable attribute to the interface definition |
| 535 | static_assert(std::is_polymorphic<MediaController>::value, "MediaController is not polymorphic" ); |
| 536 | |
| 537 | // If you hit this assertion you either have a use after free bug, or |
| 538 | // MediaController has subclasses. If MediaController has subclasses that get passed |
| 539 | // to toJS() we currently require MediaController you to opt out of binding hardening |
| 540 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 541 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 542 | #endif |
| 543 | return createWrapper<MediaController>(globalObject, WTFMove(impl)); |
| 544 | } |
| 545 | |
| 546 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaController& impl) |
| 547 | { |
| 548 | return wrap(state, globalObject, impl); |
| 549 | } |
| 550 | |
| 551 | MediaController* JSMediaController::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 552 | { |
| 553 | if (auto* wrapper = jsDynamicCast<JSMediaController*>(vm, value)) |
| 554 | return &wrapper->wrapped(); |
| 555 | return nullptr; |
| 556 | } |
| 557 | |
| 558 | } |
| 559 | |
| 560 | #endif // ENABLE(VIDEO) |
| 561 | |