blob: 8c05c6ab0069df8bea98b02cc35b3b0add396bb7 [file] [log] [blame]
/*
This file is part of the WebKit open source project.
This file has been generated by generate-bindings.pl. DO NOT MODIFY!
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "JSDataTransfer.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "JSElement.h"
#include "JSFileList.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/FunctionPrototype.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
#if ENABLE(DATA_TRANSFER_ITEMS)
#include "JSDataTransferItemList.h"
#endif
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionClearData(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionGetData(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionSetData(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionSetDragImage(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsDataTransferDropEffect(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSDataTransferDropEffect(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsDataTransferEffectAllowed(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSDataTransferEffectAllowed(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsDataTransferTypes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsDataTransferFiles(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
#if ENABLE(DATA_TRANSFER_ITEMS)
JSC::EncodedJSValue jsDataTransferItems(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
#endif
JSC::EncodedJSValue jsDataTransferConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSDataTransferConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSDataTransferPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSDataTransferPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSDataTransferPrototype* ptr = new (NotNull, JSC::allocateCell<JSDataTransferPrototype>(vm.heap)) JSDataTransferPrototype(vm, globalObject, structure);
ptr->finishCreation(vm);
return ptr;
}
DECLARE_INFO;
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
}
private:
JSDataTransferPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSDataTransfer> JSDataTransferConstructor;
template<> JSValue JSDataTransferConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
UNUSED_PARAM(vm);
return globalObject.functionPrototype();
}
template<> void JSDataTransferConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSDataTransfer::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("DataTransfer"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSDataTransferConstructor::s_info = { "DataTransfer", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDataTransferConstructor) };
/* Hash table for prototype */
static const HashTableValue JSDataTransferPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDataTransferConstructor) } },
{ "dropEffect", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferDropEffect), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDataTransferDropEffect) } },
{ "effectAllowed", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferEffectAllowed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDataTransferEffectAllowed) } },
{ "types", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferTypes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "files", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferFiles), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
#if ENABLE(DATA_TRANSFER_ITEMS)
{ "items", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataTransferItems), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
{ "clearData", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDataTransferPrototypeFunctionClearData), (intptr_t) (0) } },
{ "getData", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDataTransferPrototypeFunctionGetData), (intptr_t) (1) } },
{ "setData", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDataTransferPrototypeFunctionSetData), (intptr_t) (2) } },
{ "setDragImage", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDataTransferPrototypeFunctionSetDragImage), (intptr_t) (3) } },
};
const ClassInfo JSDataTransferPrototype::s_info = { "DataTransferPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDataTransferPrototype) };
void JSDataTransferPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSDataTransferPrototypeTableValues, *this);
}
const ClassInfo JSDataTransfer::s_info = { "DataTransfer", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDataTransfer) };
JSDataTransfer::JSDataTransfer(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DataTransfer>&& impl)
: JSDOMWrapper<DataTransfer>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSDataTransfer::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSDataTransferPrototype::create(vm, globalObject, JSDataTransferPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSDataTransfer::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSDataTransfer>(vm, globalObject);
}
void JSDataTransfer::destroy(JSC::JSCell* cell)
{
JSDataTransfer* thisObject = static_cast<JSDataTransfer*>(cell);
thisObject->JSDataTransfer::~JSDataTransfer();
}
EncodedJSValue jsDataTransferDropEffect(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSDataTransfer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "DataTransfer", "dropEffect");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.dropEffect());
return JSValue::encode(result);
}
EncodedJSValue jsDataTransferEffectAllowed(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSDataTransfer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "DataTransfer", "effectAllowed");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.effectAllowed());
return JSValue::encode(result);
}
EncodedJSValue jsDataTransferTypes(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSDataTransfer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "DataTransfer", "types");
}
return JSValue::encode(castedThis->types(*state));
}
EncodedJSValue jsDataTransferFiles(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSDataTransfer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "DataTransfer", "files");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.files());
return JSValue::encode(result);
}
#if ENABLE(DATA_TRANSFER_ITEMS)
EncodedJSValue jsDataTransferItems(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSDataTransfer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "DataTransfer", "items");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.items());
return JSValue::encode(result);
}
#endif
EncodedJSValue jsDataTransferConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSDataTransferPrototype* domObject = jsDynamicCast<JSDataTransferPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSDataTransfer::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSDataTransferConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSDataTransferPrototype* domObject = jsDynamicCast<JSDataTransferPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject)) {
throwVMTypeError(state, throwScope);
return false;
}
// Shadowing a built-in constructor
return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
}
bool setJSDataTransferDropEffect(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSDataTransfer* castedThis = jsDynamicCast<JSDataTransfer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "DataTransfer", "dropEffect");
}
auto& impl = castedThis->wrapped();
auto nativeValue = value.toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setDropEffect(WTFMove(nativeValue));
return true;
}
bool setJSDataTransferEffectAllowed(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSDataTransfer* castedThis = jsDynamicCast<JSDataTransfer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "DataTransfer", "effectAllowed");
}
auto& impl = castedThis->wrapped();
auto nativeValue = value.toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setEffectAllowed(WTFMove(nativeValue));
return true;
}
JSValue JSDataTransfer::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSDataTransferConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionClearData(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDataTransfer*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DataTransfer", "clearData");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDataTransfer::info());
auto& impl = castedThis->wrapped();
auto type = state->argument(0).isUndefined() ? String() : state->uncheckedArgument(0).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.clearData(WTFMove(type));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionGetData(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDataTransfer*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DataTransfer", "getData");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDataTransfer::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto type = state->uncheckedArgument(0).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = jsStringWithCache(state, impl.getData(WTFMove(type)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionSetData(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDataTransfer*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DataTransfer", "setData");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDataTransfer::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 2))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto type = state->uncheckedArgument(0).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto data = state->uncheckedArgument(1).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.setData(WTFMove(type), WTFMove(data));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsDataTransferPrototypeFunctionSetDragImage(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDataTransfer*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DataTransfer", "setDragImage");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDataTransfer::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 3))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
Element* image = nullptr;
if (!state->uncheckedArgument(0).isUndefinedOrNull()) {
image = JSElement::toWrapped(state->uncheckedArgument(0));
if (UNLIKELY(!image))
return throwArgumentTypeError(*state, throwScope, 0, "image", "DataTransfer", "setDragImage", "Element");
}
auto x = convert<int32_t>(*state, state->uncheckedArgument(1), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto y = convert<int32_t>(*state, state->uncheckedArgument(2), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.setDragImage(WTFMove(image), WTFMove(x), WTFMove(y));
return JSValue::encode(jsUndefined());
}
bool JSDataTransferOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
UNUSED_PARAM(handle);
UNUSED_PARAM(visitor);
return false;
}
void JSDataTransferOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsDataTransfer = jsCast<JSDataTransfer*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsDataTransfer->wrapped(), jsDataTransfer);
}
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DataTransfer>&& impl)
{
return createWrapper<DataTransfer>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DataTransfer& impl)
{
return wrap(state, globalObject, impl);
}
DataTransfer* JSDataTransfer::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSDataTransfer*>(value))
return &wrapper->wrapped();
return nullptr;
}
}