This source file includes following definitions.
- stateAttributeGetterCustom
- pushStateMethodCustom
- replaceStateMethodCustom
#include "config.h"
#include "V8History.h"
#include "V8Window.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8HiddenValue.h"
#include "core/dom/ExceptionCode.h"
#include "core/frame/History.h"
namespace WebCore {
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);
}
void V8History::pushStateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "pushState", "History", info.Holder(), info.GetIsolate());
RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(info[0], 0, 0, exceptionState, info.GetIsolate());
if (exceptionState.throwIfNeeded())
return;
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullCheck>, title, info[1]);
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullCheck>, url, argumentOrNull(info, 2));
History* history = V8History::toNative(info.Holder());
history->stateObjectAdded(historyState.release(), title, url, UpdateBackForwardList, exceptionState);
V8HiddenValue::deleteHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()));
exceptionState.throwIfNeeded();
}
void V8History::replaceStateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "replaceState", "History", info.Holder(), info.GetIsolate());
RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(info[0], 0, 0, exceptionState, info.GetIsolate());
if (exceptionState.throwIfNeeded())
return;
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullCheck>, title, info[1]);
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullCheck>, url, argumentOrNull(info, 2));
History* history = V8History::toNative(info.Holder());
history->stateObjectAdded(historyState.release(), title, url, DoNotUpdateBackForwardList, exceptionState);
V8HiddenValue::deleteHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()));
exceptionState.throwIfNeeded();
}
}