| 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 | #include "JSDOMPlugin.h" |
| 23 | |
| 24 | #include "JSDOMAbstractOperations.h" |
| 25 | #include "JSDOMAttribute.h" |
| 26 | #include "JSDOMBinding.h" |
| 27 | #include "JSDOMConstructorNotConstructable.h" |
| 28 | #include "JSDOMConvertInterface.h" |
| 29 | #include "JSDOMConvertNullable.h" |
| 30 | #include "JSDOMConvertNumbers.h" |
| 31 | #include "JSDOMConvertStrings.h" |
| 32 | #include "JSDOMExceptionHandling.h" |
| 33 | #include "JSDOMGlobalObject.h" |
| 34 | #include "JSDOMMimeType.h" |
| 35 | #include "JSDOMOperation.h" |
| 36 | #include "JSDOMWrapperCache.h" |
| 37 | #include "ScriptExecutionContext.h" |
| 38 | #include <JavaScriptCore/ArrayPrototype.h> |
| 39 | #include <JavaScriptCore/BuiltinNames.h> |
| 40 | #include <JavaScriptCore/FunctionPrototype.h> |
| 41 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 42 | #include <JavaScriptCore/JSCInlines.h> |
| 43 | #include <JavaScriptCore/PropertyNameArray.h> |
| 44 | #include <wtf/GetPtr.h> |
| 45 | #include <wtf/PointerPreparations.h> |
| 46 | #include <wtf/URL.h> |
| 47 | |
| 48 | |
| 49 | namespace WebCore { |
| 50 | using namespace JSC; |
| 51 | |
| 52 | // Functions |
| 53 | |
| 54 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMPluginPrototypeFunctionItem(JSC::ExecState*); |
| 55 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMPluginPrototypeFunctionNamedItem(JSC::ExecState*); |
| 56 | |
| 57 | // Attributes |
| 58 | |
| 59 | JSC::EncodedJSValue jsDOMPluginConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 60 | bool setJSDOMPluginConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 61 | JSC::EncodedJSValue jsDOMPluginName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 62 | JSC::EncodedJSValue jsDOMPluginFilename(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 63 | JSC::EncodedJSValue jsDOMPluginDescription(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 64 | JSC::EncodedJSValue jsDOMPluginLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 65 | |
| 66 | class JSDOMPluginPrototype : public JSC::JSNonFinalObject { |
| 67 | public: |
| 68 | using Base = JSC::JSNonFinalObject; |
| 69 | static JSDOMPluginPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 70 | { |
| 71 | JSDOMPluginPrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMPluginPrototype>(vm.heap)) JSDOMPluginPrototype(vm, globalObject, structure); |
| 72 | ptr->finishCreation(vm); |
| 73 | return ptr; |
| 74 | } |
| 75 | |
| 76 | DECLARE_INFO; |
| 77 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 78 | { |
| 79 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 80 | } |
| 81 | |
| 82 | private: |
| 83 | JSDOMPluginPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 84 | : JSC::JSNonFinalObject(vm, structure) |
| 85 | { |
| 86 | } |
| 87 | |
| 88 | void finishCreation(JSC::VM&); |
| 89 | }; |
| 90 | |
| 91 | using JSDOMPluginConstructor = JSDOMConstructorNotConstructable<JSDOMPlugin>; |
| 92 | |
| 93 | template<> JSValue JSDOMPluginConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 94 | { |
| 95 | UNUSED_PARAM(vm); |
| 96 | return globalObject.functionPrototype(); |
| 97 | } |
| 98 | |
| 99 | template<> void JSDOMPluginConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 100 | { |
| 101 | putDirect(vm, vm.propertyNames->prototype, JSDOMPlugin::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 102 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Plugin"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 103 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 104 | } |
| 105 | |
| 106 | template<> const ClassInfo JSDOMPluginConstructor::s_info = { "Plugin" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMPluginConstructor) }; |
| 107 | |
| 108 | /* Hash table for prototype */ |
| 109 | |
| 110 | static const HashTableValue JSDOMPluginPrototypeTableValues[] = |
| 111 | { |
| 112 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMPluginConstructor) } }, |
| 113 | { "name" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 114 | { "filename" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginFilename), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 115 | { "description" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginDescription), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 116 | { "length" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 117 | { "item" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMPluginPrototypeFunctionItem), (intptr_t) (1) } }, |
| 118 | { "namedItem" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMPluginPrototypeFunctionNamedItem), (intptr_t) (1) } }, |
| 119 | }; |
| 120 | |
| 121 | const ClassInfo JSDOMPluginPrototype::s_info = { "PluginPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMPluginPrototype) }; |
| 122 | |
| 123 | void JSDOMPluginPrototype::finishCreation(VM& vm) |
| 124 | { |
| 125 | Base::finishCreation(vm); |
| 126 | reifyStaticProperties(vm, JSDOMPlugin::info(), JSDOMPluginPrototypeTableValues, *this); |
| 127 | putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
| 128 | } |
| 129 | |
| 130 | const ClassInfo JSDOMPlugin::s_info = { "Plugin" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMPlugin) }; |
| 131 | |
| 132 | JSDOMPlugin::JSDOMPlugin(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMPlugin>&& impl) |
| 133 | : JSDOMWrapper<DOMPlugin>(structure, globalObject, WTFMove(impl)) |
| 134 | { |
| 135 | } |
| 136 | |
| 137 | void JSDOMPlugin::finishCreation(VM& vm) |
| 138 | { |
| 139 | Base::finishCreation(vm); |
| 140 | ASSERT(inherits(vm, info())); |
| 141 | |
| 142 | } |
| 143 | |
| 144 | JSObject* JSDOMPlugin::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 145 | { |
| 146 | return JSDOMPluginPrototype::create(vm, &globalObject, JSDOMPluginPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 147 | } |
| 148 | |
| 149 | JSObject* JSDOMPlugin::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 150 | { |
| 151 | return getDOMPrototype<JSDOMPlugin>(vm, globalObject); |
| 152 | } |
| 153 | |
| 154 | JSValue JSDOMPlugin::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 155 | { |
| 156 | return getDOMConstructor<JSDOMPluginConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 157 | } |
| 158 | |
| 159 | void JSDOMPlugin::destroy(JSC::JSCell* cell) |
| 160 | { |
| 161 | JSDOMPlugin* thisObject = static_cast<JSDOMPlugin*>(cell); |
| 162 | thisObject->JSDOMPlugin::~JSDOMPlugin(); |
| 163 | } |
| 164 | |
| 165 | bool JSDOMPlugin::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot) |
| 166 | { |
| 167 | auto* thisObject = jsCast<JSDOMPlugin*>(object); |
| 168 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 169 | if (auto index = parseIndex(propertyName)) { |
| 170 | if (index.value() < thisObject->wrapped().length()) { |
| 171 | auto value = toJS<IDLNullable<IDLInterface<DOMMimeType>>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value())); |
| 172 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
| 173 | return true; |
| 174 | } |
| 175 | return JSObject::getOwnPropertySlot(object, state, propertyName, slot); |
| 176 | } |
| 177 | using GetterIDLType = IDLInterface<DOMMimeType>; |
| 178 | auto getterFunctor = [] (auto& thisObject, auto propertyName) -> Optional<typename GetterIDLType::ImplementationType> { |
| 179 | auto result = thisObject.wrapped().namedItem(propertyNameToAtomicString(propertyName)); |
| 180 | if (!GetterIDLType::isNullValue(result)) |
| 181 | return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) }; |
| 182 | return WTF::nullopt; |
| 183 | }; |
| 184 | if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::No>(*state, *thisObject, propertyName, getterFunctor)) { |
| 185 | auto value = toJS<IDLNullable<IDLInterface<DOMMimeType>>>(*state, *thisObject->globalObject(), WTFMove(namedProperty.value())); |
| 186 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), value); |
| 187 | return true; |
| 188 | } |
| 189 | return JSObject::getOwnPropertySlot(object, state, propertyName, slot); |
| 190 | } |
| 191 | |
| 192 | bool JSDOMPlugin::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot) |
| 193 | { |
| 194 | auto* thisObject = jsCast<JSDOMPlugin*>(object); |
| 195 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 196 | if (LIKELY(index <= MAX_ARRAY_INDEX)) { |
| 197 | if (index < thisObject->wrapped().length()) { |
| 198 | auto value = toJS<IDLNullable<IDLInterface<DOMMimeType>>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index)); |
| 199 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
| 200 | return true; |
| 201 | } |
| 202 | return JSObject::getOwnPropertySlotByIndex(object, state, index, slot); |
| 203 | } |
| 204 | auto propertyName = Identifier::from(state, index); |
| 205 | using GetterIDLType = IDLInterface<DOMMimeType>; |
| 206 | auto getterFunctor = [] (auto& thisObject, auto propertyName) -> Optional<typename GetterIDLType::ImplementationType> { |
| 207 | auto result = thisObject.wrapped().namedItem(propertyNameToAtomicString(propertyName)); |
| 208 | if (!GetterIDLType::isNullValue(result)) |
| 209 | return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) }; |
| 210 | return WTF::nullopt; |
| 211 | }; |
| 212 | if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::No>(*state, *thisObject, propertyName, getterFunctor)) { |
| 213 | auto value = toJS<IDLNullable<IDLInterface<DOMMimeType>>>(*state, *thisObject->globalObject(), WTFMove(namedProperty.value())); |
| 214 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), value); |
| 215 | return true; |
| 216 | } |
| 217 | return JSObject::getOwnPropertySlotByIndex(object, state, index, slot); |
| 218 | } |
| 219 | |
| 220 | void JSDOMPlugin::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode) |
| 221 | { |
| 222 | auto* thisObject = jsCast<JSDOMPlugin*>(object); |
| 223 | ASSERT_GC_OBJECT_INHERITS(object, info()); |
| 224 | for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i) |
| 225 | propertyNames.add(Identifier::from(state, i)); |
| 226 | if (mode.includeDontEnumProperties()) { |
| 227 | for (auto& propertyName : thisObject->wrapped().supportedPropertyNames()) |
| 228 | propertyNames.add(Identifier::fromString(state, propertyName)); |
| 229 | } |
| 230 | JSObject::getOwnPropertyNames(object, state, propertyNames, mode); |
| 231 | } |
| 232 | |
| 233 | template<> inline JSDOMPlugin* IDLAttribute<JSDOMPlugin>::cast(ExecState& state, EncodedJSValue thisValue) |
| 234 | { |
| 235 | return jsDynamicCast<JSDOMPlugin*>(state.vm(), JSValue::decode(thisValue)); |
| 236 | } |
| 237 | |
| 238 | template<> inline JSDOMPlugin* IDLOperation<JSDOMPlugin>::cast(ExecState& state) |
| 239 | { |
| 240 | return jsDynamicCast<JSDOMPlugin*>(state.vm(), state.thisValue()); |
| 241 | } |
| 242 | |
| 243 | EncodedJSValue jsDOMPluginConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 244 | { |
| 245 | VM& vm = state->vm(); |
| 246 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 247 | auto* prototype = jsDynamicCast<JSDOMPluginPrototype*>(vm, JSValue::decode(thisValue)); |
| 248 | if (UNLIKELY(!prototype)) |
| 249 | return throwVMTypeError(state, throwScope); |
| 250 | return JSValue::encode(JSDOMPlugin::getConstructor(state->vm(), prototype->globalObject())); |
| 251 | } |
| 252 | |
| 253 | bool setJSDOMPluginConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 254 | { |
| 255 | VM& vm = state->vm(); |
| 256 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 257 | auto* prototype = jsDynamicCast<JSDOMPluginPrototype*>(vm, JSValue::decode(thisValue)); |
| 258 | if (UNLIKELY(!prototype)) { |
| 259 | throwVMTypeError(state, throwScope); |
| 260 | return false; |
| 261 | } |
| 262 | // Shadowing a built-in constructor |
| 263 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 264 | } |
| 265 | |
| 266 | static inline JSValue jsDOMPluginNameGetter(ExecState& state, JSDOMPlugin& thisObject, ThrowScope& throwScope) |
| 267 | { |
| 268 | UNUSED_PARAM(throwScope); |
| 269 | UNUSED_PARAM(state); |
| 270 | auto& impl = thisObject.wrapped(); |
| 271 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.name()); |
| 272 | return result; |
| 273 | } |
| 274 | |
| 275 | EncodedJSValue jsDOMPluginName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 276 | { |
| 277 | return IDLAttribute<JSDOMPlugin>::get<jsDOMPluginNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name" ); |
| 278 | } |
| 279 | |
| 280 | static inline JSValue jsDOMPluginFilenameGetter(ExecState& state, JSDOMPlugin& thisObject, ThrowScope& throwScope) |
| 281 | { |
| 282 | UNUSED_PARAM(throwScope); |
| 283 | UNUSED_PARAM(state); |
| 284 | auto& impl = thisObject.wrapped(); |
| 285 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.filename()); |
| 286 | return result; |
| 287 | } |
| 288 | |
| 289 | EncodedJSValue jsDOMPluginFilename(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 290 | { |
| 291 | return IDLAttribute<JSDOMPlugin>::get<jsDOMPluginFilenameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "filename" ); |
| 292 | } |
| 293 | |
| 294 | static inline JSValue jsDOMPluginDescriptionGetter(ExecState& state, JSDOMPlugin& thisObject, ThrowScope& throwScope) |
| 295 | { |
| 296 | UNUSED_PARAM(throwScope); |
| 297 | UNUSED_PARAM(state); |
| 298 | auto& impl = thisObject.wrapped(); |
| 299 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.description()); |
| 300 | return result; |
| 301 | } |
| 302 | |
| 303 | EncodedJSValue jsDOMPluginDescription(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 304 | { |
| 305 | return IDLAttribute<JSDOMPlugin>::get<jsDOMPluginDescriptionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "description" ); |
| 306 | } |
| 307 | |
| 308 | static inline JSValue jsDOMPluginLengthGetter(ExecState& state, JSDOMPlugin& thisObject, ThrowScope& throwScope) |
| 309 | { |
| 310 | UNUSED_PARAM(throwScope); |
| 311 | UNUSED_PARAM(state); |
| 312 | auto& impl = thisObject.wrapped(); |
| 313 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length()); |
| 314 | return result; |
| 315 | } |
| 316 | |
| 317 | EncodedJSValue jsDOMPluginLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 318 | { |
| 319 | return IDLAttribute<JSDOMPlugin>::get<jsDOMPluginLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length" ); |
| 320 | } |
| 321 | |
| 322 | static inline JSC::EncodedJSValue jsDOMPluginPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSDOMPlugin>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 323 | { |
| 324 | UNUSED_PARAM(state); |
| 325 | UNUSED_PARAM(throwScope); |
| 326 | auto& impl = castedThis->wrapped(); |
| 327 | if (UNLIKELY(state->argumentCount() < 1)) |
| 328 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 329 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
| 330 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 331 | return JSValue::encode(toJS<IDLNullable<IDLInterface<DOMMimeType>>>(*state, *castedThis->globalObject(), impl.item(WTFMove(index)))); |
| 332 | } |
| 333 | |
| 334 | EncodedJSValue JSC_HOST_CALL jsDOMPluginPrototypeFunctionItem(ExecState* state) |
| 335 | { |
| 336 | return IDLOperation<JSDOMPlugin>::call<jsDOMPluginPrototypeFunctionItemBody>(*state, "item" ); |
| 337 | } |
| 338 | |
| 339 | static inline JSC::EncodedJSValue jsDOMPluginPrototypeFunctionNamedItemBody(JSC::ExecState* state, typename IDLOperation<JSDOMPlugin>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 340 | { |
| 341 | UNUSED_PARAM(state); |
| 342 | UNUSED_PARAM(throwScope); |
| 343 | auto& impl = castedThis->wrapped(); |
| 344 | if (UNLIKELY(state->argumentCount() < 1)) |
| 345 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 346 | auto name = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 347 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 348 | return JSValue::encode(toJS<IDLNullable<IDLInterface<DOMMimeType>>>(*state, *castedThis->globalObject(), impl.namedItem(WTFMove(name)))); |
| 349 | } |
| 350 | |
| 351 | EncodedJSValue JSC_HOST_CALL jsDOMPluginPrototypeFunctionNamedItem(ExecState* state) |
| 352 | { |
| 353 | return IDLOperation<JSDOMPlugin>::call<jsDOMPluginPrototypeFunctionNamedItemBody>(*state, "namedItem" ); |
| 354 | } |
| 355 | |
| 356 | void JSDOMPlugin::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 357 | { |
| 358 | auto* thisObject = jsCast<JSDOMPlugin*>(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 JSDOMPluginOwner::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 JSDOMPluginOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 374 | { |
| 375 | auto* jsDOMPlugin = static_cast<JSDOMPlugin*>(handle.slot()->asCell()); |
| 376 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 377 | uncacheWrapper(world, &jsDOMPlugin->wrapped(), jsDOMPlugin); |
| 378 | } |
| 379 | |
| 380 | #if ENABLE(BINDING_INTEGRITY) |
| 381 | #if PLATFORM(WIN) |
| 382 | #pragma warning(disable: 4483) |
| 383 | extern "C" { extern void (*const __identifier("??_7DOMPlugin@WebCore@@6B@" )[])(); } |
| 384 | #else |
| 385 | extern "C" { extern void* _ZTVN7WebCore9DOMPluginE[]; } |
| 386 | #endif |
| 387 | #endif |
| 388 | |
| 389 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMPlugin>&& impl) |
| 390 | { |
| 391 | |
| 392 | #if ENABLE(BINDING_INTEGRITY) |
| 393 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 394 | #if PLATFORM(WIN) |
| 395 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7DOMPlugin@WebCore@@6B@" )); |
| 396 | #else |
| 397 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore9DOMPluginE[2]); |
| 398 | #endif |
| 399 | |
| 400 | // If this fails DOMPlugin does not have a vtable, so you need to add the |
| 401 | // ImplementationLacksVTable attribute to the interface definition |
| 402 | static_assert(std::is_polymorphic<DOMPlugin>::value, "DOMPlugin is not polymorphic" ); |
| 403 | |
| 404 | // If you hit this assertion you either have a use after free bug, or |
| 405 | // DOMPlugin has subclasses. If DOMPlugin has subclasses that get passed |
| 406 | // to toJS() we currently require DOMPlugin you to opt out of binding hardening |
| 407 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 408 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 409 | #endif |
| 410 | return createWrapper<DOMPlugin>(globalObject, WTFMove(impl)); |
| 411 | } |
| 412 | |
| 413 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMPlugin& impl) |
| 414 | { |
| 415 | return wrap(state, globalObject, impl); |
| 416 | } |
| 417 | |
| 418 | DOMPlugin* JSDOMPlugin::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 419 | { |
| 420 | if (auto* wrapper = jsDynamicCast<JSDOMPlugin*>(vm, value)) |
| 421 | return &wrapper->wrapped(); |
| 422 | return nullptr; |
| 423 | } |
| 424 | |
| 425 | } |
| 426 | |