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