This source file includes following definitions.
- cacheState
- stateAttributeGetterCustom
#include "config.h"
#include "V8PopStateEvent.h"
#include "V8History.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8HiddenValue.h"
#include "core/events/PopStateEvent.h"
#include "core/frame/History.h"
namespace WebCore {
static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> popStateEvent, v8::Handle<v8::Value> state, v8::Isolate* isolate)
{
V8HiddenValue::setHiddenValue(isolate, popStateEvent, V8HiddenValue::state(isolate), state);
return state;
}
void V8PopStateEvent::stateAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
v8::Handle<v8::Value> result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()));
if (!result.IsEmpty()) {
v8SetReturnValue(info, result);
return;
}
PopStateEvent* event = V8PopStateEvent::toNative(info.Holder());
History* history = event->history();
if (!history || !event->serializedState()) {
if (!event->serializedState()) {
v8::Local<v8::Value> mainWorldState = V8HiddenValue::getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenValue::state(info.GetIsolate()));
if (!mainWorldState.IsEmpty())
event->setSerializedState(SerializedScriptValue::createAndSwallowExceptions(mainWorldState, info.GetIsolate()));
}
if (event->serializedState())
result = event->serializedState()->deserialize();
else
result = v8::Null(info.GetIsolate());
v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
return;
}
bool isSameState = history->isSameAsCurrentState(event->serializedState());
if (isSameState) {
v8::Handle<v8::Object> v8History = toV8(history, info.Holder(), info.GetIsolate()).As<v8::Object>();
if (!history->stateChanged()) {
result = V8HiddenValue::getHiddenValue(info.GetIsolate(), v8History, V8HiddenValue::state(info.GetIsolate()));
if (!result.IsEmpty()) {
v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
return;
}
}
result = event->serializedState()->deserialize(info.GetIsolate());
V8HiddenValue::setHiddenValue(info.GetIsolate(), v8History, V8HiddenValue::state(info.GetIsolate()), result);
} else {
result = event->serializedState()->deserialize(info.GetIsolate());
}
v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
}
}