| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "V8History.h" | 32 #include "V8History.h" |
| 33 | 33 |
| 34 #include "V8Window.h" | 34 #include "V8Window.h" |
| 35 #include "bindings/v8/ExceptionState.h" | 35 #include "bindings/v8/ExceptionState.h" |
| 36 #include "bindings/v8/SerializedScriptValue.h" | 36 #include "bindings/v8/SerializedScriptValue.h" |
| 37 #include "bindings/v8/V8Binding.h" | 37 #include "bindings/v8/V8Binding.h" |
| 38 #include "bindings/v8/V8HiddenPropertyName.h" | |
| 39 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
| 40 #include "core/frame/History.h" | 39 #include "core/frame/History.h" |
| 41 | 40 |
| 42 namespace WebCore { | 41 namespace WebCore { |
| 43 | 42 |
| 44 void V8History::stateAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Va
lue>& info) | 43 void V8History::stateAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Va
lue>& info) |
| 45 { | 44 { |
| 46 History* history = V8History::toNative(info.Holder()); | 45 History* history = V8History::toNative(info.Holder()); |
| 47 | 46 |
| 48 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(V8HiddenProperty
Name::state(info.GetIsolate())); | 47 v8::Handle<v8::Value> value = getHiddenValue(info.GetIsolate(), info.Holder(
), "state"); |
| 49 | 48 |
| 50 if (!value.IsEmpty() && !history->stateChanged()) { | 49 if (!value.IsEmpty() && !history->stateChanged()) { |
| 51 v8SetReturnValue(info, value); | 50 v8SetReturnValue(info, value); |
| 52 return; | 51 return; |
| 53 } | 52 } |
| 54 | 53 |
| 55 RefPtr<SerializedScriptValue> serialized = history->state(); | 54 RefPtr<SerializedScriptValue> serialized = history->state(); |
| 56 value = serialized ? serialized->deserialize(info.GetIsolate()) : v8::Handle
<v8::Value>(v8::Null(info.GetIsolate())); | 55 value = serialized ? serialized->deserialize(info.GetIsolate()) : v8::Handle
<v8::Value>(v8::Null(info.GetIsolate())); |
| 57 info.Holder()->SetHiddenValue(V8HiddenPropertyName::state(info.GetIsolate())
, value); | 56 setHiddenValue(info.GetIsolate(), info.Holder(), "state", value); |
| 58 | 57 |
| 59 v8SetReturnValue(info, value); | 58 v8SetReturnValue(info, value); |
| 60 } | 59 } |
| 61 | 60 |
| 62 void V8History::pushStateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) | 61 void V8History::pushStateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 63 { | 62 { |
| 64 ExceptionState exceptionState(ExceptionState::ExecutionContext, "pushState",
"History", info.Holder(), info.GetIsolate()); | 63 ExceptionState exceptionState(ExceptionState::ExecutionContext, "pushState",
"History", info.Holder(), info.GetIsolate()); |
| 65 RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(i
nfo[0], 0, 0, exceptionState, info.GetIsolate()); | 64 RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(i
nfo[0], 0, 0, exceptionState, info.GetIsolate()); |
| 66 if (exceptionState.throwIfNeeded()) | 65 if (exceptionState.throwIfNeeded()) |
| 67 return; | 66 return; |
| 68 | 67 |
| 69 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, title, info[1]); | 68 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, title, info[1]); |
| 70 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, url, argumentOrNull(info, 2)); | 69 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, url, argumentOrNull(info, 2)); |
| 71 | 70 |
| 72 History* history = V8History::toNative(info.Holder()); | 71 History* history = V8History::toNative(info.Holder()); |
| 73 history->stateObjectAdded(historyState.release(), title, url, SameDocumentNa
vigationPushState, exceptionState); | 72 history->stateObjectAdded(historyState.release(), title, url, SameDocumentNa
vigationPushState, exceptionState); |
| 74 info.Holder()->DeleteHiddenValue(V8HiddenPropertyName::state(info.GetIsolate
())); | 73 deleteHiddenValue(info.GetIsolate(), info.Holder(), "state"); |
| 75 exceptionState.throwIfNeeded(); | 74 exceptionState.throwIfNeeded(); |
| 76 } | 75 } |
| 77 | 76 |
| 78 void V8History::replaceStateMethodCustom(const v8::FunctionCallbackInfo<v8::Valu
e>& info) | 77 void V8History::replaceStateMethodCustom(const v8::FunctionCallbackInfo<v8::Valu
e>& info) |
| 79 { | 78 { |
| 80 ExceptionState exceptionState(ExceptionState::ExecutionContext, "replaceStat
e", "History", info.Holder(), info.GetIsolate()); | 79 ExceptionState exceptionState(ExceptionState::ExecutionContext, "replaceStat
e", "History", info.Holder(), info.GetIsolate()); |
| 81 RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(i
nfo[0], 0, 0, exceptionState, info.GetIsolate()); | 80 RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(i
nfo[0], 0, 0, exceptionState, info.GetIsolate()); |
| 82 if (exceptionState.throwIfNeeded()) | 81 if (exceptionState.throwIfNeeded()) |
| 83 return; | 82 return; |
| 84 | 83 |
| 85 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, title, info[1]); | 84 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, title, info[1]); |
| 86 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, url, argumentOrNull(info, 2)); | 85 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, url, argumentOrNull(info, 2)); |
| 87 | 86 |
| 88 History* history = V8History::toNative(info.Holder()); | 87 History* history = V8History::toNative(info.Holder()); |
| 89 history->stateObjectAdded(historyState.release(), title, url, SameDocumentNa
vigationReplaceState, exceptionState); | 88 history->stateObjectAdded(historyState.release(), title, url, SameDocumentNa
vigationReplaceState, exceptionState); |
| 90 info.Holder()->DeleteHiddenValue(V8HiddenPropertyName::state(info.GetIsolate
())); | 89 deleteHiddenValue(info.GetIsolate(), info.Holder(), "state"); |
| 91 exceptionState.throwIfNeeded(); | 90 exceptionState.throwIfNeeded(); |
| 92 } | 91 } |
| 93 | 92 |
| 94 } // namespace WebCore | 93 } // namespace WebCore |
| OLD | NEW |