| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 : Event(type, initializer) | 47 : Event(type, initializer) |
| 48 , m_dataType(DataTypeScriptValue) | 48 , m_dataType(DataTypeScriptValue) |
| 49 , m_source(nullptr) | 49 , m_source(nullptr) |
| 50 { | 50 { |
| 51 if (initializer.hasData()) | 51 if (initializer.hasData()) |
| 52 m_dataAsScriptValue = initializer.data(); | 52 m_dataAsScriptValue = initializer.data(); |
| 53 if (initializer.hasOrigin()) | 53 if (initializer.hasOrigin()) |
| 54 m_origin = initializer.origin(); | 54 m_origin = initializer.origin(); |
| 55 if (initializer.hasLastEventId()) | 55 if (initializer.hasLastEventId()) |
| 56 m_lastEventId = initializer.lastEventId(); | 56 m_lastEventId = initializer.lastEventId(); |
| 57 if (initializer.hasSource() && isValidSource(initializer.source().get())) | 57 if (initializer.hasSource() && isValidSource(initializer.source())) |
| 58 m_source = initializer.source(); | 58 m_source = initializer.source(); |
| 59 if (initializer.hasPorts()) | 59 if (initializer.hasPorts()) |
| 60 m_ports = new MessagePortArray(initializer.ports()); | 60 m_ports = new MessagePortArray(initializer.ports()); |
| 61 ASSERT(isValidSource(m_source.get())); | 61 ASSERT(isValidSource(m_source.get())); |
| 62 } | 62 } |
| 63 | 63 |
| 64 MessageEvent::MessageEvent(const String& origin, const String& lastEventId, Pass
RefPtrWillBeRawPtr<EventTarget> source, MessagePortArray* ports, const String& s
uborigin) | 64 MessageEvent::MessageEvent(const String& origin, const String& lastEventId, RawP
tr<EventTarget> source, MessagePortArray* ports, const String& suborigin) |
| 65 : Event(EventTypeNames::message, false, false) | 65 : Event(EventTypeNames::message, false, false) |
| 66 , m_dataType(DataTypeScriptValue) | 66 , m_dataType(DataTypeScriptValue) |
| 67 , m_origin(origin) | 67 , m_origin(origin) |
| 68 , m_lastEventId(lastEventId) | 68 , m_lastEventId(lastEventId) |
| 69 , m_source(source) | 69 , m_source(source) |
| 70 , m_ports(ports) | 70 , m_ports(ports) |
| 71 { | 71 { |
| 72 ASSERT(isValidSource(m_source.get())); | 72 ASSERT(isValidSource(m_source.get())); |
| 73 } | 73 } |
| 74 | 74 |
| 75 MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String&
origin, const String& lastEventId, PassRefPtrWillBeRawPtr<EventTarget> source,
MessagePortArray* ports, const String& suborigin) | 75 MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String&
origin, const String& lastEventId, RawPtr<EventTarget> source, MessagePortArray
* ports, const String& suborigin) |
| 76 : Event(EventTypeNames::message, false, false) | 76 : Event(EventTypeNames::message, false, false) |
| 77 , m_dataType(DataTypeSerializedScriptValue) | 77 , m_dataType(DataTypeSerializedScriptValue) |
| 78 , m_dataAsSerializedScriptValue(data) | 78 , m_dataAsSerializedScriptValue(data) |
| 79 , m_origin(origin) | 79 , m_origin(origin) |
| 80 , m_lastEventId(lastEventId) | 80 , m_lastEventId(lastEventId) |
| 81 , m_source(source) | 81 , m_source(source) |
| 82 , m_ports(ports) | 82 , m_ports(ports) |
| 83 { | 83 { |
| 84 if (m_dataAsSerializedScriptValue) | 84 if (m_dataAsSerializedScriptValue) |
| 85 m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptC
ontext(); | 85 m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptC
ontext(); |
| 86 ASSERT(isValidSource(m_source.get())); | 86 ASSERT(isValidSource(m_source.get())); |
| 87 } | 87 } |
| 88 | 88 |
| 89 MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String&
origin, const String& lastEventId, PassRefPtrWillBeRawPtr<EventTarget> source,
PassOwnPtr<MessagePortChannelArray> channels, const String& suborigin) | 89 MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String&
origin, const String& lastEventId, RawPtr<EventTarget> source, PassOwnPtr<Messa
gePortChannelArray> channels, const String& suborigin) |
| 90 : Event(EventTypeNames::message, false, false) | 90 : Event(EventTypeNames::message, false, false) |
| 91 , m_dataType(DataTypeSerializedScriptValue) | 91 , m_dataType(DataTypeSerializedScriptValue) |
| 92 , m_dataAsSerializedScriptValue(data) | 92 , m_dataAsSerializedScriptValue(data) |
| 93 , m_origin(origin) | 93 , m_origin(origin) |
| 94 , m_lastEventId(lastEventId) | 94 , m_lastEventId(lastEventId) |
| 95 , m_source(source) | 95 , m_source(source) |
| 96 , m_channels(channels) | 96 , m_channels(channels) |
| 97 , m_suborigin(suborigin) | 97 , m_suborigin(suborigin) |
| 98 { | 98 { |
| 99 if (m_dataAsSerializedScriptValue) | 99 if (m_dataAsSerializedScriptValue) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 122 , m_dataType(DataTypeArrayBuffer) | 122 , m_dataType(DataTypeArrayBuffer) |
| 123 , m_dataAsArrayBuffer(data) | 123 , m_dataAsArrayBuffer(data) |
| 124 , m_origin(origin) | 124 , m_origin(origin) |
| 125 { | 125 { |
| 126 } | 126 } |
| 127 | 127 |
| 128 MessageEvent::~MessageEvent() | 128 MessageEvent::~MessageEvent() |
| 129 { | 129 { |
| 130 } | 130 } |
| 131 | 131 |
| 132 PassRefPtrWillBeRawPtr<MessageEvent> MessageEvent::create(const AtomicString& ty
pe, const MessageEventInit& initializer, ExceptionState& exceptionState) | 132 RawPtr<MessageEvent> MessageEvent::create(const AtomicString& type, const Messag
eEventInit& initializer, ExceptionState& exceptionState) |
| 133 { | 133 { |
| 134 if (initializer.source().get() && !isValidSource(initializer.source().get())
) { | 134 if (initializer.source() && !isValidSource(initializer.source())) { |
| 135 exceptionState.throwTypeError("The optional 'source' property is neither
a Window nor MessagePort."); | 135 exceptionState.throwTypeError("The optional 'source' property is neither
a Window nor MessagePort."); |
| 136 return nullptr; | 136 return nullptr; |
| 137 } | 137 } |
| 138 return adoptRefWillBeNoop(new MessageEvent(type, initializer)); | 138 return new MessageEvent(type, initializer); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bo
ol cancelable, ScriptValue data, const String& origin, const String& lastEventId
, DOMWindow* source, MessagePortArray* ports) | 141 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bo
ol cancelable, ScriptValue data, const String& origin, const String& lastEventId
, DOMWindow* source, MessagePortArray* ports) |
| 142 { | 142 { |
| 143 if (dispatched()) | 143 if (dispatched()) |
| 144 return; | 144 return; |
| 145 | 145 |
| 146 initEvent(type, canBubble, cancelable); | 146 initEvent(type, canBubble, cancelable); |
| 147 | 147 |
| 148 m_dataType = DataTypeScriptValue; | 148 m_dataType = DataTypeScriptValue; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 break; | 231 break; |
| 232 case MessageEvent::DataTypeArrayBuffer: | 232 case MessageEvent::DataTypeArrayBuffer: |
| 233 V8HiddenValue::setHiddenValue(ScriptState::current(isolate), wrapper, V8
HiddenValue::arrayBufferData(isolate), toV8(dataAsArrayBuffer(), wrapper, isolat
e)); | 233 V8HiddenValue::setHiddenValue(ScriptState::current(isolate), wrapper, V8
HiddenValue::arrayBufferData(isolate), toV8(dataAsArrayBuffer(), wrapper, isolat
e)); |
| 234 break; | 234 break; |
| 235 } | 235 } |
| 236 | 236 |
| 237 return wrapper; | 237 return wrapper; |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace blink | 240 } // namespace blink |
| OLD | NEW |