Changeset 207505 in webkit


Ignore:
Timestamp:
Oct 18, 2016 5:05:09 PM (8 years ago)
Author:
weinig@apple.com
Message:

Simplify SerializedScriptValue, MessagePortArray and ArrayBufferArray to ease generation
https://bugs.webkit.org/show_bug.cgi?id=163625

Reviewed by Chris Dumez.

  • Replace uses of MessagePortArray (a.k.a. Vector<RefPtr<MessagePort>, 1>) with Vector<RefPtr<MessagePort>>.
  • Replace uses of ArrayBufferArray (a.k.a. Vector<RefPtr<ArrayBuffer>, 1>) with Vector<RefPtr<ArrayBuffer>>.
  • Add convenience functions to SerializedScriptValue to allow calling with fewer parameters.
  • Move MessagePorts and ArrayBuffers more where possible.
  • Modules/indexeddb/IDBObjectStore.cpp:

(WebCore::IDBObjectStore::putOrAdd):

  • Modules/indexeddb/server/UniqueIDBDatabase.cpp:

(WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):

  • bindings/js/IDBBindingUtilities.cpp:

(WebCore::deserializeIDBValueToJSValue):

  • bindings/js/JSCustomEventCustom.cpp:

(WebCore::JSCustomEvent::detail):

  • bindings/js/JSHistoryCustom.cpp:

(WebCore::JSHistory::state):
(WebCore::JSHistory::pushState):
(WebCore::JSHistory::replaceState):

  • bindings/js/JSPopStateEventCustom.cpp:

(WebCore::JSPopStateEvent::state):

  • dom/CustomEvent.cpp:

(WebCore::CustomEvent::trySerializeDetail):

  • dom/ErrorEvent.cpp:

(WebCore::ErrorEvent::sanitizedErrorValue):
(WebCore::ErrorEvent::trySerializeError):

  • dom/PopStateEvent.cpp:

(WebCore::PopStateEvent::trySerializeState):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::postMessage):

  • page/DOMWindow.h:
  • workers/DedicatedWorkerGlobalScope.cpp:

(WebCore::DedicatedWorkerGlobalScope::postMessage):

  • workers/DedicatedWorkerGlobalScope.h:
  • workers/Worker.cpp:

(WebCore::Worker::postMessage):

  • workers/Worker.h:
  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::handlePostMessage):

  • bindings/js/JSDictionary.cpp:

(WebCore::JSDictionary::convertValue):

  • bindings/js/JSDictionary.h:

Updated for new SerializedScriptValue interface/vector naming.

  • bindings/js/JSMessageEventCustom.cpp:

(WebCore::handleInitMessageEvent):
Update handleInitMessageEvent to check for exceptions and use convert for the MessagePort sequence.

  • bindings/js/JSMessagePortCustom.cpp:

(WebCore::extractTransferables):
(WebCore::fillMessagePortArray): Deleted.

  • bindings/js/JSMessagePortCustom.h:

(WebCore::handlePostMessage):
Rename fillMessagePortArray to extractTransferables to better express what it does.

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneSerializer::serialize):
(WebCore::CloneSerializer::CloneSerializer):
(WebCore::CloneSerializer::fillTransferMap):
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::CloneDeserializer::deserialize):
(WebCore::CloneDeserializer::CloneDeserializer):
(WebCore::CloneDeserializer::readTerminal):
(WebCore::SerializedScriptValue::transferArrayBuffers):
(WebCore::SerializedScriptValue::create):
(WebCore::SerializedScriptValue::deserialize):

  • bindings/js/SerializedScriptValue.h:

Simplify interface to allow more callers to avoid passing default arguments. Use ExecState& more.

  • bindings/scripts/CodeGeneratorJS.pm:

(GetNativeVectorType):
Remove special case for MessagePort.
(JSValueToNative):
(NativeToJSValue):
Updated for new SerializedScriptValue interface.

  • dom/MessageEvent.cpp:

(WebCore::MessageEvent::MessageEvent):
(WebCore::MessageEvent::create):
(WebCore::MessageEvent::initMessageEvent):
(WebCore::MessageEvent::trySerializeData):

  • dom/MessageEvent.h:

Store the MessagePort sequence as a Vector<RefPtr<MessagePort>> rather than in a unique_ptr.

  • dom/MessageEvent.idl:

Update last type in init functions to be sequence<MessagePort> rather than Array. They are still
custom, as we don't quite generate these correctly yet.

  • dom/MessagePort.cpp:

(WebCore::MessagePort::postMessage):
(WebCore::MessagePort::dispatchMessages):
(WebCore::MessagePort::disentanglePorts):
(WebCore::MessagePort::entanglePorts):

  • dom/MessagePort.h:

Update interface to take MessagePort vectors by rvalue reference.

Location:
trunk/Source/WebCore
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207501 r207505  
     12016-10-18  Sam Weinig  <sam@webkit.org>
     2
     3        Simplify SerializedScriptValue, MessagePortArray and ArrayBufferArray to ease generation
     4        https://bugs.webkit.org/show_bug.cgi?id=163625
     5
     6        Reviewed by Chris Dumez.
     7
     8        - Replace uses of MessagePortArray (a.k.a. Vector<RefPtr<MessagePort>, 1>) with Vector<RefPtr<MessagePort>>.
     9        - Replace uses of ArrayBufferArray (a.k.a. Vector<RefPtr<ArrayBuffer>, 1>) with Vector<RefPtr<ArrayBuffer>>.
     10        - Add convenience functions to SerializedScriptValue to allow calling with fewer parameters.
     11        - Move MessagePorts and ArrayBuffers more where possible.
     12
     13        * Modules/indexeddb/IDBObjectStore.cpp:
     14        (WebCore::IDBObjectStore::putOrAdd):
     15        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
     16        (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
     17        * bindings/js/IDBBindingUtilities.cpp:
     18        (WebCore::deserializeIDBValueToJSValue):
     19        * bindings/js/JSCustomEventCustom.cpp:
     20        (WebCore::JSCustomEvent::detail):
     21        * bindings/js/JSHistoryCustom.cpp:
     22        (WebCore::JSHistory::state):
     23        (WebCore::JSHistory::pushState):
     24        (WebCore::JSHistory::replaceState):
     25        * bindings/js/JSPopStateEventCustom.cpp:
     26        (WebCore::JSPopStateEvent::state):
     27        * dom/CustomEvent.cpp:
     28        (WebCore::CustomEvent::trySerializeDetail):
     29        * dom/ErrorEvent.cpp:
     30        (WebCore::ErrorEvent::sanitizedErrorValue):
     31        (WebCore::ErrorEvent::trySerializeError):
     32        * dom/PopStateEvent.cpp:
     33        (WebCore::PopStateEvent::trySerializeState):
     34        * page/DOMWindow.cpp:
     35        (WebCore::DOMWindow::postMessage):
     36        * page/DOMWindow.h:
     37        * workers/DedicatedWorkerGlobalScope.cpp:
     38        (WebCore::DedicatedWorkerGlobalScope::postMessage):
     39        * workers/DedicatedWorkerGlobalScope.h:
     40        * workers/Worker.cpp:
     41        (WebCore::Worker::postMessage):
     42        * workers/Worker.h:
     43        * bindings/js/JSDOMWindowCustom.cpp:
     44        (WebCore::handlePostMessage):
     45        * bindings/js/JSDictionary.cpp:
     46        (WebCore::JSDictionary::convertValue):
     47        * bindings/js/JSDictionary.h:
     48        Updated for new SerializedScriptValue interface/vector naming.
     49
     50        * bindings/js/JSMessageEventCustom.cpp:
     51        (WebCore::handleInitMessageEvent):
     52        Update handleInitMessageEvent to check for exceptions and use convert for the MessagePort sequence.
     53
     54        * bindings/js/JSMessagePortCustom.cpp:
     55        (WebCore::extractTransferables):
     56        (WebCore::fillMessagePortArray): Deleted.
     57        * bindings/js/JSMessagePortCustom.h:
     58        (WebCore::handlePostMessage):
     59        Rename fillMessagePortArray to extractTransferables to better express what it does.
     60
     61        * bindings/js/SerializedScriptValue.cpp:
     62        (WebCore::CloneSerializer::serialize):
     63        (WebCore::CloneSerializer::CloneSerializer):
     64        (WebCore::CloneSerializer::fillTransferMap):
     65        (WebCore::CloneSerializer::dumpIfTerminal):
     66        (WebCore::CloneDeserializer::deserialize):
     67        (WebCore::CloneDeserializer::CloneDeserializer):
     68        (WebCore::CloneDeserializer::readTerminal):
     69        (WebCore::SerializedScriptValue::transferArrayBuffers):
     70        (WebCore::SerializedScriptValue::create):
     71        (WebCore::SerializedScriptValue::deserialize):
     72        * bindings/js/SerializedScriptValue.h:
     73        Simplify interface to allow more callers to avoid passing default arguments. Use ExecState& more.
     74        * bindings/scripts/CodeGeneratorJS.pm:
     75        (GetNativeVectorType):
     76        Remove special case for MessagePort.
     77        (JSValueToNative):
     78        (NativeToJSValue):
     79        Updated for new SerializedScriptValue interface.
     80
     81        * dom/MessageEvent.cpp:
     82        (WebCore::MessageEvent::MessageEvent):
     83        (WebCore::MessageEvent::create):
     84        (WebCore::MessageEvent::initMessageEvent):
     85        (WebCore::MessageEvent::trySerializeData):
     86        * dom/MessageEvent.h:
     87        Store the MessagePort sequence as a Vector<RefPtr<MessagePort>> rather than in a unique_ptr.
     88
     89        * dom/MessageEvent.idl:
     90        Update last type in init functions to be sequence<MessagePort> rather than Array. They are still
     91        custom, as we don't quite generate these correctly yet.
     92
     93        * dom/MessagePort.cpp:
     94        (WebCore::MessagePort::postMessage):
     95        (WebCore::MessagePort::dispatchMessages):
     96        (WebCore::MessagePort::disentanglePorts):
     97        (WebCore::MessagePort::entanglePorts):
     98        * dom/MessagePort.h:
     99        Update interface to take MessagePort vectors by rvalue reference.
     100
    11012016-10-18  Chris Dumez  <cdumez@apple.com>
    2102
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp

    r206976 r207505  
    237237        return Exception { IDBDatabaseException::ReadOnlyError, ASCIILiteral("Failed to store record in an IDBObjectStore: The transaction is read-only.") };
    238238
    239     RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(&state, value, nullptr, nullptr);
     239    auto serializedValue = SerializedScriptValue::create(state, value);
    240240    if (UNLIKELY(scope.exception())) {
    241241        // Clear the DOM exception from the serializer so we can give a more targeted exception.
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

    r205569 r207505  
    875875        }
    876876
    877         auto serializedValue = SerializedScriptValue::create(&databaseThreadExecState(), value, nullptr, nullptr);
     877        auto serializedValue = SerializedScriptValue::create(databaseThreadExecState(), value);
    878878        if (UNLIKELY(scope.exception())) {
    879879            postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBDatabaseException::ConstraintError, ASCIILiteral("Unable to serialize record value after injecting record key")), usedKey));
  • trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp

    r207150 r207505  
    4141#include "JSDOMStringList.h"
    4242#include "Logging.h"
     43#include "MessagePort.h"
    4344#include "ScriptExecutionContext.h"
    4445#include "SerializedScriptValue.h"
     
    329330
    330331    exec.vm().apiLock().lock();
    331     JSValue result = serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing, value.blobURLs(), value.blobFilePaths());
     332    Vector<RefPtr<MessagePort>> messagePorts;
     333    JSValue result = serializedValue->deserialize(exec, exec.lexicalGlobalObject(), messagePorts, value.blobURLs(), value.blobFilePaths(), NonThrowing);
    332334    exec.vm().apiLock().unlock();
    333335
  • trunk/Source/WebCore/bindings/js/JSCustomEventCustom.cpp

    r202023 r207505  
    5151        if (!serializedDetail)
    5252            return jsNull();
    53         return serializedDetail->deserialize(&state, globalObject(), nullptr);
     53        return serializedDetail->deserialize(state, globalObject());
    5454    }
    5555
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r206777 r207505  
    506506        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    507507
    508     MessagePortArray messagePorts;
    509     ArrayBufferArray arrayBuffers;
     508    Vector<RefPtr<MessagePort>> messagePorts;
     509    Vector<RefPtr<JSC::ArrayBuffer>> arrayBuffers;
    510510
    511511    // This function has variable arguments and can be:
     
    522522            transferablesArgIndex = 1;
    523523        }
    524         fillMessagePortArray(state, state.argument(transferablesArgIndex), messagePorts, arrayBuffers);
    525     }
    526     RETURN_IF_EXCEPTION(scope, JSValue());
    527 
    528     auto message = SerializedScriptValue::create(&state, state.uncheckedArgument(0), &messagePorts, &arrayBuffers);
     524        extractTransferables(state, state.argument(transferablesArgIndex), messagePorts, arrayBuffers);
     525    }
     526    RETURN_IF_EXCEPTION(scope, JSValue());
     527
     528    auto message = SerializedScriptValue::create(state, state.uncheckedArgument(0), messagePorts, WTFMove(arrayBuffers));
    529529
    530530    RETURN_IF_EXCEPTION(scope, JSValue());
     
    534534
    535535    ExceptionCode ec = 0;
    536     impl.postMessage(WTFMove(message), &messagePorts, targetOrigin, callerDOMWindow(&state), ec);
     536    impl.postMessage(WTFMove(message), WTFMove(messagePorts), targetOrigin, callerDOMWindow(&state), ec);
    537537    setDOMException(&state, ec);
    538538
  • trunk/Source/WebCore/bindings/js/JSDictionary.cpp

    r207501 r207505  
    3131#include "Dictionary.h"
    3232#include "JSCSSFontFaceRule.h"
     33#include "JSDOMConvert.h"
    3334#include "JSDOMError.h"
    3435#include "JSDOMWindow.h"
    3536#include "JSEventTarget.h"
    36 #include "JSMessagePortCustom.h"
     37#include "JSMessagePort.h"
    3738#include "JSNode.h"
    3839#include "JSStorage.h"
     
    178179void JSDictionary::convertValue(ExecState* exec, JSValue value, RefPtr<SerializedScriptValue>& result)
    179180{
    180     result = SerializedScriptValue::create(exec, value, 0, 0);
     181    result = SerializedScriptValue::create(*exec, value);
    181182}
    182183
     
    209210}
    210211
    211 void JSDictionary::convertValue(ExecState* exec, JSValue value, MessagePortArray& result)
    212 {
    213     ArrayBufferArray arrayBuffers;
    214     fillMessagePortArray(*exec, value, result, arrayBuffers);
     212void JSDictionary::convertValue(ExecState* exec, JSValue value, Vector<RefPtr<MessagePort>>& result)
     213{
     214    result = convert<IDLSequence<IDLInterface<MessagePort>>>(*exec, value);
    215215}
    216216
  • trunk/Source/WebCore/bindings/js/JSDictionary.h

    r206983 r207505  
    137137    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Node>& result);
    138138    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Storage>& result);
    139     static void convertValue(JSC::ExecState*, JSC::JSValue, MessagePortArray& result);
     139    static void convertValue(JSC::ExecState*, JSC::JSValue, Vector<RefPtr<MessagePort>>& result);
    140140#if ENABLE(VIDEO_TRACK)
    141141    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<TrackBase>& result);
  • trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp

    r206976 r207505  
    4949
    5050    RefPtr<SerializedScriptValue> serialized = history.state();
    51     JSValue result = serialized ? serialized->deserialize(&state, globalObject(), 0) : jsNull();
     51    JSValue result = serialized ? serialized->deserialize(state, globalObject()) : jsNull();
    5252    m_state.set(state.vm(), this, result);
    5353    return result;
     
    6363        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    6464
    65     auto historyState = SerializedScriptValue::create(&state, state.uncheckedArgument(0), 0, 0);
     65    auto historyState = SerializedScriptValue::create(state, state.uncheckedArgument(0));
    6666    RETURN_IF_EXCEPTION(scope, JSValue());
    6767
     
    9292        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    9393
    94     auto historyState = SerializedScriptValue::create(&state, state.uncheckedArgument(0), 0, 0);
     94    auto historyState = SerializedScriptValue::create(state, state.uncheckedArgument(0));
    9595    RETURN_IF_EXCEPTION(scope, JSValue());
    9696
  • trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp

    r207381 r207505  
    3434#include "JSBlob.h"
    3535#include "JSDOMBinding.h"
     36#include "JSDOMConvert.h"
    3637#include "JSDOMWindow.h"
    3738#include "JSEventTarget.h"
    3839#include "JSMessagePort.h"
    39 #include "JSMessagePortCustom.h"
    4040#include "MessageEvent.h"
    4141#include <runtime/JSArray.h>
     
    6868                RefPtr<SerializedScriptValue> serializedValue = event.trySerializeData(&state);
    6969                if (serializedValue)
    70                     result = serializedValue->deserialize(&state, globalObject(), nullptr);
     70                    result = serializedValue->deserialize(state, globalObject());
    7171                else
    7272                    result = jsNull();
     
    7979    case MessageEvent::DataTypeSerializedScriptValue:
    8080        if (RefPtr<SerializedScriptValue> serializedValue = event.dataAsSerializedScriptValue()) {
    81             MessagePortArray ports = wrapped().ports();
     81            Vector<RefPtr<MessagePort>> ports = wrapped().ports();
    8282            // FIXME: Why does this suppress exceptions?
    83             result = serializedValue->deserialize(&state, globalObject(), &ports, NonThrowing);
     83            result = serializedValue->deserialize(state, globalObject(), ports, NonThrowing);
    8484        } else
    8585            result = jsNull();
     
    110110
    111111    const String& typeArg = state.argument(0).toString(&state)->value(&state);
     112    RETURN_IF_EXCEPTION(scope, JSValue());
     113
    112114    bool canBubbleArg = state.argument(1).toBoolean(&state);
     115    RETURN_IF_EXCEPTION(scope, JSValue());
     116
    113117    bool cancelableArg = state.argument(2).toBoolean(&state);
     118    RETURN_IF_EXCEPTION(scope, JSValue());
     119
     120    JSValue dataArg = state.argument(3);
     121
    114122    const String originArg = valueToUSVString(&state, state.argument(4));
     123    RETURN_IF_EXCEPTION(scope, JSValue());
     124
    115125    const String lastEventIdArg = state.argument(5).toString(&state)->value(&state);
     126    RETURN_IF_EXCEPTION(scope, JSValue());
     127
    116128    auto sourceArg = convert<IDLNullable<IDLUnion<IDLInterface<DOMWindow>, IDLInterface<MessagePort>>>>(state, state.argument(6));
    117     std::unique_ptr<MessagePortArray> messagePorts;
    118     std::unique_ptr<ArrayBufferArray> arrayBuffers;
     129    RETURN_IF_EXCEPTION(scope, JSValue());
     130   
     131    Vector<RefPtr<MessagePort>> messagePorts;
    119132    if (!state.argument(7).isUndefinedOrNull()) {
    120         messagePorts = std::make_unique<MessagePortArray>();
    121         arrayBuffers = std::make_unique<ArrayBufferArray>();
    122         fillMessagePortArray(state, state.argument(7), *messagePorts, *arrayBuffers);
     133        messagePorts = convert<IDLSequence<IDLInterface<MessagePort>>>(state, state.argument(7));
    123134        RETURN_IF_EXCEPTION(scope, JSValue());
    124135    }
    125     Deprecated::ScriptValue dataArg(vm, state.argument(3));
    126     RETURN_IF_EXCEPTION(scope, JSValue());
    127136
    128137    MessageEvent& event = jsEvent->wrapped();
    129     event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, WTFMove(sourceArg), WTFMove(messagePorts));
    130     jsEvent->m_data.set(vm, jsEvent, dataArg.jsValue());
     138    event.initMessageEvent(state, typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, WTFMove(sourceArg), WTFMove(messagePorts));
     139    jsEvent->m_data.set(vm, jsEvent, dataArg);
    131140    return jsUndefined();
    132141}
  • trunk/Source/WebCore/bindings/js/JSMessagePortCustom.cpp

    r206386 r207505  
    5858}
    5959
    60 void fillMessagePortArray(JSC::ExecState& state, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers)
     60void extractTransferables(JSC::ExecState& state, JSC::JSValue value, Vector<RefPtr<MessagePort>>& portArray, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers)
    6161{
    6262    VM& vm = state.vm();
    6363    auto scope = DECLARE_THROW_SCOPE(vm);
    6464
    65     // Convert from the passed-in JS array-like object to a MessagePortArray.
    66     // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec.
    6765    if (value.isUndefinedOrNull()) {
    6866        portArray.resize(0);
     
    7977        JSValue value = object->get(&state, i);
    8078        RETURN_IF_EXCEPTION(scope, void());
    81         // Validation of non-null objects, per HTML5 spec 10.3.3.
     79
    8280        if (value.isUndefinedOrNull()) {
    8381            setDOMException(&state, INVALID_STATE_ERR);
  • trunk/Source/WebCore/bindings/js/JSMessagePortCustom.h

    r206386 r207505  
    4343    typedef int ExceptionCode;
    4444
    45     // Helper function which pulls the values out of a JS sequence and into a MessagePortArray.
    46     // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec.
    47     // May generate an exception via the passed ExecState.
    48     void fillMessagePortArray(JSC::ExecState&, JSC::JSValue, MessagePortArray&, ArrayBufferArray&);
     45    void extractTransferables(JSC::ExecState&, JSC::JSValue, Vector<RefPtr<MessagePort>>&, Vector<RefPtr<JSC::ArrayBuffer>>&);
    4946
    5047    // Helper function to convert from JS postMessage arguments to WebCore postMessage arguments.
     
    5855            return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    5956
    60         MessagePortArray portArray;
    61         ArrayBufferArray arrayBufferArray;
    62         fillMessagePortArray(state, state.argument(1), portArray, arrayBufferArray);
    63         auto message = SerializedScriptValue::create(&state, state.uncheckedArgument(0), &portArray, &arrayBufferArray);
     57       
     58        Vector<RefPtr<MessagePort>> messagePortArray;
     59        Vector<RefPtr<JSC::ArrayBuffer>> arrayBufferArray;
     60        extractTransferables(state, state.argument(1), messagePortArray, arrayBufferArray);
     61       
     62        auto message = SerializedScriptValue::create(state, state.uncheckedArgument(0), messagePortArray, WTFMove(arrayBufferArray));
    6463        RETURN_IF_EXCEPTION(scope, JSC::JSValue());
    6564
    6665        ExceptionCode ec = 0;
    67         impl->postMessage(WTFMove(message), &portArray, ec);
     66        impl->postMessage(WTFMove(message), WTFMove(messagePortArray), ec);
    6867        setDOMException(&state, ec);
    6968        return JSC::jsUndefined();
  • trunk/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp

    r205462 r207505  
    6565        if (eventState.isObject() && &worldForDOMObject(eventState.getObject()) != &currentWorld(&state)) {
    6666            if (auto serializedValue = event.trySerializeState(&state))
    67                 eventState = serializedValue->deserialize(&state, globalObject(), nullptr);
     67                eventState = serializedValue->deserialize(state, globalObject());
    6868            else
    6969                eventState = jsNull();
     
    8989        result = jsHistory->state(state);
    9090    } else
    91         result = event.serializedState()->deserialize(&state, globalObject(), 0);
     91        result = event.serializedState()->deserialize(state, globalObject());
    9292
    9393    return cacheState(state, this, result);
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r206196 r207505  
    475475class CloneSerializer : CloneBase {
    476476public:
    477     static SerializationReturnCode serialize(ExecState* exec, JSValue value,
    478                                              MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers,
    479                                              Vector<String>& blobURLs, Vector<uint8_t>& out)
     477    static SerializationReturnCode serialize(ExecState* exec, JSValue value, Vector<RefPtr<MessagePort>>& messagePorts, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers, Vector<String>& blobURLs, Vector<uint8_t>& out)
    480478    {
    481479        CloneSerializer serializer(exec, messagePorts, arrayBuffers, blobURLs, out);
     
    526524    typedef HashMap<JSObject*, uint32_t> ObjectPool;
    527525
    528     CloneSerializer(ExecState* exec, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, Vector<String>& blobURLs, Vector<uint8_t>& out)
     526    CloneSerializer(ExecState* exec, Vector<RefPtr<MessagePort>>& messagePorts, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers, Vector<String>& blobURLs, Vector<uint8_t>& out)
    529527        : CloneBase(exec)
    530528        , m_buffer(out)
     
    538536
    539537    template <class T>
    540     void fillTransferMap(Vector<RefPtr<T>, 1>* input, ObjectPool& result)
    541     {
    542         if (!input)
     538    void fillTransferMap(Vector<RefPtr<T>>& input, ObjectPool& result)
     539    {
     540        if (input.isEmpty())
    543541            return;
    544542        JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject());
    545         for (size_t i = 0; i < input->size(); i++) {
    546             JSC::JSValue value = toJS(m_exec, globalObject, input->at(i).get());
     543        for (size_t i = 0; i < input.size(); i++) {
     544            JSC::JSValue value = toJS(m_exec, globalObject, input[i].get());
    547545            JSC::JSObject* obj = value.getObject();
    548546            if (obj && !result.contains(obj))
     
    878876                Vector<uint8_t> serializedKey;
    879877                Vector<String> dummyBlobURLs;
    880                 CloneSerializer rawKeySerializer(m_exec, nullptr, nullptr, dummyBlobURLs, serializedKey);
     878                Vector<RefPtr<MessagePort>> dummyMessagePorts;
     879                Vector<RefPtr<JSC::ArrayBuffer>> dummyArrayBuffers;
     880                CloneSerializer rawKeySerializer(m_exec, dummyMessagePorts, dummyArrayBuffers, dummyBlobURLs, serializedKey);
    881881                rawKeySerializer.write(key);
    882882                Vector<uint8_t> wrappedKey;
     
    14881488    }
    14891489
    1490     static DeserializationResult deserialize(ExecState* exec, JSGlobalObject* globalObject, MessagePortArray* messagePorts, ArrayBufferContentsArray* arrayBufferContentsArray, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths)
     1490    static DeserializationResult deserialize(ExecState* exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContentsArray, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths)
    14911491    {
    14921492        if (!buffer.size())
     
    15371537    };
    15381538
    1539     CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, MessagePortArray* messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer)
     1539    CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer)
    15401540        : CloneBase(exec)
    15411541        , m_globalObject(globalObject)
     
    15521552    }
    15531553
    1554     CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, MessagePortArray* messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths)
     1554    CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths)
    15551555        : CloneBase(exec)
    15561556        , m_globalObject(globalObject)
     
    23482348            uint32_t index;
    23492349            bool indexSuccessfullyRead = read(index);
    2350             if (!indexSuccessfullyRead || !m_messagePorts || index >= m_messagePorts->size()) {
     2350            if (!indexSuccessfullyRead || index >= m_messagePorts.size()) {
    23512351                fail();
    23522352                return JSValue();
    23532353            }
    2354             return getJSValue(m_messagePorts->at(index).get());
     2354            return getJSValue(m_messagePorts[index].get());
    23552355        }
    23562356        case ArrayBufferTag: {
     
    23992399            }
    24002400            JSValue cryptoKey;
    2401             CloneDeserializer rawKeyDeserializer(m_exec, m_globalObject, nullptr, nullptr, serializedKey);
     2401            Vector<RefPtr<MessagePort>> dummyMessagePorts;
     2402            CloneDeserializer rawKeyDeserializer(m_exec, m_globalObject, dummyMessagePorts, nullptr, serializedKey);
    24022403            if (!rawKeyDeserializer.readCryptoKey(cryptoKey)) {
    24032404                fail();
     
    24292430    unsigned m_version;
    24302431    Vector<CachedString> m_constantPool;
    2431     MessagePortArray* m_messagePorts;
     2432    Vector<RefPtr<MessagePort>>& m_messagePorts;
    24322433    ArrayBufferContentsArray* m_arrayBufferContents;
    2433     ArrayBufferArray m_arrayBuffers;
     2434    Vector<RefPtr<JSC::ArrayBuffer>> m_arrayBuffers;
    24342435    Vector<String> m_blobURLs;
    24352436    Vector<String> m_blobFilePaths;
     
    26552656
    26562657std::unique_ptr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValue::transferArrayBuffers(
    2657     ExecState* exec, ArrayBufferArray& arrayBuffers, SerializationReturnCode& code)
     2658    ExecState* exec, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers, SerializationReturnCode& code)
    26582659{
    26592660    for (size_t i = 0; i < arrayBuffers.size(); i++) {
     
    26832684}
    26842685
    2685 RefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState* exec, JSValue value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, SerializationErrorMode throwExceptions)
     2686RefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState& exec, JSValue value, SerializationErrorMode throwExceptions)
     2687{
     2688    Vector<RefPtr<MessagePort>> messagePorts;
     2689    return SerializedScriptValue::create(exec, value, messagePorts, { }, throwExceptions);
     2690}
     2691
     2692RefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState& exec, JSValue value, Vector<RefPtr<MessagePort>>& messagePorts, Vector<RefPtr<JSC::ArrayBuffer>>&& arrayBuffers, SerializationErrorMode throwExceptions)
    26862693{
    26872694    Vector<uint8_t> buffer;
    26882695    Vector<String> blobURLs;
    2689     SerializationReturnCode code = CloneSerializer::serialize(exec, value, messagePorts, arrayBuffers, blobURLs, buffer);
     2696    SerializationReturnCode code = CloneSerializer::serialize(&exec, value, messagePorts, arrayBuffers, blobURLs, buffer);
    26902697
    26912698    std::unique_ptr<ArrayBufferContentsArray> arrayBufferContentsArray;
    2692 
    2693     if (arrayBuffers && serializationDidCompleteSuccessfully(code))
    2694         arrayBufferContentsArray = transferArrayBuffers(exec, *arrayBuffers, code);
     2699    if (!arrayBuffers.isEmpty() && serializationDidCompleteSuccessfully(code))
     2700        arrayBufferContentsArray = transferArrayBuffers(&exec, arrayBuffers, code);
    26952701
    26962702    if (throwExceptions == Throwing)
    2697         maybeThrowExceptionIfSerializationFailed(exec, code);
     2703        maybeThrowExceptionIfSerializationFailed(&exec, code);
    26982704
    26992705    if (!serializationDidCompleteSuccessfully(code))
     
    27192725
    27202726    JSValue value = toJS(exec, apiValue);
    2721     RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(exec, value, nullptr, nullptr);
     2727    RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(*exec, value);
    27222728    if (UNLIKELY(scope.exception())) {
    27232729        if (exception)
     
    27352741}
    27362742
    2737 JSValue SerializedScriptValue::deserialize(ExecState* exec, JSGlobalObject* globalObject, MessagePortArray* messagePorts, SerializationErrorMode throwExceptions)
    2738 {
    2739     Vector<String> dummyBlobs, dummyPaths;
    2740     return deserialize(exec, globalObject, messagePorts, throwExceptions, dummyBlobs, dummyPaths);
    2741 }
    2742 
    2743 JSValue SerializedScriptValue::deserialize(ExecState* exec, JSGlobalObject* globalObject, MessagePortArray* messagePorts, SerializationErrorMode throwExceptions, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths)
    2744 {
    2745     DeserializationResult result = CloneDeserializer::deserialize(exec, globalObject, messagePorts, m_arrayBufferContentsArray.get(), m_data, blobURLs, blobFilePaths);
     2743JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, SerializationErrorMode throwExceptions)
     2744{
     2745    Vector<RefPtr<MessagePort>> dummyMessagePorts;
     2746    return deserialize(exec, globalObject, dummyMessagePorts, throwExceptions);
     2747}
     2748
     2749JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, SerializationErrorMode throwExceptions)
     2750{
     2751    Vector<String> dummyBlobs;
     2752    Vector<String> dummyPaths;
     2753    return deserialize(exec, globalObject, messagePorts, dummyBlobs, dummyPaths, throwExceptions);
     2754}
     2755
     2756JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths, SerializationErrorMode throwExceptions)
     2757{
     2758    DeserializationResult result = CloneDeserializer::deserialize(&exec, globalObject, messagePorts, m_arrayBufferContentsArray.get(), m_data, blobURLs, blobFilePaths);
    27462759    if (throwExceptions == Throwing)
    2747         maybeThrowExceptionIfSerializationFailed(exec, result.second);
     2760        maybeThrowExceptionIfSerializationFailed(&exec, result.second);
    27482761    return result.first ? result.first : jsNull();
    27492762}
     
    27562769    auto scope = DECLARE_CATCH_SCOPE(vm);
    27572770
    2758     JSValue value = deserialize(exec, exec->lexicalGlobalObject(), nullptr);
     2771    JSValue value = deserialize(*exec, exec->lexicalGlobalObject());
    27592772    if (UNLIKELY(scope.exception())) {
    27602773        if (exception)
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.h

    r202530 r207505  
    4343class IDBValue;
    4444class MessagePort;
    45 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;
    46 typedef Vector<RefPtr<JSC::ArrayBuffer>, 1> ArrayBufferArray;
    4745 
    4846enum SerializationReturnCode {
     
    6260class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue> {
    6361public:
    64     WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSC::ExecState*, JSC::JSValue, MessagePortArray*, ArrayBufferArray*, SerializationErrorMode = Throwing);
     62    WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSC::ExecState&, JSC::JSValue, SerializationErrorMode = Throwing);
     63    WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSC::ExecState&, JSC::JSValue, Vector<RefPtr<MessagePort>>&, Vector<RefPtr<JSC::ArrayBuffer>>&&, SerializationErrorMode = Throwing);
    6564
    6665    WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(StringView);
     
    7271    static Ref<SerializedScriptValue> nullValue();
    7372
    74     WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState*, JSC::JSGlobalObject*, MessagePortArray*, SerializationErrorMode = Throwing);
    75     JSC::JSValue deserialize(JSC::ExecState*, JSC::JSGlobalObject*, MessagePortArray*, SerializationErrorMode, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths);
     73    WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, SerializationErrorMode = Throwing);
     74    WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, Vector<RefPtr<MessagePort>>&, SerializationErrorMode = Throwing);
     75    JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, Vector<RefPtr<MessagePort>>&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths, SerializationErrorMode = Throwing);
    7676
    7777    static uint32_t wireFormatVersion();
     
    104104    static void maybeThrowExceptionIfSerializationFailed(JSC::ExecState*, SerializationReturnCode);
    105105    static bool serializationDidCompleteSuccessfully(SerializationReturnCode);
    106     static std::unique_ptr<ArrayBufferContentsArray> transferArrayBuffers(JSC::ExecState*, ArrayBufferArray&, SerializationReturnCode&);
     106    static std::unique_ptr<ArrayBufferContentsArray> transferArrayBuffers(JSC::ExecState*, Vector<RefPtr<JSC::ArrayBuffer>>&, SerializationReturnCode&);
    107107
    108108    WEBCORE_EXPORT SerializedScriptValue(Vector<unsigned char>&&);
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r207498 r207505  
    49064906
    49074907    my $innerType = $codeGenerator->GetSequenceOrFrozenArrayInnerType($type);
    4908     return "MessagePortArray" if $innerType eq "MessagePort";
    49094908    return "Vector<" . GetNativeVectorInnerType($innerType) . ">";
    49104909}
     
    51695168    if ($type eq "SerializedScriptValue") {
    51705169        AddToImplIncludes("SerializedScriptValue.h", $conditional);
    5171         return ("SerializedScriptValue::create($statePointer, $value, 0, 0)", 1);
     5170        return ("SerializedScriptValue::create($stateReference, $value)", 1);
    51725171    }
    51735172
     
    52755274    if ($type eq "SerializedScriptValue") {
    52765275        AddToImplIncludes("SerializedScriptValue.h", $conditional);
    5277         return "$value ? $value->deserialize($statePointer, $globalObject, 0) : jsNull()";
     5276        return "$value ? $value->deserialize($stateReference, $globalObject) : jsNull()";
    52785277    }
    52795278
  • trunk/Source/WebCore/dom/CustomEvent.cpp

    r206964 r207505  
    6262{
    6363    if (!m_triedToSerialize) {
    64         m_serializedDetail = SerializedScriptValue::create(&state, m_detail, nullptr, nullptr, NonThrowing);
     64        m_serializedDetail = SerializedScriptValue::create(state, m_detail, NonThrowing);
    6565        m_triedToSerialize = true;
    6666    }
  • trunk/Source/WebCore/dom/ErrorEvent.cpp

    r207215 r207505  
    8282        if (!serializedError)
    8383            return jsNull();
    84         return serializedError->deserialize(&exec, &globalObject, nullptr);
     84        return serializedError->deserialize(exec, &globalObject);
    8585    }
    8686
     
    9191{
    9292    if (!m_triedToSerialize) {
    93         m_serializedDetail = SerializedScriptValue::create(&exec, m_error, nullptr, nullptr, NonThrowing);
     93        m_serializedDetail = SerializedScriptValue::create(exec, m_error, NonThrowing);
    9494        m_triedToSerialize = true;
    9595    }
  • trunk/Source/WebCore/dom/MessageEvent.cpp

    r207381 r207505  
    4949    , m_lastEventId(initializer.lastEventId)
    5050    , m_source(WTFMove(initializer.source))
    51     , m_ports(std::make_unique<MessagePortArray>(initializer.ports))
    52 {
    53 }
    54 
    55 inline MessageEvent::MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray> ports)
     51    , m_ports(WTFMove(initializer.ports))
     52{
     53}
     54
     55inline MessageEvent::MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, Vector<RefPtr<MessagePort>>&& ports)
    5656    : Event(eventNames().messageEvent, false, false)
    5757    , m_dataType(DataTypeSerializedScriptValue)
     
    9797}
    9898
    99 Ref<MessageEvent> MessageEvent::create(std::unique_ptr<MessagePortArray> ports, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source)
     99Ref<MessageEvent> MessageEvent::create(Vector<RefPtr<MessagePort>>&& ports, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source)
    100100{
    101101    return adoptRef(*new MessageEvent(WTFMove(data), origin, lastEventId, WTFMove(source), WTFMove(ports)));
     
    136136}
    137137
    138 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray> ports)
     138void MessageEvent::initMessageEvent(ExecState& state, const AtomicString& type, bool canBubble, bool cancelable, JSValue data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, Vector<RefPtr<MessagePort>>&& ports)
    139139{
    140140    if (dispatched())
     
    144144
    145145    m_dataType = DataTypeScriptValue;
    146     m_dataAsScriptValue = data;
     146    m_dataAsScriptValue = Deprecated::ScriptValue(state.vm(), data);
    147147    m_dataAsSerializedScriptValue = nullptr;
    148148    m_triedToSerialize = false;
     
    153153}
    154154
    155 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray> ports)
     155void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, Vector<RefPtr<MessagePort>>&& ports)
    156156{
    157157    if (dispatched())
     
    186186   
    187187    if (!m_dataAsSerializedScriptValue && !m_triedToSerialize) {
    188         m_dataAsSerializedScriptValue = SerializedScriptValue::create(exec, m_dataAsScriptValue.jsValue(), nullptr, nullptr, NonThrowing);
     188        m_dataAsSerializedScriptValue = SerializedScriptValue::create(*exec, m_dataAsScriptValue.jsValue(), NonThrowing);
    189189        m_triedToSerialize = true;
    190190    }
  • trunk/Source/WebCore/dom/MessageEvent.h

    r207381 r207505  
    4343class MessageEvent final : public Event {
    4444public:
    45     static Ref<MessageEvent> create(std::unique_ptr<MessagePortArray>, RefPtr<SerializedScriptValue>&&, const String& origin = { }, const String& lastEventId = { }, Optional<MessageEventSource>&& source = Nullopt);
     45    static Ref<MessageEvent> create(Vector<RefPtr<MessagePort>>&&, RefPtr<SerializedScriptValue>&&, const String& origin = { }, const String& lastEventId = { }, Optional<MessageEventSource>&& source = Nullopt);
    4646    static Ref<MessageEvent> create(const AtomicString& type, RefPtr<SerializedScriptValue>&&, const String& origin, const String& lastEventId);
    4747    static Ref<MessageEvent> create(const String& data, const String& origin = { });
     
    5555        String lastEventId;
    5656        Optional<MessageEventSource> source;
    57         MessagePortArray ports;
     57        Vector<RefPtr<MessagePort>> ports;
    5858    };
    5959    static Ref<MessageEvent> create(JSC::ExecState&, const AtomicString& type, Init&, IsTrusted = IsTrusted::No);
     
    6161    virtual ~MessageEvent();
    6262
    63     void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray>);
    64     void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray>);
     63    void initMessageEvent(JSC::ExecState&, const AtomicString& type, bool canBubble, bool cancelable, JSC::JSValue data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&&, Vector<RefPtr<MessagePort>>&&);
     64    void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&&, Vector<RefPtr<MessagePort>>&&);
    6565
    6666    const String& origin() const { return m_origin; }
    6767    const String& lastEventId() const { return m_lastEventId; }
    6868    EventTarget* source() const;
    69     MessagePortArray ports() const { return m_ports ? *m_ports : MessagePortArray(); }
     69    const Vector<RefPtr<MessagePort>>& ports() const { return m_ports; }
    7070
    7171    // FIXME: Remove this when we have custom ObjC binding support.
     
    9393    MessageEvent();
    9494    MessageEvent(JSC::ExecState&, const AtomicString&, Init&, IsTrusted);
    95     MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray>);
     95    MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&&, Vector<RefPtr<MessagePort>>&&);
    9696    MessageEvent(const AtomicString& type, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId);
    9797    MessageEvent(const String& data, const String& origin);
     
    109109    String m_lastEventId;
    110110    Optional<MessageEventSource> m_source;
    111     std::unique_ptr<MessagePortArray> m_ports;
     111    Vector<RefPtr<MessagePort>> m_ports;
    112112};
    113113
  • trunk/Source/WebCore/dom/MessageEvent.idl

    r207381 r207505  
    4040    [Custom] void initMessageEvent(optional DOMString typeArg, optional boolean canBubbleArg, optional boolean cancelableArg,
    4141        optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional (DOMWindow or MessagePort)? sourceArg,
    42         optional Array messagePorts);
    43 
     42        optional sequence<MessagePort> messagePorts);
    4443    [Custom] void webkitInitMessageEvent(optional DOMString typeArg, optional boolean canBubbleArg, optional boolean cancelableArg,
    4544        optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional (DOMWindow or MessagePort)? sourceArg,
    46         optional Array transferables);
     45        optional sequence<MessagePort> messagePorts);
    4746};
    4847
  • trunk/Source/WebCore/dom/MessagePort.cpp

    r204259 r207505  
    5454}
    5555
    56 void MessagePort::postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray* ports, ExceptionCode& ec)
     56void MessagePort::postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec)
    5757{
    5858    if (!isEntangled())
     
    6262    std::unique_ptr<MessagePortChannelArray> channels;
    6363    // Make sure we aren't connected to any of the passed-in ports.
    64     if (ports) {
    65         for (auto& dataPort : *ports) {
     64    if (!ports.isEmpty()) {
     65        for (auto& dataPort : ports) {
    6666            if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort.get())) {
    6767                ec = DATA_CLONE_ERR;
     
    6969            }
    7070        }
    71         channels = MessagePort::disentanglePorts(ports, ec);
     71        channels = MessagePort::disentanglePorts(WTFMove(ports), ec);
    7272        if (ec)
    7373            return;
     
    153153            return;
    154154
    155         std::unique_ptr<MessagePortArray> ports = MessagePort::entanglePorts(*m_scriptExecutionContext, WTFMove(channels));
     155        Vector<RefPtr<MessagePort>> ports = MessagePort::entanglePorts(*m_scriptExecutionContext, WTFMove(channels));
    156156        Ref<Event> event = MessageEvent::create(WTFMove(ports), WTFMove(message));
    157157        dispatchEvent(event);
     
    175175}
    176176
    177 std::unique_ptr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessagePortArray* ports, ExceptionCode& ec)
    178 {
    179     if (!ports || !ports->size())
     177std::unique_ptr<MessagePortChannelArray> MessagePort::disentanglePorts(Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec)
     178{
     179    if (ports.isEmpty())
    180180        return nullptr;
    181181
     
    184184
    185185    // Walk the incoming array - if there are any duplicate ports, or null ports or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec).
    186     for (auto& port : *ports) {
     186    for (auto& port : ports) {
    187187        if (!port || port->isNeutered() || portSet.contains(port.get())) {
    188188            ec = DATA_CLONE_ERR;
     
    193193
    194194    // Passed-in ports passed validity checks, so we can disentangle them.
    195     auto portArray = std::make_unique<MessagePortChannelArray>(ports->size());
    196     for (unsigned int i = 0 ; i < ports->size() ; ++i) {
    197         std::unique_ptr<MessagePortChannel> channel = (*ports)[i]->disentangle();
     195    auto portArray = std::make_unique<MessagePortChannelArray>(ports.size());
     196    for (unsigned int i = 0 ; i < ports.size() ; ++i) {
     197        std::unique_ptr<MessagePortChannel> channel = ports[i]->disentangle();
    198198        (*portArray)[i] = WTFMove(channel);
    199199    }
     
    201201}
    202202
    203 std::unique_ptr<MessagePortArray> MessagePort::entanglePorts(ScriptExecutionContext& context, std::unique_ptr<MessagePortChannelArray> channels)
     203Vector<RefPtr<MessagePort>> MessagePort::entanglePorts(ScriptExecutionContext& context, std::unique_ptr<MessagePortChannelArray> channels)
    204204{
    205205    if (!channels || !channels->size())
    206         return nullptr;
    207 
    208     auto portArray = std::make_unique<MessagePortArray>(channels->size());
     206        return { };
     207
     208    Vector<RefPtr<MessagePort>> portArray;
     209    portArray.reserveInitialCapacity(channels->size());
    209210    for (unsigned int i = 0; i < channels->size(); ++i) {
    210211        auto port = MessagePort::create(context);
    211212        port->entangle(WTFMove((*channels)[i]));
    212         (*portArray)[i] = WTFMove(port);
     213        portArray.uncheckedAppend(WTFMove(port));
    213214    }
    214215    return portArray;
  • trunk/Source/WebCore/dom/MessagePort.h

    r204259 r207505  
    4343    class ScriptExecutionContext;
    4444
    45     // The overwhelmingly common case is sending a single port, so handle that efficiently with an inline buffer of size 1.
    46     typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;
    47 
    4845    class MessagePort final : public RefCounted<MessagePort>, public EventTargetWithInlineData {
    4946    public:
     
    5148        virtual ~MessagePort();
    5249
    53         void postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*, ExceptionCode&);
     50        void postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&&, ExceptionCode&);
    5451
    5552        void start();
     
    6057
    6158        // Returns 0 if there is an exception, or if the passed-in array is 0/empty.
    62         static std::unique_ptr<MessagePortChannelArray> disentanglePorts(const MessagePortArray*, ExceptionCode&);
     59        static std::unique_ptr<MessagePortChannelArray> disentanglePorts(Vector<RefPtr<MessagePort>>&&, ExceptionCode&);
    6360
    64         // Returns 0 if the passed array is 0/empty.
    65         static std::unique_ptr<MessagePortArray> entanglePorts(ScriptExecutionContext&, std::unique_ptr<MessagePortChannelArray>);
     61        static Vector<RefPtr<MessagePort>> entanglePorts(ScriptExecutionContext&, std::unique_ptr<MessagePortChannelArray>);
    6662
    6763        void messageAvailable();
  • trunk/Source/WebCore/dom/PopStateEvent.cpp

    r207215 r207505  
    7171   
    7272    if (!m_serializedState && !m_triedToSerialize) {
    73         m_serializedState = SerializedScriptValue::create(exec, m_state.jsValue(), nullptr, nullptr, NonThrowing);
     73        m_serializedState = SerializedScriptValue::create(*exec, m_state.jsValue(), NonThrowing);
    7474        m_triedToSerialize = true;
    7575    }
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r207381 r207505  
    907907}
    908908
    909 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, const String& targetOrigin, DOMWindow& source, ExceptionCode& ec)
     909void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, Vector<RefPtr<MessagePort>>&& ports, const String& targetOrigin, DOMWindow& source, ExceptionCode& ec)
    910910{
    911911    if (!isCurrentlyDisplayedInFrame())
     
    931931    }
    932932
    933     auto channels = MessagePort::disentanglePorts(ports, ec);
     933    auto channels = MessagePort::disentanglePorts(WTFMove(ports), ec);
    934934    if (ec)
    935935        return;
  • trunk/Source/WebCore/page/DOMWindow.h

    r207040 r207505  
    8989    struct WindowFeatures;
    9090
    91     typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;
    92 
    9391    typedef int ExceptionCode;
    9492
     
    242240        String crossDomainAccessErrorMessage(const DOMWindow& activeWindow);
    243241
    244         void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, const String& targetOrigin, DOMWindow& source, ExceptionCode&);
     242        void postMessage(PassRefPtr<SerializedScriptValue> message, Vector<RefPtr<MessagePort>>&&, const String& targetOrigin, DOMWindow& source, ExceptionCode&);
    245243        void postMessageTimerFired(PostMessageTimer&);
    246244        void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, Event&, PassRefPtr<Inspector::ScriptCallStack>);
  • trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp

    r204259 r207505  
    6464}
    6565
    66 void DedicatedWorkerGlobalScope::postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray* ports, ExceptionCode& ec)
     66void DedicatedWorkerGlobalScope::postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec)
    6767{
    6868    // Disentangle the port in preparation for sending it to the remote context.
    69     auto channels = MessagePort::disentanglePorts(ports, ec);
     69    auto channels = MessagePort::disentanglePorts(WTFMove(ports), ec);
    7070    if (ec)
    7171        return;
  • trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h

    r204259 r207505  
    5454        EventTargetInterface eventTargetInterface() const override;
    5555
    56         void postMessage(RefPtr<SerializedScriptValue>&&, const MessagePortArray*, ExceptionCode&);
     56        void postMessage(RefPtr<SerializedScriptValue>&&, Vector<RefPtr<MessagePort>>&&, ExceptionCode&);
    5757
    5858        DedicatedWorkerThread& thread();
  • trunk/Source/WebCore/workers/Worker.cpp

    r204259 r207505  
    108108}
    109109
    110 void Worker::postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray* ports, ExceptionCode& ec)
     110void Worker::postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec)
    111111{
    112112    // Disentangle the port in preparation for sending it to the remote context.
    113     auto channels = MessagePort::disentanglePorts(ports, ec);
     113    auto channels = MessagePort::disentanglePorts(WTFMove(ports), ec);
    114114    if (ec)
    115115        return;
  • trunk/Source/WebCore/workers/Worker.h

    r204466 r207505  
    5555        EventTargetInterface eventTargetInterface() const override { return WorkerEventTargetInterfaceType; }
    5656
    57         void postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*, ExceptionCode&);
     57        void postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&&, ExceptionCode&);
    5858
    5959        void terminate();
Note: See TracChangeset for help on using the changeset viewer.