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