OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Henry Mason (hmason@mac.com) | 2 * Copyright (C) 2007 Henry Mason (hmason@mac.com) |
3 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include "bindings/core/v8/ExceptionMessages.h" | 30 #include "bindings/core/v8/ExceptionMessages.h" |
31 #include "bindings/core/v8/ExceptionState.h" | 31 #include "bindings/core/v8/ExceptionState.h" |
32 #include "bindings/core/v8/V8ArrayBuffer.h" | 32 #include "bindings/core/v8/V8ArrayBuffer.h" |
33 #include "bindings/core/v8/V8PrivateProperty.h" | 33 #include "bindings/core/v8/V8PrivateProperty.h" |
34 #include <memory> | 34 #include <memory> |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 static inline bool isValidSource(EventTarget* source) { | 38 static inline bool isValidSource(EventTarget* source) { |
39 return !source || source->toLocalDOMWindow() || source->toMessagePort(); | 39 return !source || source->toLocalDOMWindow() || source->toMessagePort() || |
| 40 source->toServiceWorker(); |
40 } | 41 } |
41 | 42 |
42 MessageEvent::MessageEvent() : m_dataType(DataTypeScriptValue) {} | 43 MessageEvent::MessageEvent() : m_dataType(DataTypeScriptValue) {} |
43 | 44 |
44 MessageEvent::MessageEvent(const AtomicString& type, | 45 MessageEvent::MessageEvent(const AtomicString& type, |
45 const MessageEventInit& initializer) | 46 const MessageEventInit& initializer) |
46 : Event(type, initializer), | 47 : Event(type, initializer), |
47 m_dataType(DataTypeScriptValue), | 48 m_dataType(DataTypeScriptValue), |
48 m_source(nullptr) { | 49 m_source(nullptr) { |
49 if (initializer.hasData()) | 50 if (initializer.hasData()) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 149 } |
149 return new MessageEvent(type, initializer); | 150 return new MessageEvent(type, initializer); |
150 } | 151 } |
151 | 152 |
152 void MessageEvent::initMessageEvent(const AtomicString& type, | 153 void MessageEvent::initMessageEvent(const AtomicString& type, |
153 bool canBubble, | 154 bool canBubble, |
154 bool cancelable, | 155 bool cancelable, |
155 ScriptValue data, | 156 ScriptValue data, |
156 const String& origin, | 157 const String& origin, |
157 const String& lastEventId, | 158 const String& lastEventId, |
158 DOMWindow* source, | 159 EventTarget* source, |
159 MessagePortArray* ports) { | 160 MessagePortArray* ports) { |
160 if (isBeingDispatched()) | 161 if (isBeingDispatched()) |
161 return; | 162 return; |
162 | 163 |
163 initEvent(type, canBubble, cancelable); | 164 initEvent(type, canBubble, cancelable); |
164 | 165 |
165 m_dataType = DataTypeScriptValue; | 166 m_dataType = DataTypeScriptValue; |
166 m_dataAsScriptValue = data; | 167 m_dataAsScriptValue = data; |
167 m_origin = origin; | 168 m_origin = origin; |
168 m_lastEventId = lastEventId; | 169 m_lastEventId = lastEventId; |
169 m_source = source; | 170 m_source = source; |
170 m_ports = ports; | 171 m_ports = ports; |
171 m_suborigin = ""; | 172 m_suborigin = ""; |
172 } | 173 } |
173 | 174 |
174 void MessageEvent::initMessageEvent(const AtomicString& type, | 175 void MessageEvent::initMessageEvent(const AtomicString& type, |
175 bool canBubble, | 176 bool canBubble, |
176 bool cancelable, | 177 bool cancelable, |
177 PassRefPtr<SerializedScriptValue> data, | 178 PassRefPtr<SerializedScriptValue> data, |
178 const String& origin, | 179 const String& origin, |
179 const String& lastEventId, | 180 const String& lastEventId, |
180 DOMWindow* source, | 181 EventTarget* source, |
181 MessagePortArray* ports) { | 182 MessagePortArray* ports) { |
182 if (isBeingDispatched()) | 183 if (isBeingDispatched()) |
183 return; | 184 return; |
184 | 185 |
185 initEvent(type, canBubble, cancelable); | 186 initEvent(type, canBubble, cancelable); |
186 | 187 |
187 m_dataType = DataTypeSerializedScriptValue; | 188 m_dataType = DataTypeSerializedScriptValue; |
188 m_dataAsSerializedScriptValue = data; | 189 m_dataAsSerializedScriptValue = data; |
189 m_origin = origin; | 190 m_origin = origin; |
190 m_lastEventId = lastEventId; | 191 m_lastEventId = lastEventId; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 V8PrivateProperty::getMessageEventCachedData(isolate).set( | 256 V8PrivateProperty::getMessageEventCachedData(isolate).set( |
256 isolate->GetCurrentContext(), wrapper, | 257 isolate->GetCurrentContext(), wrapper, |
257 toV8(dataAsArrayBuffer(), wrapper, isolate)); | 258 toV8(dataAsArrayBuffer(), wrapper, isolate)); |
258 break; | 259 break; |
259 } | 260 } |
260 | 261 |
261 return wrapper; | 262 return wrapper; |
262 } | 263 } |
263 | 264 |
264 } // namespace blink | 265 } // namespace blink |
OLD | NEW |