From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/dom/MessageEvent.h | 107 ++++++++++++++------------------------ 1 file changed, 40 insertions(+), 67 deletions(-) (limited to 'Source/WebCore/dom/MessageEvent.h') diff --git a/Source/WebCore/dom/MessageEvent.h b/Source/WebCore/dom/MessageEvent.h index cfb2fa414..efd65b3c4 100644 --- a/Source/WebCore/dom/MessageEvent.h +++ b/Source/WebCore/dom/MessageEvent.h @@ -11,10 +11,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -25,80 +25,51 @@ * */ -#ifndef MessageEvent_h -#define MessageEvent_h +#pragma once -#include "Blob.h" #include "DOMWindow.h" #include "Event.h" #include "MessagePort.h" #include "SerializedScriptValue.h" #include -#include +#include namespace WebCore { -class EventTarget; +class Blob; -struct MessageEventInit : public EventInit { - MessageEventInit(); +using MessageEventSource = Variant, RefPtr>; - Deprecated::ScriptValue data; - String origin; - String lastEventId; - RefPtr source; - MessagePortArray ports; -}; - -class MessageEvent : public Event { +class MessageEvent final : public Event { public: - static PassRefPtr create() - { - return adoptRef(new MessageEvent); - } - static PassRefPtr create(PassOwnPtr ports, const Deprecated::ScriptValue& data = Deprecated::ScriptValue(), const String& origin = String(), const String& lastEventId = String(), PassRefPtr source = 0) - { - return adoptRef(new MessageEvent(data, origin, lastEventId, source, ports)); - } - static PassRefPtr create(PassOwnPtr ports, PassRefPtr data, const String& origin = String(), const String& lastEventId = String(), PassRefPtr source = 0) - { - return adoptRef(new MessageEvent(data, origin, lastEventId, source, ports)); - } - static PassRefPtr create(const String& data, const String& origin = String()) - { - return adoptRef(new MessageEvent(data, origin)); - } - static PassRefPtr create(PassRefPtr data, const String& origin = String()) - { - return adoptRef(new MessageEvent(data, origin)); - } - static PassRefPtr create(PassRefPtr data, const String& origin = String()) - { - return adoptRef(new MessageEvent(data, origin)); - } - static PassRefPtr create(const AtomicString& type, const MessageEventInit& initializer) - { - return adoptRef(new MessageEvent(type, initializer)); - } + static Ref create(Vector>&&, RefPtr&&, const String& origin = { }, const String& lastEventId = { }, std::optional&& source = std::nullopt); + static Ref create(const AtomicString& type, RefPtr&&, const String& origin, const String& lastEventId); + static Ref create(const String& data, const String& origin = { }); + static Ref create(Ref&& data, const String& origin); + static Ref create(Ref&& data, const String& origin = { }); + static Ref createForBindings(); + + struct Init : EventInit { + JSC::JSValue data; + String origin; + String lastEventId; + std::optional source; + Vector> ports; + }; + static Ref create(JSC::ExecState&, const AtomicString& type, Init&&, IsTrusted = IsTrusted::No); + virtual ~MessageEvent(); - void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr); - void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr); + void initMessageEvent(JSC::ExecState&, const AtomicString& type, bool canBubble, bool cancelable, JSC::JSValue data, const String& origin, const String& lastEventId, std::optional&&, Vector>&&); const String& origin() const { return m_origin; } const String& lastEventId() const { return m_lastEventId; } - EventTarget* source() const { return m_source.get(); } - MessagePortArray ports() const { return m_ports ? *m_ports : MessagePortArray(); } + EventTarget* source() const; + const Vector>& ports() const { return m_ports; } // FIXME: Remove this when we have custom ObjC binding support. SerializedScriptValue* data() const; - // Needed for Objective-C bindings (see bug 28774). - MessagePort* messagePort(); - void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePort*); - - virtual EventInterface eventInterface() const override; - enum DataType { DataTypeScriptValue, DataTypeSerializedScriptValue, @@ -107,34 +78,36 @@ public: DataTypeArrayBuffer }; DataType dataType() const { return m_dataType; } - const Deprecated::ScriptValue& dataAsScriptValue() const { ASSERT(m_dataType == DataTypeScriptValue); return m_dataAsScriptValue; } - PassRefPtr dataAsSerializedScriptValue() const { ASSERT(m_dataType == DataTypeSerializedScriptValue); return m_dataAsSerializedScriptValue; } + JSC::JSValue dataAsScriptValue() const { ASSERT(m_dataType == DataTypeScriptValue); return m_dataAsScriptValue; } + SerializedScriptValue* dataAsSerializedScriptValue() const { ASSERT(m_dataType == DataTypeSerializedScriptValue); return m_dataAsSerializedScriptValue.get(); } String dataAsString() const { ASSERT(m_dataType == DataTypeString); return m_dataAsString; } Blob* dataAsBlob() const { ASSERT(m_dataType == DataTypeBlob); return m_dataAsBlob.get(); } ArrayBuffer* dataAsArrayBuffer() const { ASSERT(m_dataType == DataTypeArrayBuffer); return m_dataAsArrayBuffer.get(); } + RefPtr trySerializeData(JSC::ExecState*); + private: MessageEvent(); - MessageEvent(const AtomicString&, const MessageEventInit&); - MessageEvent(const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, PassRefPtr source, PassOwnPtr); - MessageEvent(PassRefPtr data, const String& origin, const String& lastEventId, PassRefPtr source, PassOwnPtr); + MessageEvent(JSC::ExecState&, const AtomicString&, Init&&, IsTrusted); + MessageEvent(RefPtr&& data, const String& origin, const String& lastEventId, std::optional&&, Vector>&&); + MessageEvent(const AtomicString& type, RefPtr&& data, const String& origin, const String& lastEventId); + MessageEvent(const String& data, const String& origin); + MessageEvent(Ref&& data, const String& origin); + MessageEvent(Ref&& data, const String& origin); - explicit MessageEvent(const String& data, const String& origin); - explicit MessageEvent(PassRefPtr data, const String& origin); - explicit MessageEvent(PassRefPtr data, const String& origin); + EventInterface eventInterface() const final; DataType m_dataType; Deprecated::ScriptValue m_dataAsScriptValue; RefPtr m_dataAsSerializedScriptValue; + bool m_triedToSerialize { false }; String m_dataAsString; RefPtr m_dataAsBlob; RefPtr m_dataAsArrayBuffer; String m_origin; String m_lastEventId; - RefPtr m_source; - OwnPtr m_ports; + std::optional m_source; + Vector> m_ports; }; } // namespace WebCore - -#endif // MessageEvent_h -- cgit v1.2.1