blob: 9fee10326ddef6d3778e5bb8a5440699c9cc0ff8 [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 "JSHistory.h"
#include "Document.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include <runtime/Error.h>
#include <runtime/FunctionPrototype.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionPushState(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionReplaceState(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsHistoryLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsHistoryState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsHistoryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSHistoryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSHistoryPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSHistoryPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSHistoryPrototype* ptr = new (NotNull, JSC::allocateCell<JSHistoryPrototype>(vm.heap)) JSHistoryPrototype(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:
JSHistoryPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSHistory> JSHistoryConstructor;
template<> JSValue JSHistoryConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
UNUSED_PARAM(vm);
return globalObject.functionPrototype();
}
template<> void JSHistoryConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSHistory::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("History"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSHistoryConstructor::s_info = { "History", &Base::s_info, 0, CREATE_METHOD_TABLE(JSHistoryConstructor) };
/* Hash table for prototype */
static const HashTableValue JSHistoryPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHistoryConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHistoryConstructor) } },
{ "length", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHistoryLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "state", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHistoryState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "back", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsHistoryPrototypeFunctionBack), (intptr_t) (0) } },
{ "forward", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsHistoryPrototypeFunctionForward), (intptr_t) (0) } },
{ "go", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsHistoryPrototypeFunctionGo), (intptr_t) (0) } },
{ "pushState", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsHistoryPrototypeFunctionPushState), (intptr_t) (2) } },
{ "replaceState", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsHistoryPrototypeFunctionReplaceState), (intptr_t) (2) } },
};
const ClassInfo JSHistoryPrototype::s_info = { "HistoryPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSHistoryPrototype) };
void JSHistoryPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSHistoryPrototypeTableValues, *this);
}
const ClassInfo JSHistory::s_info = { "History", &Base::s_info, 0, CREATE_METHOD_TABLE(JSHistory) };
JSHistory::JSHistory(Structure* structure, JSDOMGlobalObject& globalObject, Ref<History>&& impl)
: JSDOMWrapper<History>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSHistory::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSHistoryPrototype::create(vm, globalObject, JSHistoryPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSHistory::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSHistory>(vm, globalObject);
}
void JSHistory::destroy(JSC::JSCell* cell)
{
JSHistory* thisObject = static_cast<JSHistory*>(cell);
thisObject->JSHistory::~JSHistory();
}
EncodedJSValue jsHistoryLength(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<JSHistory*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "History", "length");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.length());
return JSValue::encode(result);
}
EncodedJSValue jsHistoryState(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<JSHistory*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "History", "state");
}
return JSValue::encode(castedThis->state(*state));
}
EncodedJSValue jsHistoryConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSHistoryPrototype* domObject = jsDynamicCast<JSHistoryPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSHistory::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSHistoryConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSHistoryPrototype* domObject = jsDynamicCast<JSHistoryPrototype*>(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 JSHistory::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSHistoryConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionBack(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSHistory*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "History", "back");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSHistory::info());
auto& impl = castedThis->wrapped();
auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
if (!context)
return JSValue::encode(jsUndefined());
ASSERT(context->isDocument());
auto& document = downcast<Document>(*context);
impl.back(document);
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionForward(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSHistory*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "History", "forward");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSHistory::info());
auto& impl = castedThis->wrapped();
auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
if (!context)
return JSValue::encode(jsUndefined());
ASSERT(context->isDocument());
auto& document = downcast<Document>(*context);
impl.forward(document);
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionGo(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSHistory*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "History", "go");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSHistory::info());
auto& impl = castedThis->wrapped();
auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
if (!context)
return JSValue::encode(jsUndefined());
ASSERT(context->isDocument());
auto& document = downcast<Document>(*context);
auto distance = convert<int32_t>(*state, state->argument(0), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.go(document, WTFMove(distance));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionPushState(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSHistory*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "History", "pushState");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSHistory::info());
return JSValue::encode(castedThis->pushState(*state));
}
EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionReplaceState(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSHistory*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "History", "replaceState");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSHistory::info());
return JSValue::encode(castedThis->replaceState(*state));
}
void JSHistory::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSHistory*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
visitor.append(&thisObject->m_state);
}
bool JSHistoryOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
auto* jsHistory = jsCast<JSHistory*>(handle.slot()->asCell());
Frame* root = WTF::getPtr(jsHistory->wrapped().frame());
if (!root)
return false;
return visitor.containsOpaqueRoot(root);
}
void JSHistoryOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsHistory = jsCast<JSHistory*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsHistory->wrapped(), jsHistory);
}
#if ENABLE(BINDING_INTEGRITY)
#if PLATFORM(WIN)
#pragma warning(disable: 4483)
extern "C" { extern void (*const __identifier("??_7History@WebCore@@6B@")[])(); }
#else
extern "C" { extern void* _ZTVN7WebCore7HistoryE[]; }
#endif
#endif
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<History>&& impl)
{
#if ENABLE(BINDING_INTEGRITY)
void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
#if PLATFORM(WIN)
void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7History@WebCore@@6B@"));
#else
void* expectedVTablePointer = &_ZTVN7WebCore7HistoryE[2];
#if COMPILER(CLANG)
// If this fails History does not have a vtable, so you need to add the
// ImplementationLacksVTable attribute to the interface definition
static_assert(__is_polymorphic(History), "History is not polymorphic");
#endif
#endif
// If you hit this assertion you either have a use after free bug, or
// History has subclasses. If History has subclasses that get passed
// to toJS() we currently require History you to opt out of binding hardening
// by adding the SkipVTableValidation attribute to the interface IDL definition
RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
#endif
return createWrapper<History>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, History& impl)
{
return wrap(state, globalObject, impl);
}
History* JSHistory::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSHistory*>(value))
return &wrapper->wrapped();
return nullptr;
}
}