本文整理汇总了C++中History::stateChanged方法的典型用法代码示例。如果您正苦于以下问题:C++ History::stateChanged方法的具体用法?C++ History::stateChanged怎么用?C++ History::stateChanged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类History
的用法示例。
在下文中一共展示了History::stateChanged方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cacheState
void V8PopStateEvent::stateAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()));
if (!result.IsEmpty()) {
v8SetReturnValue(info, result);
return;
}
PopStateEvent* event = V8PopStateEvent::toImpl(info.Holder());
History* history = event->history();
if (!history || !event->serializedState()) {
if (!event->serializedState()) {
// If we're in an isolated world and the event was created in the main world,
// we need to find the 'state' property on the main world wrapper and clone it.
v8::Local<v8::Value> mainWorldState = V8HiddenValue::getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenValue::state(info.GetIsolate()));
if (!mainWorldState.IsEmpty())
event->setSerializedState(SerializedScriptValueFactory::instance().createAndSwallowExceptions(info.GetIsolate(), mainWorldState));
}
if (event->serializedState())
result = event->serializedState()->deserialize();
else
result = v8::Null(info.GetIsolate());
v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
return;
}
// There's no cached value from a previous invocation, nor a state value was provided by the
// event, but there is a history object, so first we need to see if the state object has been
// deserialized through the history object already.
// The current history state object might've changed in the meantime, so we need to take care
// of using the correct one, and always share the same deserialization with history.state.
bool isSameState = history->isSameAsCurrentState(event->serializedState());
if (isSameState) {
v8::Local<v8::Value> v8HistoryValue = toV8(history, info.Holder(), info.GetIsolate());
if (v8HistoryValue.IsEmpty())
return;
v8::Local<v8::Object> v8History = v8HistoryValue.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()));
}
示例2: cacheState
void V8PopStateEvent::stateAttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()));
if (!result.IsEmpty()) {
v8SetReturnValue(info, result);
return;
}
PopStateEvent* event = V8PopStateEvent::toImpl(info.Holder());
History* history = event->history();
if (!history || !event->serializedState()) {
// If the event doesn't have serializedState(), it means that the
// event was initialized with PopStateEventInit. In such case, we need
// to get a v8 value for the current world from state().
if (event->serializedState())
result = event->serializedState()->deserialize();
else
result = event->state().v8ValueFor(ScriptState::current(info.GetIsolate()));
if (result.IsEmpty())
result = v8::Null(info.GetIsolate());
v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
return;
}
// There's no cached value from a previous invocation, nor a state value was provided by the
// event, but there is a history object, so first we need to see if the state object has been
// deserialized through the history object already.
// The current history state object might've changed in the meantime, so we need to take care
// of using the correct one, and always share the same deserialization with history.state.
bool isSameState = history->isSameAsCurrentState(event->serializedState());
if (isSameState) {
v8::Local<v8::Value> v8HistoryValue = toV8(history, info.Holder(), info.GetIsolate());
if (v8HistoryValue.IsEmpty())
return;
v8::Local<v8::Object> v8History = v8HistoryValue.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()));
}
示例3:
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;
}
示例4:
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;
}
示例5:
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);
}