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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 void V8PopStateEvent::stateAttrGetterCustom(v8::Local<v8::String> name, const v8
::PropertyCallbackInfo<v8::Value>& info) | 49 void V8PopStateEvent::stateAttrGetterCustom(v8::Local<v8::String> name, const v8
::PropertyCallbackInfo<v8::Value>& info) |
50 { | 50 { |
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 if (!event->state().hasNoValue()) { | 59 |
60 v8SetReturnValue(info, cacheState(info.Holder(), event->state().v8Value(
))); | 60 // This is necessary because of the V8 bug 2746. V8 returns an empty |
| 61 // handler when a hidden value is v8::Undefined. Thus, it is necessary to |
| 62 // keep extra state around in the event about whether the value was set in |
| 63 // the first place. That is, if the detail was set, and V8 returns an empty |
| 64 // handler for the value, we know that the value must actually be a |
| 65 // v8::Undefined(), so we explicitly set that here. Oy! |
| 66 // |
| 67 // Once bug 2746 is addressed, the following 'if' should become dead code |
| 68 // and should be removable. Please see the related comments in |
| 69 // V8CustomEventCustom.cpp and V8MessageEventCustom.cpp as well. |
| 70 if (event->isStateSet()) { |
| 71 v8SetReturnValue(info, v8::Undefined()); |
61 return; | 72 return; |
62 } | 73 } |
63 | 74 |
64 History* history = event->history(); | 75 History* history = event->history(); |
65 if (!history || !event->serializedState()) { | 76 if (!history || !event->serializedState()) { |
66 v8SetReturnValue(info, cacheState(info.Holder(), v8Null(info.GetIsolate(
)))); | 77 v8SetReturnValue(info, cacheState(info.Holder(), v8Null(info.GetIsolate(
)))); |
67 return; | 78 return; |
68 } | 79 } |
69 | 80 |
70 // There's no cached value from a previous invocation, nor a state value was
provided by the | 81 // There's no cached value from a previous invocation, nor a state value was
provided by the |
(...skipping 15 matching lines...) Expand all Loading... |
86 } | 97 } |
87 result = event->serializedState()->deserialize(info.GetIsolate()); | 98 result = event->serializedState()->deserialize(info.GetIsolate()); |
88 v8History->SetHiddenValue(V8HiddenPropertyName::state(), result); | 99 v8History->SetHiddenValue(V8HiddenPropertyName::state(), result); |
89 } else | 100 } else |
90 result = event->serializedState()->deserialize(info.GetIsolate()); | 101 result = event->serializedState()->deserialize(info.GetIsolate()); |
91 | 102 |
92 v8SetReturnValue(info, cacheState(info.Holder(), result)); | 103 v8SetReturnValue(info, cacheState(info.Holder(), result)); |
93 } | 104 } |
94 | 105 |
95 } // namespace WebCore | 106 } // namespace WebCore |
OLD | NEW |