JSHistoryCustom.cpp [plain text]
#include "config.h"
#include "JSHistoryCustom.h"
#include "Frame.h"
#include "History.h"
#include <runtime/PrototypeFunction.h>
using namespace JSC;
namespace WebCore {
static JSValue nonCachingStaticBackFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&)
{
return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsHistoryPrototypeFunctionBack);
}
static JSValue nonCachingStaticForwardFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&)
{
return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsHistoryPrototypeFunctionForward);
}
static JSValue nonCachingStaticGoFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&)
{
return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsHistoryPrototypeFunctionGo);
}
bool JSHistory::getOwnPropertySlotDelegate(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
String message;
if (allowsAccessFromFrame(exec, impl()->frame(), message))
return false;
const HashEntry* entry = JSHistoryPrototype::s_info.propHashTable(exec)->entry(exec, propertyName);
if (entry) {
if (entry->attributes() & Function) {
if (entry->function() == jsHistoryPrototypeFunctionBack) {
slot.setCustom(this, nonCachingStaticBackFunctionGetter);
return true;
} else if (entry->function() == jsHistoryPrototypeFunctionForward) {
slot.setCustom(this, nonCachingStaticForwardFunctionGetter);
return true;
} else if (entry->function() == jsHistoryPrototypeFunctionGo) {
slot.setCustom(this, nonCachingStaticGoFunctionGetter);
return true;
}
}
} else {
if (propertyName == exec->propertyNames().toString) {
slot.setCustom(this, objectToStringFunctionGetter);
return true;
}
}
printErrorMessageForFrame(impl()->frame(), message);
slot.setUndefined();
return true;
}
bool JSHistory::putDelegate(ExecState* exec, const Identifier&, JSValue, PutPropertySlot&)
{
if (!allowsAccessFromFrame(exec, impl()->frame()))
return true;
return false;
}
bool JSHistory::deleteProperty(ExecState* exec, const Identifier& propertyName)
{
if (!allowsAccessFromFrame(exec, impl()->frame()))
return false;
return Base::deleteProperty(exec, propertyName);
}
void JSHistory::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
{
if (!allowsAccessFromFrame(exec, impl()->frame()))
return;
Base::getPropertyNames(exec, propertyNames);
}
}