Diff
Modified: trunk/Source/WebCore/ChangeLog (207504 => 207505)
--- trunk/Source/WebCore/ChangeLog 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/ChangeLog 2016-10-19 00:05:09 UTC (rev 207505)
@@ -1,3 +1,103 @@
+2016-10-18 Sam Weinig <s...@webkit.org>
+
+ 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.
+
2016-10-18 Chris Dumez <cdu...@apple.com>
[iOS] Drop JSDictionary::convertValue() overload taking a TouchList
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp (207504 => 207505)
--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -236,7 +236,7 @@
if (m_transaction->isReadOnly())
return Exception { IDBDatabaseException::ReadOnlyError, ASCIILiteral("Failed to store record in an IDBObjectStore: The transaction is read-only.") };
- RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(&state, value, nullptr, nullptr);
+ auto serializedValue = SerializedScriptValue::create(state, value);
if (UNLIKELY(scope.exception())) {
// Clear the DOM exception from the serializer so we can give a more targeted exception.
scope.clearException();
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (207504 => 207505)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -874,7 +874,7 @@
return;
}
- auto serializedValue = SerializedScriptValue::create(&databaseThreadExecState(), value, nullptr, nullptr);
+ auto serializedValue = SerializedScriptValue::create(databaseThreadExecState(), value);
if (UNLIKELY(scope.exception())) {
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBDatabaseException::ConstraintError, ASCIILiteral("Unable to serialize record value after injecting record key")), usedKey));
return;
Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -40,6 +40,7 @@
#include "JSDOMConvert.h"
#include "JSDOMStringList.h"
#include "Logging.h"
+#include "MessagePort.h"
#include "ScriptExecutionContext.h"
#include "SerializedScriptValue.h"
#include "SharedBuffer.h"
@@ -328,7 +329,8 @@
auto serializedValue = SerializedScriptValue::createFromWireBytes(Vector<uint8_t>(data));
exec.vm().apiLock().lock();
- JSValue result = serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing, value.blobURLs(), value.blobFilePaths());
+ Vector<RefPtr<MessagePort>> messagePorts;
+ JSValue result = serializedValue->deserialize(exec, exec.lexicalGlobalObject(), messagePorts, value.blobURLs(), value.blobFilePaths(), NonThrowing);
exec.vm().apiLock().unlock();
return result;
Modified: trunk/Source/WebCore/bindings/js/JSCustomEventCustom.cpp (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/JSCustomEventCustom.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/JSCustomEventCustom.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -50,7 +50,7 @@
auto serializedDetail = event.trySerializeDetail(state);
if (!serializedDetail)
return jsNull();
- return serializedDetail->deserialize(&state, globalObject(), nullptr);
+ return serializedDetail->deserialize(state, globalObject());
}
return detail;
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -505,8 +505,8 @@
if (UNLIKELY(state.argumentCount() < 2))
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
- MessagePortArray messagePorts;
- ArrayBufferArray arrayBuffers;
+ Vector<RefPtr<MessagePort>> messagePorts;
+ Vector<RefPtr<JSC::ArrayBuffer>> arrayBuffers;
// This function has variable arguments and can be:
// Per current spec:
@@ -521,11 +521,11 @@
targetOriginArgIndex = 2;
transferablesArgIndex = 1;
}
- fillMessagePortArray(state, state.argument(transferablesArgIndex), messagePorts, arrayBuffers);
+ extractTransferables(state, state.argument(transferablesArgIndex), messagePorts, arrayBuffers);
}
RETURN_IF_EXCEPTION(scope, JSValue());
- auto message = SerializedScriptValue::create(&state, state.uncheckedArgument(0), &messagePorts, &arrayBuffers);
+ auto message = SerializedScriptValue::create(state, state.uncheckedArgument(0), messagePorts, WTFMove(arrayBuffers));
RETURN_IF_EXCEPTION(scope, JSValue());
@@ -533,7 +533,7 @@
RETURN_IF_EXCEPTION(scope, JSValue());
ExceptionCode ec = 0;
- impl.postMessage(WTFMove(message), &messagePorts, targetOrigin, callerDOMWindow(&state), ec);
+ impl.postMessage(WTFMove(message), WTFMove(messagePorts), targetOrigin, callerDOMWindow(&state), ec);
setDOMException(&state, ec);
return jsUndefined();
Modified: trunk/Source/WebCore/bindings/js/JSDictionary.cpp (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/JSDictionary.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/JSDictionary.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -30,10 +30,11 @@
#include "DOMWindow.h"
#include "Dictionary.h"
#include "JSCSSFontFaceRule.h"
+#include "JSDOMConvert.h"
#include "JSDOMError.h"
#include "JSDOMWindow.h"
#include "JSEventTarget.h"
-#include "JSMessagePortCustom.h"
+#include "JSMessagePort.h"
#include "JSNode.h"
#include "JSStorage.h"
#include "JSTrackCustom.h"
@@ -177,7 +178,7 @@
void JSDictionary::convertValue(ExecState* exec, JSValue value, RefPtr<SerializedScriptValue>& result)
{
- result = SerializedScriptValue::create(exec, value, 0, 0);
+ result = SerializedScriptValue::create(*exec, value);
}
void JSDictionary::convertValue(ExecState* state, JSValue value, RefPtr<DOMWindow>& result)
@@ -208,10 +209,9 @@
result = JSStorage::toWrapped(value);
}
-void JSDictionary::convertValue(ExecState* exec, JSValue value, MessagePortArray& result)
+void JSDictionary::convertValue(ExecState* exec, JSValue value, Vector<RefPtr<MessagePort>>& result)
{
- ArrayBufferArray arrayBuffers;
- fillMessagePortArray(*exec, value, result, arrayBuffers);
+ result = convert<IDLSequence<IDLInterface<MessagePort>>>(*exec, value);
}
#if ENABLE(VIDEO_TRACK)
Modified: trunk/Source/WebCore/bindings/js/JSDictionary.h (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/JSDictionary.h 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/JSDictionary.h 2016-10-19 00:05:09 UTC (rev 207505)
@@ -136,7 +136,7 @@
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<EventTarget>& result);
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Node>& result);
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Storage>& result);
- static void convertValue(JSC::ExecState*, JSC::JSValue, MessagePortArray& result);
+ static void convertValue(JSC::ExecState*, JSC::JSValue, Vector<RefPtr<MessagePort>>& result);
#if ENABLE(VIDEO_TRACK)
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<TrackBase>& result);
#endif
Modified: trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -48,7 +48,7 @@
return cachedValue;
RefPtr<SerializedScriptValue> serialized = history.state();
- JSValue result = serialized ? serialized->deserialize(&state, globalObject(), 0) : jsNull();
+ JSValue result = serialized ? serialized->deserialize(state, globalObject()) : jsNull();
m_state.set(state.vm(), this, result);
return result;
}
@@ -62,7 +62,7 @@
if (UNLIKELY(argCount < 2))
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
- auto historyState = SerializedScriptValue::create(&state, state.uncheckedArgument(0), 0, 0);
+ auto historyState = SerializedScriptValue::create(state, state.uncheckedArgument(0));
RETURN_IF_EXCEPTION(scope, JSValue());
// FIXME: title should not be nullable.
@@ -91,7 +91,7 @@
if (UNLIKELY(argCount < 2))
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
- auto historyState = SerializedScriptValue::create(&state, state.uncheckedArgument(0), 0, 0);
+ auto historyState = SerializedScriptValue::create(state, state.uncheckedArgument(0));
RETURN_IF_EXCEPTION(scope, JSValue());
// FIXME: title should not be nullable.
Modified: trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -33,10 +33,10 @@
#include "JSBlob.h"
#include "JSDOMBinding.h"
+#include "JSDOMConvert.h"
#include "JSDOMWindow.h"
#include "JSEventTarget.h"
#include "JSMessagePort.h"
-#include "JSMessagePortCustom.h"
#include "MessageEvent.h"
#include <runtime/JSArray.h>
#include <runtime/JSArrayBuffer.h>
@@ -67,7 +67,7 @@
if (dataValue.isObject() && &worldForDOMObject(dataValue.getObject()) != ¤tWorld(&state)) {
RefPtr<SerializedScriptValue> serializedValue = event.trySerializeData(&state);
if (serializedValue)
- result = serializedValue->deserialize(&state, globalObject(), nullptr);
+ result = serializedValue->deserialize(state, globalObject());
else
result = jsNull();
} else
@@ -78,9 +78,9 @@
case MessageEvent::DataTypeSerializedScriptValue:
if (RefPtr<SerializedScriptValue> serializedValue = event.dataAsSerializedScriptValue()) {
- MessagePortArray ports = wrapped().ports();
+ Vector<RefPtr<MessagePort>> ports = wrapped().ports();
// FIXME: Why does this suppress exceptions?
- result = serializedValue->deserialize(&state, globalObject(), &ports, NonThrowing);
+ result = serializedValue->deserialize(state, globalObject(), ports, NonThrowing);
} else
result = jsNull();
break;
@@ -109,25 +109,34 @@
auto scope = DECLARE_THROW_SCOPE(vm);
const String& typeArg = state.argument(0).toString(&state)->value(&state);
+ RETURN_IF_EXCEPTION(scope, JSValue());
+
bool canBubbleArg = state.argument(1).toBoolean(&state);
+ RETURN_IF_EXCEPTION(scope, JSValue());
+
bool cancelableArg = state.argument(2).toBoolean(&state);
+ RETURN_IF_EXCEPTION(scope, JSValue());
+
+ JSValue dataArg = state.argument(3);
+
const String originArg = valueToUSVString(&state, state.argument(4));
+ RETURN_IF_EXCEPTION(scope, JSValue());
+
const String lastEventIdArg = state.argument(5).toString(&state)->value(&state);
+ RETURN_IF_EXCEPTION(scope, JSValue());
+
auto sourceArg = convert<IDLNullable<IDLUnion<IDLInterface<DOMWindow>, IDLInterface<MessagePort>>>>(state, state.argument(6));
- std::unique_ptr<MessagePortArray> messagePorts;
- std::unique_ptr<ArrayBufferArray> arrayBuffers;
+ RETURN_IF_EXCEPTION(scope, JSValue());
+
+ Vector<RefPtr<MessagePort>> messagePorts;
if (!state.argument(7).isUndefinedOrNull()) {
- messagePorts = std::make_unique<MessagePortArray>();
- arrayBuffers = std::make_unique<ArrayBufferArray>();
- fillMessagePortArray(state, state.argument(7), *messagePorts, *arrayBuffers);
+ messagePorts = convert<IDLSequence<IDLInterface<MessagePort>>>(state, state.argument(7));
RETURN_IF_EXCEPTION(scope, JSValue());
}
- Deprecated::ScriptValue dataArg(vm, state.argument(3));
- RETURN_IF_EXCEPTION(scope, JSValue());
MessageEvent& event = jsEvent->wrapped();
- event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, WTFMove(sourceArg), WTFMove(messagePorts));
- jsEvent->m_data.set(vm, jsEvent, dataArg.jsValue());
+ event.initMessageEvent(state, typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, WTFMove(sourceArg), WTFMove(messagePorts));
+ jsEvent->m_data.set(vm, jsEvent, dataArg);
return jsUndefined();
}
Modified: trunk/Source/WebCore/bindings/js/JSMessagePortCustom.cpp (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/JSMessagePortCustom.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/JSMessagePortCustom.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -57,13 +57,11 @@
return handlePostMessage(state, &wrapped());
}
-void fillMessagePortArray(JSC::ExecState& state, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers)
+void extractTransferables(JSC::ExecState& state, JSC::JSValue value, Vector<RefPtr<MessagePort>>& portArray, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
- // Convert from the passed-in JS array-like object to a MessagePortArray.
- // 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.
if (value.isUndefinedOrNull()) {
portArray.resize(0);
arrayBuffers.resize(0);
@@ -78,7 +76,7 @@
for (unsigned i = 0 ; i < length; ++i) {
JSValue value = object->get(&state, i);
RETURN_IF_EXCEPTION(scope, void());
- // Validation of non-null objects, per HTML5 spec 10.3.3.
+
if (value.isUndefinedOrNull()) {
setDOMException(&state, INVALID_STATE_ERR);
return;
Modified: trunk/Source/WebCore/bindings/js/JSMessagePortCustom.h (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/JSMessagePortCustom.h 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/JSMessagePortCustom.h 2016-10-19 00:05:09 UTC (rev 207505)
@@ -42,10 +42,7 @@
typedef int ExceptionCode;
- // Helper function which pulls the values out of a JS sequence and into a MessagePortArray.
- // 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.
- // May generate an exception via the passed ExecState.
- void fillMessagePortArray(JSC::ExecState&, JSC::JSValue, MessagePortArray&, ArrayBufferArray&);
+ void extractTransferables(JSC::ExecState&, JSC::JSValue, Vector<RefPtr<MessagePort>>&, Vector<RefPtr<JSC::ArrayBuffer>>&);
// Helper function to convert from JS postMessage arguments to WebCore postMessage arguments.
template <typename T>
@@ -57,14 +54,16 @@
if (UNLIKELY(state.argumentCount() < 1))
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
- MessagePortArray portArray;
- ArrayBufferArray arrayBufferArray;
- fillMessagePortArray(state, state.argument(1), portArray, arrayBufferArray);
- auto message = SerializedScriptValue::create(&state, state.uncheckedArgument(0), &portArray, &arrayBufferArray);
+
+ Vector<RefPtr<MessagePort>> messagePortArray;
+ Vector<RefPtr<JSC::ArrayBuffer>> arrayBufferArray;
+ extractTransferables(state, state.argument(1), messagePortArray, arrayBufferArray);
+
+ auto message = SerializedScriptValue::create(state, state.uncheckedArgument(0), messagePortArray, WTFMove(arrayBufferArray));
RETURN_IF_EXCEPTION(scope, JSC::JSValue());
ExceptionCode ec = 0;
- impl->postMessage(WTFMove(message), &portArray, ec);
+ impl->postMessage(WTFMove(message), WTFMove(messagePortArray), ec);
setDOMException(&state, ec);
return JSC::jsUndefined();
}
Modified: trunk/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -64,7 +64,7 @@
// Ideally, we would check that the worlds have different privileges but that's not possible yet.
if (eventState.isObject() && &worldForDOMObject(eventState.getObject()) != ¤tWorld(&state)) {
if (auto serializedValue = event.trySerializeState(&state))
- eventState = serializedValue->deserialize(&state, globalObject(), nullptr);
+ eventState = serializedValue->deserialize(state, globalObject());
else
eventState = jsNull();
}
@@ -88,7 +88,7 @@
JSHistory* jsHistory = jsCast<JSHistory*>(toJS(&state, globalObject(), *history).asCell());
result = jsHistory->state(state);
} else
- result = event.serializedState()->deserialize(&state, globalObject(), 0);
+ result = event.serializedState()->deserialize(state, globalObject());
return cacheState(state, this, result);
}
Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -474,9 +474,7 @@
class CloneSerializer : CloneBase {
public:
- static SerializationReturnCode serialize(ExecState* exec, JSValue value,
- MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers,
- Vector<String>& blobURLs, Vector<uint8_t>& out)
+ static SerializationReturnCode serialize(ExecState* exec, JSValue value, Vector<RefPtr<MessagePort>>& messagePorts, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers, Vector<String>& blobURLs, Vector<uint8_t>& out)
{
CloneSerializer serializer(exec, messagePorts, arrayBuffers, blobURLs, out);
return serializer.serialize(value);
@@ -525,7 +523,7 @@
private:
typedef HashMap<JSObject*, uint32_t> ObjectPool;
- CloneSerializer(ExecState* exec, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, Vector<String>& blobURLs, Vector<uint8_t>& out)
+ CloneSerializer(ExecState* exec, Vector<RefPtr<MessagePort>>& messagePorts, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers, Vector<String>& blobURLs, Vector<uint8_t>& out)
: CloneBase(exec)
, m_buffer(out)
, m_blobURLs(blobURLs)
@@ -537,13 +535,13 @@
}
template <class T>
- void fillTransferMap(Vector<RefPtr<T>, 1>* input, ObjectPool& result)
+ void fillTransferMap(Vector<RefPtr<T>>& input, ObjectPool& result)
{
- if (!input)
+ if (input.isEmpty())
return;
JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject());
- for (size_t i = 0; i < input->size(); i++) {
- JSC::JSValue value = toJS(m_exec, globalObject, input->at(i).get());
+ for (size_t i = 0; i < input.size(); i++) {
+ JSC::JSValue value = toJS(m_exec, globalObject, input[i].get());
JSC::JSObject* obj = value.getObject();
if (obj && !result.contains(obj))
result.add(obj, i);
@@ -877,7 +875,9 @@
write(CryptoKeyTag);
Vector<uint8_t> serializedKey;
Vector<String> dummyBlobURLs;
- CloneSerializer rawKeySerializer(m_exec, nullptr, nullptr, dummyBlobURLs, serializedKey);
+ Vector<RefPtr<MessagePort>> dummyMessagePorts;
+ Vector<RefPtr<JSC::ArrayBuffer>> dummyArrayBuffers;
+ CloneSerializer rawKeySerializer(m_exec, dummyMessagePorts, dummyArrayBuffers, dummyBlobURLs, serializedKey);
rawKeySerializer.write(key);
Vector<uint8_t> wrappedKey;
if (!wrapCryptoKey(m_exec, serializedKey, wrappedKey))
@@ -1487,7 +1487,7 @@
return str;
}
- static DeserializationResult deserialize(ExecState* exec, JSGlobalObject* globalObject, MessagePortArray* messagePorts, ArrayBufferContentsArray* arrayBufferContentsArray, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths)
+ 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)
{
if (!buffer.size())
return std::make_pair(jsNull(), UnspecifiedError);
@@ -1536,7 +1536,7 @@
size_t m_index;
};
- CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, MessagePortArray* messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer)
+ CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer)
: CloneBase(exec)
, m_globalObject(globalObject)
, m_isDOMGlobalObject(globalObject->inherits(JSDOMGlobalObject::info()))
@@ -1551,7 +1551,7 @@
m_version = 0xFFFFFFFF;
}
- CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, MessagePortArray* messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths)
+ CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths)
: CloneBase(exec)
, m_globalObject(globalObject)
, m_isDOMGlobalObject(globalObject->inherits(JSDOMGlobalObject::info()))
@@ -2347,11 +2347,11 @@
case MessagePortReferenceTag: {
uint32_t index;
bool indexSuccessfullyRead = read(index);
- if (!indexSuccessfullyRead || !m_messagePorts || index >= m_messagePorts->size()) {
+ if (!indexSuccessfullyRead || index >= m_messagePorts.size()) {
fail();
return JSValue();
}
- return getJSValue(m_messagePorts->at(index).get());
+ return getJSValue(m_messagePorts[index].get());
}
case ArrayBufferTag: {
RefPtr<ArrayBuffer> arrayBuffer;
@@ -2398,7 +2398,8 @@
return JSValue();
}
JSValue cryptoKey;
- CloneDeserializer rawKeyDeserializer(m_exec, m_globalObject, nullptr, nullptr, serializedKey);
+ Vector<RefPtr<MessagePort>> dummyMessagePorts;
+ CloneDeserializer rawKeyDeserializer(m_exec, m_globalObject, dummyMessagePorts, nullptr, serializedKey);
if (!rawKeyDeserializer.readCryptoKey(cryptoKey)) {
fail();
return JSValue();
@@ -2428,9 +2429,9 @@
const uint8_t* m_end;
unsigned m_version;
Vector<CachedString> m_constantPool;
- MessagePortArray* m_messagePorts;
+ Vector<RefPtr<MessagePort>>& m_messagePorts;
ArrayBufferContentsArray* m_arrayBufferContents;
- ArrayBufferArray m_arrayBuffers;
+ Vector<RefPtr<JSC::ArrayBuffer>> m_arrayBuffers;
Vector<String> m_blobURLs;
Vector<String> m_blobFilePaths;
@@ -2654,7 +2655,7 @@
}
std::unique_ptr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValue::transferArrayBuffers(
- ExecState* exec, ArrayBufferArray& arrayBuffers, SerializationReturnCode& code)
+ ExecState* exec, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers, SerializationReturnCode& code)
{
for (size_t i = 0; i < arrayBuffers.size(); i++) {
if (arrayBuffers[i]->isNeutered()) {
@@ -2682,19 +2683,24 @@
return contents;
}
-RefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState* exec, JSValue value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, SerializationErrorMode throwExceptions)
+RefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState& exec, JSValue value, SerializationErrorMode throwExceptions)
{
+ Vector<RefPtr<MessagePort>> messagePorts;
+ return SerializedScriptValue::create(exec, value, messagePorts, { }, throwExceptions);
+}
+
+RefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState& exec, JSValue value, Vector<RefPtr<MessagePort>>& messagePorts, Vector<RefPtr<JSC::ArrayBuffer>>&& arrayBuffers, SerializationErrorMode throwExceptions)
+{
Vector<uint8_t> buffer;
Vector<String> blobURLs;
- SerializationReturnCode code = CloneSerializer::serialize(exec, value, messagePorts, arrayBuffers, blobURLs, buffer);
+ SerializationReturnCode code = CloneSerializer::serialize(&exec, value, messagePorts, arrayBuffers, blobURLs, buffer);
std::unique_ptr<ArrayBufferContentsArray> arrayBufferContentsArray;
+ if (!arrayBuffers.isEmpty() && serializationDidCompleteSuccessfully(code))
+ arrayBufferContentsArray = transferArrayBuffers(&exec, arrayBuffers, code);
- if (arrayBuffers && serializationDidCompleteSuccessfully(code))
- arrayBufferContentsArray = transferArrayBuffers(exec, *arrayBuffers, code);
-
if (throwExceptions == Throwing)
- maybeThrowExceptionIfSerializationFailed(exec, code);
+ maybeThrowExceptionIfSerializationFailed(&exec, code);
if (!serializationDidCompleteSuccessfully(code))
return nullptr;
@@ -2718,7 +2724,7 @@
auto scope = DECLARE_CATCH_SCOPE(vm);
JSValue value = toJS(exec, apiValue);
- RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(exec, value, nullptr, nullptr);
+ RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(*exec, value);
if (UNLIKELY(scope.exception())) {
if (exception)
*exception = toRef(exec, scope.exception()->value());
@@ -2734,17 +2740,24 @@
return CloneDeserializer::deserializeString(m_data);
}
-JSValue SerializedScriptValue::deserialize(ExecState* exec, JSGlobalObject* globalObject, MessagePortArray* messagePorts, SerializationErrorMode throwExceptions)
+JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, SerializationErrorMode throwExceptions)
{
- Vector<String> dummyBlobs, dummyPaths;
- return deserialize(exec, globalObject, messagePorts, throwExceptions, dummyBlobs, dummyPaths);
+ Vector<RefPtr<MessagePort>> dummyMessagePorts;
+ return deserialize(exec, globalObject, dummyMessagePorts, throwExceptions);
}
-JSValue SerializedScriptValue::deserialize(ExecState* exec, JSGlobalObject* globalObject, MessagePortArray* messagePorts, SerializationErrorMode throwExceptions, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths)
+JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, SerializationErrorMode throwExceptions)
{
- DeserializationResult result = CloneDeserializer::deserialize(exec, globalObject, messagePorts, m_arrayBufferContentsArray.get(), m_data, blobURLs, blobFilePaths);
+ Vector<String> dummyBlobs;
+ Vector<String> dummyPaths;
+ return deserialize(exec, globalObject, messagePorts, dummyBlobs, dummyPaths, throwExceptions);
+}
+
+JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths, SerializationErrorMode throwExceptions)
+{
+ DeserializationResult result = CloneDeserializer::deserialize(&exec, globalObject, messagePorts, m_arrayBufferContentsArray.get(), m_data, blobURLs, blobFilePaths);
if (throwExceptions == Throwing)
- maybeThrowExceptionIfSerializationFailed(exec, result.second);
+ maybeThrowExceptionIfSerializationFailed(&exec, result.second);
return result.first ? result.first : jsNull();
}
@@ -2755,7 +2768,7 @@
JSLockHolder locker(vm);
auto scope = DECLARE_CATCH_SCOPE(vm);
- JSValue value = deserialize(exec, exec->lexicalGlobalObject(), nullptr);
+ JSValue value = deserialize(*exec, exec->lexicalGlobalObject());
if (UNLIKELY(scope.exception())) {
if (exception)
*exception = toRef(exec, scope.exception()->value());
Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.h (207504 => 207505)
--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.h 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.h 2016-10-19 00:05:09 UTC (rev 207505)
@@ -42,8 +42,6 @@
class IDBValue;
class MessagePort;
-typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;
-typedef Vector<RefPtr<JSC::ArrayBuffer>, 1> ArrayBufferArray;
enum SerializationReturnCode {
SuccessfullyCompleted,
@@ -61,7 +59,8 @@
class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue> {
public:
- WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSC::ExecState*, JSC::JSValue, MessagePortArray*, ArrayBufferArray*, SerializationErrorMode = Throwing);
+ WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSC::ExecState&, JSC::JSValue, SerializationErrorMode = Throwing);
+ WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSC::ExecState&, JSC::JSValue, Vector<RefPtr<MessagePort>>&, Vector<RefPtr<JSC::ArrayBuffer>>&&, SerializationErrorMode = Throwing);
WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(StringView);
static Ref<SerializedScriptValue> adopt(Vector<uint8_t>&& buffer)
@@ -71,8 +70,9 @@
static Ref<SerializedScriptValue> nullValue();
- WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState*, JSC::JSGlobalObject*, MessagePortArray*, SerializationErrorMode = Throwing);
- JSC::JSValue deserialize(JSC::ExecState*, JSC::JSGlobalObject*, MessagePortArray*, SerializationErrorMode, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths);
+ WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, SerializationErrorMode = Throwing);
+ WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, Vector<RefPtr<MessagePort>>&, SerializationErrorMode = Throwing);
+ JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, Vector<RefPtr<MessagePort>>&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths, SerializationErrorMode = Throwing);
static uint32_t wireFormatVersion();
@@ -103,7 +103,7 @@
typedef Vector<JSC::ArrayBufferContents> ArrayBufferContentsArray;
static void maybeThrowExceptionIfSerializationFailed(JSC::ExecState*, SerializationReturnCode);
static bool serializationDidCompleteSuccessfully(SerializationReturnCode);
- static std::unique_ptr<ArrayBufferContentsArray> transferArrayBuffers(JSC::ExecState*, ArrayBufferArray&, SerializationReturnCode&);
+ static std::unique_ptr<ArrayBufferContentsArray> transferArrayBuffers(JSC::ExecState*, Vector<RefPtr<JSC::ArrayBuffer>>&, SerializationReturnCode&);
WEBCORE_EXPORT SerializedScriptValue(Vector<unsigned char>&&);
SerializedScriptValue(Vector<unsigned char>&&, const Vector<String>& blobURLs, std::unique_ptr<ArrayBufferContentsArray>&&);
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (207504 => 207505)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-10-19 00:05:09 UTC (rev 207505)
@@ -4905,7 +4905,6 @@
die "This should only be called for sequence or array types" unless $codeGenerator->IsSequenceOrFrozenArrayType($type);
my $innerType = $codeGenerator->GetSequenceOrFrozenArrayInnerType($type);
- return "MessagePortArray" if $innerType eq "MessagePort";
return "Vector<" . GetNativeVectorInnerType($innerType) . ">";
}
@@ -5168,7 +5167,7 @@
if ($type eq "SerializedScriptValue") {
AddToImplIncludes("SerializedScriptValue.h", $conditional);
- return ("SerializedScriptValue::create($statePointer, $value, 0, 0)", 1);
+ return ("SerializedScriptValue::create($stateReference, $value)", 1);
}
if ($type eq "Dictionary") {
@@ -5274,7 +5273,7 @@
if ($type eq "SerializedScriptValue") {
AddToImplIncludes("SerializedScriptValue.h", $conditional);
- return "$value ? $value->deserialize($statePointer, $globalObject, 0) : jsNull()";
+ return "$value ? $value->deserialize($stateReference, $globalObject) : jsNull()";
}
AddToImplIncludes("StyleProperties.h", $conditional) if $type eq "CSSStyleDeclaration";
Modified: trunk/Source/WebCore/dom/CustomEvent.cpp (207504 => 207505)
--- trunk/Source/WebCore/dom/CustomEvent.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/dom/CustomEvent.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -61,7 +61,7 @@
RefPtr<SerializedScriptValue> CustomEvent::trySerializeDetail(JSC::ExecState& state)
{
if (!m_triedToSerialize) {
- m_serializedDetail = SerializedScriptValue::create(&state, m_detail, nullptr, nullptr, NonThrowing);
+ m_serializedDetail = SerializedScriptValue::create(state, m_detail, NonThrowing);
m_triedToSerialize = true;
}
return m_serializedDetail;
Modified: trunk/Source/WebCore/dom/ErrorEvent.cpp (207504 => 207505)
--- trunk/Source/WebCore/dom/ErrorEvent.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/dom/ErrorEvent.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -81,7 +81,7 @@
auto serializedError = trySerializeError(exec);
if (!serializedError)
return jsNull();
- return serializedError->deserialize(&exec, &globalObject, nullptr);
+ return serializedError->deserialize(exec, &globalObject);
}
return error;
@@ -90,7 +90,7 @@
RefPtr<SerializedScriptValue> ErrorEvent::trySerializeError(ExecState& exec)
{
if (!m_triedToSerialize) {
- m_serializedDetail = SerializedScriptValue::create(&exec, m_error, nullptr, nullptr, NonThrowing);
+ m_serializedDetail = SerializedScriptValue::create(exec, m_error, NonThrowing);
m_triedToSerialize = true;
}
return m_serializedDetail;
Modified: trunk/Source/WebCore/dom/MessageEvent.cpp (207504 => 207505)
--- trunk/Source/WebCore/dom/MessageEvent.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/dom/MessageEvent.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -48,11 +48,11 @@
, m_origin(initializer.origin)
, m_lastEventId(initializer.lastEventId)
, m_source(WTFMove(initializer.source))
- , m_ports(std::make_unique<MessagePortArray>(initializer.ports))
+ , m_ports(WTFMove(initializer.ports))
{
}
-inline MessageEvent::MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray> ports)
+inline MessageEvent::MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, Vector<RefPtr<MessagePort>>&& ports)
: Event(eventNames().messageEvent, false, false)
, m_dataType(DataTypeSerializedScriptValue)
, m_dataAsSerializedScriptValue(WTFMove(data))
@@ -96,7 +96,7 @@
{
}
-Ref<MessageEvent> MessageEvent::create(std::unique_ptr<MessagePortArray> ports, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source)
+Ref<MessageEvent> MessageEvent::create(Vector<RefPtr<MessagePort>>&& ports, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source)
{
return adoptRef(*new MessageEvent(WTFMove(data), origin, lastEventId, WTFMove(source), WTFMove(ports)));
}
@@ -135,7 +135,7 @@
{
}
-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)
+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)
{
if (dispatched())
return;
@@ -143,7 +143,7 @@
initEvent(type, canBubble, cancelable);
m_dataType = DataTypeScriptValue;
- m_dataAsScriptValue = data;
+ m_dataAsScriptValue = Deprecated::ScriptValue(state.vm(), data);
m_dataAsSerializedScriptValue = nullptr;
m_triedToSerialize = false;
m_origin = origin;
@@ -152,7 +152,7 @@
m_ports = WTFMove(ports);
}
-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)
+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)
{
if (dispatched())
return;
@@ -185,7 +185,7 @@
ASSERT(!m_dataAsScriptValue.hasNoValue());
if (!m_dataAsSerializedScriptValue && !m_triedToSerialize) {
- m_dataAsSerializedScriptValue = SerializedScriptValue::create(exec, m_dataAsScriptValue.jsValue(), nullptr, nullptr, NonThrowing);
+ m_dataAsSerializedScriptValue = SerializedScriptValue::create(*exec, m_dataAsScriptValue.jsValue(), NonThrowing);
m_triedToSerialize = true;
}
Modified: trunk/Source/WebCore/dom/MessageEvent.h (207504 => 207505)
--- trunk/Source/WebCore/dom/MessageEvent.h 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/dom/MessageEvent.h 2016-10-19 00:05:09 UTC (rev 207505)
@@ -42,7 +42,7 @@
class MessageEvent final : public Event {
public:
- static Ref<MessageEvent> create(std::unique_ptr<MessagePortArray>, RefPtr<SerializedScriptValue>&&, const String& origin = { }, const String& lastEventId = { }, Optional<MessageEventSource>&& source = Nullopt);
+ static Ref<MessageEvent> create(Vector<RefPtr<MessagePort>>&&, RefPtr<SerializedScriptValue>&&, const String& origin = { }, const String& lastEventId = { }, Optional<MessageEventSource>&& source = Nullopt);
static Ref<MessageEvent> create(const AtomicString& type, RefPtr<SerializedScriptValue>&&, const String& origin, const String& lastEventId);
static Ref<MessageEvent> create(const String& data, const String& origin = { });
static Ref<MessageEvent> create(Ref<Blob>&& data, const String& origin);
@@ -54,19 +54,19 @@
String origin;
String lastEventId;
Optional<MessageEventSource> source;
- MessagePortArray ports;
+ Vector<RefPtr<MessagePort>> ports;
};
static Ref<MessageEvent> create(JSC::ExecState&, const AtomicString& type, Init&, IsTrusted = IsTrusted::No);
virtual ~MessageEvent();
- void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray>);
- 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>);
+ 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>>&&);
+ void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&&, Vector<RefPtr<MessagePort>>&&);
const String& origin() const { return m_origin; }
const String& lastEventId() const { return m_lastEventId; }
EventTarget* source() const;
- MessagePortArray ports() const { return m_ports ? *m_ports : MessagePortArray(); }
+ const Vector<RefPtr<MessagePort>>& ports() const { return m_ports; }
// FIXME: Remove this when we have custom ObjC binding support.
SerializedScriptValue* data() const;
@@ -92,7 +92,7 @@
private:
MessageEvent();
MessageEvent(JSC::ExecState&, const AtomicString&, Init&, IsTrusted);
- MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray>);
+ MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&&, Vector<RefPtr<MessagePort>>&&);
MessageEvent(const AtomicString& type, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId);
MessageEvent(const String& data, const String& origin);
MessageEvent(Ref<Blob>&& data, const String& origin);
@@ -108,7 +108,7 @@
String m_origin;
String m_lastEventId;
Optional<MessageEventSource> m_source;
- std::unique_ptr<MessagePortArray> m_ports;
+ Vector<RefPtr<MessagePort>> m_ports;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/MessageEvent.idl (207504 => 207505)
--- trunk/Source/WebCore/dom/MessageEvent.idl 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/dom/MessageEvent.idl 2016-10-19 00:05:09 UTC (rev 207505)
@@ -39,11 +39,10 @@
[Custom] void initMessageEvent(optional DOMString typeArg, optional boolean canBubbleArg, optional boolean cancelableArg,
optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional (DOMWindow or MessagePort)? sourceArg,
- optional Array messagePorts);
-
+ optional sequence<MessagePort> messagePorts);
[Custom] void webkitInitMessageEvent(optional DOMString typeArg, optional boolean canBubbleArg, optional boolean cancelableArg,
optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional (DOMWindow or MessagePort)? sourceArg,
- optional Array transferables);
+ optional sequence<MessagePort> messagePorts);
};
dictionary MessageEventInit : EventInit {
Modified: trunk/Source/WebCore/dom/MessagePort.cpp (207504 => 207505)
--- trunk/Source/WebCore/dom/MessagePort.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/dom/MessagePort.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -53,7 +53,7 @@
m_scriptExecutionContext->destroyedMessagePort(*this);
}
-void MessagePort::postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray* ports, ExceptionCode& ec)
+void MessagePort::postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec)
{
if (!isEntangled())
return;
@@ -61,14 +61,14 @@
std::unique_ptr<MessagePortChannelArray> channels;
// Make sure we aren't connected to any of the passed-in ports.
- if (ports) {
- for (auto& dataPort : *ports) {
+ if (!ports.isEmpty()) {
+ for (auto& dataPort : ports) {
if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort.get())) {
ec = DATA_CLONE_ERR;
return;
}
}
- channels = MessagePort::disentanglePorts(ports, ec);
+ channels = MessagePort::disentanglePorts(WTFMove(ports), ec);
if (ec)
return;
}
@@ -152,7 +152,7 @@
if (is<WorkerGlobalScope>(*m_scriptExecutionContext) && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).isClosing())
return;
- std::unique_ptr<MessagePortArray> ports = MessagePort::entanglePorts(*m_scriptExecutionContext, WTFMove(channels));
+ Vector<RefPtr<MessagePort>> ports = MessagePort::entanglePorts(*m_scriptExecutionContext, WTFMove(channels));
Ref<Event> event = MessageEvent::create(WTFMove(ports), WTFMove(message));
dispatchEvent(event);
}
@@ -174,9 +174,9 @@
return m_entangledChannel ? m_entangledChannel->locallyEntangledPort(m_scriptExecutionContext) : nullptr;
}
-std::unique_ptr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessagePortArray* ports, ExceptionCode& ec)
+std::unique_ptr<MessagePortChannelArray> MessagePort::disentanglePorts(Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec)
{
- if (!ports || !ports->size())
+ if (ports.isEmpty())
return nullptr;
// HashSet used to efficiently check for duplicates in the passed-in array.
@@ -183,7 +183,7 @@
HashSet<MessagePort*> portSet;
// 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).
- for (auto& port : *ports) {
+ for (auto& port : ports) {
if (!port || port->isNeutered() || portSet.contains(port.get())) {
ec = DATA_CLONE_ERR;
return nullptr;
@@ -192,24 +192,25 @@
}
// Passed-in ports passed validity checks, so we can disentangle them.
- auto portArray = std::make_unique<MessagePortChannelArray>(ports->size());
- for (unsigned int i = 0 ; i < ports->size() ; ++i) {
- std::unique_ptr<MessagePortChannel> channel = (*ports)[i]->disentangle();
+ auto portArray = std::make_unique<MessagePortChannelArray>(ports.size());
+ for (unsigned int i = 0 ; i < ports.size() ; ++i) {
+ std::unique_ptr<MessagePortChannel> channel = ports[i]->disentangle();
(*portArray)[i] = WTFMove(channel);
}
return portArray;
}
-std::unique_ptr<MessagePortArray> MessagePort::entanglePorts(ScriptExecutionContext& context, std::unique_ptr<MessagePortChannelArray> channels)
+Vector<RefPtr<MessagePort>> MessagePort::entanglePorts(ScriptExecutionContext& context, std::unique_ptr<MessagePortChannelArray> channels)
{
if (!channels || !channels->size())
- return nullptr;
+ return { };
- auto portArray = std::make_unique<MessagePortArray>(channels->size());
+ Vector<RefPtr<MessagePort>> portArray;
+ portArray.reserveInitialCapacity(channels->size());
for (unsigned int i = 0; i < channels->size(); ++i) {
auto port = MessagePort::create(context);
port->entangle(WTFMove((*channels)[i]));
- (*portArray)[i] = WTFMove(port);
+ portArray.uncheckedAppend(WTFMove(port));
}
return portArray;
}
Modified: trunk/Source/WebCore/dom/MessagePort.h (207504 => 207505)
--- trunk/Source/WebCore/dom/MessagePort.h 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/dom/MessagePort.h 2016-10-19 00:05:09 UTC (rev 207505)
@@ -42,15 +42,12 @@
class MessagePort;
class ScriptExecutionContext;
- // The overwhelmingly common case is sending a single port, so handle that efficiently with an inline buffer of size 1.
- typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;
-
class MessagePort final : public RefCounted<MessagePort>, public EventTargetWithInlineData {
public:
static Ref<MessagePort> create(ScriptExecutionContext& scriptExecutionContext) { return adoptRef(*new MessagePort(scriptExecutionContext)); }
virtual ~MessagePort();
- void postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*, ExceptionCode&);
+ void postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&&, ExceptionCode&);
void start();
void close();
@@ -59,10 +56,9 @@
std::unique_ptr<MessagePortChannel> disentangle();
// Returns 0 if there is an exception, or if the passed-in array is 0/empty.
- static std::unique_ptr<MessagePortChannelArray> disentanglePorts(const MessagePortArray*, ExceptionCode&);
+ static std::unique_ptr<MessagePortChannelArray> disentanglePorts(Vector<RefPtr<MessagePort>>&&, ExceptionCode&);
- // Returns 0 if the passed array is 0/empty.
- static std::unique_ptr<MessagePortArray> entanglePorts(ScriptExecutionContext&, std::unique_ptr<MessagePortChannelArray>);
+ static Vector<RefPtr<MessagePort>> entanglePorts(ScriptExecutionContext&, std::unique_ptr<MessagePortChannelArray>);
void messageAvailable();
bool started() const { return m_started; }
Modified: trunk/Source/WebCore/dom/PopStateEvent.cpp (207504 => 207505)
--- trunk/Source/WebCore/dom/PopStateEvent.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/dom/PopStateEvent.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -70,7 +70,7 @@
ASSERT(!m_state.hasNoValue());
if (!m_serializedState && !m_triedToSerialize) {
- m_serializedState = SerializedScriptValue::create(exec, m_state.jsValue(), nullptr, nullptr, NonThrowing);
+ m_serializedState = SerializedScriptValue::create(*exec, m_state.jsValue(), NonThrowing);
m_triedToSerialize = true;
}
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (207504 => 207505)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -906,7 +906,7 @@
return m_localStorage.get();
}
-void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, const String& targetOrigin, DOMWindow& source, ExceptionCode& ec)
+void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, Vector<RefPtr<MessagePort>>&& ports, const String& targetOrigin, DOMWindow& source, ExceptionCode& ec)
{
if (!isCurrentlyDisplayedInFrame())
return;
@@ -930,7 +930,7 @@
}
}
- auto channels = MessagePort::disentanglePorts(ports, ec);
+ auto channels = MessagePort::disentanglePorts(WTFMove(ports), ec);
if (ec)
return;
Modified: trunk/Source/WebCore/page/DOMWindow.h (207504 => 207505)
--- trunk/Source/WebCore/page/DOMWindow.h 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/page/DOMWindow.h 2016-10-19 00:05:09 UTC (rev 207505)
@@ -88,8 +88,6 @@
struct WindowFeatures;
- typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;
-
typedef int ExceptionCode;
enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForwardList };
@@ -241,7 +239,7 @@
void printErrorMessage(const String&);
String crossDomainAccessErrorMessage(const DOMWindow& activeWindow);
- void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, const String& targetOrigin, DOMWindow& source, ExceptionCode&);
+ void postMessage(PassRefPtr<SerializedScriptValue> message, Vector<RefPtr<MessagePort>>&&, const String& targetOrigin, DOMWindow& source, ExceptionCode&);
void postMessageTimerFired(PostMessageTimer&);
void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, Event&, PassRefPtr<Inspector::ScriptCallStack>);
Modified: trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp (207504 => 207505)
--- trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -63,10 +63,10 @@
return DedicatedWorkerGlobalScopeEventTargetInterfaceType;
}
-void DedicatedWorkerGlobalScope::postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray* ports, ExceptionCode& ec)
+void DedicatedWorkerGlobalScope::postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec)
{
// Disentangle the port in preparation for sending it to the remote context.
- auto channels = MessagePort::disentanglePorts(ports, ec);
+ auto channels = MessagePort::disentanglePorts(WTFMove(ports), ec);
if (ec)
return;
thread().workerObjectProxy().postMessageToWorkerObject(WTFMove(message), WTFMove(channels));
Modified: trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h (207504 => 207505)
--- trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h 2016-10-19 00:05:09 UTC (rev 207505)
@@ -53,7 +53,7 @@
// EventTarget
EventTargetInterface eventTargetInterface() const override;
- void postMessage(RefPtr<SerializedScriptValue>&&, const MessagePortArray*, ExceptionCode&);
+ void postMessage(RefPtr<SerializedScriptValue>&&, Vector<RefPtr<MessagePort>>&&, ExceptionCode&);
DedicatedWorkerThread& thread();
Modified: trunk/Source/WebCore/workers/Worker.cpp (207504 => 207505)
--- trunk/Source/WebCore/workers/Worker.cpp 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/workers/Worker.cpp 2016-10-19 00:05:09 UTC (rev 207505)
@@ -107,10 +107,10 @@
m_contextProxy->workerObjectDestroyed();
}
-void Worker::postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray* ports, ExceptionCode& ec)
+void Worker::postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, ExceptionCode& ec)
{
// Disentangle the port in preparation for sending it to the remote context.
- auto channels = MessagePort::disentanglePorts(ports, ec);
+ auto channels = MessagePort::disentanglePorts(WTFMove(ports), ec);
if (ec)
return;
m_contextProxy->postMessageToWorkerGlobalScope(WTFMove(message), WTFMove(channels));
Modified: trunk/Source/WebCore/workers/Worker.h (207504 => 207505)
--- trunk/Source/WebCore/workers/Worker.h 2016-10-18 23:55:04 UTC (rev 207504)
+++ trunk/Source/WebCore/workers/Worker.h 2016-10-19 00:05:09 UTC (rev 207505)
@@ -54,7 +54,7 @@
EventTargetInterface eventTargetInterface() const override { return WorkerEventTargetInterfaceType; }
- void postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*, ExceptionCode&);
+ void postMessage(RefPtr<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&&, ExceptionCode&);
void terminate();