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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 auto private_cached_data = | 48 auto private_cached_data = |
49 V8PrivateProperty::GetMessageEventCachedData(isolate); | 49 V8PrivateProperty::GetMessageEventCachedData(isolate); |
50 v8::Local<v8::Value> cached_data = | 50 v8::Local<v8::Value> cached_data = |
51 private_cached_data.GetOrEmpty(info.Holder()); | 51 private_cached_data.GetOrEmpty(info.Holder()); |
52 if (!cached_data.IsEmpty()) { | 52 if (!cached_data.IsEmpty()) { |
53 V8SetReturnValue(info, cached_data); | 53 V8SetReturnValue(info, cached_data); |
54 return; | 54 return; |
55 } | 55 } |
56 | 56 |
57 MessageEvent* event = V8MessageEvent::toImpl(info.Holder()); | 57 MessageEvent* event = V8MessageEvent::toImpl(info.Holder()); |
| 58 ScriptState* script_state = ScriptState::Current(isolate); |
58 | 59 |
59 v8::Local<v8::Value> result; | 60 v8::Local<v8::Value> result; |
60 switch (event->GetDataType()) { | 61 switch (event->GetDataType()) { |
61 case MessageEvent::kDataTypeScriptValue: | 62 case MessageEvent::kDataTypeV8Reference: |
62 result = | 63 result = event->DataAsScriptValue(script_state).V8Value(); |
63 event->DataAsScriptValue().V8ValueFor(ScriptState::Current(isolate)); | |
64 if (result.IsEmpty()) | 64 if (result.IsEmpty()) |
65 result = v8::Null(isolate); | 65 result = v8::Null(isolate); |
66 break; | 66 break; |
67 | 67 |
68 case MessageEvent::kDataTypeSerializedScriptValue: | 68 case MessageEvent::kDataTypeSerializedScriptValue: |
69 if (SerializedScriptValue* serialized_value = | 69 if (SerializedScriptValue* serialized_value = |
70 event->DataAsSerializedScriptValue()) { | 70 event->DataAsSerializedScriptValue()) { |
71 MessagePortArray ports = event->ports(); | 71 MessagePortArray ports = event->ports(); |
72 SerializedScriptValue::DeserializeOptions options; | 72 SerializedScriptValue::DeserializeOptions options; |
73 options.message_ports = &ports; | 73 options.message_ports = &ports; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 V8EventTarget::toImplWithTypeCheck(info.GetIsolate(), info[6]); | 119 V8EventTarget::toImplWithTypeCheck(info.GetIsolate(), info[6]); |
120 MessagePortArray* port_array = nullptr; | 120 MessagePortArray* port_array = nullptr; |
121 const int kPortArrayIndex = 7; | 121 const int kPortArrayIndex = 7; |
122 if (!IsUndefinedOrNull(info[kPortArrayIndex])) { | 122 if (!IsUndefinedOrNull(info[kPortArrayIndex])) { |
123 port_array = new MessagePortArray; | 123 port_array = new MessagePortArray; |
124 *port_array = NativeValueTraits<IDLSequence<MessagePort>>::NativeValue( | 124 *port_array = NativeValueTraits<IDLSequence<MessagePort>>::NativeValue( |
125 info.GetIsolate(), info[kPortArrayIndex], exception_state); | 125 info.GetIsolate(), info[kPortArrayIndex], exception_state); |
126 if (exception_state.HadException()) | 126 if (exception_state.HadException()) |
127 return; | 127 return; |
128 } | 128 } |
129 event->initMessageEvent( | 129 ScriptState* script_state = ScriptState::Current(info.GetIsolate()); |
130 type_arg, can_bubble_arg, cancelable_arg, | 130 event->initMessageEvent(script_state, type_arg, can_bubble_arg, |
131 ScriptValue(ScriptState::Current(info.GetIsolate()), data_arg), | 131 cancelable_arg, ScriptValue(script_state, data_arg), |
132 origin_arg, last_event_id_arg, source_arg, port_array); | 132 origin_arg, last_event_id_arg, source_arg, |
| 133 port_array); |
133 } | 134 } |
134 | 135 |
135 } // namespace blink | 136 } // namespace blink |
OLD | NEW |