Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 16 matching lines...) Expand all Loading... | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 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 "V8CustomEvent.h" | 32 #include "V8CustomEvent.h" |
| 33 | 33 |
| 34 #include "V8Event.h" | 34 #include "V8Event.h" |
| 35 #include "bindings/v8/Dictionary.h" | 35 #include "bindings/v8/Dictionary.h" |
| 36 #include "bindings/v8/ScriptState.h" | 36 #include "bindings/v8/ScriptState.h" |
| 37 #include "bindings/v8/ScriptValue.h" | 37 #include "bindings/v8/SerializedScriptValue.h" |
| 38 #include "bindings/v8/V8Binding.h" | 38 #include "bindings/v8/V8Binding.h" |
| 39 #include "bindings/v8/V8DOMWrapper.h" | 39 #include "bindings/v8/V8DOMWrapper.h" |
| 40 #include "bindings/v8/V8HiddenPropertyName.h" | 40 #include "bindings/v8/V8HiddenPropertyName.h" |
| 41 #include "core/dom/ContextFeatures.h" | 41 #include "core/dom/ContextFeatures.h" |
| 42 #include "core/dom/ExceptionCode.h" | 42 #include "core/dom/ExceptionCode.h" |
| 43 #include "core/page/Frame.h" | 43 #include "core/page/Frame.h" |
| 44 #include "RuntimeEnabledFeatures.h" | 44 #include "RuntimeEnabledFeatures.h" |
| 45 | 45 |
| 46 namespace WebCore { | 46 namespace WebCore { |
| 47 | 47 |
| 48 static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> customEvent, v8:: Handle<v8::Value> detail) | 48 static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> customEvent, v8:: Handle<v8::Value> detail) |
| 49 { | 49 { |
| 50 customEvent->SetHiddenValue(V8HiddenPropertyName::detail(), detail); | 50 customEvent->SetHiddenValue(V8HiddenPropertyName::detail(), detail); |
| 51 return detail; | 51 return detail; |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 void V8CustomEvent::detailAttrGetterCustom(v8::Local<v8::String> name, const v8: :PropertyCallbackInfo<v8::Value>& info) | 55 void V8CustomEvent::detailAttrGetterCustom(v8::Local<v8::String> name, const v8: :PropertyCallbackInfo<v8::Value>& info) |
| 56 { | 56 { |
| 57 CustomEvent* event = V8CustomEvent::toNative(info.Holder()); | 57 CustomEvent* event = V8CustomEvent::toNative(info.Holder()); |
| 58 | 58 |
| 59 v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropert yName::detail()); | 59 v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropert yName::detail()); |
| 60 | 60 |
| 61 if (!result.IsEmpty()) { | 61 if (!result.IsEmpty()) { |
| 62 v8SetReturnValue(info, result); | 62 v8SetReturnValue(info, result); |
| 63 return; | 63 return; |
| 64 } | 64 } |
| 65 | 65 |
| 66 SerializedScriptValue* serialized = event->serializedScriptValue(); | 66 if (!event->serializedScriptValue()) { |
| 67 if (serialized) { | 67 v8::Local<v8::Value> mainWorldDetail = getHiddenValueFromMainWorldWrappe r(info.GetIsolate(), event, V8HiddenPropertyName::detail()); |
| 68 result = serialized->deserialize(); | 68 if (!mainWorldDetail.IsEmpty()) |
| 69 event->setSerializedDetail(SerializedScriptValue::createSwallowExcep tions(mainWorldDetail, info.GetIsolate())); | |
|
haraken
2013/07/18 00:00:29
What happens if SerializedScriptValue::createSwall
adamk
2013/07/18 01:09:14
I don't believe that's possible. Is it? Even if it
haraken
2013/07/18 01:28:01
I thought it might be possible in a situation wher
| |
| 70 } | |
| 71 | |
| 72 if (event->serializedScriptValue()) { | |
| 73 result = event->serializedScriptValue()->deserialize(); | |
|
haraken
2013/07/18 00:00:29
Would it be possible to avoid deserializing the Se
adamk
2013/07/18 01:09:14
The entire point of the patch is to force a serial
haraken
2013/07/18 01:28:01
sorry, I was confused. Now got it! (You might want
adamk
2013/07/18 16:48:32
I think it's my fault, this CL came out of an in-p
| |
| 69 v8SetReturnValue(info, cacheState(info.Holder(), result)); | 74 v8SetReturnValue(info, cacheState(info.Holder(), result)); |
| 70 return; | 75 return; |
| 71 } | 76 } |
| 72 | 77 |
| 73 v8SetReturnValue(info, cacheState(info.Holder(), v8::Null(info.GetIsolate()) )); | 78 v8SetReturnValue(info, cacheState(info.Holder(), v8::Null(info.GetIsolate()) )); |
| 74 } | 79 } |
| 75 | 80 |
| 76 void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v 8::Value>& args) | 81 void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v 8::Value>& args) |
| 77 { | 82 { |
| 78 CustomEvent* event = V8CustomEvent::toNative(args.Holder()); | 83 CustomEvent* event = V8CustomEvent::toNative(args.Holder()); |
| 79 ASSERT(!event->serializedScriptValue()); | 84 ASSERT(!event->serializedScriptValue()); |
| 80 | 85 |
| 81 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, typeArg, args[0]); | 86 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, typeArg, args[0]); |
| 82 V8TRYCATCH_VOID(bool, canBubbleArg, args[1]->BooleanValue()); | 87 V8TRYCATCH_VOID(bool, canBubbleArg, args[1]->BooleanValue()); |
| 83 V8TRYCATCH_VOID(bool, cancelableArg, args[2]->BooleanValue()); | 88 V8TRYCATCH_VOID(bool, cancelableArg, args[2]->BooleanValue()); |
| 84 v8::Handle<v8::Value> detailsArg = args[3]; | 89 v8::Handle<v8::Value> detailsArg = args[3]; |
| 85 | 90 |
| 86 args.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), detailsArg); | |
| 87 event->initEvent(typeArg, canBubbleArg, cancelableArg); | 91 event->initEvent(typeArg, canBubbleArg, cancelableArg); |
| 92 | |
| 93 if (!detailsArg.IsEmpty()) { | |
| 94 args.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), detailsArg ); | |
| 95 if (isolatedWorldForIsolate(args.GetIsolate())) | |
| 96 event->setSerializedDetail(SerializedScriptValue::createSwallowExcep tions(detailsArg, args.GetIsolate())); | |
| 97 } | |
| 88 } | 98 } |
| 89 | 99 |
| 90 } // namespace WebCore | 100 } // namespace WebCore |
| OLD | NEW |