Changeset 207505 in webkit
- Timestamp:
- Oct 18, 2016 5:05:09 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207501 r207505 1 2016-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 1 101 2016-10-18 Chris Dumez <cdumez@apple.com> 2 102 -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
r206976 r207505 237 237 return Exception { IDBDatabaseException::ReadOnlyError, ASCIILiteral("Failed to store record in an IDBObjectStore: The transaction is read-only.") }; 238 238 239 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(&state, value, nullptr, nullptr);239 auto serializedValue = SerializedScriptValue::create(state, value); 240 240 if (UNLIKELY(scope.exception())) { 241 241 // 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 875 875 } 876 876 877 auto serializedValue = SerializedScriptValue::create( &databaseThreadExecState(), value, nullptr, nullptr);877 auto serializedValue = SerializedScriptValue::create(databaseThreadExecState(), value); 878 878 if (UNLIKELY(scope.exception())) { 879 879 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 41 41 #include "JSDOMStringList.h" 42 42 #include "Logging.h" 43 #include "MessagePort.h" 43 44 #include "ScriptExecutionContext.h" 44 45 #include "SerializedScriptValue.h" … … 329 330 330 331 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); 332 334 exec.vm().apiLock().unlock(); 333 335 -
trunk/Source/WebCore/bindings/js/JSCustomEventCustom.cpp
r202023 r207505 51 51 if (!serializedDetail) 52 52 return jsNull(); 53 return serializedDetail->deserialize( &state, globalObject(), nullptr);53 return serializedDetail->deserialize(state, globalObject()); 54 54 } 55 55 -
trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
r206777 r207505 506 506 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 507 507 508 MessagePortArraymessagePorts;509 ArrayBufferArrayarrayBuffers;508 Vector<RefPtr<MessagePort>> messagePorts; 509 Vector<RefPtr<JSC::ArrayBuffer>> arrayBuffers; 510 510 511 511 // This function has variable arguments and can be: … … 522 522 transferablesArgIndex = 1; 523 523 } 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)); 529 529 530 530 RETURN_IF_EXCEPTION(scope, JSValue()); … … 534 534 535 535 ExceptionCode ec = 0; 536 impl.postMessage(WTFMove(message), &messagePorts, targetOrigin, callerDOMWindow(&state), ec);536 impl.postMessage(WTFMove(message), WTFMove(messagePorts), targetOrigin, callerDOMWindow(&state), ec); 537 537 setDOMException(&state, ec); 538 538 -
trunk/Source/WebCore/bindings/js/JSDictionary.cpp
r207501 r207505 31 31 #include "Dictionary.h" 32 32 #include "JSCSSFontFaceRule.h" 33 #include "JSDOMConvert.h" 33 34 #include "JSDOMError.h" 34 35 #include "JSDOMWindow.h" 35 36 #include "JSEventTarget.h" 36 #include "JSMessagePort Custom.h"37 #include "JSMessagePort.h" 37 38 #include "JSNode.h" 38 39 #include "JSStorage.h" … … 178 179 void JSDictionary::convertValue(ExecState* exec, JSValue value, RefPtr<SerializedScriptValue>& result) 179 180 { 180 result = SerializedScriptValue::create( exec, value, 0, 0);181 result = SerializedScriptValue::create(*exec, value); 181 182 } 182 183 … … 209 210 } 210 211 211 void JSDictionary::convertValue(ExecState* exec, JSValue value, MessagePortArray& result) 212 { 213 ArrayBufferArray arrayBuffers; 214 fillMessagePortArray(*exec, value, result, arrayBuffers); 212 void JSDictionary::convertValue(ExecState* exec, JSValue value, Vector<RefPtr<MessagePort>>& result) 213 { 214 result = convert<IDLSequence<IDLInterface<MessagePort>>>(*exec, value); 215 215 } 216 216 -
trunk/Source/WebCore/bindings/js/JSDictionary.h
r206983 r207505 137 137 static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Node>& result); 138 138 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); 140 140 #if ENABLE(VIDEO_TRACK) 141 141 static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<TrackBase>& result); -
trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp
r206976 r207505 49 49 50 50 RefPtr<SerializedScriptValue> serialized = history.state(); 51 JSValue result = serialized ? serialized->deserialize( &state, globalObject(), 0) : jsNull();51 JSValue result = serialized ? serialized->deserialize(state, globalObject()) : jsNull(); 52 52 m_state.set(state.vm(), this, result); 53 53 return result; … … 63 63 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 64 64 65 auto historyState = SerializedScriptValue::create( &state, state.uncheckedArgument(0), 0, 0);65 auto historyState = SerializedScriptValue::create(state, state.uncheckedArgument(0)); 66 66 RETURN_IF_EXCEPTION(scope, JSValue()); 67 67 … … 92 92 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 93 93 94 auto historyState = SerializedScriptValue::create( &state, state.uncheckedArgument(0), 0, 0);94 auto historyState = SerializedScriptValue::create(state, state.uncheckedArgument(0)); 95 95 RETURN_IF_EXCEPTION(scope, JSValue()); 96 96 -
trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp
r207381 r207505 34 34 #include "JSBlob.h" 35 35 #include "JSDOMBinding.h" 36 #include "JSDOMConvert.h" 36 37 #include "JSDOMWindow.h" 37 38 #include "JSEventTarget.h" 38 39 #include "JSMessagePort.h" 39 #include "JSMessagePortCustom.h"40 40 #include "MessageEvent.h" 41 41 #include <runtime/JSArray.h> … … 68 68 RefPtr<SerializedScriptValue> serializedValue = event.trySerializeData(&state); 69 69 if (serializedValue) 70 result = serializedValue->deserialize( &state, globalObject(), nullptr);70 result = serializedValue->deserialize(state, globalObject()); 71 71 else 72 72 result = jsNull(); … … 79 79 case MessageEvent::DataTypeSerializedScriptValue: 80 80 if (RefPtr<SerializedScriptValue> serializedValue = event.dataAsSerializedScriptValue()) { 81 MessagePortArrayports = wrapped().ports();81 Vector<RefPtr<MessagePort>> ports = wrapped().ports(); 82 82 // FIXME: Why does this suppress exceptions? 83 result = serializedValue->deserialize( &state, globalObject(), &ports, NonThrowing);83 result = serializedValue->deserialize(state, globalObject(), ports, NonThrowing); 84 84 } else 85 85 result = jsNull(); … … 110 110 111 111 const String& typeArg = state.argument(0).toString(&state)->value(&state); 112 RETURN_IF_EXCEPTION(scope, JSValue()); 113 112 114 bool canBubbleArg = state.argument(1).toBoolean(&state); 115 RETURN_IF_EXCEPTION(scope, JSValue()); 116 113 117 bool cancelableArg = state.argument(2).toBoolean(&state); 118 RETURN_IF_EXCEPTION(scope, JSValue()); 119 120 JSValue dataArg = state.argument(3); 121 114 122 const String originArg = valueToUSVString(&state, state.argument(4)); 123 RETURN_IF_EXCEPTION(scope, JSValue()); 124 115 125 const String lastEventIdArg = state.argument(5).toString(&state)->value(&state); 126 RETURN_IF_EXCEPTION(scope, JSValue()); 127 116 128 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; 119 132 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)); 123 134 RETURN_IF_EXCEPTION(scope, JSValue()); 124 135 } 125 Deprecated::ScriptValue dataArg(vm, state.argument(3));126 RETURN_IF_EXCEPTION(scope, JSValue());127 136 128 137 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); 131 140 return jsUndefined(); 132 141 } -
trunk/Source/WebCore/bindings/js/JSMessagePortCustom.cpp
r206386 r207505 58 58 } 59 59 60 void fillMessagePortArray(JSC::ExecState& state, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers)60 void extractTransferables(JSC::ExecState& state, JSC::JSValue value, Vector<RefPtr<MessagePort>>& portArray, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers) 61 61 { 62 62 VM& vm = state.vm(); 63 63 auto scope = DECLARE_THROW_SCOPE(vm); 64 64 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.67 65 if (value.isUndefinedOrNull()) { 68 66 portArray.resize(0); … … 79 77 JSValue value = object->get(&state, i); 80 78 RETURN_IF_EXCEPTION(scope, void()); 81 // Validation of non-null objects, per HTML5 spec 10.3.3. 79 82 80 if (value.isUndefinedOrNull()) { 83 81 setDOMException(&state, INVALID_STATE_ERR); -
trunk/Source/WebCore/bindings/js/JSMessagePortCustom.h
r206386 r207505 43 43 typedef int ExceptionCode; 44 44 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>>&); 49 46 50 47 // Helper function to convert from JS postMessage arguments to WebCore postMessage arguments. … … 58 55 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 59 56 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)); 64 63 RETURN_IF_EXCEPTION(scope, JSC::JSValue()); 65 64 66 65 ExceptionCode ec = 0; 67 impl->postMessage(WTFMove(message), &portArray, ec);66 impl->postMessage(WTFMove(message), WTFMove(messagePortArray), ec); 68 67 setDOMException(&state, ec); 69 68 return JSC::jsUndefined(); -
trunk/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp
r205462 r207505 65 65 if (eventState.isObject() && &worldForDOMObject(eventState.getObject()) != ¤tWorld(&state)) { 66 66 if (auto serializedValue = event.trySerializeState(&state)) 67 eventState = serializedValue->deserialize( &state, globalObject(), nullptr);67 eventState = serializedValue->deserialize(state, globalObject()); 68 68 else 69 69 eventState = jsNull(); … … 89 89 result = jsHistory->state(state); 90 90 } else 91 result = event.serializedState()->deserialize( &state, globalObject(), 0);91 result = event.serializedState()->deserialize(state, globalObject()); 92 92 93 93 return cacheState(state, this, result); -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp
r206196 r207505 475 475 class CloneSerializer : CloneBase { 476 476 public: 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) 480 478 { 481 479 CloneSerializer serializer(exec, messagePorts, arrayBuffers, blobURLs, out); … … 526 524 typedef HashMap<JSObject*, uint32_t> ObjectPool; 527 525 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) 529 527 : CloneBase(exec) 530 528 , m_buffer(out) … … 538 536 539 537 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()) 543 541 return; 544 542 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()); 547 545 JSC::JSObject* obj = value.getObject(); 548 546 if (obj && !result.contains(obj)) … … 878 876 Vector<uint8_t> serializedKey; 879 877 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); 881 881 rawKeySerializer.write(key); 882 882 Vector<uint8_t> wrappedKey; … … 1488 1488 } 1489 1489 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) 1491 1491 { 1492 1492 if (!buffer.size()) … … 1537 1537 }; 1538 1538 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) 1540 1540 : CloneBase(exec) 1541 1541 , m_globalObject(globalObject) … … 1552 1552 } 1553 1553 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) 1555 1555 : CloneBase(exec) 1556 1556 , m_globalObject(globalObject) … … 2348 2348 uint32_t index; 2349 2349 bool indexSuccessfullyRead = read(index); 2350 if (!indexSuccessfullyRead || !m_messagePorts || index >= m_messagePorts->size()) {2350 if (!indexSuccessfullyRead || index >= m_messagePorts.size()) { 2351 2351 fail(); 2352 2352 return JSValue(); 2353 2353 } 2354 return getJSValue(m_messagePorts ->at(index).get());2354 return getJSValue(m_messagePorts[index].get()); 2355 2355 } 2356 2356 case ArrayBufferTag: { … … 2399 2399 } 2400 2400 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); 2402 2403 if (!rawKeyDeserializer.readCryptoKey(cryptoKey)) { 2403 2404 fail(); … … 2429 2430 unsigned m_version; 2430 2431 Vector<CachedString> m_constantPool; 2431 MessagePortArray*m_messagePorts;2432 Vector<RefPtr<MessagePort>>& m_messagePorts; 2432 2433 ArrayBufferContentsArray* m_arrayBufferContents; 2433 ArrayBufferArraym_arrayBuffers;2434 Vector<RefPtr<JSC::ArrayBuffer>> m_arrayBuffers; 2434 2435 Vector<String> m_blobURLs; 2435 2436 Vector<String> m_blobFilePaths; … … 2655 2656 2656 2657 std::unique_ptr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValue::transferArrayBuffers( 2657 ExecState* exec, ArrayBufferArray& arrayBuffers, SerializationReturnCode& code)2658 ExecState* exec, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers, SerializationReturnCode& code) 2658 2659 { 2659 2660 for (size_t i = 0; i < arrayBuffers.size(); i++) { … … 2683 2684 } 2684 2685 2685 RefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState* exec, JSValue value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, SerializationErrorMode throwExceptions) 2686 RefPtr<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 2692 RefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState& exec, JSValue value, Vector<RefPtr<MessagePort>>& messagePorts, Vector<RefPtr<JSC::ArrayBuffer>>&& arrayBuffers, SerializationErrorMode throwExceptions) 2686 2693 { 2687 2694 Vector<uint8_t> buffer; 2688 2695 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); 2690 2697 2691 2698 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); 2695 2701 2696 2702 if (throwExceptions == Throwing) 2697 maybeThrowExceptionIfSerializationFailed( exec, code);2703 maybeThrowExceptionIfSerializationFailed(&exec, code); 2698 2704 2699 2705 if (!serializationDidCompleteSuccessfully(code)) … … 2719 2725 2720 2726 JSValue value = toJS(exec, apiValue); 2721 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create( exec, value, nullptr, nullptr);2727 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(*exec, value); 2722 2728 if (UNLIKELY(scope.exception())) { 2723 2729 if (exception) … … 2735 2741 } 2736 2742 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); 2743 JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, SerializationErrorMode throwExceptions) 2744 { 2745 Vector<RefPtr<MessagePort>> dummyMessagePorts; 2746 return deserialize(exec, globalObject, dummyMessagePorts, throwExceptions); 2747 } 2748 2749 JSValue 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 2756 JSValue 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); 2746 2759 if (throwExceptions == Throwing) 2747 maybeThrowExceptionIfSerializationFailed( exec, result.second);2760 maybeThrowExceptionIfSerializationFailed(&exec, result.second); 2748 2761 return result.first ? result.first : jsNull(); 2749 2762 } … … 2756 2769 auto scope = DECLARE_CATCH_SCOPE(vm); 2757 2770 2758 JSValue value = deserialize( exec, exec->lexicalGlobalObject(), nullptr);2771 JSValue value = deserialize(*exec, exec->lexicalGlobalObject()); 2759 2772 if (UNLIKELY(scope.exception())) { 2760 2773 if (exception) -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.h
r202530 r207505 43 43 class IDBValue; 44 44 class MessagePort; 45 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;46 typedef Vector<RefPtr<JSC::ArrayBuffer>, 1> ArrayBufferArray;47 45 48 46 enum SerializationReturnCode { … … 62 60 class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue> { 63 61 public: 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); 65 64 66 65 WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(StringView); … … 72 71 static Ref<SerializedScriptValue> nullValue(); 73 72 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); 76 76 77 77 static uint32_t wireFormatVersion(); … … 104 104 static void maybeThrowExceptionIfSerializationFailed(JSC::ExecState*, SerializationReturnCode); 105 105 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&); 107 107 108 108 WEBCORE_EXPORT SerializedScriptValue(Vector<unsigned char>&&); -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r207498 r207505 4906 4906 4907 4907 my $innerType = $codeGenerator->GetSequenceOrFrozenArrayInnerType($type); 4908 return "MessagePortArray" if $innerType eq "MessagePort";4909 4908 return "Vector<" . GetNativeVectorInnerType($innerType) . ">"; 4910 4909 } … … 5169 5168 if ($type eq "SerializedScriptValue") { 5170 5169 AddToImplIncludes("SerializedScriptValue.h", $conditional); 5171 return ("SerializedScriptValue::create($state Pointer, $value, 0, 0)", 1);5170 return ("SerializedScriptValue::create($stateReference, $value)", 1); 5172 5171 } 5173 5172 … … 5275 5274 if ($type eq "SerializedScriptValue") { 5276 5275 AddToImplIncludes("SerializedScriptValue.h", $conditional); 5277 return "$value ? $value->deserialize($state Pointer, $globalObject, 0) : jsNull()";5276 return "$value ? $value->deserialize($stateReference, $globalObject) : jsNull()"; 5278 5277 } 5279 5278 -
trunk/Source/WebCore/dom/CustomEvent.cpp
r206964 r207505 62 62 { 63 63 if (!m_triedToSerialize) { 64 m_serializedDetail = SerializedScriptValue::create( &state, m_detail, nullptr, nullptr, NonThrowing);64 m_serializedDetail = SerializedScriptValue::create(state, m_detail, NonThrowing); 65 65 m_triedToSerialize = true; 66 66 } -
trunk/Source/WebCore/dom/ErrorEvent.cpp
r207215 r207505 82 82 if (!serializedError) 83 83 return jsNull(); 84 return serializedError->deserialize( &exec, &globalObject, nullptr);84 return serializedError->deserialize(exec, &globalObject); 85 85 } 86 86 … … 91 91 { 92 92 if (!m_triedToSerialize) { 93 m_serializedDetail = SerializedScriptValue::create( &exec, m_error, nullptr, nullptr, NonThrowing);93 m_serializedDetail = SerializedScriptValue::create(exec, m_error, NonThrowing); 94 94 m_triedToSerialize = true; 95 95 } -
trunk/Source/WebCore/dom/MessageEvent.cpp
r207381 r207505 49 49 , m_lastEventId(initializer.lastEventId) 50 50 , 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 55 inline MessageEvent::MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, Vector<RefPtr<MessagePort>>&& ports) 56 56 : Event(eventNames().messageEvent, false, false) 57 57 , m_dataType(DataTypeSerializedScriptValue) … … 97 97 } 98 98 99 Ref<MessageEvent> MessageEvent::create( std::unique_ptr<MessagePortArray>ports, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source)99 Ref<MessageEvent> MessageEvent::create(Vector<RefPtr<MessagePort>>&& ports, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source) 100 100 { 101 101 return adoptRef(*new MessageEvent(WTFMove(data), origin, lastEventId, WTFMove(source), WTFMove(ports))); … … 136 136 } 137 137 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)138 void 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) 139 139 { 140 140 if (dispatched()) … … 144 144 145 145 m_dataType = DataTypeScriptValue; 146 m_dataAsScriptValue = data;146 m_dataAsScriptValue = Deprecated::ScriptValue(state.vm(), data); 147 147 m_dataAsSerializedScriptValue = nullptr; 148 148 m_triedToSerialize = false; … … 153 153 } 154 154 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)155 void 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) 156 156 { 157 157 if (dispatched()) … … 186 186 187 187 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); 189 189 m_triedToSerialize = true; 190 190 } -
trunk/Source/WebCore/dom/MessageEvent.h
r207381 r207505 43 43 class MessageEvent final : public Event { 44 44 public: 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); 46 46 static Ref<MessageEvent> create(const AtomicString& type, RefPtr<SerializedScriptValue>&&, const String& origin, const String& lastEventId); 47 47 static Ref<MessageEvent> create(const String& data, const String& origin = { }); … … 55 55 String lastEventId; 56 56 Optional<MessageEventSource> source; 57 MessagePortArrayports;57 Vector<RefPtr<MessagePort>> ports; 58 58 }; 59 59 static Ref<MessageEvent> create(JSC::ExecState&, const AtomicString& type, Init&, IsTrusted = IsTrusted::No); … … 61 61 virtual ~MessageEvent(); 62 62 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>>&&); 65 65 66 66 const String& origin() const { return m_origin; } 67 67 const String& lastEventId() const { return m_lastEventId; } 68 68 EventTarget* source() const; 69 MessagePortArray ports() const { return m_ports ? *m_ports : MessagePortArray(); }69 const Vector<RefPtr<MessagePort>>& ports() const { return m_ports; } 70 70 71 71 // FIXME: Remove this when we have custom ObjC binding support. … … 93 93 MessageEvent(); 94 94 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>>&&); 96 96 MessageEvent(const AtomicString& type, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId); 97 97 MessageEvent(const String& data, const String& origin); … … 109 109 String m_lastEventId; 110 110 Optional<MessageEventSource> m_source; 111 std::unique_ptr<MessagePortArray> m_ports;111 Vector<RefPtr<MessagePort>> m_ports; 112 112 }; 113 113 -
trunk/Source/WebCore/dom/MessageEvent.idl
r207381 r207505 40 40 [Custom] void initMessageEvent(optional DOMString typeArg, optional boolean canBubbleArg, optional boolean cancelableArg, 41 41 optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional (DOMWindow or MessagePort)? sourceArg, 42 optional Array messagePorts); 43 42 optional sequence<MessagePort> messagePorts); 44 43 [Custom] void webkitInitMessageEvent(optional DOMString typeArg, optional boolean canBubbleArg, optional boolean cancelableArg, 45 44 optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional (DOMWindow or MessagePort)? sourceArg, 46 optional Array transferables);45 optional sequence<MessagePort> messagePorts); 47 46 }; 48 47 -
trunk/Source/WebCore/dom/MessagePort.cpp
r204259 r207505 54 54 } 55 55 56 void MessagePort::postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*ports, ExceptionCode& ec)56 void MessagePort::postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec) 57 57 { 58 58 if (!isEntangled()) … … 62 62 std::unique_ptr<MessagePortChannelArray> channels; 63 63 // 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) { 66 66 if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort.get())) { 67 67 ec = DATA_CLONE_ERR; … … 69 69 } 70 70 } 71 channels = MessagePort::disentanglePorts( ports, ec);71 channels = MessagePort::disentanglePorts(WTFMove(ports), ec); 72 72 if (ec) 73 73 return; … … 153 153 return; 154 154 155 std::unique_ptr<MessagePortArray> ports = MessagePort::entanglePorts(*m_scriptExecutionContext, WTFMove(channels));155 Vector<RefPtr<MessagePort>> ports = MessagePort::entanglePorts(*m_scriptExecutionContext, WTFMove(channels)); 156 156 Ref<Event> event = MessageEvent::create(WTFMove(ports), WTFMove(message)); 157 157 dispatchEvent(event); … … 175 175 } 176 176 177 std::unique_ptr<MessagePortChannelArray> MessagePort::disentanglePorts( const MessagePortArray*ports, ExceptionCode& ec)178 { 179 if ( !ports || !ports->size())177 std::unique_ptr<MessagePortChannelArray> MessagePort::disentanglePorts(Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec) 178 { 179 if (ports.isEmpty()) 180 180 return nullptr; 181 181 … … 184 184 185 185 // 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) { 187 187 if (!port || port->isNeutered() || portSet.contains(port.get())) { 188 188 ec = DATA_CLONE_ERR; … … 193 193 194 194 // 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(); 198 198 (*portArray)[i] = WTFMove(channel); 199 199 } … … 201 201 } 202 202 203 std::unique_ptr<MessagePortArray> MessagePort::entanglePorts(ScriptExecutionContext& context, std::unique_ptr<MessagePortChannelArray> channels)203 Vector<RefPtr<MessagePort>> MessagePort::entanglePorts(ScriptExecutionContext& context, std::unique_ptr<MessagePortChannelArray> channels) 204 204 { 205 205 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()); 209 210 for (unsigned int i = 0; i < channels->size(); ++i) { 210 211 auto port = MessagePort::create(context); 211 212 port->entangle(WTFMove((*channels)[i])); 212 (*portArray)[i] = WTFMove(port);213 portArray.uncheckedAppend(WTFMove(port)); 213 214 } 214 215 return portArray; -
trunk/Source/WebCore/dom/MessagePort.h
r204259 r207505 43 43 class ScriptExecutionContext; 44 44 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 48 45 class MessagePort final : public RefCounted<MessagePort>, public EventTargetWithInlineData { 49 46 public: … … 51 48 virtual ~MessagePort(); 52 49 53 void postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*, ExceptionCode&);50 void postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&&, ExceptionCode&); 54 51 55 52 void start(); … … 60 57 61 58 // 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&); 63 60 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>); 66 62 67 63 void messageAvailable(); -
trunk/Source/WebCore/dom/PopStateEvent.cpp
r207215 r207505 71 71 72 72 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); 74 74 m_triedToSerialize = true; 75 75 } -
trunk/Source/WebCore/page/DOMWindow.cpp
r207381 r207505 907 907 } 908 908 909 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*ports, const String& targetOrigin, DOMWindow& source, ExceptionCode& ec)909 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, Vector<RefPtr<MessagePort>>&& ports, const String& targetOrigin, DOMWindow& source, ExceptionCode& ec) 910 910 { 911 911 if (!isCurrentlyDisplayedInFrame()) … … 931 931 } 932 932 933 auto channels = MessagePort::disentanglePorts( ports, ec);933 auto channels = MessagePort::disentanglePorts(WTFMove(ports), ec); 934 934 if (ec) 935 935 return; -
trunk/Source/WebCore/page/DOMWindow.h
r207040 r207505 89 89 struct WindowFeatures; 90 90 91 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;92 93 91 typedef int ExceptionCode; 94 92 … … 242 240 String crossDomainAccessErrorMessage(const DOMWindow& activeWindow); 243 241 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&); 245 243 void postMessageTimerFired(PostMessageTimer&); 246 244 void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, Event&, PassRefPtr<Inspector::ScriptCallStack>); -
trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp
r204259 r207505 64 64 } 65 65 66 void DedicatedWorkerGlobalScope::postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*ports, ExceptionCode& ec)66 void DedicatedWorkerGlobalScope::postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec) 67 67 { 68 68 // 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); 70 70 if (ec) 71 71 return; -
trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h
r204259 r207505 54 54 EventTargetInterface eventTargetInterface() const override; 55 55 56 void postMessage(RefPtr<SerializedScriptValue>&&, const MessagePortArray*, ExceptionCode&);56 void postMessage(RefPtr<SerializedScriptValue>&&, Vector<RefPtr<MessagePort>>&&, ExceptionCode&); 57 57 58 58 DedicatedWorkerThread& thread(); -
trunk/Source/WebCore/workers/Worker.cpp
r204259 r207505 108 108 } 109 109 110 void Worker::postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*ports, ExceptionCode& ec)110 void Worker::postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec) 111 111 { 112 112 // 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); 114 114 if (ec) 115 115 return; -
trunk/Source/WebCore/workers/Worker.h
r204466 r207505 55 55 EventTargetInterface eventTargetInterface() const override { return WorkerEventTargetInterfaceType; } 56 56 57 void postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*, ExceptionCode&);57 void postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&&, ExceptionCode&); 58 58 59 59 void terminate();
Note: See TracChangeset
for help on using the changeset viewer.