| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 void V8MessageEvent::dataAttrGetterCustom(v8::Local<v8::String> name, const v8::
PropertyCallbackInfo<v8::Value>& info) | 46 void V8MessageEvent::dataAttrGetterCustom(v8::Local<v8::String> name, const v8::
PropertyCallbackInfo<v8::Value>& info) |
| 47 { | 47 { |
| 48 MessageEvent* event = V8MessageEvent::toNative(info.Holder()); | 48 MessageEvent* event = V8MessageEvent::toNative(info.Holder()); |
| 49 | 49 |
| 50 v8::Handle<v8::Value> result; | 50 v8::Handle<v8::Value> result; |
| 51 switch (event->dataType()) { | 51 switch (event->dataType()) { |
| 52 case MessageEvent::DataTypeScriptValue: { | 52 case MessageEvent::DataTypeScriptValue: { |
| 53 result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::data()); | 53 result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::data()); |
| 54 if (result.IsEmpty()) | 54 if (result.IsEmpty()) { |
| 55 result = v8::Null(info.GetIsolate()); | 55 if (!event->dataAsSerializedScriptValue()) { |
| 56 // If we're in an isolated world and the event was created in th
e main world, |
| 57 // we need to find the 'data' property on the main world wrapper
and clone it. |
| 58 v8::Local<v8::Value> mainWorldData = getHiddenValueFromMainWorld
Wrapper(info.GetIsolate(), event, V8HiddenPropertyName::data()); |
| 59 if (!mainWorldData.IsEmpty()) |
| 60 event->setSerializedData(SerializedScriptValue::createAndSwa
llowExceptions(mainWorldData, info.GetIsolate())); |
| 61 } |
| 62 if (event->dataAsSerializedScriptValue()) |
| 63 result = event->dataAsSerializedScriptValue()->deserialize(info.
GetIsolate()); |
| 64 else |
| 65 result = v8::Null(info.GetIsolate()); |
| 66 } |
| 56 break; | 67 break; |
| 57 } | 68 } |
| 58 | 69 |
| 59 case MessageEvent::DataTypeSerializedScriptValue: | 70 case MessageEvent::DataTypeSerializedScriptValue: |
| 60 if (SerializedScriptValue* serializedValue = event->dataAsSerializedScri
ptValue()) { | 71 if (SerializedScriptValue* serializedValue = event->dataAsSerializedScri
ptValue()) { |
| 61 MessagePortArray ports = event->ports(); | 72 MessagePortArray ports = event->ports(); |
| 62 result = serializedValue->deserialize(info.GetIsolate(), &ports); | 73 result = serializedValue->deserialize(info.GetIsolate(), &ports); |
| 63 } else { | 74 } else { |
| 64 result = v8::Null(info.GetIsolate()); | 75 result = v8::Null(info.GetIsolate()); |
| 65 } | 76 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 if (!window.IsEmpty()) | 115 if (!window.IsEmpty()) |
| 105 sourceArg = V8Window::toNative(window); | 116 sourceArg = V8Window::toNative(window); |
| 106 } | 117 } |
| 107 OwnPtr<MessagePortArray> portArray; | 118 OwnPtr<MessagePortArray> portArray; |
| 108 | 119 |
| 109 if (!isUndefinedOrNull(args[7])) { | 120 if (!isUndefinedOrNull(args[7])) { |
| 110 portArray = adoptPtr(new MessagePortArray); | 121 portArray = adoptPtr(new MessagePortArray); |
| 111 if (!getMessagePortArray(args[7], *portArray, args.GetIsolate())) | 122 if (!getMessagePortArray(args[7], *portArray, args.GetIsolate())) |
| 112 return; | 123 return; |
| 113 } | 124 } |
| 114 args.Holder()->SetHiddenValue(V8HiddenPropertyName::data(), dataArg); | |
| 115 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, las
tEventIdArg, sourceArg, portArray.release()); | 125 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, las
tEventIdArg, sourceArg, portArray.release()); |
| 126 |
| 127 if (!dataArg.IsEmpty()) { |
| 128 args.Holder()->SetHiddenValue(V8HiddenPropertyName::data(), dataArg); |
| 129 if (isolatedWorldForIsolate(args.GetIsolate())) |
| 130 event->setSerializedData(SerializedScriptValue::createAndSwallowExce
ptions(dataArg, args.GetIsolate())); |
| 131 } |
| 116 } | 132 } |
| 117 | 133 |
| 118 void V8MessageEvent::webkitInitMessageEventMethodCustom(const v8::FunctionCallba
ckInfo<v8::Value>& args) | 134 void V8MessageEvent::webkitInitMessageEventMethodCustom(const v8::FunctionCallba
ckInfo<v8::Value>& args) |
| 119 { | 135 { |
| 120 initMessageEventMethodCustom(args); | 136 initMessageEventMethodCustom(args); |
| 121 } | 137 } |
| 122 | 138 |
| 123 | 139 |
| 124 } // namespace WebCore | 140 } // namespace WebCore |
| OLD | NEW |