blob: e89c6e566a9ee5da7486e310d9944e8d850e9a89 [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 "JSMouseEvent.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "JSDOMWindow.h"
#include "JSDataTransfer.h"
#include "JSDictionary.h"
#include "JSEventTarget.h"
#include "JSNode.h"
#include <runtime/Error.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsMouseEventPrototypeFunctionInitMouseEvent(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsMouseEventScreenX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventScreenY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventClientX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventClientY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventCtrlKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventShiftKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventAltKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventMetaKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventButton(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventRelatedTarget(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
#if ENABLE(POINTER_LOCK)
JSC::EncodedJSValue jsMouseEventMovementX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
#endif
#if ENABLE(POINTER_LOCK)
JSC::EncodedJSValue jsMouseEventMovementY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
#endif
#if ENABLE(MOUSE_FORCE_EVENTS)
JSC::EncodedJSValue jsMouseEventWebkitForce(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
#endif
JSC::EncodedJSValue jsMouseEventOffsetX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventOffsetY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventFromElement(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventToElement(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventDataTransfer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMouseEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSMouseEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSMouseEventPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSMouseEventPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSMouseEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSMouseEventPrototype>(vm.heap)) JSMouseEventPrototype(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:
JSMouseEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructor<JSMouseEvent> JSMouseEventConstructor;
/* Hash table for constructor */
static const HashTableValue JSMouseEventConstructorTableValues[] =
{
#if ENABLE(MOUSE_FORCE_EVENTS)
{ "WEBKIT_FORCE_AT_MOUSE_DOWN", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
#if ENABLE(MOUSE_FORCE_EVENTS)
{ "WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
};
template<> EncodedJSValue JSC_HOST_CALL JSMouseEventConstructor::construct(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto* jsConstructor = jsCast<JSMouseEventConstructor*>(state->callee());
ASSERT(jsConstructor);
if (!jsConstructor->scriptExecutionContext())
return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "MouseEvent");
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());
MouseEventInit 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 (!fillMouseEventInit(eventInit, dictionary))
return JSValue::encode(jsUndefined());
}
Ref<MouseEvent> event = MouseEvent::createForBindings(eventType, eventInit);
return JSValue::encode(createWrapper<MouseEvent>(jsConstructor->globalObject(), WTFMove(event)));
}
bool fillMouseEventInit(MouseEventInit& eventInit, JSDictionary& dictionary)
{
if (!fillUIEventInit(eventInit, dictionary))
return false;
if (!dictionary.tryGetProperty("screenX", eventInit.screenX))
return false;
if (!dictionary.tryGetProperty("screenY", eventInit.screenY))
return false;
if (!dictionary.tryGetProperty("clientX", eventInit.clientX))
return false;
if (!dictionary.tryGetProperty("clientY", eventInit.clientY))
return false;
if (!dictionary.tryGetProperty("ctrlKey", eventInit.ctrlKey))
return false;
if (!dictionary.tryGetProperty("shiftKey", eventInit.shiftKey))
return false;
if (!dictionary.tryGetProperty("altKey", eventInit.altKey))
return false;
if (!dictionary.tryGetProperty("metaKey", eventInit.metaKey))
return false;
if (!dictionary.tryGetProperty("button", eventInit.button))
return false;
if (!dictionary.tryGetProperty("relatedTarget", eventInit.relatedTarget))
return false;
return true;
}
template<> JSValue JSMouseEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSUIEvent::getConstructor(vm, &globalObject);
}
template<> void JSMouseEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSMouseEvent::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("MouseEvent"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum);
reifyStaticProperties(vm, JSMouseEventConstructorTableValues, *this);
}
template<> ConstructType JSMouseEventConstructor::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 JSMouseEventConstructor::s_info = { "MouseEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMouseEventConstructor) };
/* Hash table for prototype */
static const HashTableValue JSMouseEventPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMouseEventConstructor) } },
{ "screenX", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventScreenX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "screenY", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventScreenY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "clientX", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventClientX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "clientY", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventClientY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "ctrlKey", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventCtrlKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "shiftKey", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventShiftKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "altKey", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventAltKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "metaKey", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventMetaKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "button", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventButton), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "relatedTarget", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventRelatedTarget), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
#if ENABLE(POINTER_LOCK)
{ "movementX", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventMovementX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
#if ENABLE(POINTER_LOCK)
{ "movementY", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventMovementY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
#if ENABLE(MOUSE_FORCE_EVENTS)
{ "webkitForce", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventWebkitForce), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
{ "offsetX", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventOffsetX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "offsetY", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventOffsetY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "x", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "y", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "fromElement", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventFromElement), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "toElement", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventToElement), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "dataTransfer", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventDataTransfer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "initMouseEvent", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMouseEventPrototypeFunctionInitMouseEvent), (intptr_t) (0) } },
#if ENABLE(MOUSE_FORCE_EVENTS)
{ "WEBKIT_FORCE_AT_MOUSE_DOWN", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
#if ENABLE(MOUSE_FORCE_EVENTS)
{ "WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
};
const ClassInfo JSMouseEventPrototype::s_info = { "MouseEventPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMouseEventPrototype) };
void JSMouseEventPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSMouseEventPrototypeTableValues, *this);
}
const ClassInfo JSMouseEvent::s_info = { "MouseEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMouseEvent) };
JSMouseEvent::JSMouseEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MouseEvent>&& impl)
: JSUIEvent(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSMouseEvent::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSMouseEventPrototype::create(vm, globalObject, JSMouseEventPrototype::createStructure(vm, globalObject, JSUIEvent::prototype(vm, globalObject)));
}
JSObject* JSMouseEvent::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSMouseEvent>(vm, globalObject);
}
EncodedJSValue jsMouseEventScreenX(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "screenX");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.screenX());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventScreenY(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "screenY");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.screenY());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventClientX(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "clientX");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.clientX());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventClientY(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "clientY");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.clientY());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventCtrlKey(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "ctrlKey");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.ctrlKey());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventShiftKey(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "shiftKey");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.shiftKey());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventAltKey(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "altKey");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.altKey());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventMetaKey(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "metaKey");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.metaKey());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventButton(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "button");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.button());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventRelatedTarget(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "relatedTarget");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.relatedTarget());
return JSValue::encode(result);
}
#if ENABLE(POINTER_LOCK)
EncodedJSValue jsMouseEventMovementX(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "movementX");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.movementX());
return JSValue::encode(result);
}
#endif
#if ENABLE(POINTER_LOCK)
EncodedJSValue jsMouseEventMovementY(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "movementY");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.movementY());
return JSValue::encode(result);
}
#endif
#if ENABLE(MOUSE_FORCE_EVENTS)
EncodedJSValue jsMouseEventWebkitForce(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "webkitForce");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.force());
return JSValue::encode(result);
}
#endif
EncodedJSValue jsMouseEventOffsetX(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "offsetX");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.offsetX());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventOffsetY(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "offsetY");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.offsetY());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventX(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "x");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.x());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventY(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "y");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.y());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventFromElement(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "fromElement");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.fromElement());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventToElement(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "toElement");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.toElement());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventDataTransfer(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<JSMouseEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MouseEvent", "dataTransfer");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.dataTransfer());
return JSValue::encode(result);
}
EncodedJSValue jsMouseEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMouseEventPrototype* domObject = jsDynamicCast<JSMouseEventPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSMouseEvent::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSMouseEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSMouseEventPrototype* domObject = jsDynamicCast<JSMouseEventPrototype*>(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 JSMouseEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSMouseEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsMouseEventPrototypeFunctionInitMouseEvent(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSMouseEvent*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "MouseEvent", "initMouseEvent");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSMouseEvent::info());
auto& impl = castedThis->wrapped();
auto type = state->argument(0).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto canBubble = state->argument(1).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto cancelable = state->argument(2).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
DOMWindow* view = nullptr;
if (!state->argument(3).isUndefinedOrNull()) {
view = JSDOMWindow::toWrapped(*state, state->uncheckedArgument(3));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
if (UNLIKELY(!view))
return throwArgumentTypeError(*state, throwScope, 3, "view", "MouseEvent", "initMouseEvent", "DOMWindow");
}
auto detail = convert<int32_t>(*state, state->argument(4), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto screenX = convert<int32_t>(*state, state->argument(5), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto screenY = convert<int32_t>(*state, state->argument(6), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto clientX = convert<int32_t>(*state, state->argument(7), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto clientY = convert<int32_t>(*state, state->argument(8), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto ctrlKey = state->argument(9).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto altKey = state->argument(10).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto shiftKey = state->argument(11).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto metaKey = state->argument(12).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto button = convert<uint16_t>(*state, state->argument(13), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
EventTarget* relatedTarget = nullptr;
if (!state->argument(14).isUndefinedOrNull()) {
relatedTarget = JSEventTarget::toWrapped(*state, state->uncheckedArgument(14));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
if (UNLIKELY(!relatedTarget))
return throwArgumentTypeError(*state, throwScope, 14, "relatedTarget", "MouseEvent", "initMouseEvent", "EventTarget");
}
impl.initMouseEvent(WTFMove(type), WTFMove(canBubble), WTFMove(cancelable), WTFMove(view), WTFMove(detail), WTFMove(screenX), WTFMove(screenY), WTFMove(clientX), WTFMove(clientY), WTFMove(ctrlKey), WTFMove(altKey), WTFMove(shiftKey), WTFMove(metaKey), WTFMove(button), WTFMove(relatedTarget));
return JSValue::encode(jsUndefined());
}
}