| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropert
yName::state()); | 51 v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropert
yName::state()); |
| 52 | 52 |
| 53 if (!result.IsEmpty()) { | 53 if (!result.IsEmpty()) { |
| 54 v8SetReturnValue(info, result); | 54 v8SetReturnValue(info, result); |
| 55 return; | 55 return; |
| 56 } | 56 } |
| 57 | 57 |
| 58 PopStateEvent* event = V8PopStateEvent::toNative(info.Holder()); | 58 PopStateEvent* event = V8PopStateEvent::toNative(info.Holder()); |
| 59 History* history = event->history(); | 59 History* history = event->history(); |
| 60 if (!history || !event->serializedState()) { | 60 if (!history || !event->serializedState()) { |
| 61 v8SetReturnValue(info, cacheState(info.Holder(), v8::Null(info.GetIsolat
e()))); | 61 if (!event->serializedState()) { |
| 62 v8::Local<v8::Value> mainWorldState = getHiddenValueFromMainWorldWra
pper(info.GetIsolate(), event, V8HiddenPropertyName::state()); |
| 63 if (!mainWorldState.IsEmpty()) |
| 64 event->setSerializedState(SerializedScriptValue::createSwallowEx
ceptions(mainWorldState, info.GetIsolate())); |
| 65 } |
| 66 if (event->serializedState()) |
| 67 result = event->serializedState()->deserialize(); |
| 68 else |
| 69 result = v8::Null(info.GetIsolate()); |
| 70 v8SetReturnValue(info, cacheState(info.Holder(), result)); |
| 62 return; | 71 return; |
| 63 } | 72 } |
| 64 | 73 |
| 65 // There's no cached value from a previous invocation, nor a state value was
provided by the | 74 // There's no cached value from a previous invocation, nor a state value was
provided by the |
| 66 // event, but there is a history object, so first we need to see if the stat
e object has been | 75 // event, but there is a history object, so first we need to see if the stat
e object has been |
| 67 // deserialized through the history object already. | 76 // deserialized through the history object already. |
| 68 // The current history state object might've changed in the meantime, so we
need to take care | 77 // The current history state object might've changed in the meantime, so we
need to take care |
| 69 // of using the correct one, and always share the same deserialization with
history.state. | 78 // of using the correct one, and always share the same deserialization with
history.state. |
| 70 | 79 |
| 71 bool isSameState = history->isSameAsCurrentState(event->serializedState()); | 80 bool isSameState = history->isSameAsCurrentState(event->serializedState()); |
| 72 | 81 |
| 73 if (isSameState) { | 82 if (isSameState) { |
| 74 v8::Handle<v8::Object> v8History = toV8Fast(history, info, event).As<v8:
:Object>(); | 83 v8::Handle<v8::Object> v8History = toV8Fast(history, info, event).As<v8:
:Object>(); |
| 75 if (!history->stateChanged()) { | 84 if (!history->stateChanged()) { |
| 76 result = v8History->GetHiddenValue(V8HiddenPropertyName::state()); | 85 result = v8History->GetHiddenValue(V8HiddenPropertyName::state()); |
| 77 if (!result.IsEmpty()) { | 86 if (!result.IsEmpty()) { |
| 78 v8SetReturnValue(info, cacheState(info.Holder(), result)); | 87 v8SetReturnValue(info, cacheState(info.Holder(), result)); |
| 79 return; | 88 return; |
| 80 } | 89 } |
| 81 } | 90 } |
| 82 result = event->serializedState()->deserialize(info.GetIsolate()); | 91 result = event->serializedState()->deserialize(info.GetIsolate()); |
| 83 v8History->SetHiddenValue(V8HiddenPropertyName::state(), result); | 92 v8History->SetHiddenValue(V8HiddenPropertyName::state(), result); |
| 84 } else | 93 } else { |
| 85 result = event->serializedState()->deserialize(info.GetIsolate()); | 94 result = event->serializedState()->deserialize(info.GetIsolate()); |
| 95 } |
| 86 | 96 |
| 87 v8SetReturnValue(info, cacheState(info.Holder(), result)); | 97 v8SetReturnValue(info, cacheState(info.Holder(), result)); |
| 88 } | 98 } |
| 89 | 99 |
| 90 } // namespace WebCore | 100 } // namespace WebCore |
| OLD | NEW |