blob: 07dd45e6a7a3b1108a7384abeeb155fabe978ab1 [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 "JSHTMLCanvasElement.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include <runtime/Error.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionToDataURL(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionGetContext(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsHTMLCanvasElementWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSHTMLCanvasElementWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsHTMLCanvasElementHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSHTMLCanvasElementHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsHTMLCanvasElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSHTMLCanvasElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSHTMLCanvasElementPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSHTMLCanvasElementPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSHTMLCanvasElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLCanvasElementPrototype>(vm.heap)) JSHTMLCanvasElementPrototype(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:
JSHTMLCanvasElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSHTMLCanvasElement> JSHTMLCanvasElementConstructor;
template<> JSValue JSHTMLCanvasElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSHTMLElement::getConstructor(vm, &globalObject);
}
template<> void JSHTMLCanvasElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSHTMLCanvasElement::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("HTMLCanvasElement"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSHTMLCanvasElementConstructor::s_info = { "HTMLCanvasElement", &Base::s_info, 0, CREATE_METHOD_TABLE(JSHTMLCanvasElementConstructor) };
/* Hash table for prototype */
static const HashTableValue JSHTMLCanvasElementPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLCanvasElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLCanvasElementConstructor) } },
{ "width", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLCanvasElementWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLCanvasElementWidth) } },
{ "height", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLCanvasElementHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLCanvasElementHeight) } },
{ "toDataURL", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsHTMLCanvasElementPrototypeFunctionToDataURL), (intptr_t) (0) } },
{ "getContext", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsHTMLCanvasElementPrototypeFunctionGetContext), (intptr_t) (1) } },
};
const ClassInfo JSHTMLCanvasElementPrototype::s_info = { "HTMLCanvasElementPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSHTMLCanvasElementPrototype) };
void JSHTMLCanvasElementPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSHTMLCanvasElementPrototypeTableValues, *this);
}
const ClassInfo JSHTMLCanvasElement::s_info = { "HTMLCanvasElement", &Base::s_info, 0, CREATE_METHOD_TABLE(JSHTMLCanvasElement) };
JSHTMLCanvasElement::JSHTMLCanvasElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLCanvasElement>&& impl)
: JSHTMLElement(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSHTMLCanvasElement::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSHTMLCanvasElementPrototype::create(vm, globalObject, JSHTMLCanvasElementPrototype::createStructure(vm, globalObject, JSHTMLElement::prototype(vm, globalObject)));
}
JSObject* JSHTMLCanvasElement::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSHTMLCanvasElement>(vm, globalObject);
}
EncodedJSValue jsHTMLCanvasElementWidth(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<JSHTMLCanvasElement*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "HTMLCanvasElement", "width");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.width());
return JSValue::encode(result);
}
EncodedJSValue jsHTMLCanvasElementHeight(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<JSHTMLCanvasElement*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "HTMLCanvasElement", "height");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.height());
return JSValue::encode(result);
}
EncodedJSValue jsHTMLCanvasElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSHTMLCanvasElementPrototype* domObject = jsDynamicCast<JSHTMLCanvasElementPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSHTMLCanvasElement::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSHTMLCanvasElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSHTMLCanvasElementPrototype* domObject = jsDynamicCast<JSHTMLCanvasElementPrototype*>(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 setJSHTMLCanvasElementWidth(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);
JSHTMLCanvasElement* castedThis = jsDynamicCast<JSHTMLCanvasElement*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "HTMLCanvasElement", "width");
}
auto& impl = castedThis->wrapped();
auto nativeValue = convert<uint32_t>(*state, value, NormalConversion);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setWidth(WTFMove(nativeValue));
return true;
}
bool setJSHTMLCanvasElementHeight(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);
JSHTMLCanvasElement* castedThis = jsDynamicCast<JSHTMLCanvasElement*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "HTMLCanvasElement", "height");
}
auto& impl = castedThis->wrapped();
auto nativeValue = convert<uint32_t>(*state, value, NormalConversion);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setHeight(WTFMove(nativeValue));
return true;
}
JSValue JSHTMLCanvasElement::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSHTMLCanvasElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionToDataURL(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSHTMLCanvasElement*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "HTMLCanvasElement", "toDataURL");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSHTMLCanvasElement::info());
return JSValue::encode(castedThis->toDataURL(*state));
}
EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionGetContext(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSHTMLCanvasElement*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "HTMLCanvasElement", "getContext");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSHTMLCanvasElement::info());
return JSValue::encode(castedThis->getContext(*state));
}
void JSHTMLCanvasElement::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSHTMLCanvasElement*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
thisObject->wrapped().visitJSEventListeners(visitor);
visitor.reportExtraMemoryVisited(thisObject->wrapped().memoryCost());
#if ENABLE(RESOURCE_USAGE)
visitor.reportExternalMemoryVisited(thisObject->wrapped().externalMemoryCost());
#endif
}
size_t JSHTMLCanvasElement::estimatedSize(JSCell* cell)
{
auto* thisObject = jsCast<JSHTMLCanvasElement*>(cell);
return Base::estimatedSize(thisObject) + thisObject->wrapped().memoryCost();
}
HTMLCanvasElement* JSHTMLCanvasElement::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSHTMLCanvasElement*>(value))
return &wrapper->wrapped();
return nullptr;
}
}