blob: 3358770ead0151a298c34c69a832bf21582a87e6 [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 "JSCompositionEvent.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMWindow.h"
#include "JSDictionary.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsCompositionEventPrototypeFunctionInitCompositionEvent(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsCompositionEventData(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsCompositionEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSCompositionEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSCompositionEventPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSCompositionEventPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSCompositionEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSCompositionEventPrototype>(vm.heap)) JSCompositionEventPrototype(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:
JSCompositionEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructor<JSCompositionEvent> JSCompositionEventConstructor;
template<> EncodedJSValue JSC_HOST_CALL JSCompositionEventConstructor::construct(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto* jsConstructor = jsCast<JSCompositionEventConstructor*>(state->callee());
ASSERT(jsConstructor);
if (!jsConstructor->scriptExecutionContext())
return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "CompositionEvent");
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());
CompositionEventInit 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 (!fillCompositionEventInit(eventInit, dictionary))
return JSValue::encode(jsUndefined());
}
Ref<CompositionEvent> event = CompositionEvent::createForBindings(eventType, eventInit);
return JSValue::encode(createWrapper<CompositionEvent>(jsConstructor->globalObject(), WTFMove(event)));
}
bool fillCompositionEventInit(CompositionEventInit& eventInit, JSDictionary& dictionary)
{
if (!fillUIEventInit(eventInit, dictionary))
return false;
if (!dictionary.tryGetProperty("data", eventInit.data))
return false;
return true;
}
template<> JSValue JSCompositionEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSUIEvent::getConstructor(vm, &globalObject);
}
template<> void JSCompositionEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSCompositionEvent::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("CompositionEvent"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum);
}
template<> ConstructType JSCompositionEventConstructor::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 JSCompositionEventConstructor::s_info = { "CompositionEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCompositionEventConstructor) };
/* Hash table for prototype */
static const HashTableValue JSCompositionEventPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCompositionEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCompositionEventConstructor) } },
{ "data", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCompositionEventData), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "initCompositionEvent", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsCompositionEventPrototypeFunctionInitCompositionEvent), (intptr_t) (0) } },
};
const ClassInfo JSCompositionEventPrototype::s_info = { "CompositionEventPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCompositionEventPrototype) };
void JSCompositionEventPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSCompositionEventPrototypeTableValues, *this);
}
const ClassInfo JSCompositionEvent::s_info = { "CompositionEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCompositionEvent) };
JSCompositionEvent::JSCompositionEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CompositionEvent>&& impl)
: JSUIEvent(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSCompositionEvent::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSCompositionEventPrototype::create(vm, globalObject, JSCompositionEventPrototype::createStructure(vm, globalObject, JSUIEvent::prototype(vm, globalObject)));
}
JSObject* JSCompositionEvent::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSCompositionEvent>(vm, globalObject);
}
EncodedJSValue jsCompositionEventData(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<JSCompositionEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "CompositionEvent", "data");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.data());
return JSValue::encode(result);
}
EncodedJSValue jsCompositionEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSCompositionEventPrototype* domObject = jsDynamicCast<JSCompositionEventPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSCompositionEvent::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSCompositionEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSCompositionEventPrototype* domObject = jsDynamicCast<JSCompositionEventPrototype*>(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 JSCompositionEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSCompositionEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsCompositionEventPrototypeFunctionInitCompositionEvent(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSCompositionEvent*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "CompositionEvent", "initCompositionEvent");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSCompositionEvent::info());
auto& impl = castedThis->wrapped();
auto typeArg = state->argument(0).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto canBubbleArg = state->argument(1).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto cancelableArg = state->argument(2).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
DOMWindow* viewArg = nullptr;
if (!state->argument(3).isUndefinedOrNull()) {
viewArg = JSDOMWindow::toWrapped(*state, state->uncheckedArgument(3));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
if (UNLIKELY(!viewArg))
return throwArgumentTypeError(*state, throwScope, 3, "viewArg", "CompositionEvent", "initCompositionEvent", "DOMWindow");
}
auto dataArg = state->argument(4).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.initCompositionEvent(WTFMove(typeArg), WTFMove(canBubbleArg), WTFMove(cancelableArg), WTFMove(viewArg), WTFMove(dataArg));
return JSValue::encode(jsUndefined());
}
}