| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "V8MessageEvent.h" | 32 #include "V8MessageEvent.h" |
| 33 | 33 |
| 34 #include "V8Blob.h" | 34 #include "V8Blob.h" |
| 35 #include "V8MessagePort.h" | 35 #include "V8MessagePort.h" |
| 36 #include "V8Window.h" | 36 #include "V8Window.h" |
| 37 #include "bindings/v8/SerializedScriptValue.h" | 37 #include "bindings/v8/SerializedScriptValue.h" |
| 38 #include "bindings/v8/V8Binding.h" | 38 #include "bindings/v8/V8Binding.h" |
| 39 #include "bindings/v8/V8HiddenPropertyName.h" | |
| 40 #include "bindings/v8/custom/V8ArrayBufferCustom.h" | 39 #include "bindings/v8/custom/V8ArrayBufferCustom.h" |
| 41 #include "core/events/MessageEvent.h" | 40 #include "core/events/MessageEvent.h" |
| 42 | 41 |
| 43 namespace WebCore { | 42 namespace WebCore { |
| 44 | 43 |
| 45 void V8MessageEvent::dataAttributeGetterCustom(const v8::PropertyCallbackInfo<v8
::Value>& info) | 44 void V8MessageEvent::dataAttributeGetterCustom(const v8::PropertyCallbackInfo<v8
::Value>& info) |
| 46 { | 45 { |
| 47 MessageEvent* event = V8MessageEvent::toNative(info.Holder()); | 46 MessageEvent* event = V8MessageEvent::toNative(info.Holder()); |
| 48 | 47 |
| 49 v8::Handle<v8::Value> result; | 48 v8::Handle<v8::Value> result; |
| 50 switch (event->dataType()) { | 49 switch (event->dataType()) { |
| 51 case MessageEvent::DataTypeScriptValue: { | 50 case MessageEvent::DataTypeScriptValue: { |
| 52 result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::data(info.G
etIsolate())); | 51 result = getHiddenValue(info.GetIsolate(), info.Holder(), "data"); |
| 53 if (result.IsEmpty()) { | 52 if (result.IsEmpty()) { |
| 54 if (!event->dataAsSerializedScriptValue()) { | 53 if (!event->dataAsSerializedScriptValue()) { |
| 55 // If we're in an isolated world and the event was created in th
e main world, | 54 // If we're in an isolated world and the event was created in th
e main world, |
| 56 // we need to find the 'data' property on the main world wrapper
and clone it. | 55 // we need to find the 'data' property on the main world wrapper
and clone it. |
| 57 v8::Local<v8::Value> mainWorldData = getHiddenValueFromMainWorld
Wrapper(info.GetIsolate(), event, V8HiddenPropertyName::data(info.GetIsolate()))
; | 56 v8::Local<v8::Value> mainWorldData = getHiddenValueFromMainWorld
Wrapper(info.GetIsolate(), event, "data"); |
| 58 if (!mainWorldData.IsEmpty()) | 57 if (!mainWorldData.IsEmpty()) |
| 59 event->setSerializedData(SerializedScriptValue::createAndSwa
llowExceptions(mainWorldData, info.GetIsolate())); | 58 event->setSerializedData(SerializedScriptValue::createAndSwa
llowExceptions(mainWorldData, info.GetIsolate())); |
| 60 } | 59 } |
| 61 if (event->dataAsSerializedScriptValue()) | 60 if (event->dataAsSerializedScriptValue()) |
| 62 result = event->dataAsSerializedScriptValue()->deserialize(info.
GetIsolate()); | 61 result = event->dataAsSerializedScriptValue()->deserialize(info.
GetIsolate()); |
| 63 else | 62 else |
| 64 result = v8::Null(info.GetIsolate()); | 63 result = v8::Null(info.GetIsolate()); |
| 65 } | 64 } |
| 66 break; | 65 break; |
| 67 } | 66 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 OwnPtr<MessagePortArray> portArray; | 109 OwnPtr<MessagePortArray> portArray; |
| 111 const int portArrayIndex = 7; | 110 const int portArrayIndex = 7; |
| 112 if (!isUndefinedOrNull(info[portArrayIndex])) { | 111 if (!isUndefinedOrNull(info[portArrayIndex])) { |
| 113 portArray = adoptPtr(new MessagePortArray); | 112 portArray = adoptPtr(new MessagePortArray); |
| 114 if (!getMessagePortArray(info[portArrayIndex], portArrayIndex + 1, *port
Array, info.GetIsolate())) | 113 if (!getMessagePortArray(info[portArrayIndex], portArrayIndex + 1, *port
Array, info.GetIsolate())) |
| 115 return; | 114 return; |
| 116 } | 115 } |
| 117 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, las
tEventIdArg, sourceArg, portArray.release()); | 116 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, las
tEventIdArg, sourceArg, portArray.release()); |
| 118 | 117 |
| 119 if (!dataArg.IsEmpty()) { | 118 if (!dataArg.IsEmpty()) { |
| 120 info.Holder()->SetHiddenValue(V8HiddenPropertyName::data(info.GetIsolate
()), dataArg); | 119 setHiddenValue(info.GetIsolate(), info.Holder(), "data", dataArg); |
| 121 if (isolatedWorldForIsolate(info.GetIsolate())) | 120 if (isolatedWorldForIsolate(info.GetIsolate())) |
| 122 event->setSerializedData(SerializedScriptValue::createAndSwallowExce
ptions(dataArg, info.GetIsolate())); | 121 event->setSerializedData(SerializedScriptValue::createAndSwallowExce
ptions(dataArg, info.GetIsolate())); |
| 123 } | 122 } |
| 124 } | 123 } |
| 125 | 124 |
| 126 void V8MessageEvent::webkitInitMessageEventMethodCustom(const v8::FunctionCallba
ckInfo<v8::Value>& info) | 125 void V8MessageEvent::webkitInitMessageEventMethodCustom(const v8::FunctionCallba
ckInfo<v8::Value>& info) |
| 127 { | 126 { |
| 128 initMessageEventMethodCustom(info); | 127 initMessageEventMethodCustom(info); |
| 129 } | 128 } |
| 130 | 129 |
| 131 | 130 |
| 132 } // namespace WebCore | 131 } // namespace WebCore |
| OLD | NEW |