blob: 665d5b46aa8eb24f76aa6acd0c5f487bc9847e58 [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 "JSWheelEvent.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "JSDOMWindow.h"
#include "JSDictionary.h"
#include <runtime/Error.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsWheelEventPrototypeFunctionInitWebKitWheelEvent(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsWheelEventDeltaX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsWheelEventDeltaY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsWheelEventDeltaZ(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsWheelEventDeltaMode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsWheelEventWheelDeltaX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsWheelEventWheelDeltaY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsWheelEventWheelDelta(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsWheelEventWebkitDirectionInvertedFromDevice(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsWheelEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSWheelEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSWheelEventPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSWheelEventPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSWheelEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSWheelEventPrototype>(vm.heap)) JSWheelEventPrototype(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:
JSWheelEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructor<JSWheelEvent> JSWheelEventConstructor;
/* Hash table for constructor */
static const HashTableValue JSWheelEventConstructorTableValues[] =
{
{ "DOM_DELTA_PIXEL", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x00) } },
{ "DOM_DELTA_LINE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x01) } },
{ "DOM_DELTA_PAGE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x02) } },
};
static_assert(WheelEvent::DOM_DELTA_PIXEL == 0x00, "DOM_DELTA_PIXEL in WheelEvent does not match value from IDL");
static_assert(WheelEvent::DOM_DELTA_LINE == 0x01, "DOM_DELTA_LINE in WheelEvent does not match value from IDL");
static_assert(WheelEvent::DOM_DELTA_PAGE == 0x02, "DOM_DELTA_PAGE in WheelEvent does not match value from IDL");
template<> EncodedJSValue JSC_HOST_CALL JSWheelEventConstructor::construct(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto* jsConstructor = jsCast<JSWheelEventConstructor*>(state->callee());
ASSERT(jsConstructor);
if (!jsConstructor->scriptExecutionContext())
return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "WheelEvent");
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
AtomicString eventType = state->uncheckedArgument(0).toString(state)->toAtomicString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
WheelEventInit eventInit;
JSValue initializerValue = state->argument(1);
if (!initializerValue.isUndefinedOrNull()) {
// Given the above test, this will always yield an object.
JSObject* initializerObject = initializerValue.toObject(state);
ASSERT(!throwScope.exception());
// Create the dictionary wrapper from the initializer object.
JSDictionary dictionary(state, initializerObject);
// Attempt to fill in the EventInit.
if (!fillWheelEventInit(eventInit, dictionary))
return JSValue::encode(jsUndefined());
}
Ref<WheelEvent> event = WheelEvent::createForBindings(eventType, eventInit);
return JSValue::encode(createWrapper<WheelEvent>(jsConstructor->globalObject(), WTFMove(event)));
}
bool fillWheelEventInit(WheelEventInit& eventInit, JSDictionary& dictionary)
{
if (!fillMouseEventInit(eventInit, dictionary))
return false;
if (!dictionary.tryGetProperty("deltaX", eventInit.deltaX))
return false;
if (!dictionary.tryGetProperty("deltaY", eventInit.deltaY))
return false;
if (!dictionary.tryGetProperty("deltaZ", eventInit.deltaZ))
return false;
if (!dictionary.tryGetProperty("deltaMode", eventInit.deltaMode))
return false;
if (!dictionary.tryGetProperty("wheelDeltaX", eventInit.wheelDeltaX))
return false;
if (!dictionary.tryGetProperty("wheelDeltaY", eventInit.wheelDeltaY))
return false;
return true;
}
template<> JSValue JSWheelEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSMouseEvent::getConstructor(vm, &globalObject);
}
template<> void JSWheelEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSWheelEvent::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("WheelEvent"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum);
reifyStaticProperties(vm, JSWheelEventConstructorTableValues, *this);
}
template<> ConstructType JSWheelEventConstructor::getConstructData(JSCell* cell, ConstructData& constructData)
{
#if ENABLE(DOM4_EVENTS_CONSTRUCTOR)
UNUSED_PARAM(cell);
constructData.native.function = construct;
return ConstructType::Host;
#else
return Base::getConstructData(cell, constructData);
#endif
}
template<> const ClassInfo JSWheelEventConstructor::s_info = { "WheelEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWheelEventConstructor) };
/* Hash table for prototype */
static const HashTableValue JSWheelEventPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWheelEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWheelEventConstructor) } },
{ "deltaX", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWheelEventDeltaX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "deltaY", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWheelEventDeltaY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "deltaZ", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWheelEventDeltaZ), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "deltaMode", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWheelEventDeltaMode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "wheelDeltaX", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWheelEventWheelDeltaX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "wheelDeltaY", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWheelEventWheelDeltaY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "wheelDelta", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWheelEventWheelDelta), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "webkitDirectionInvertedFromDevice", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWheelEventWebkitDirectionInvertedFromDevice), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "initWebKitWheelEvent", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsWheelEventPrototypeFunctionInitWebKitWheelEvent), (intptr_t) (0) } },
{ "DOM_DELTA_PIXEL", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x00) } },
{ "DOM_DELTA_LINE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x01) } },
{ "DOM_DELTA_PAGE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x02) } },
};
const ClassInfo JSWheelEventPrototype::s_info = { "WheelEventPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWheelEventPrototype) };
void JSWheelEventPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSWheelEventPrototypeTableValues, *this);
}
const ClassInfo JSWheelEvent::s_info = { "WheelEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWheelEvent) };
JSWheelEvent::JSWheelEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WheelEvent>&& impl)
: JSMouseEvent(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSWheelEvent::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSWheelEventPrototype::create(vm, globalObject, JSWheelEventPrototype::createStructure(vm, globalObject, JSMouseEvent::prototype(vm, globalObject)));
}
JSObject* JSWheelEvent::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSWheelEvent>(vm, globalObject);
}
EncodedJSValue jsWheelEventDeltaX(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<JSWheelEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "WheelEvent", "deltaX");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.deltaX());
return JSValue::encode(result);
}
EncodedJSValue jsWheelEventDeltaY(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<JSWheelEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "WheelEvent", "deltaY");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.deltaY());
return JSValue::encode(result);
}
EncodedJSValue jsWheelEventDeltaZ(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<JSWheelEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "WheelEvent", "deltaZ");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.deltaZ());
return JSValue::encode(result);
}
EncodedJSValue jsWheelEventDeltaMode(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<JSWheelEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "WheelEvent", "deltaMode");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.deltaMode());
return JSValue::encode(result);
}
EncodedJSValue jsWheelEventWheelDeltaX(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<JSWheelEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "WheelEvent", "wheelDeltaX");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.wheelDeltaX());
return JSValue::encode(result);
}
EncodedJSValue jsWheelEventWheelDeltaY(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<JSWheelEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "WheelEvent", "wheelDeltaY");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.wheelDeltaY());
return JSValue::encode(result);
}
EncodedJSValue jsWheelEventWheelDelta(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<JSWheelEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "WheelEvent", "wheelDelta");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.wheelDelta());
return JSValue::encode(result);
}
EncodedJSValue jsWheelEventWebkitDirectionInvertedFromDevice(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<JSWheelEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "WheelEvent", "webkitDirectionInvertedFromDevice");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.webkitDirectionInvertedFromDevice());
return JSValue::encode(result);
}
EncodedJSValue jsWheelEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSWheelEventPrototype* domObject = jsDynamicCast<JSWheelEventPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSWheelEvent::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSWheelEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSWheelEventPrototype* domObject = jsDynamicCast<JSWheelEventPrototype*>(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);
}
JSValue JSWheelEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSWheelEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsWheelEventPrototypeFunctionInitWebKitWheelEvent(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSWheelEvent*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "WheelEvent", "initWebKitWheelEvent");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSWheelEvent::info());
auto& impl = castedThis->wrapped();
auto wheelDeltaX = convert<int32_t>(*state, state->argument(0), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto wheelDeltaY = convert<int32_t>(*state, state->argument(1), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
DOMWindow* view = nullptr;
if (!state->argument(2).isUndefinedOrNull()) {
view = JSDOMWindow::toWrapped(*state, state->uncheckedArgument(2));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
if (UNLIKELY(!view))
return throwArgumentTypeError(*state, throwScope, 2, "view", "WheelEvent", "initWebKitWheelEvent", "DOMWindow");
}
auto screenX = convert<int32_t>(*state, state->argument(3), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto screenY = convert<int32_t>(*state, state->argument(4), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto clientX = convert<int32_t>(*state, state->argument(5), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto clientY = convert<int32_t>(*state, state->argument(6), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto ctrlKey = state->argument(7).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto altKey = state->argument(8).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto shiftKey = state->argument(9).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto metaKey = state->argument(10).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.initWebKitWheelEvent(WTFMove(wheelDeltaX), WTFMove(wheelDeltaY), WTFMove(view), WTFMove(screenX), WTFMove(screenY), WTFMove(clientX), WTFMove(clientY), WTFMove(ctrlKey), WTFMove(altKey), WTFMove(shiftKey), WTFMove(metaKey));
return JSValue::encode(jsUndefined());
}
}