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