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