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 "JSOverflowEvent.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructor.h" |
27 | #include "JSDOMConvertBoolean.h" |
28 | #include "JSDOMConvertInterface.h" |
29 | #include "JSDOMConvertNumbers.h" |
30 | #include "JSDOMConvertStrings.h" |
31 | #include "JSDOMExceptionHandling.h" |
32 | #include "JSDOMWrapperCache.h" |
33 | #include "ScriptExecutionContext.h" |
34 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
35 | #include <JavaScriptCore/JSCInlines.h> |
36 | #include <wtf/GetPtr.h> |
37 | #include <wtf/PointerPreparations.h> |
38 | #include <wtf/URL.h> |
39 | |
40 | |
41 | namespace WebCore { |
42 | using namespace JSC; |
43 | |
44 | template<> OverflowEvent::Init convertDictionary<OverflowEvent::Init>(ExecState& state, JSValue value) |
45 | { |
46 | VM& vm = state.vm(); |
47 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
48 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
49 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
50 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
51 | throwTypeError(&state, throwScope); |
52 | return { }; |
53 | } |
54 | OverflowEvent::Init result; |
55 | JSValue bubblesValue; |
56 | if (isNullOrUndefined) |
57 | bubblesValue = jsUndefined(); |
58 | else { |
59 | bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles" )); |
60 | RETURN_IF_EXCEPTION(throwScope, { }); |
61 | } |
62 | if (!bubblesValue.isUndefined()) { |
63 | result.bubbles = convert<IDLBoolean>(state, bubblesValue); |
64 | RETURN_IF_EXCEPTION(throwScope, { }); |
65 | } else |
66 | result.bubbles = false; |
67 | JSValue cancelableValue; |
68 | if (isNullOrUndefined) |
69 | cancelableValue = jsUndefined(); |
70 | else { |
71 | cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable" )); |
72 | RETURN_IF_EXCEPTION(throwScope, { }); |
73 | } |
74 | if (!cancelableValue.isUndefined()) { |
75 | result.cancelable = convert<IDLBoolean>(state, cancelableValue); |
76 | RETURN_IF_EXCEPTION(throwScope, { }); |
77 | } else |
78 | result.cancelable = false; |
79 | JSValue composedValue; |
80 | if (isNullOrUndefined) |
81 | composedValue = jsUndefined(); |
82 | else { |
83 | composedValue = object->get(&state, Identifier::fromString(&state, "composed" )); |
84 | RETURN_IF_EXCEPTION(throwScope, { }); |
85 | } |
86 | if (!composedValue.isUndefined()) { |
87 | result.composed = convert<IDLBoolean>(state, composedValue); |
88 | RETURN_IF_EXCEPTION(throwScope, { }); |
89 | } else |
90 | result.composed = false; |
91 | JSValue horizontalOverflowValue; |
92 | if (isNullOrUndefined) |
93 | horizontalOverflowValue = jsUndefined(); |
94 | else { |
95 | horizontalOverflowValue = object->get(&state, Identifier::fromString(&state, "horizontalOverflow" )); |
96 | RETURN_IF_EXCEPTION(throwScope, { }); |
97 | } |
98 | if (!horizontalOverflowValue.isUndefined()) { |
99 | result.horizontalOverflow = convert<IDLBoolean>(state, horizontalOverflowValue); |
100 | RETURN_IF_EXCEPTION(throwScope, { }); |
101 | } else |
102 | result.horizontalOverflow = false; |
103 | JSValue orientValue; |
104 | if (isNullOrUndefined) |
105 | orientValue = jsUndefined(); |
106 | else { |
107 | orientValue = object->get(&state, Identifier::fromString(&state, "orient" )); |
108 | RETURN_IF_EXCEPTION(throwScope, { }); |
109 | } |
110 | if (!orientValue.isUndefined()) { |
111 | result.orient = convert<IDLUnsignedShort>(state, orientValue); |
112 | RETURN_IF_EXCEPTION(throwScope, { }); |
113 | } else |
114 | result.orient = 0; |
115 | JSValue verticalOverflowValue; |
116 | if (isNullOrUndefined) |
117 | verticalOverflowValue = jsUndefined(); |
118 | else { |
119 | verticalOverflowValue = object->get(&state, Identifier::fromString(&state, "verticalOverflow" )); |
120 | RETURN_IF_EXCEPTION(throwScope, { }); |
121 | } |
122 | if (!verticalOverflowValue.isUndefined()) { |
123 | result.verticalOverflow = convert<IDLBoolean>(state, verticalOverflowValue); |
124 | RETURN_IF_EXCEPTION(throwScope, { }); |
125 | } else |
126 | result.verticalOverflow = false; |
127 | return result; |
128 | } |
129 | |
130 | // Attributes |
131 | |
132 | JSC::EncodedJSValue jsOverflowEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
133 | bool setJSOverflowEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
134 | JSC::EncodedJSValue jsOverflowEventOrient(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
135 | JSC::EncodedJSValue jsOverflowEventHorizontalOverflow(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
136 | JSC::EncodedJSValue jsOverflowEventVerticalOverflow(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
137 | |
138 | class JSOverflowEventPrototype : public JSC::JSNonFinalObject { |
139 | public: |
140 | using Base = JSC::JSNonFinalObject; |
141 | static JSOverflowEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
142 | { |
143 | JSOverflowEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSOverflowEventPrototype>(vm.heap)) JSOverflowEventPrototype(vm, globalObject, structure); |
144 | ptr->finishCreation(vm); |
145 | return ptr; |
146 | } |
147 | |
148 | DECLARE_INFO; |
149 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
150 | { |
151 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
152 | } |
153 | |
154 | private: |
155 | JSOverflowEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
156 | : JSC::JSNonFinalObject(vm, structure) |
157 | { |
158 | } |
159 | |
160 | void finishCreation(JSC::VM&); |
161 | }; |
162 | |
163 | using JSOverflowEventConstructor = JSDOMConstructor<JSOverflowEvent>; |
164 | |
165 | /* Hash table for constructor */ |
166 | |
167 | static const HashTableValue JSOverflowEventConstructorTableValues[] = |
168 | { |
169 | { "HORIZONTAL" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
170 | { "VERTICAL" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
171 | { "BOTH" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
172 | }; |
173 | |
174 | static_assert(OverflowEvent::HORIZONTAL == 0, "HORIZONTAL in OverflowEvent does not match value from IDL" ); |
175 | static_assert(OverflowEvent::VERTICAL == 1, "VERTICAL in OverflowEvent does not match value from IDL" ); |
176 | static_assert(OverflowEvent::BOTH == 2, "BOTH in OverflowEvent does not match value from IDL" ); |
177 | |
178 | template<> EncodedJSValue JSC_HOST_CALL JSOverflowEventConstructor::construct(ExecState* state) |
179 | { |
180 | VM& vm = state->vm(); |
181 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
182 | UNUSED_PARAM(throwScope); |
183 | auto* castedThis = jsCast<JSOverflowEventConstructor*>(state->jsCallee()); |
184 | ASSERT(castedThis); |
185 | if (UNLIKELY(state->argumentCount() < 1)) |
186 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
187 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
188 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
189 | auto eventInitDict = convert<IDLDictionary<OverflowEvent::Init>>(*state, state->argument(1)); |
190 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
191 | auto object = OverflowEvent::create(WTFMove(type), WTFMove(eventInitDict)); |
192 | return JSValue::encode(toJSNewlyCreated<IDLInterface<OverflowEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
193 | } |
194 | |
195 | template<> JSValue JSOverflowEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
196 | { |
197 | return JSEvent::getConstructor(vm, &globalObject); |
198 | } |
199 | |
200 | template<> void JSOverflowEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
201 | { |
202 | putDirect(vm, vm.propertyNames->prototype, JSOverflowEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
203 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("OverflowEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
204 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
205 | reifyStaticProperties(vm, JSOverflowEvent::info(), JSOverflowEventConstructorTableValues, *this); |
206 | } |
207 | |
208 | template<> const ClassInfo JSOverflowEventConstructor::s_info = { "OverflowEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSOverflowEventConstructor) }; |
209 | |
210 | /* Hash table for prototype */ |
211 | |
212 | static const HashTableValue JSOverflowEventPrototypeTableValues[] = |
213 | { |
214 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOverflowEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSOverflowEventConstructor) } }, |
215 | { "orient" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOverflowEventOrient), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
216 | { "horizontalOverflow" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOverflowEventHorizontalOverflow), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
217 | { "verticalOverflow" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOverflowEventVerticalOverflow), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
218 | { "HORIZONTAL" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
219 | { "VERTICAL" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
220 | { "BOTH" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
221 | }; |
222 | |
223 | const ClassInfo JSOverflowEventPrototype::s_info = { "OverflowEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSOverflowEventPrototype) }; |
224 | |
225 | void JSOverflowEventPrototype::finishCreation(VM& vm) |
226 | { |
227 | Base::finishCreation(vm); |
228 | reifyStaticProperties(vm, JSOverflowEvent::info(), JSOverflowEventPrototypeTableValues, *this); |
229 | } |
230 | |
231 | const ClassInfo JSOverflowEvent::s_info = { "OverflowEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSOverflowEvent) }; |
232 | |
233 | JSOverflowEvent::JSOverflowEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<OverflowEvent>&& impl) |
234 | : JSEvent(structure, globalObject, WTFMove(impl)) |
235 | { |
236 | } |
237 | |
238 | void JSOverflowEvent::finishCreation(VM& vm) |
239 | { |
240 | Base::finishCreation(vm); |
241 | ASSERT(inherits(vm, info())); |
242 | |
243 | } |
244 | |
245 | JSObject* JSOverflowEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
246 | { |
247 | return JSOverflowEventPrototype::create(vm, &globalObject, JSOverflowEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
248 | } |
249 | |
250 | JSObject* JSOverflowEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
251 | { |
252 | return getDOMPrototype<JSOverflowEvent>(vm, globalObject); |
253 | } |
254 | |
255 | JSValue JSOverflowEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
256 | { |
257 | return getDOMConstructor<JSOverflowEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
258 | } |
259 | |
260 | template<> inline JSOverflowEvent* IDLAttribute<JSOverflowEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
261 | { |
262 | return jsDynamicCast<JSOverflowEvent*>(state.vm(), JSValue::decode(thisValue)); |
263 | } |
264 | |
265 | EncodedJSValue jsOverflowEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
266 | { |
267 | VM& vm = state->vm(); |
268 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
269 | auto* prototype = jsDynamicCast<JSOverflowEventPrototype*>(vm, JSValue::decode(thisValue)); |
270 | if (UNLIKELY(!prototype)) |
271 | return throwVMTypeError(state, throwScope); |
272 | return JSValue::encode(JSOverflowEvent::getConstructor(state->vm(), prototype->globalObject())); |
273 | } |
274 | |
275 | bool setJSOverflowEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
276 | { |
277 | VM& vm = state->vm(); |
278 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
279 | auto* prototype = jsDynamicCast<JSOverflowEventPrototype*>(vm, JSValue::decode(thisValue)); |
280 | if (UNLIKELY(!prototype)) { |
281 | throwVMTypeError(state, throwScope); |
282 | return false; |
283 | } |
284 | // Shadowing a built-in constructor |
285 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
286 | } |
287 | |
288 | static inline JSValue jsOverflowEventOrientGetter(ExecState& state, JSOverflowEvent& thisObject, ThrowScope& throwScope) |
289 | { |
290 | UNUSED_PARAM(throwScope); |
291 | UNUSED_PARAM(state); |
292 | auto& impl = thisObject.wrapped(); |
293 | JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.orient()); |
294 | return result; |
295 | } |
296 | |
297 | EncodedJSValue jsOverflowEventOrient(ExecState* state, EncodedJSValue thisValue, PropertyName) |
298 | { |
299 | return IDLAttribute<JSOverflowEvent>::get<jsOverflowEventOrientGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "orient" ); |
300 | } |
301 | |
302 | static inline JSValue jsOverflowEventHorizontalOverflowGetter(ExecState& state, JSOverflowEvent& thisObject, ThrowScope& throwScope) |
303 | { |
304 | UNUSED_PARAM(throwScope); |
305 | UNUSED_PARAM(state); |
306 | auto& impl = thisObject.wrapped(); |
307 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.horizontalOverflow()); |
308 | return result; |
309 | } |
310 | |
311 | EncodedJSValue jsOverflowEventHorizontalOverflow(ExecState* state, EncodedJSValue thisValue, PropertyName) |
312 | { |
313 | return IDLAttribute<JSOverflowEvent>::get<jsOverflowEventHorizontalOverflowGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "horizontalOverflow" ); |
314 | } |
315 | |
316 | static inline JSValue jsOverflowEventVerticalOverflowGetter(ExecState& state, JSOverflowEvent& thisObject, ThrowScope& throwScope) |
317 | { |
318 | UNUSED_PARAM(throwScope); |
319 | UNUSED_PARAM(state); |
320 | auto& impl = thisObject.wrapped(); |
321 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.verticalOverflow()); |
322 | return result; |
323 | } |
324 | |
325 | EncodedJSValue jsOverflowEventVerticalOverflow(ExecState* state, EncodedJSValue thisValue, PropertyName) |
326 | { |
327 | return IDLAttribute<JSOverflowEvent>::get<jsOverflowEventVerticalOverflowGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "verticalOverflow" ); |
328 | } |
329 | |
330 | void JSOverflowEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
331 | { |
332 | auto* thisObject = jsCast<JSOverflowEvent*>(cell); |
333 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
334 | if (thisObject->scriptExecutionContext()) |
335 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
336 | Base::heapSnapshot(cell, builder); |
337 | } |
338 | |
339 | #if ENABLE(BINDING_INTEGRITY) |
340 | #if PLATFORM(WIN) |
341 | #pragma warning(disable: 4483) |
342 | extern "C" { extern void (*const __identifier("??_7OverflowEvent@WebCore@@6B@" )[])(); } |
343 | #else |
344 | extern "C" { extern void* _ZTVN7WebCore13OverflowEventE[]; } |
345 | #endif |
346 | #endif |
347 | |
348 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<OverflowEvent>&& impl) |
349 | { |
350 | |
351 | #if ENABLE(BINDING_INTEGRITY) |
352 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
353 | #if PLATFORM(WIN) |
354 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7OverflowEvent@WebCore@@6B@" )); |
355 | #else |
356 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore13OverflowEventE[2]); |
357 | #endif |
358 | |
359 | // If this fails OverflowEvent does not have a vtable, so you need to add the |
360 | // ImplementationLacksVTable attribute to the interface definition |
361 | static_assert(std::is_polymorphic<OverflowEvent>::value, "OverflowEvent is not polymorphic" ); |
362 | |
363 | // If you hit this assertion you either have a use after free bug, or |
364 | // OverflowEvent has subclasses. If OverflowEvent has subclasses that get passed |
365 | // to toJS() we currently require OverflowEvent you to opt out of binding hardening |
366 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
367 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
368 | #endif |
369 | return createWrapper<OverflowEvent>(globalObject, WTFMove(impl)); |
370 | } |
371 | |
372 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, OverflowEvent& impl) |
373 | { |
374 | return wrap(state, globalObject, impl); |
375 | } |
376 | |
377 | |
378 | } |
379 | |