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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 namespace WebCore { | 43 namespace WebCore { |
44 | 44 |
45 void V8MessageEvent::dataAttributeGetterCustom(v8::Local<v8::String> name, const
v8::PropertyCallbackInfo<v8::Value>& info) | 45 void V8MessageEvent::dataAttributeGetterCustom(v8::Local<v8::String> name, const
v8::PropertyCallbackInfo<v8::Value>& info) |
46 { | 46 { |
47 MessageEvent* event = V8MessageEvent::toNative(info.Holder()); | 47 MessageEvent* event = V8MessageEvent::toNative(info.Holder()); |
48 | 48 |
49 v8::Handle<v8::Value> result; | 49 v8::Handle<v8::Value> result; |
50 switch (event->dataType()) { | 50 switch (event->dataType()) { |
51 case MessageEvent::DataTypeScriptValue: { | 51 case MessageEvent::DataTypeScriptValue: { |
52 result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::data()); | 52 result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::data(info.G
etIsolate())); |
53 if (result.IsEmpty()) { | 53 if (result.IsEmpty()) { |
54 if (!event->dataAsSerializedScriptValue()) { | 54 if (!event->dataAsSerializedScriptValue()) { |
55 // If we're in an isolated world and the event was created in th
e main world, | 55 // 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. | 56 // 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()); | 57 v8::Local<v8::Value> mainWorldData = getHiddenValueFromMainWorld
Wrapper(info.GetIsolate(), event, V8HiddenPropertyName::data(info.GetIsolate()))
; |
58 if (!mainWorldData.IsEmpty()) | 58 if (!mainWorldData.IsEmpty()) |
59 event->setSerializedData(SerializedScriptValue::createAndSwa
llowExceptions(mainWorldData, info.GetIsolate())); | 59 event->setSerializedData(SerializedScriptValue::createAndSwa
llowExceptions(mainWorldData, info.GetIsolate())); |
60 } | 60 } |
61 if (event->dataAsSerializedScriptValue()) | 61 if (event->dataAsSerializedScriptValue()) |
62 result = event->dataAsSerializedScriptValue()->deserialize(info.
GetIsolate()); | 62 result = event->dataAsSerializedScriptValue()->deserialize(info.
GetIsolate()); |
63 else | 63 else |
64 result = v8::Null(info.GetIsolate()); | 64 result = v8::Null(info.GetIsolate()); |
65 } | 65 } |
66 break; | 66 break; |
67 } | 67 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 OwnPtr<MessagePortArray> portArray; | 117 OwnPtr<MessagePortArray> portArray; |
118 | 118 |
119 if (!isUndefinedOrNull(args[7])) { | 119 if (!isUndefinedOrNull(args[7])) { |
120 portArray = adoptPtr(new MessagePortArray); | 120 portArray = adoptPtr(new MessagePortArray); |
121 if (!getMessagePortArray(args[7], *portArray, args.GetIsolate())) | 121 if (!getMessagePortArray(args[7], *portArray, args.GetIsolate())) |
122 return; | 122 return; |
123 } | 123 } |
124 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, las
tEventIdArg, sourceArg, portArray.release()); | 124 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, las
tEventIdArg, sourceArg, portArray.release()); |
125 | 125 |
126 if (!dataArg.IsEmpty()) { | 126 if (!dataArg.IsEmpty()) { |
127 args.Holder()->SetHiddenValue(V8HiddenPropertyName::data(), dataArg); | 127 args.Holder()->SetHiddenValue(V8HiddenPropertyName::data(args.GetIsolate
()), dataArg); |
128 if (isolatedWorldForIsolate(args.GetIsolate())) | 128 if (isolatedWorldForIsolate(args.GetIsolate())) |
129 event->setSerializedData(SerializedScriptValue::createAndSwallowExce
ptions(dataArg, args.GetIsolate())); | 129 event->setSerializedData(SerializedScriptValue::createAndSwallowExce
ptions(dataArg, args.GetIsolate())); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 void V8MessageEvent::webkitInitMessageEventMethodCustom(const v8::FunctionCallba
ckInfo<v8::Value>& args) | 133 void V8MessageEvent::webkitInitMessageEventMethodCustom(const v8::FunctionCallba
ckInfo<v8::Value>& args) |
134 { | 134 { |
135 initMessageEventMethodCustom(args); | 135 initMessageEventMethodCustom(args); |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 } // namespace WebCore | 139 } // namespace WebCore |
OLD | NEW |