示例#1
0
JSValue JSHistory::state(ExecState *exec) const
{
    History* history = static_cast<History*>(impl());

    JSValue cachedValue = m_state.get();
    if (!cachedValue.isEmpty() && !history->stateChanged())
        return cachedValue;

    RefPtr<SerializedScriptValue> serialized = history->state();
    JSValue result = serialized ? serialized->deserialize(exec, globalObject(), 0) : jsNull();
    const_cast<JSHistory*>(this)->m_state.set(exec->vm(), this, result);
    return result;
}
示例#2
0
v8::Handle<v8::Value> V8History::stateAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    History* history = V8History::toNative(info.Holder());

    v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(V8HiddenPropertyName::state());

    if (!value.IsEmpty() && !history->stateChanged())
        return value;

    RefPtr<SerializedScriptValue> serialized = history->state();
    value = serialized ? serialized->deserialize(info.GetIsolate()) : v8::Handle<v8::Value>(v8Null(info.GetIsolate()));
    info.Holder()->SetHiddenValue(V8HiddenPropertyName::state(), value);

    return value;
}
示例#3
0
v8::Handle<v8::Value> V8History::stateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.History.state");
    History* history = V8History::toNative(info.Holder());

    v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(V8HiddenPropertyName::state());

    if (!value.IsEmpty() && !history->stateChanged())
        return value;

    SerializedScriptValue* serialized = history->state();
    value = serialized ? serialized->deserialize(0, info.GetIsolate()) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate()));
    info.Holder()->SetHiddenValue(V8HiddenPropertyName::state(), value);

    return value;
}
void V8History::stateAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
    History* history = V8History::toNative(info.Holder());

    v8::Handle<v8::Value> value = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()));

    if (!value.IsEmpty() && !history->stateChanged()) {
        v8SetReturnValue(info, value);
        return;
    }

    RefPtr<SerializedScriptValue> serialized = history->state();
    value = serialized ? serialized->deserialize(info.GetIsolate()) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate()));
    V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()), value);

    v8SetReturnValue(info, value);
}