| 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(CSS_TYPED_OM) |
| 24 | |
| 25 | #include "JSStylePropertyMapReadOnly.h" |
| 26 | |
| 27 | #include "JSDOMBinding.h" |
| 28 | #include "JSDOMConstructorNotConstructable.h" |
| 29 | #include "JSDOMConvertInterface.h" |
| 30 | #include "JSDOMConvertNullable.h" |
| 31 | #include "JSDOMConvertStrings.h" |
| 32 | #include "JSDOMExceptionHandling.h" |
| 33 | #include "JSDOMGlobalObject.h" |
| 34 | #include "JSDOMOperation.h" |
| 35 | #include "JSDOMWrapperCache.h" |
| 36 | #include "JSTypedOMCSSStyleValue.h" |
| 37 | #include "ScriptExecutionContext.h" |
| 38 | #include <JavaScriptCore/FunctionPrototype.h> |
| 39 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 40 | #include <JavaScriptCore/JSCInlines.h> |
| 41 | #include <wtf/GetPtr.h> |
| 42 | #include <wtf/PointerPreparations.h> |
| 43 | #include <wtf/URL.h> |
| 44 | |
| 45 | |
| 46 | namespace WebCore { |
| 47 | using namespace JSC; |
| 48 | |
| 49 | // Functions |
| 50 | |
| 51 | JSC::EncodedJSValue JSC_HOST_CALL jsStylePropertyMapReadOnlyPrototypeFunctionGet(JSC::ExecState*); |
| 52 | |
| 53 | // Attributes |
| 54 | |
| 55 | JSC::EncodedJSValue jsStylePropertyMapReadOnlyConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 56 | bool setJSStylePropertyMapReadOnlyConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 57 | |
| 58 | class JSStylePropertyMapReadOnlyPrototype : public JSC::JSNonFinalObject { |
| 59 | public: |
| 60 | using Base = JSC::JSNonFinalObject; |
| 61 | static JSStylePropertyMapReadOnlyPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 62 | { |
| 63 | JSStylePropertyMapReadOnlyPrototype* ptr = new (NotNull, JSC::allocateCell<JSStylePropertyMapReadOnlyPrototype>(vm.heap)) JSStylePropertyMapReadOnlyPrototype(vm, globalObject, structure); |
| 64 | ptr->finishCreation(vm); |
| 65 | return ptr; |
| 66 | } |
| 67 | |
| 68 | DECLARE_INFO; |
| 69 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 70 | { |
| 71 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 72 | } |
| 73 | |
| 74 | private: |
| 75 | JSStylePropertyMapReadOnlyPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 76 | : JSC::JSNonFinalObject(vm, structure) |
| 77 | { |
| 78 | } |
| 79 | |
| 80 | void finishCreation(JSC::VM&); |
| 81 | }; |
| 82 | |
| 83 | using JSStylePropertyMapReadOnlyConstructor = JSDOMConstructorNotConstructable<JSStylePropertyMapReadOnly>; |
| 84 | |
| 85 | template<> JSValue JSStylePropertyMapReadOnlyConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 86 | { |
| 87 | UNUSED_PARAM(vm); |
| 88 | return globalObject.functionPrototype(); |
| 89 | } |
| 90 | |
| 91 | template<> void JSStylePropertyMapReadOnlyConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 92 | { |
| 93 | putDirect(vm, vm.propertyNames->prototype, JSStylePropertyMapReadOnly::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 94 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("StylePropertyMapReadOnly"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 95 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 96 | } |
| 97 | |
| 98 | template<> const ClassInfo JSStylePropertyMapReadOnlyConstructor::s_info = { "StylePropertyMapReadOnly" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStylePropertyMapReadOnlyConstructor) }; |
| 99 | |
| 100 | /* Hash table for prototype */ |
| 101 | |
| 102 | static const HashTableValue JSStylePropertyMapReadOnlyPrototypeTableValues[] = |
| 103 | { |
| 104 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStylePropertyMapReadOnlyConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSStylePropertyMapReadOnlyConstructor) } }, |
| 105 | { "get" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsStylePropertyMapReadOnlyPrototypeFunctionGet), (intptr_t) (1) } }, |
| 106 | }; |
| 107 | |
| 108 | const ClassInfo JSStylePropertyMapReadOnlyPrototype::s_info = { "StylePropertyMapReadOnlyPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStylePropertyMapReadOnlyPrototype) }; |
| 109 | |
| 110 | void JSStylePropertyMapReadOnlyPrototype::finishCreation(VM& vm) |
| 111 | { |
| 112 | Base::finishCreation(vm); |
| 113 | reifyStaticProperties(vm, JSStylePropertyMapReadOnly::info(), JSStylePropertyMapReadOnlyPrototypeTableValues, *this); |
| 114 | } |
| 115 | |
| 116 | const ClassInfo JSStylePropertyMapReadOnly::s_info = { "StylePropertyMapReadOnly" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStylePropertyMapReadOnly) }; |
| 117 | |
| 118 | JSStylePropertyMapReadOnly::JSStylePropertyMapReadOnly(Structure* structure, JSDOMGlobalObject& globalObject, Ref<StylePropertyMapReadOnly>&& impl) |
| 119 | : JSDOMWrapper<StylePropertyMapReadOnly>(structure, globalObject, WTFMove(impl)) |
| 120 | { |
| 121 | } |
| 122 | |
| 123 | void JSStylePropertyMapReadOnly::finishCreation(VM& vm) |
| 124 | { |
| 125 | Base::finishCreation(vm); |
| 126 | ASSERT(inherits(vm, info())); |
| 127 | |
| 128 | } |
| 129 | |
| 130 | JSObject* JSStylePropertyMapReadOnly::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 131 | { |
| 132 | return JSStylePropertyMapReadOnlyPrototype::create(vm, &globalObject, JSStylePropertyMapReadOnlyPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 133 | } |
| 134 | |
| 135 | JSObject* JSStylePropertyMapReadOnly::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 136 | { |
| 137 | return getDOMPrototype<JSStylePropertyMapReadOnly>(vm, globalObject); |
| 138 | } |
| 139 | |
| 140 | JSValue JSStylePropertyMapReadOnly::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 141 | { |
| 142 | return getDOMConstructor<JSStylePropertyMapReadOnlyConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 143 | } |
| 144 | |
| 145 | void JSStylePropertyMapReadOnly::destroy(JSC::JSCell* cell) |
| 146 | { |
| 147 | JSStylePropertyMapReadOnly* thisObject = static_cast<JSStylePropertyMapReadOnly*>(cell); |
| 148 | thisObject->JSStylePropertyMapReadOnly::~JSStylePropertyMapReadOnly(); |
| 149 | } |
| 150 | |
| 151 | template<> inline JSStylePropertyMapReadOnly* IDLOperation<JSStylePropertyMapReadOnly>::cast(ExecState& state) |
| 152 | { |
| 153 | return jsDynamicCast<JSStylePropertyMapReadOnly*>(state.vm(), state.thisValue()); |
| 154 | } |
| 155 | |
| 156 | EncodedJSValue jsStylePropertyMapReadOnlyConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 157 | { |
| 158 | VM& vm = state->vm(); |
| 159 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 160 | auto* prototype = jsDynamicCast<JSStylePropertyMapReadOnlyPrototype*>(vm, JSValue::decode(thisValue)); |
| 161 | if (UNLIKELY(!prototype)) |
| 162 | return throwVMTypeError(state, throwScope); |
| 163 | return JSValue::encode(JSStylePropertyMapReadOnly::getConstructor(state->vm(), prototype->globalObject())); |
| 164 | } |
| 165 | |
| 166 | bool setJSStylePropertyMapReadOnlyConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 167 | { |
| 168 | VM& vm = state->vm(); |
| 169 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 170 | auto* prototype = jsDynamicCast<JSStylePropertyMapReadOnlyPrototype*>(vm, JSValue::decode(thisValue)); |
| 171 | if (UNLIKELY(!prototype)) { |
| 172 | throwVMTypeError(state, throwScope); |
| 173 | return false; |
| 174 | } |
| 175 | // Shadowing a built-in constructor |
| 176 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 177 | } |
| 178 | |
| 179 | static inline JSC::EncodedJSValue jsStylePropertyMapReadOnlyPrototypeFunctionGetBody(JSC::ExecState* state, typename IDLOperation<JSStylePropertyMapReadOnly>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 180 | { |
| 181 | UNUSED_PARAM(state); |
| 182 | UNUSED_PARAM(throwScope); |
| 183 | auto& impl = castedThis->wrapped(); |
| 184 | if (UNLIKELY(state->argumentCount() < 1)) |
| 185 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 186 | auto property = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
| 187 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 188 | return JSValue::encode(toJS<IDLNullable<IDLInterface<TypedOMCSSStyleValue>>>(*state, *castedThis->globalObject(), impl.get(WTFMove(property)))); |
| 189 | } |
| 190 | |
| 191 | EncodedJSValue JSC_HOST_CALL jsStylePropertyMapReadOnlyPrototypeFunctionGet(ExecState* state) |
| 192 | { |
| 193 | return IDLOperation<JSStylePropertyMapReadOnly>::call<jsStylePropertyMapReadOnlyPrototypeFunctionGetBody>(*state, "get" ); |
| 194 | } |
| 195 | |
| 196 | void JSStylePropertyMapReadOnly::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 197 | { |
| 198 | auto* thisObject = jsCast<JSStylePropertyMapReadOnly*>(cell); |
| 199 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 200 | if (thisObject->scriptExecutionContext()) |
| 201 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 202 | Base::heapSnapshot(cell, builder); |
| 203 | } |
| 204 | |
| 205 | bool JSStylePropertyMapReadOnlyOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 206 | { |
| 207 | UNUSED_PARAM(handle); |
| 208 | UNUSED_PARAM(visitor); |
| 209 | UNUSED_PARAM(reason); |
| 210 | return false; |
| 211 | } |
| 212 | |
| 213 | void JSStylePropertyMapReadOnlyOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 214 | { |
| 215 | auto* jsStylePropertyMapReadOnly = static_cast<JSStylePropertyMapReadOnly*>(handle.slot()->asCell()); |
| 216 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 217 | uncacheWrapper(world, &jsStylePropertyMapReadOnly->wrapped(), jsStylePropertyMapReadOnly); |
| 218 | } |
| 219 | |
| 220 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<StylePropertyMapReadOnly>&& impl) |
| 221 | { |
| 222 | return createWrapper<StylePropertyMapReadOnly>(globalObject, WTFMove(impl)); |
| 223 | } |
| 224 | |
| 225 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, StylePropertyMapReadOnly& impl) |
| 226 | { |
| 227 | return wrap(state, globalObject, impl); |
| 228 | } |
| 229 | |
| 230 | StylePropertyMapReadOnly* JSStylePropertyMapReadOnly::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 231 | { |
| 232 | if (auto* wrapper = jsDynamicCast<JSStylePropertyMapReadOnly*>(vm, value)) |
| 233 | return &wrapper->wrapped(); |
| 234 | return nullptr; |
| 235 | } |
| 236 | |
| 237 | } |
| 238 | |
| 239 | #endif // ENABLE(CSS_TYPED_OM) |
| 240 | |