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 "JSDOMRect.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructor.h" |
27 | #include "JSDOMConvertDictionary.h" |
28 | #include "JSDOMConvertInterface.h" |
29 | #include "JSDOMConvertNumbers.h" |
30 | #include "JSDOMExceptionHandling.h" |
31 | #include "JSDOMGlobalObject.h" |
32 | #include "JSDOMOperation.h" |
33 | #include "JSDOMRect.h" |
34 | #include "JSDOMRectInit.h" |
35 | #include "JSDOMWrapperCache.h" |
36 | #include "ScriptExecutionContext.h" |
37 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
38 | #include <JavaScriptCore/JSCInlines.h> |
39 | #include <wtf/GetPtr.h> |
40 | #include <wtf/PointerPreparations.h> |
41 | #include <wtf/URL.h> |
42 | |
43 | |
44 | namespace WebCore { |
45 | using namespace JSC; |
46 | |
47 | // Functions |
48 | |
49 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMRectConstructorFunctionFromRect(JSC::ExecState*); |
50 | |
51 | // Attributes |
52 | |
53 | JSC::EncodedJSValue jsDOMRectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
54 | bool setJSDOMRectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
55 | JSC::EncodedJSValue jsDOMRectX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
56 | bool setJSDOMRectX(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
57 | JSC::EncodedJSValue jsDOMRectY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
58 | bool setJSDOMRectY(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
59 | JSC::EncodedJSValue jsDOMRectWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
60 | bool setJSDOMRectWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
61 | JSC::EncodedJSValue jsDOMRectHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
62 | bool setJSDOMRectHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
63 | |
64 | class JSDOMRectPrototype : public JSC::JSNonFinalObject { |
65 | public: |
66 | using Base = JSC::JSNonFinalObject; |
67 | static JSDOMRectPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
68 | { |
69 | JSDOMRectPrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMRectPrototype>(vm.heap)) JSDOMRectPrototype(vm, globalObject, structure); |
70 | ptr->finishCreation(vm); |
71 | return ptr; |
72 | } |
73 | |
74 | DECLARE_INFO; |
75 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
76 | { |
77 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
78 | } |
79 | |
80 | private: |
81 | JSDOMRectPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
82 | : JSC::JSNonFinalObject(vm, structure) |
83 | { |
84 | } |
85 | |
86 | void finishCreation(JSC::VM&); |
87 | }; |
88 | |
89 | using JSDOMRectConstructor = JSDOMConstructor<JSDOMRect>; |
90 | |
91 | /* Hash table for constructor */ |
92 | |
93 | static const HashTableValue JSDOMRectConstructorTableValues[] = |
94 | { |
95 | { "fromRect" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMRectConstructorFunctionFromRect), (intptr_t) (0) } }, |
96 | }; |
97 | |
98 | template<> EncodedJSValue JSC_HOST_CALL JSDOMRectConstructor::construct(ExecState* state) |
99 | { |
100 | VM& vm = state->vm(); |
101 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
102 | UNUSED_PARAM(throwScope); |
103 | auto* castedThis = jsCast<JSDOMRectConstructor*>(state->jsCallee()); |
104 | ASSERT(castedThis); |
105 | auto x = state->argument(0).isUndefined() ? 0 : convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
106 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
107 | auto y = state->argument(1).isUndefined() ? 0 : convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
108 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
109 | auto width = state->argument(2).isUndefined() ? 0 : convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(2)); |
110 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
111 | auto height = state->argument(3).isUndefined() ? 0 : convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(3)); |
112 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
113 | auto object = DOMRect::create(WTFMove(x), WTFMove(y), WTFMove(width), WTFMove(height)); |
114 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DOMRect>>(*state, *castedThis->globalObject(), WTFMove(object))); |
115 | } |
116 | |
117 | template<> JSValue JSDOMRectConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
118 | { |
119 | return JSDOMRectReadOnly::getConstructor(vm, &globalObject); |
120 | } |
121 | |
122 | template<> void JSDOMRectConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
123 | { |
124 | putDirect(vm, vm.propertyNames->prototype, JSDOMRect::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
125 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("DOMRect"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
126 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
127 | reifyStaticProperties(vm, JSDOMRect::info(), JSDOMRectConstructorTableValues, *this); |
128 | } |
129 | |
130 | template<> const ClassInfo JSDOMRectConstructor::s_info = { "DOMRect" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMRectConstructor) }; |
131 | |
132 | /* Hash table for prototype */ |
133 | |
134 | static const HashTableValue JSDOMRectPrototypeTableValues[] = |
135 | { |
136 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMRectConstructor) } }, |
137 | { "x" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMRectX) } }, |
138 | { "y" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMRectY) } }, |
139 | { "width" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMRectWidth) } }, |
140 | { "height" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMRectHeight) } }, |
141 | }; |
142 | |
143 | const ClassInfo JSDOMRectPrototype::s_info = { "DOMRectPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMRectPrototype) }; |
144 | |
145 | void JSDOMRectPrototype::finishCreation(VM& vm) |
146 | { |
147 | Base::finishCreation(vm); |
148 | reifyStaticProperties(vm, JSDOMRect::info(), JSDOMRectPrototypeTableValues, *this); |
149 | } |
150 | |
151 | const ClassInfo JSDOMRect::s_info = { "DOMRect" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMRect) }; |
152 | |
153 | JSDOMRect::JSDOMRect(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMRect>&& impl) |
154 | : JSDOMRectReadOnly(structure, globalObject, WTFMove(impl)) |
155 | { |
156 | } |
157 | |
158 | void JSDOMRect::finishCreation(VM& vm) |
159 | { |
160 | Base::finishCreation(vm); |
161 | ASSERT(inherits(vm, info())); |
162 | |
163 | } |
164 | |
165 | JSObject* JSDOMRect::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
166 | { |
167 | return JSDOMRectPrototype::create(vm, &globalObject, JSDOMRectPrototype::createStructure(vm, &globalObject, JSDOMRectReadOnly::prototype(vm, globalObject))); |
168 | } |
169 | |
170 | JSObject* JSDOMRect::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
171 | { |
172 | return getDOMPrototype<JSDOMRect>(vm, globalObject); |
173 | } |
174 | |
175 | JSValue JSDOMRect::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
176 | { |
177 | return getDOMConstructor<JSDOMRectConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
178 | } |
179 | |
180 | template<> inline JSDOMRect* IDLAttribute<JSDOMRect>::cast(ExecState& state, EncodedJSValue thisValue) |
181 | { |
182 | return jsDynamicCast<JSDOMRect*>(state.vm(), JSValue::decode(thisValue)); |
183 | } |
184 | |
185 | template<> inline JSDOMRect* IDLOperation<JSDOMRect>::cast(ExecState& state) |
186 | { |
187 | return jsDynamicCast<JSDOMRect*>(state.vm(), state.thisValue()); |
188 | } |
189 | |
190 | EncodedJSValue jsDOMRectConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
191 | { |
192 | VM& vm = state->vm(); |
193 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
194 | auto* prototype = jsDynamicCast<JSDOMRectPrototype*>(vm, JSValue::decode(thisValue)); |
195 | if (UNLIKELY(!prototype)) |
196 | return throwVMTypeError(state, throwScope); |
197 | return JSValue::encode(JSDOMRect::getConstructor(state->vm(), prototype->globalObject())); |
198 | } |
199 | |
200 | bool setJSDOMRectConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
201 | { |
202 | VM& vm = state->vm(); |
203 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
204 | auto* prototype = jsDynamicCast<JSDOMRectPrototype*>(vm, JSValue::decode(thisValue)); |
205 | if (UNLIKELY(!prototype)) { |
206 | throwVMTypeError(state, throwScope); |
207 | return false; |
208 | } |
209 | // Shadowing a built-in constructor |
210 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
211 | } |
212 | |
213 | static inline JSValue jsDOMRectXGetter(ExecState& state, JSDOMRect& thisObject, ThrowScope& throwScope) |
214 | { |
215 | UNUSED_PARAM(throwScope); |
216 | UNUSED_PARAM(state); |
217 | auto& impl = thisObject.wrapped(); |
218 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.x()); |
219 | return result; |
220 | } |
221 | |
222 | EncodedJSValue jsDOMRectX(ExecState* state, EncodedJSValue thisValue, PropertyName) |
223 | { |
224 | return IDLAttribute<JSDOMRect>::get<jsDOMRectXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "x" ); |
225 | } |
226 | |
227 | static inline bool setJSDOMRectXSetter(ExecState& state, JSDOMRect& thisObject, JSValue value, ThrowScope& throwScope) |
228 | { |
229 | UNUSED_PARAM(throwScope); |
230 | auto& impl = thisObject.wrapped(); |
231 | auto nativeValue = convert<IDLUnrestrictedDouble>(state, value); |
232 | RETURN_IF_EXCEPTION(throwScope, false); |
233 | AttributeSetter::call(state, throwScope, [&] { |
234 | return impl.setX(WTFMove(nativeValue)); |
235 | }); |
236 | return true; |
237 | } |
238 | |
239 | bool setJSDOMRectX(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
240 | { |
241 | return IDLAttribute<JSDOMRect>::set<setJSDOMRectXSetter>(*state, thisValue, encodedValue, "x" ); |
242 | } |
243 | |
244 | static inline JSValue jsDOMRectYGetter(ExecState& state, JSDOMRect& thisObject, ThrowScope& throwScope) |
245 | { |
246 | UNUSED_PARAM(throwScope); |
247 | UNUSED_PARAM(state); |
248 | auto& impl = thisObject.wrapped(); |
249 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.y()); |
250 | return result; |
251 | } |
252 | |
253 | EncodedJSValue jsDOMRectY(ExecState* state, EncodedJSValue thisValue, PropertyName) |
254 | { |
255 | return IDLAttribute<JSDOMRect>::get<jsDOMRectYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "y" ); |
256 | } |
257 | |
258 | static inline bool setJSDOMRectYSetter(ExecState& state, JSDOMRect& thisObject, JSValue value, ThrowScope& throwScope) |
259 | { |
260 | UNUSED_PARAM(throwScope); |
261 | auto& impl = thisObject.wrapped(); |
262 | auto nativeValue = convert<IDLUnrestrictedDouble>(state, value); |
263 | RETURN_IF_EXCEPTION(throwScope, false); |
264 | AttributeSetter::call(state, throwScope, [&] { |
265 | return impl.setY(WTFMove(nativeValue)); |
266 | }); |
267 | return true; |
268 | } |
269 | |
270 | bool setJSDOMRectY(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
271 | { |
272 | return IDLAttribute<JSDOMRect>::set<setJSDOMRectYSetter>(*state, thisValue, encodedValue, "y" ); |
273 | } |
274 | |
275 | static inline JSValue jsDOMRectWidthGetter(ExecState& state, JSDOMRect& thisObject, ThrowScope& throwScope) |
276 | { |
277 | UNUSED_PARAM(throwScope); |
278 | UNUSED_PARAM(state); |
279 | auto& impl = thisObject.wrapped(); |
280 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.width()); |
281 | return result; |
282 | } |
283 | |
284 | EncodedJSValue jsDOMRectWidth(ExecState* state, EncodedJSValue thisValue, PropertyName) |
285 | { |
286 | return IDLAttribute<JSDOMRect>::get<jsDOMRectWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width" ); |
287 | } |
288 | |
289 | static inline bool setJSDOMRectWidthSetter(ExecState& state, JSDOMRect& thisObject, JSValue value, ThrowScope& throwScope) |
290 | { |
291 | UNUSED_PARAM(throwScope); |
292 | auto& impl = thisObject.wrapped(); |
293 | auto nativeValue = convert<IDLUnrestrictedDouble>(state, value); |
294 | RETURN_IF_EXCEPTION(throwScope, false); |
295 | AttributeSetter::call(state, throwScope, [&] { |
296 | return impl.setWidth(WTFMove(nativeValue)); |
297 | }); |
298 | return true; |
299 | } |
300 | |
301 | bool setJSDOMRectWidth(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
302 | { |
303 | return IDLAttribute<JSDOMRect>::set<setJSDOMRectWidthSetter>(*state, thisValue, encodedValue, "width" ); |
304 | } |
305 | |
306 | static inline JSValue jsDOMRectHeightGetter(ExecState& state, JSDOMRect& thisObject, ThrowScope& throwScope) |
307 | { |
308 | UNUSED_PARAM(throwScope); |
309 | UNUSED_PARAM(state); |
310 | auto& impl = thisObject.wrapped(); |
311 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.height()); |
312 | return result; |
313 | } |
314 | |
315 | EncodedJSValue jsDOMRectHeight(ExecState* state, EncodedJSValue thisValue, PropertyName) |
316 | { |
317 | return IDLAttribute<JSDOMRect>::get<jsDOMRectHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height" ); |
318 | } |
319 | |
320 | static inline bool setJSDOMRectHeightSetter(ExecState& state, JSDOMRect& thisObject, JSValue value, ThrowScope& throwScope) |
321 | { |
322 | UNUSED_PARAM(throwScope); |
323 | auto& impl = thisObject.wrapped(); |
324 | auto nativeValue = convert<IDLUnrestrictedDouble>(state, value); |
325 | RETURN_IF_EXCEPTION(throwScope, false); |
326 | AttributeSetter::call(state, throwScope, [&] { |
327 | return impl.setHeight(WTFMove(nativeValue)); |
328 | }); |
329 | return true; |
330 | } |
331 | |
332 | bool setJSDOMRectHeight(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
333 | { |
334 | return IDLAttribute<JSDOMRect>::set<setJSDOMRectHeightSetter>(*state, thisValue, encodedValue, "height" ); |
335 | } |
336 | |
337 | static inline JSC::EncodedJSValue jsDOMRectConstructorFunctionFromRectBody(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
338 | { |
339 | UNUSED_PARAM(state); |
340 | UNUSED_PARAM(throwScope); |
341 | auto other = convert<IDLDictionary<DOMRectInit>>(*state, state->argument(0)); |
342 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
343 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DOMRect>>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), DOMRect::fromRect(WTFMove(other)))); |
344 | } |
345 | |
346 | EncodedJSValue JSC_HOST_CALL jsDOMRectConstructorFunctionFromRect(ExecState* state) |
347 | { |
348 | return IDLOperation<JSDOMRect>::callStatic<jsDOMRectConstructorFunctionFromRectBody>(*state, "fromRect" ); |
349 | } |
350 | |
351 | void JSDOMRect::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
352 | { |
353 | auto* thisObject = jsCast<JSDOMRect*>(cell); |
354 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
355 | if (thisObject->scriptExecutionContext()) |
356 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
357 | Base::heapSnapshot(cell, builder); |
358 | } |
359 | |
360 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMRect>&& impl) |
361 | { |
362 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
363 | // attribute. You should remove that attribute. If the class has subclasses |
364 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
365 | // attribute to DOMRect. |
366 | static_assert(!std::is_polymorphic<DOMRect>::value, "DOMRect is polymorphic but the IDL claims it is not" ); |
367 | return createWrapper<DOMRect>(globalObject, WTFMove(impl)); |
368 | } |
369 | |
370 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMRect& impl) |
371 | { |
372 | return wrap(state, globalObject, impl); |
373 | } |
374 | |
375 | |
376 | } |
377 | |