| 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_PAINTING_API) |
| 24 | |
| 25 | #include "JSCSSPaintSize.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructorNotConstructable.h" |
| 30 | #include "JSDOMConvertNumbers.h" |
| 31 | #include "JSDOMExceptionHandling.h" |
| 32 | #include "JSDOMWrapperCache.h" |
| 33 | #include "ScriptExecutionContext.h" |
| 34 | #include <JavaScriptCore/FunctionPrototype.h> |
| 35 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 36 | #include <JavaScriptCore/JSCInlines.h> |
| 37 | #include <wtf/GetPtr.h> |
| 38 | #include <wtf/PointerPreparations.h> |
| 39 | #include <wtf/URL.h> |
| 40 | |
| 41 | |
| 42 | namespace WebCore { |
| 43 | using namespace JSC; |
| 44 | |
| 45 | // Attributes |
| 46 | |
| 47 | JSC::EncodedJSValue jsCSSPaintSizeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 48 | bool setJSCSSPaintSizeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 49 | JSC::EncodedJSValue jsCSSPaintSizeWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 50 | JSC::EncodedJSValue jsCSSPaintSizeHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 51 | |
| 52 | class JSCSSPaintSizePrototype : public JSC::JSNonFinalObject { |
| 53 | public: |
| 54 | using Base = JSC::JSNonFinalObject; |
| 55 | static JSCSSPaintSizePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 56 | { |
| 57 | JSCSSPaintSizePrototype* ptr = new (NotNull, JSC::allocateCell<JSCSSPaintSizePrototype>(vm.heap)) JSCSSPaintSizePrototype(vm, globalObject, structure); |
| 58 | ptr->finishCreation(vm); |
| 59 | return ptr; |
| 60 | } |
| 61 | |
| 62 | DECLARE_INFO; |
| 63 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 64 | { |
| 65 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 66 | } |
| 67 | |
| 68 | private: |
| 69 | JSCSSPaintSizePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 70 | : JSC::JSNonFinalObject(vm, structure) |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | void finishCreation(JSC::VM&); |
| 75 | }; |
| 76 | |
| 77 | using JSCSSPaintSizeConstructor = JSDOMConstructorNotConstructable<JSCSSPaintSize>; |
| 78 | |
| 79 | template<> JSValue JSCSSPaintSizeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 80 | { |
| 81 | UNUSED_PARAM(vm); |
| 82 | return globalObject.functionPrototype(); |
| 83 | } |
| 84 | |
| 85 | template<> void JSCSSPaintSizeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 86 | { |
| 87 | putDirect(vm, vm.propertyNames->prototype, JSCSSPaintSize::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 88 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CSSPaintSize"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 89 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 90 | } |
| 91 | |
| 92 | template<> const ClassInfo JSCSSPaintSizeConstructor::s_info = { "CSSPaintSize" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSPaintSizeConstructor) }; |
| 93 | |
| 94 | /* Hash table for prototype */ |
| 95 | |
| 96 | static const HashTableValue JSCSSPaintSizePrototypeTableValues[] = |
| 97 | { |
| 98 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSPaintSizeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSPaintSizeConstructor) } }, |
| 99 | { "width" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSPaintSizeWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 100 | { "height" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSPaintSizeHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 101 | }; |
| 102 | |
| 103 | const ClassInfo JSCSSPaintSizePrototype::s_info = { "CSSPaintSizePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSPaintSizePrototype) }; |
| 104 | |
| 105 | void JSCSSPaintSizePrototype::finishCreation(VM& vm) |
| 106 | { |
| 107 | Base::finishCreation(vm); |
| 108 | reifyStaticProperties(vm, JSCSSPaintSize::info(), JSCSSPaintSizePrototypeTableValues, *this); |
| 109 | } |
| 110 | |
| 111 | const ClassInfo JSCSSPaintSize::s_info = { "CSSPaintSize" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSPaintSize) }; |
| 112 | |
| 113 | JSCSSPaintSize::JSCSSPaintSize(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CSSPaintSize>&& impl) |
| 114 | : JSDOMWrapper<CSSPaintSize>(structure, globalObject, WTFMove(impl)) |
| 115 | { |
| 116 | } |
| 117 | |
| 118 | void JSCSSPaintSize::finishCreation(VM& vm) |
| 119 | { |
| 120 | Base::finishCreation(vm); |
| 121 | ASSERT(inherits(vm, info())); |
| 122 | |
| 123 | } |
| 124 | |
| 125 | JSObject* JSCSSPaintSize::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 126 | { |
| 127 | return JSCSSPaintSizePrototype::create(vm, &globalObject, JSCSSPaintSizePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 128 | } |
| 129 | |
| 130 | JSObject* JSCSSPaintSize::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 131 | { |
| 132 | return getDOMPrototype<JSCSSPaintSize>(vm, globalObject); |
| 133 | } |
| 134 | |
| 135 | JSValue JSCSSPaintSize::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 136 | { |
| 137 | return getDOMConstructor<JSCSSPaintSizeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 138 | } |
| 139 | |
| 140 | void JSCSSPaintSize::destroy(JSC::JSCell* cell) |
| 141 | { |
| 142 | JSCSSPaintSize* thisObject = static_cast<JSCSSPaintSize*>(cell); |
| 143 | thisObject->JSCSSPaintSize::~JSCSSPaintSize(); |
| 144 | } |
| 145 | |
| 146 | template<> inline JSCSSPaintSize* IDLAttribute<JSCSSPaintSize>::cast(ExecState& state, EncodedJSValue thisValue) |
| 147 | { |
| 148 | return jsDynamicCast<JSCSSPaintSize*>(state.vm(), JSValue::decode(thisValue)); |
| 149 | } |
| 150 | |
| 151 | EncodedJSValue jsCSSPaintSizeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 152 | { |
| 153 | VM& vm = state->vm(); |
| 154 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 155 | auto* prototype = jsDynamicCast<JSCSSPaintSizePrototype*>(vm, JSValue::decode(thisValue)); |
| 156 | if (UNLIKELY(!prototype)) |
| 157 | return throwVMTypeError(state, throwScope); |
| 158 | return JSValue::encode(JSCSSPaintSize::getConstructor(state->vm(), prototype->globalObject())); |
| 159 | } |
| 160 | |
| 161 | bool setJSCSSPaintSizeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 162 | { |
| 163 | VM& vm = state->vm(); |
| 164 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 165 | auto* prototype = jsDynamicCast<JSCSSPaintSizePrototype*>(vm, JSValue::decode(thisValue)); |
| 166 | if (UNLIKELY(!prototype)) { |
| 167 | throwVMTypeError(state, throwScope); |
| 168 | return false; |
| 169 | } |
| 170 | // Shadowing a built-in constructor |
| 171 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 172 | } |
| 173 | |
| 174 | static inline JSValue jsCSSPaintSizeWidthGetter(ExecState& state, JSCSSPaintSize& thisObject, ThrowScope& throwScope) |
| 175 | { |
| 176 | UNUSED_PARAM(throwScope); |
| 177 | UNUSED_PARAM(state); |
| 178 | auto& impl = thisObject.wrapped(); |
| 179 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.width()); |
| 180 | return result; |
| 181 | } |
| 182 | |
| 183 | EncodedJSValue jsCSSPaintSizeWidth(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 184 | { |
| 185 | return IDLAttribute<JSCSSPaintSize>::get<jsCSSPaintSizeWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width" ); |
| 186 | } |
| 187 | |
| 188 | static inline JSValue jsCSSPaintSizeHeightGetter(ExecState& state, JSCSSPaintSize& thisObject, ThrowScope& throwScope) |
| 189 | { |
| 190 | UNUSED_PARAM(throwScope); |
| 191 | UNUSED_PARAM(state); |
| 192 | auto& impl = thisObject.wrapped(); |
| 193 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.height()); |
| 194 | return result; |
| 195 | } |
| 196 | |
| 197 | EncodedJSValue jsCSSPaintSizeHeight(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 198 | { |
| 199 | return IDLAttribute<JSCSSPaintSize>::get<jsCSSPaintSizeHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height" ); |
| 200 | } |
| 201 | |
| 202 | void JSCSSPaintSize::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 203 | { |
| 204 | auto* thisObject = jsCast<JSCSSPaintSize*>(cell); |
| 205 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 206 | if (thisObject->scriptExecutionContext()) |
| 207 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 208 | Base::heapSnapshot(cell, builder); |
| 209 | } |
| 210 | |
| 211 | bool JSCSSPaintSizeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 212 | { |
| 213 | UNUSED_PARAM(handle); |
| 214 | UNUSED_PARAM(visitor); |
| 215 | UNUSED_PARAM(reason); |
| 216 | return false; |
| 217 | } |
| 218 | |
| 219 | void JSCSSPaintSizeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 220 | { |
| 221 | auto* jsCSSPaintSize = static_cast<JSCSSPaintSize*>(handle.slot()->asCell()); |
| 222 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 223 | uncacheWrapper(world, &jsCSSPaintSize->wrapped(), jsCSSPaintSize); |
| 224 | } |
| 225 | |
| 226 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<CSSPaintSize>&& impl) |
| 227 | { |
| 228 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 229 | // attribute. You should remove that attribute. If the class has subclasses |
| 230 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 231 | // attribute to CSSPaintSize. |
| 232 | static_assert(!std::is_polymorphic<CSSPaintSize>::value, "CSSPaintSize is polymorphic but the IDL claims it is not" ); |
| 233 | return createWrapper<CSSPaintSize>(globalObject, WTFMove(impl)); |
| 234 | } |
| 235 | |
| 236 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, CSSPaintSize& impl) |
| 237 | { |
| 238 | return wrap(state, globalObject, impl); |
| 239 | } |
| 240 | |
| 241 | CSSPaintSize* JSCSSPaintSize::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 242 | { |
| 243 | if (auto* wrapper = jsDynamicCast<JSCSSPaintSize*>(vm, value)) |
| 244 | return &wrapper->wrapped(); |
| 245 | return nullptr; |
| 246 | } |
| 247 | |
| 248 | } |
| 249 | |
| 250 | #endif // ENABLE(CSS_PAINTING_API) |
| 251 | |