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 "JSDataTransfer.h" |
23 | |
24 | #include "Document.h" |
25 | #include "JSDOMAttribute.h" |
26 | #include "JSDOMBinding.h" |
27 | #include "JSDOMConstructorNotConstructable.h" |
28 | #include "JSDOMConvertInterface.h" |
29 | #include "JSDOMConvertNullable.h" |
30 | #include "JSDOMConvertNumbers.h" |
31 | #include "JSDOMConvertSequences.h" |
32 | #include "JSDOMConvertStrings.h" |
33 | #include "JSDOMExceptionHandling.h" |
34 | #include "JSDOMGlobalObject.h" |
35 | #include "JSDOMOperation.h" |
36 | #include "JSDOMWrapperCache.h" |
37 | #include "JSDataTransferItemList.h" |
38 | #include "JSElement.h" |
39 | #include "JSFileList.h" |
40 | #include "RuntimeEnabledFeatures.h" |
41 | #include "ScriptExecutionContext.h" |
42 | #include <JavaScriptCore/FunctionPrototype.h> |
43 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
44 | #include <JavaScriptCore/JSArray.h> |
45 | #include <JavaScriptCore/JSCInlines.h> |
46 | #include <wtf/GetPtr.h> |
47 | #include <wtf/PointerPreparations.h> |
48 | #include <wtf/URL.h> |
49 | |
50 | |
51 | namespace WebCore { |
52 | using namespace JSC; |
53 | |
54 | // Functions |
55 | |
56 | JSC::EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionSetDragImage(JSC::ExecState*); |
57 | JSC::EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionGetData(JSC::ExecState*); |
58 | JSC::EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionSetData(JSC::ExecState*); |
59 | JSC::EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionClearData(JSC::ExecState*); |
60 | |
61 | // Attributes |
62 | |
63 | JSC::EncodedJSValue jsDataTransferConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
64 | bool setJSDataTransferConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
65 | JSC::EncodedJSValue jsDataTransferDropEffect(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
66 | bool setJSDataTransferDropEffect(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
67 | JSC::EncodedJSValue jsDataTransferEffectAllowed(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
68 | bool setJSDataTransferEffectAllowed(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
69 | JSC::EncodedJSValue jsDataTransferItems(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
70 | JSC::EncodedJSValue jsDataTransferTypes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
71 | JSC::EncodedJSValue jsDataTransferFiles(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
72 | |
73 | class JSDataTransferPrototype : public JSC::JSNonFinalObject { |
74 | public: |
75 | using Base = JSC::JSNonFinalObject; |
76 | static JSDataTransferPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
77 | { |
78 | JSDataTransferPrototype* ptr = new (NotNull, JSC::allocateCell<JSDataTransferPrototype>(vm.heap)) JSDataTransferPrototype(vm, globalObject, structure); |
79 | ptr->finishCreation(vm); |
80 | return ptr; |
81 | } |
82 | |
83 | DECLARE_INFO; |
84 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
85 | { |
86 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
87 | } |
88 | |
89 | private: |
90 | JSDataTransferPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
91 | : JSC::JSNonFinalObject(vm, structure) |
92 | { |
93 | } |
94 | |
95 | void finishCreation(JSC::VM&); |
96 | }; |
97 | |
98 | using JSDataTransferConstructor = JSDOMConstructorNotConstructable<JSDataTransfer>; |
99 | |
100 | template<> JSValue JSDataTransferConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
101 | { |
102 | UNUSED_PARAM(vm); |
103 | return globalObject.functionPrototype(); |
104 | } |
105 | |
106 | template<> void JSDataTransferConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
107 | { |
108 | putDirect(vm, vm.propertyNames->prototype, JSDataTransfer::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
109 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("DataTransfer"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
110 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
111 | } |
112 | |
113 | template<> const ClassInfo JSDataTransferConstructor::s_info = { "DataTransfer" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDataTransferConstructor) }; |
114 | |
115 | /* Hash table for prototype */ |
116 | |
117 | static const HashTableValue JSDataTransferPrototypeTableValues[] = |
118 | { |
119 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDataTransferConstructor) } }, |
120 | { "dropEffect" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferDropEffect), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDataTransferDropEffect) } }, |
121 | { "effectAllowed" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferEffectAllowed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDataTransferEffectAllowed) } }, |
122 | { "items" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferItems), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
123 | { "types" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferTypes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
124 | { "files" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferFiles), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
125 | { "setDragImage" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDataTransferPrototypeFunctionSetDragImage), (intptr_t) (3) } }, |
126 | { "getData" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDataTransferPrototypeFunctionGetData), (intptr_t) (1) } }, |
127 | { "setData" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDataTransferPrototypeFunctionSetData), (intptr_t) (2) } }, |
128 | { "clearData" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDataTransferPrototypeFunctionClearData), (intptr_t) (0) } }, |
129 | }; |
130 | |
131 | const ClassInfo JSDataTransferPrototype::s_info = { "DataTransferPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDataTransferPrototype) }; |
132 | |
133 | void JSDataTransferPrototype::finishCreation(VM& vm) |
134 | { |
135 | Base::finishCreation(vm); |
136 | reifyStaticProperties(vm, JSDataTransfer::info(), JSDataTransferPrototypeTableValues, *this); |
137 | bool hasDisabledRuntimeProperties = false; |
138 | if (!RuntimeEnabledFeatures::sharedFeatures().dataTransferItemsEnabled()) { |
139 | hasDisabledRuntimeProperties = true; |
140 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("items" ), strlen("items" )); |
141 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
142 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
143 | } |
144 | if (hasDisabledRuntimeProperties && structure()->isDictionary()) |
145 | flattenDictionaryObject(vm); |
146 | } |
147 | |
148 | const ClassInfo JSDataTransfer::s_info = { "DataTransfer" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDataTransfer) }; |
149 | |
150 | JSDataTransfer::JSDataTransfer(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DataTransfer>&& impl) |
151 | : JSDOMWrapper<DataTransfer>(structure, globalObject, WTFMove(impl)) |
152 | { |
153 | } |
154 | |
155 | void JSDataTransfer::finishCreation(VM& vm) |
156 | { |
157 | Base::finishCreation(vm); |
158 | ASSERT(inherits(vm, info())); |
159 | |
160 | } |
161 | |
162 | JSObject* JSDataTransfer::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
163 | { |
164 | return JSDataTransferPrototype::create(vm, &globalObject, JSDataTransferPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
165 | } |
166 | |
167 | JSObject* JSDataTransfer::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
168 | { |
169 | return getDOMPrototype<JSDataTransfer>(vm, globalObject); |
170 | } |
171 | |
172 | JSValue JSDataTransfer::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
173 | { |
174 | return getDOMConstructor<JSDataTransferConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
175 | } |
176 | |
177 | void JSDataTransfer::destroy(JSC::JSCell* cell) |
178 | { |
179 | JSDataTransfer* thisObject = static_cast<JSDataTransfer*>(cell); |
180 | thisObject->JSDataTransfer::~JSDataTransfer(); |
181 | } |
182 | |
183 | template<> inline JSDataTransfer* IDLAttribute<JSDataTransfer>::cast(ExecState& state, EncodedJSValue thisValue) |
184 | { |
185 | return jsDynamicCast<JSDataTransfer*>(state.vm(), JSValue::decode(thisValue)); |
186 | } |
187 | |
188 | template<> inline JSDataTransfer* IDLOperation<JSDataTransfer>::cast(ExecState& state) |
189 | { |
190 | return jsDynamicCast<JSDataTransfer*>(state.vm(), state.thisValue()); |
191 | } |
192 | |
193 | EncodedJSValue jsDataTransferConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
194 | { |
195 | VM& vm = state->vm(); |
196 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
197 | auto* prototype = jsDynamicCast<JSDataTransferPrototype*>(vm, JSValue::decode(thisValue)); |
198 | if (UNLIKELY(!prototype)) |
199 | return throwVMTypeError(state, throwScope); |
200 | return JSValue::encode(JSDataTransfer::getConstructor(state->vm(), prototype->globalObject())); |
201 | } |
202 | |
203 | bool setJSDataTransferConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
204 | { |
205 | VM& vm = state->vm(); |
206 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
207 | auto* prototype = jsDynamicCast<JSDataTransferPrototype*>(vm, JSValue::decode(thisValue)); |
208 | if (UNLIKELY(!prototype)) { |
209 | throwVMTypeError(state, throwScope); |
210 | return false; |
211 | } |
212 | // Shadowing a built-in constructor |
213 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
214 | } |
215 | |
216 | static inline JSValue jsDataTransferDropEffectGetter(ExecState& state, JSDataTransfer& thisObject, ThrowScope& throwScope) |
217 | { |
218 | UNUSED_PARAM(throwScope); |
219 | UNUSED_PARAM(state); |
220 | auto& impl = thisObject.wrapped(); |
221 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.dropEffect()); |
222 | return result; |
223 | } |
224 | |
225 | EncodedJSValue jsDataTransferDropEffect(ExecState* state, EncodedJSValue thisValue, PropertyName) |
226 | { |
227 | return IDLAttribute<JSDataTransfer>::get<jsDataTransferDropEffectGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "dropEffect" ); |
228 | } |
229 | |
230 | static inline bool setJSDataTransferDropEffectSetter(ExecState& state, JSDataTransfer& thisObject, JSValue value, ThrowScope& throwScope) |
231 | { |
232 | UNUSED_PARAM(throwScope); |
233 | auto& impl = thisObject.wrapped(); |
234 | auto nativeValue = convert<IDLDOMString>(state, value); |
235 | RETURN_IF_EXCEPTION(throwScope, false); |
236 | AttributeSetter::call(state, throwScope, [&] { |
237 | return impl.setDropEffect(WTFMove(nativeValue)); |
238 | }); |
239 | return true; |
240 | } |
241 | |
242 | bool setJSDataTransferDropEffect(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
243 | { |
244 | return IDLAttribute<JSDataTransfer>::set<setJSDataTransferDropEffectSetter>(*state, thisValue, encodedValue, "dropEffect" ); |
245 | } |
246 | |
247 | static inline JSValue jsDataTransferEffectAllowedGetter(ExecState& state, JSDataTransfer& thisObject, ThrowScope& throwScope) |
248 | { |
249 | UNUSED_PARAM(throwScope); |
250 | UNUSED_PARAM(state); |
251 | auto& impl = thisObject.wrapped(); |
252 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.effectAllowed()); |
253 | return result; |
254 | } |
255 | |
256 | EncodedJSValue jsDataTransferEffectAllowed(ExecState* state, EncodedJSValue thisValue, PropertyName) |
257 | { |
258 | return IDLAttribute<JSDataTransfer>::get<jsDataTransferEffectAllowedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "effectAllowed" ); |
259 | } |
260 | |
261 | static inline bool setJSDataTransferEffectAllowedSetter(ExecState& state, JSDataTransfer& thisObject, JSValue value, ThrowScope& throwScope) |
262 | { |
263 | UNUSED_PARAM(throwScope); |
264 | auto& impl = thisObject.wrapped(); |
265 | auto nativeValue = convert<IDLDOMString>(state, value); |
266 | RETURN_IF_EXCEPTION(throwScope, false); |
267 | AttributeSetter::call(state, throwScope, [&] { |
268 | return impl.setEffectAllowed(WTFMove(nativeValue)); |
269 | }); |
270 | return true; |
271 | } |
272 | |
273 | bool setJSDataTransferEffectAllowed(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
274 | { |
275 | return IDLAttribute<JSDataTransfer>::set<setJSDataTransferEffectAllowedSetter>(*state, thisValue, encodedValue, "effectAllowed" ); |
276 | } |
277 | |
278 | static inline JSValue jsDataTransferItemsGetter(ExecState& state, JSDataTransfer& thisObject, ThrowScope& throwScope) |
279 | { |
280 | UNUSED_PARAM(throwScope); |
281 | UNUSED_PARAM(state); |
282 | auto& impl = thisObject.wrapped(); |
283 | JSValue result = toJS<IDLInterface<DataTransferItemList>>(state, *thisObject.globalObject(), throwScope, impl.items()); |
284 | return result; |
285 | } |
286 | |
287 | EncodedJSValue jsDataTransferItems(ExecState* state, EncodedJSValue thisValue, PropertyName) |
288 | { |
289 | return IDLAttribute<JSDataTransfer>::get<jsDataTransferItemsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "items" ); |
290 | } |
291 | |
292 | static inline JSValue jsDataTransferTypesGetter(ExecState& state, JSDataTransfer& thisObject, ThrowScope& throwScope) |
293 | { |
294 | UNUSED_PARAM(throwScope); |
295 | UNUSED_PARAM(state); |
296 | auto& impl = thisObject.wrapped(); |
297 | JSValue result = toJS<IDLFrozenArray<IDLDOMString>>(state, *thisObject.globalObject(), throwScope, impl.types()); |
298 | return result; |
299 | } |
300 | |
301 | EncodedJSValue jsDataTransferTypes(ExecState* state, EncodedJSValue thisValue, PropertyName) |
302 | { |
303 | return IDLAttribute<JSDataTransfer>::get<jsDataTransferTypesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "types" ); |
304 | } |
305 | |
306 | static inline JSValue jsDataTransferFilesGetter(ExecState& state, JSDataTransfer& thisObject, ThrowScope& throwScope) |
307 | { |
308 | UNUSED_PARAM(throwScope); |
309 | UNUSED_PARAM(state); |
310 | auto& impl = thisObject.wrapped(); |
311 | JSValue result = toJS<IDLInterface<FileList>>(state, *thisObject.globalObject(), throwScope, impl.files()); |
312 | return result; |
313 | } |
314 | |
315 | EncodedJSValue jsDataTransferFiles(ExecState* state, EncodedJSValue thisValue, PropertyName) |
316 | { |
317 | return IDLAttribute<JSDataTransfer>::get<jsDataTransferFilesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "files" ); |
318 | } |
319 | |
320 | static inline JSC::EncodedJSValue jsDataTransferPrototypeFunctionSetDragImageBody(JSC::ExecState* state, typename IDLOperation<JSDataTransfer>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
321 | { |
322 | UNUSED_PARAM(state); |
323 | UNUSED_PARAM(throwScope); |
324 | auto& impl = castedThis->wrapped(); |
325 | if (UNLIKELY(state->argumentCount() < 3)) |
326 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
327 | auto image = convert<IDLNullable<IDLInterface<Element>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "image" , "DataTransfer" , "setDragImage" , "Element" ); }); |
328 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
329 | auto x = convert<IDLLong>(*state, state->uncheckedArgument(1)); |
330 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
331 | auto y = convert<IDLLong>(*state, state->uncheckedArgument(2)); |
332 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
333 | impl.setDragImage(WTFMove(image), WTFMove(x), WTFMove(y)); |
334 | return JSValue::encode(jsUndefined()); |
335 | } |
336 | |
337 | EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionSetDragImage(ExecState* state) |
338 | { |
339 | return IDLOperation<JSDataTransfer>::call<jsDataTransferPrototypeFunctionSetDragImageBody>(*state, "setDragImage" ); |
340 | } |
341 | |
342 | static inline JSC::EncodedJSValue jsDataTransferPrototypeFunctionGetDataBody(JSC::ExecState* state, typename IDLOperation<JSDataTransfer>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
343 | { |
344 | UNUSED_PARAM(state); |
345 | UNUSED_PARAM(throwScope); |
346 | auto& impl = castedThis->wrapped(); |
347 | if (UNLIKELY(state->argumentCount() < 1)) |
348 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
349 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
350 | if (UNLIKELY(!context)) |
351 | return JSValue::encode(jsUndefined()); |
352 | ASSERT(context->isDocument()); |
353 | auto& document = downcast<Document>(*context); |
354 | auto format = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
355 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
356 | return JSValue::encode(toJS<IDLDOMString>(*state, impl.getData(document, WTFMove(format)))); |
357 | } |
358 | |
359 | EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionGetData(ExecState* state) |
360 | { |
361 | return IDLOperation<JSDataTransfer>::call<jsDataTransferPrototypeFunctionGetDataBody>(*state, "getData" ); |
362 | } |
363 | |
364 | static inline JSC::EncodedJSValue jsDataTransferPrototypeFunctionSetDataBody(JSC::ExecState* state, typename IDLOperation<JSDataTransfer>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
365 | { |
366 | UNUSED_PARAM(state); |
367 | UNUSED_PARAM(throwScope); |
368 | auto& impl = castedThis->wrapped(); |
369 | if (UNLIKELY(state->argumentCount() < 2)) |
370 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
371 | auto format = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
372 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
373 | auto data = convert<IDLDOMString>(*state, state->uncheckedArgument(1)); |
374 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
375 | impl.setData(WTFMove(format), WTFMove(data)); |
376 | return JSValue::encode(jsUndefined()); |
377 | } |
378 | |
379 | EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionSetData(ExecState* state) |
380 | { |
381 | return IDLOperation<JSDataTransfer>::call<jsDataTransferPrototypeFunctionSetDataBody>(*state, "setData" ); |
382 | } |
383 | |
384 | static inline JSC::EncodedJSValue jsDataTransferPrototypeFunctionClearDataBody(JSC::ExecState* state, typename IDLOperation<JSDataTransfer>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
385 | { |
386 | UNUSED_PARAM(state); |
387 | UNUSED_PARAM(throwScope); |
388 | auto& impl = castedThis->wrapped(); |
389 | auto format = state->argument(0).isUndefined() ? String() : convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
390 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
391 | impl.clearData(WTFMove(format)); |
392 | return JSValue::encode(jsUndefined()); |
393 | } |
394 | |
395 | EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionClearData(ExecState* state) |
396 | { |
397 | return IDLOperation<JSDataTransfer>::call<jsDataTransferPrototypeFunctionClearDataBody>(*state, "clearData" ); |
398 | } |
399 | |
400 | void JSDataTransfer::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
401 | { |
402 | auto* thisObject = jsCast<JSDataTransfer*>(cell); |
403 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
404 | if (thisObject->scriptExecutionContext()) |
405 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
406 | Base::heapSnapshot(cell, builder); |
407 | } |
408 | |
409 | bool JSDataTransferOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
410 | { |
411 | UNUSED_PARAM(handle); |
412 | UNUSED_PARAM(visitor); |
413 | UNUSED_PARAM(reason); |
414 | return false; |
415 | } |
416 | |
417 | void JSDataTransferOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
418 | { |
419 | auto* jsDataTransfer = static_cast<JSDataTransfer*>(handle.slot()->asCell()); |
420 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
421 | uncacheWrapper(world, &jsDataTransfer->wrapped(), jsDataTransfer); |
422 | } |
423 | |
424 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DataTransfer>&& impl) |
425 | { |
426 | return createWrapper<DataTransfer>(globalObject, WTFMove(impl)); |
427 | } |
428 | |
429 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DataTransfer& impl) |
430 | { |
431 | return wrap(state, globalObject, impl); |
432 | } |
433 | |
434 | DataTransfer* JSDataTransfer::toWrapped(JSC::VM& vm, JSC::JSValue value) |
435 | { |
436 | if (auto* wrapper = jsDynamicCast<JSDataTransfer*>(vm, value)) |
437 | return &wrapper->wrapped(); |
438 | return nullptr; |
439 | } |
440 | |
441 | } |
442 | |