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 "JSDOMRectList.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertInterface.h"
28#include "JSDOMConvertNumbers.h"
29#include "JSDOMExceptionHandling.h"
30#include "JSDOMGlobalObject.h"
31#include "JSDOMOperation.h"
32#include "JSDOMRect.h"
33#include "JSDOMWrapperCache.h"
34#include "ScriptExecutionContext.h"
35#include <JavaScriptCore/ArrayPrototype.h>
36#include <JavaScriptCore/BuiltinNames.h>
37#include <JavaScriptCore/FunctionPrototype.h>
38#include <JavaScriptCore/HeapSnapshotBuilder.h>
39#include <JavaScriptCore/JSCInlines.h>
40#include <JavaScriptCore/PropertyNameArray.h>
41#include <wtf/GetPtr.h>
42#include <wtf/PointerPreparations.h>
43#include <wtf/URL.h>
44
45
46namespace WebCore {
47using namespace JSC;
48
49// Functions
50
51JSC::EncodedJSValue JSC_HOST_CALL jsDOMRectListPrototypeFunctionItem(JSC::ExecState*);
52
53// Attributes
54
55JSC::EncodedJSValue jsDOMRectListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
56bool setJSDOMRectListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
57JSC::EncodedJSValue jsDOMRectListLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
58
59class JSDOMRectListPrototype : public JSC::JSNonFinalObject {
60public:
61 using Base = JSC::JSNonFinalObject;
62 static JSDOMRectListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
63 {
64 JSDOMRectListPrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMRectListPrototype>(vm.heap)) JSDOMRectListPrototype(vm, globalObject, structure);
65 ptr->finishCreation(vm);
66 return ptr;
67 }
68
69 DECLARE_INFO;
70 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
71 {
72 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
73 }
74
75private:
76 JSDOMRectListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
77 : JSC::JSNonFinalObject(vm, structure)
78 {
79 }
80
81 void finishCreation(JSC::VM&);
82};
83
84using JSDOMRectListConstructor = JSDOMConstructorNotConstructable<JSDOMRectList>;
85
86template<> JSValue JSDOMRectListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
87{
88 UNUSED_PARAM(vm);
89 return globalObject.functionPrototype();
90}
91
92template<> void JSDOMRectListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
93{
94 putDirect(vm, vm.propertyNames->prototype, JSDOMRectList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
95 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("DOMRectList"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
96 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
97}
98
99template<> const ClassInfo JSDOMRectListConstructor::s_info = { "DOMRectList", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMRectListConstructor) };
100
101/* Hash table for prototype */
102
103static const HashTableValue JSDOMRectListPrototypeTableValues[] =
104{
105 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMRectListConstructor) } },
106 { "length", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectListLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
107 { "item", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMRectListPrototypeFunctionItem), (intptr_t) (1) } },
108};
109
110const ClassInfo JSDOMRectListPrototype::s_info = { "DOMRectListPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMRectListPrototype) };
111
112void JSDOMRectListPrototype::finishCreation(VM& vm)
113{
114 Base::finishCreation(vm);
115 reifyStaticProperties(vm, JSDOMRectList::info(), JSDOMRectListPrototypeTableValues, *this);
116 putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum));
117}
118
119const ClassInfo JSDOMRectList::s_info = { "DOMRectList", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMRectList) };
120
121JSDOMRectList::JSDOMRectList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMRectList>&& impl)
122 : JSDOMWrapper<DOMRectList>(structure, globalObject, WTFMove(impl))
123{
124}
125
126void JSDOMRectList::finishCreation(VM& vm)
127{
128 Base::finishCreation(vm);
129 ASSERT(inherits(vm, info()));
130
131}
132
133JSObject* JSDOMRectList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
134{
135 return JSDOMRectListPrototype::create(vm, &globalObject, JSDOMRectListPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
136}
137
138JSObject* JSDOMRectList::prototype(VM& vm, JSDOMGlobalObject& globalObject)
139{
140 return getDOMPrototype<JSDOMRectList>(vm, globalObject);
141}
142
143JSValue JSDOMRectList::getConstructor(VM& vm, const JSGlobalObject* globalObject)
144{
145 return getDOMConstructor<JSDOMRectListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
146}
147
148void JSDOMRectList::destroy(JSC::JSCell* cell)
149{
150 JSDOMRectList* thisObject = static_cast<JSDOMRectList*>(cell);
151 thisObject->JSDOMRectList::~JSDOMRectList();
152}
153
154bool JSDOMRectList::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
155{
156 auto* thisObject = jsCast<JSDOMRectList*>(object);
157 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
158 if (auto index = parseIndex(propertyName)) {
159 if (index.value() < thisObject->wrapped().length()) {
160 auto value = toJS<IDLInterface<DOMRect>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value()));
161 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
162 return true;
163 }
164 }
165 return JSObject::getOwnPropertySlot(object, state, propertyName, slot);
166}
167
168bool JSDOMRectList::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
169{
170 auto* thisObject = jsCast<JSDOMRectList*>(object);
171 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
172 if (LIKELY(index <= MAX_ARRAY_INDEX)) {
173 if (index < thisObject->wrapped().length()) {
174 auto value = toJS<IDLInterface<DOMRect>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index));
175 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
176 return true;
177 }
178 }
179 return JSObject::getOwnPropertySlotByIndex(object, state, index, slot);
180}
181
182void JSDOMRectList::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
183{
184 auto* thisObject = jsCast<JSDOMRectList*>(object);
185 ASSERT_GC_OBJECT_INHERITS(object, info());
186 for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i)
187 propertyNames.add(Identifier::from(state, i));
188 JSObject::getOwnPropertyNames(object, state, propertyNames, mode);
189}
190
191template<> inline JSDOMRectList* IDLAttribute<JSDOMRectList>::cast(ExecState& state, EncodedJSValue thisValue)
192{
193 return jsDynamicCast<JSDOMRectList*>(state.vm(), JSValue::decode(thisValue));
194}
195
196template<> inline JSDOMRectList* IDLOperation<JSDOMRectList>::cast(ExecState& state)
197{
198 return jsDynamicCast<JSDOMRectList*>(state.vm(), state.thisValue());
199}
200
201EncodedJSValue jsDOMRectListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
202{
203 VM& vm = state->vm();
204 auto throwScope = DECLARE_THROW_SCOPE(vm);
205 auto* prototype = jsDynamicCast<JSDOMRectListPrototype*>(vm, JSValue::decode(thisValue));
206 if (UNLIKELY(!prototype))
207 return throwVMTypeError(state, throwScope);
208 return JSValue::encode(JSDOMRectList::getConstructor(state->vm(), prototype->globalObject()));
209}
210
211bool setJSDOMRectListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
212{
213 VM& vm = state->vm();
214 auto throwScope = DECLARE_THROW_SCOPE(vm);
215 auto* prototype = jsDynamicCast<JSDOMRectListPrototype*>(vm, JSValue::decode(thisValue));
216 if (UNLIKELY(!prototype)) {
217 throwVMTypeError(state, throwScope);
218 return false;
219 }
220 // Shadowing a built-in constructor
221 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
222}
223
224static inline JSValue jsDOMRectListLengthGetter(ExecState& state, JSDOMRectList& thisObject, ThrowScope& throwScope)
225{
226 UNUSED_PARAM(throwScope);
227 UNUSED_PARAM(state);
228 auto& impl = thisObject.wrapped();
229 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length());
230 return result;
231}
232
233EncodedJSValue jsDOMRectListLength(ExecState* state, EncodedJSValue thisValue, PropertyName)
234{
235 return IDLAttribute<JSDOMRectList>::get<jsDOMRectListLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length");
236}
237
238static inline JSC::EncodedJSValue jsDOMRectListPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSDOMRectList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
239{
240 UNUSED_PARAM(state);
241 UNUSED_PARAM(throwScope);
242 auto& impl = castedThis->wrapped();
243 if (UNLIKELY(state->argumentCount() < 1))
244 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
245 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0));
246 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
247 return JSValue::encode(toJS<IDLInterface<DOMRect>>(*state, *castedThis->globalObject(), impl.item(WTFMove(index))));
248}
249
250EncodedJSValue JSC_HOST_CALL jsDOMRectListPrototypeFunctionItem(ExecState* state)
251{
252 return IDLOperation<JSDOMRectList>::call<jsDOMRectListPrototypeFunctionItemBody>(*state, "item");
253}
254
255void JSDOMRectList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
256{
257 auto* thisObject = jsCast<JSDOMRectList*>(cell);
258 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
259 if (thisObject->scriptExecutionContext())
260 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
261 Base::heapSnapshot(cell, builder);
262}
263
264bool JSDOMRectListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
265{
266 UNUSED_PARAM(handle);
267 UNUSED_PARAM(visitor);
268 UNUSED_PARAM(reason);
269 return false;
270}
271
272void JSDOMRectListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
273{
274 auto* jsDOMRectList = static_cast<JSDOMRectList*>(handle.slot()->asCell());
275 auto& world = *static_cast<DOMWrapperWorld*>(context);
276 uncacheWrapper(world, &jsDOMRectList->wrapped(), jsDOMRectList);
277}
278
279JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMRectList>&& impl)
280{
281 // If you hit this failure the interface definition has the ImplementationLacksVTable
282 // attribute. You should remove that attribute. If the class has subclasses
283 // that may be passed through this toJS() function you should use the SkipVTableValidation
284 // attribute to DOMRectList.
285 static_assert(!std::is_polymorphic<DOMRectList>::value, "DOMRectList is polymorphic but the IDL claims it is not");
286 return createWrapper<DOMRectList>(globalObject, WTFMove(impl));
287}
288
289JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMRectList& impl)
290{
291 return wrap(state, globalObject, impl);
292}
293
294DOMRectList* JSDOMRectList::toWrapped(JSC::VM& vm, JSC::JSValue value)
295{
296 if (auto* wrapper = jsDynamicCast<JSDOMRectList*>(vm, value))
297 return &wrapper->wrapped();
298 return nullptr;
299}
300
301}
302