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 v8::Local<v8::Value> mainWorldData = getHiddenValueFromMainWorld
Wrapper(info.GetIsolate(), event, V8HiddenPropertyName::data()); |
| 57 if (!mainWorldData.IsEmpty()) |
| 58 event->setSerializedData(SerializedScriptValue::createAndSwa
llowExceptions(mainWorldData, info.GetIsolate())); |
| 59 } |
| 60 if (event->dataAsSerializedScriptValue()) |
| 61 result = event->dataAsSerializedScriptValue()->deserialize(info.
GetIsolate()); |
| 62 else |
| 63 result = v8::Null(info.GetIsolate()); |
| 64 } |
56 break; | 65 break; |
57 } | 66 } |
58 | 67 |
59 case MessageEvent::DataTypeSerializedScriptValue: | 68 case MessageEvent::DataTypeSerializedScriptValue: |
60 if (SerializedScriptValue* serializedValue = event->dataAsSerializedScri
ptValue()) { | 69 if (SerializedScriptValue* serializedValue = event->dataAsSerializedScri
ptValue()) { |
61 MessagePortArray ports = event->ports(); | 70 MessagePortArray ports = event->ports(); |
62 result = serializedValue->deserialize(info.GetIsolate(), &ports); | 71 result = serializedValue->deserialize(info.GetIsolate(), &ports); |
63 } else { | 72 } else { |
64 result = v8::Null(info.GetIsolate()); | 73 result = v8::Null(info.GetIsolate()); |
65 } | 74 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if (!window.IsEmpty()) | 113 if (!window.IsEmpty()) |
105 sourceArg = V8Window::toNative(window); | 114 sourceArg = V8Window::toNative(window); |
106 } | 115 } |
107 OwnPtr<MessagePortArray> portArray; | 116 OwnPtr<MessagePortArray> portArray; |
108 | 117 |
109 if (!isUndefinedOrNull(args[7])) { | 118 if (!isUndefinedOrNull(args[7])) { |
110 portArray = adoptPtr(new MessagePortArray); | 119 portArray = adoptPtr(new MessagePortArray); |
111 if (!getMessagePortArray(args[7], *portArray, args.GetIsolate())) | 120 if (!getMessagePortArray(args[7], *portArray, args.GetIsolate())) |
112 return; | 121 return; |
113 } | 122 } |
114 args.Holder()->SetHiddenValue(V8HiddenPropertyName::data(), dataArg); | |
115 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, las
tEventIdArg, sourceArg, portArray.release()); | 123 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, las
tEventIdArg, sourceArg, portArray.release()); |
| 124 |
| 125 if (!dataArg.IsEmpty()) { |
| 126 args.Holder()->SetHiddenValue(V8HiddenPropertyName::data(), dataArg); |
| 127 if (isolatedWorldForIsolate(args.GetIsolate())) |
| 128 event->setSerializedData(SerializedScriptValue::createAndSwallowExce
ptions(dataArg, args.GetIsolate())); |
| 129 } |
116 } | 130 } |
117 | 131 |
118 void V8MessageEvent::webkitInitMessageEventMethodCustom(const v8::FunctionCallba
ckInfo<v8::Value>& args) | 132 void V8MessageEvent::webkitInitMessageEventMethodCustom(const v8::FunctionCallba
ckInfo<v8::Value>& args) |
119 { | 133 { |
120 initMessageEventMethodCustom(args); | 134 initMessageEventMethodCustom(args); |
121 } | 135 } |
122 | 136 |
123 | 137 |
124 } // namespace WebCore | 138 } // namespace WebCore |
OLD | NEW |