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