WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP Patch
237241_wip.patch (text/plain), 40.04 KB, created by
Chris Dumez
on 2022-02-26 23:41:36 PST
(
hide
)
Description:
WIP Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2022-02-26 23:41:36 PST
Size:
40.04 KB
patch
obsolete
>diff --git a/Source/WebCore/Modules/indexeddb/IDBValue.cpp b/Source/WebCore/Modules/indexeddb/IDBValue.cpp >index a361113ddc52..72825540cf5a 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBValue.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBValue.cpp >@@ -36,7 +36,7 @@ IDBValue::IDBValue() > } > > IDBValue::IDBValue(const SerializedScriptValue& scriptValue) >- : m_data(ThreadSafeDataBuffer::copyVector(scriptValue.data())) >+ : m_data(ThreadSafeDataBuffer::copyVector(scriptValue.wireBytes())) > , m_blobURLs(scriptValue.blobURLs()) > { > } >@@ -47,7 +47,7 @@ IDBValue::IDBValue(const ThreadSafeDataBuffer& value) > } > > IDBValue::IDBValue(const SerializedScriptValue& scriptValue, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths) >- : m_data(ThreadSafeDataBuffer::copyVector(scriptValue.data())) >+ : m_data(ThreadSafeDataBuffer::copyVector(scriptValue.wireBytes())) > , m_blobURLs(blobURLs) > , m_blobFilePaths(blobFilePaths) > { >diff --git a/Source/WebCore/Modules/webaudio/AudioWorkletNode.cpp b/Source/WebCore/Modules/webaudio/AudioWorkletNode.cpp >index a5b28c853fbb..44a5658f6e76 100644 >--- a/Source/WebCore/Modules/webaudio/AudioWorkletNode.cpp >+++ b/Source/WebCore/Modules/webaudio/AudioWorkletNode.cpp >@@ -90,12 +90,9 @@ ExceptionOr<Ref<AudioWorkletNode>> AudioWorkletNode::create(JSC::JSGlobalObject& > { > auto lock = JSC::JSLockHolder { &globalObject }; > auto* jsOptions = convertDictionaryToJS(globalObject, *JSC::jsCast<JSDOMGlobalObject*>(&globalObject), options); >- Vector<RefPtr<MessagePort>> ports; >- auto serializedValue = SerializedScriptValue::create(globalObject, jsOptions, { }, ports, SerializationContext::WorkerPostMessage); >- if (serializedValue.hasException()) >+ serializedOptions = SerializedScriptValue::create(globalObject, jsOptions, SerializationErrorMode::NonThrowing, SerializationContext::WorkerPostMessage); >+ if (!serializedOptions) > serializedOptions = SerializedScriptValue::nullValue(); >- else >- serializedOptions = serializedValue.releaseReturnValue(); > } > > auto parameterData = WTFMove(options.parameterData); >diff --git a/Source/WebCore/bindings/js/SerializedScriptValue.cpp b/Source/WebCore/bindings/js/SerializedScriptValue.cpp >index 4252a564763b..5ec221bd2339 100644 >--- a/Source/WebCore/bindings/js/SerializedScriptValue.cpp >+++ b/Source/WebCore/bindings/js/SerializedScriptValue.cpp >@@ -4102,12 +4102,6 @@ error: > > SerializedScriptValue::~SerializedScriptValue() = default; > >-SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>&& buffer) >- : m_data(WTFMove(buffer)) >-{ >- m_memoryCost = computeMemoryCost(); >-} >- > SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>&& buffer, std::unique_ptr<ArrayBufferContentsArray>&& arrayBufferContentsArray > #if ENABLE(WEB_RTC) > , Vector<std::unique_ptr<DetachedRTCDataChannel>>&& detachedRTCDataChannels >@@ -4269,51 +4263,6 @@ static Exception exceptionForSerializationFailure(SerializationReturnCode code) > return Exception { TypeError }; > } > >-RefPtr<SerializedScriptValue> SerializedScriptValue::create(JSGlobalObject& lexicalGlobalObject, JSValue value, SerializationErrorMode throwExceptions) >-{ >- Vector<uint8_t> buffer; >- Vector<BlobURLHandle> blobHandles; >- Vector<RefPtr<MessagePort>> dummyMessagePorts; >- Vector<RefPtr<ImageBitmap>> dummyImageBitmaps; >-#if ENABLE(OFFSCREEN_CANVAS_IN_WORKERS) >- Vector<RefPtr<OffscreenCanvas>> dummyOffscreenCanvases; >-#endif >-#if ENABLE(WEB_RTC) >- Vector<Ref<RTCDataChannel>> dummyRTCDataChannels; >-#endif >- Vector<RefPtr<JSC::ArrayBuffer>> dummyArrayBuffers; >-#if ENABLE(WEBASSEMBLY) >- WasmModuleArray dummyModules; >- WasmMemoryHandleArray dummyMemoryHandles; >-#endif >- ArrayBufferContentsArray dummySharedBuffers; >- auto code = CloneSerializer::serialize(&lexicalGlobalObject, value, dummyMessagePorts, dummyArrayBuffers, dummyImageBitmaps, >-#if ENABLE(OFFSCREEN_CANVAS_IN_WORKERS) >- dummyOffscreenCanvases, >-#endif >-#if ENABLE(WEB_RTC) >- dummyRTCDataChannels, >-#endif >-#if ENABLE(WEBASSEMBLY) >- dummyModules, >- dummyMemoryHandles, >-#endif >- blobHandles, buffer, SerializationContext::Default, dummySharedBuffers); >- >-#if ENABLE(WEBASSEMBLY) >- ASSERT_WITH_MESSAGE(dummyModules.isEmpty(), "Wasm::Module serialization is only allowed in the postMessage context"); >- ASSERT_WITH_MESSAGE(dummyMemoryHandles.isEmpty(), "Wasm::Memory serialization is only allowed in the postMessage context"); >-#endif >- >- if (throwExceptions == SerializationErrorMode::Throwing) >- maybeThrowExceptionIfSerializationFailed(lexicalGlobalObject, code); >- >- if (code != SerializationReturnCode::SuccessfullyCompleted) >- return nullptr; >- >- return adoptRef(*new SerializedScriptValue(WTFMove(buffer), blobHandles, nullptr, nullptr, { })); >-} >- > static bool containsDuplicates(const Vector<RefPtr<ImageBitmap>>& imageBitmaps) > { > HashSet<ImageBitmap*> visited; >@@ -4354,7 +4303,16 @@ static bool canDetachRTCDataChannels(const Vector<Ref<RTCDataChannel>>& channels > } > #endif > >-ExceptionOr<Ref<SerializedScriptValue>> SerializedScriptValue::create(JSGlobalObject& lexicalGlobalObject, JSValue value, Vector<JSC::Strong<JSC::JSObject>>&& transferList, Vector<RefPtr<MessagePort>>& messagePorts, SerializationContext context) >+RefPtr<SerializedScriptValue> SerializedScriptValue::create(JSC::JSGlobalObject& globalObject, JSC::JSValue value, SerializationErrorMode throwExceptions, SerializationContext serializationContext) >+{ >+ Vector<RefPtr<MessagePort>> dummyPorts; >+ auto result = create(globalObject, value, { }, dummyPorts, throwExceptions, serializationContext); >+ if (result.hasException()) >+ return nullptr; >+ return result.releaseReturnValue(); >+} >+ >+ExceptionOr<Ref<SerializedScriptValue>> SerializedScriptValue::create(JSGlobalObject& lexicalGlobalObject, JSValue value, Vector<JSC::Strong<JSC::JSObject>>&& transferList, Vector<RefPtr<MessagePort>>& messagePorts, SerializationErrorMode throwExceptions, SerializationContext context) > { > VM& vm = lexicalGlobalObject.vm(); > Vector<RefPtr<JSC::ArrayBuffer>> arrayBuffers; >@@ -4443,6 +4401,9 @@ ExceptionOr<Ref<SerializedScriptValue>> SerializedScriptValue::create(JSGlobalOb > #endif > blobHandles, buffer, context, *sharedBuffers); > >+ if (throwExceptions == SerializationErrorMode::Throwing) >+ maybeThrowExceptionIfSerializationFailed(lexicalGlobalObject, code); >+ > if (code != SerializationReturnCode::SuccessfullyCompleted) > return exceptionForSerializationFailure(code); > >@@ -4504,7 +4465,7 @@ RefPtr<SerializedScriptValue> SerializedScriptValue::create(JSContextRef originC > return serializedValue; > } > >-String SerializedScriptValue::toString() >+String SerializedScriptValue::toString() const > { > return CloneDeserializer::deserializeString(m_data); > } >diff --git a/Source/WebCore/bindings/js/SerializedScriptValue.h b/Source/WebCore/bindings/js/SerializedScriptValue.h >index ef37f1d0ca46..ea6f1cdcfa70 100644 >--- a/Source/WebCore/bindings/js/SerializedScriptValue.h >+++ b/Source/WebCore/bindings/js/SerializedScriptValue.h >@@ -71,15 +71,10 @@ DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(SerializedScriptValue); > class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue> { > WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(SerializedScriptValue); > public: >- WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSC::JSGlobalObject&, JSC::JSValue, SerializationErrorMode = SerializationErrorMode::Throwing); >- >- WEBCORE_EXPORT static ExceptionOr<Ref<SerializedScriptValue>> create(JSC::JSGlobalObject&, JSC::JSValue, Vector<JSC::Strong<JSC::JSObject>>&& transfer, Vector<RefPtr<MessagePort>>&, SerializationContext = SerializationContext::Default); >+ WEBCORE_EXPORT static ExceptionOr<Ref<SerializedScriptValue>> create(JSC::JSGlobalObject&, JSC::JSValue, Vector<JSC::Strong<JSC::JSObject>>&& transfer, Vector<RefPtr<MessagePort>>&, SerializationErrorMode = SerializationErrorMode::NonThrowing, SerializationContext = SerializationContext::Default); >+ WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSC::JSGlobalObject&, JSC::JSValue, SerializationErrorMode = SerializationErrorMode::Throwing, SerializationContext = SerializationContext::Default); > > WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(StringView); >- static Ref<SerializedScriptValue> adopt(Vector<uint8_t>&& buffer) >- { >- return adoptRef(*new SerializedScriptValue(WTFMove(buffer))); >- } > > static Ref<SerializedScriptValue> nullValue(); > >@@ -89,13 +84,12 @@ public: > > static uint32_t wireFormatVersion(); > >- String toString(); >+ String toString() const; > > // API implementation helpers. These don't expose special behavior for ArrayBuffers or MessagePorts. > WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSContextRef, JSValueRef, JSValueRef* exception); > WEBCORE_EXPORT JSValueRef deserialize(JSContextRef, JSValueRef* exception); > >- const Vector<uint8_t>& data() const { return m_data; } > bool hasBlobURLs() const { return !m_blobHandles.isEmpty(); } > > Vector<String> blobURLs() const; >@@ -106,7 +100,7 @@ public: > { > return adoptRef(*new SerializedScriptValue(WTFMove(data))); > } >- const Vector<uint8_t>& toWireBytes() const { return m_data; } >+ const Vector<uint8_t>& wireBytes() const { return m_data; } > > template<class Encoder> void encode(Encoder&) const; > template<class Decoder> static RefPtr<SerializedScriptValue> decode(Decoder&); >@@ -116,10 +110,9 @@ public: > WEBCORE_EXPORT ~SerializedScriptValue(); > > private: >- WEBCORE_EXPORT SerializedScriptValue(Vector<unsigned char>&&); >- WEBCORE_EXPORT SerializedScriptValue(Vector<unsigned char>&&, std::unique_ptr<ArrayBufferContentsArray>&& >+ WEBCORE_EXPORT SerializedScriptValue(Vector<unsigned char>&&, std::unique_ptr<ArrayBufferContentsArray>&& = nullptr > #if ENABLE(WEB_RTC) >- , Vector<std::unique_ptr<DetachedRTCDataChannel>>&& >+ , Vector<std::unique_ptr<DetachedRTCDataChannel>>&& = { } > #endif > ); > >diff --git a/Source/WebCore/dom/BroadcastChannel.cpp b/Source/WebCore/dom/BroadcastChannel.cpp >index e76253cd648b..2b6eab3a5cdd 100644 >--- a/Source/WebCore/dom/BroadcastChannel.cpp >+++ b/Source/WebCore/dom/BroadcastChannel.cpp >@@ -239,7 +239,7 @@ void BroadcastChannel::dispatchMessage(Ref<SerializedScriptValue>&& message) > > queueTaskKeepingObjectAlive(*this, TaskSource::PostedMessageQueue, [this, message = WTFMove(message)]() mutable { > if (!m_isClosed && scriptExecutionContext()) >- dispatchEvent(MessageEvent::create({ }, WTFMove(message), scriptExecutionContext()->securityOrigin()->toString())); >+ dispatchEvent(MessageEvent::create(WTFMove(message), scriptExecutionContext()->securityOrigin()->toString())); > }); > } > >diff --git a/Source/WebCore/dom/MessageEvent.cpp b/Source/WebCore/dom/MessageEvent.cpp >index 288f462862a9..6a3279b52147 100644 >--- a/Source/WebCore/dom/MessageEvent.cpp >+++ b/Source/WebCore/dom/MessageEvent.cpp >@@ -52,8 +52,8 @@ inline MessageEvent::MessageEvent(const AtomString& type, Init&& initializer, Is > { > } > >-inline MessageEvent::MessageEvent(DataType&& data, const String& origin, const String& lastEventId, std::optional<MessageEventSource>&& source, Vector<RefPtr<MessagePort>>&& ports) >- : Event(eventNames().messageEvent, CanBubble::No, IsCancelable::No) >+inline MessageEvent::MessageEvent(const AtomString& type, DataType&& data, const String& origin, const String& lastEventId, std::optional<MessageEventSource>&& source, Vector<RefPtr<MessagePort>>&& ports) >+ : Event(type, CanBubble::No, IsCancelable::No) > , m_data(WTFMove(data)) > , m_origin(origin) > , m_lastEventId(lastEventId) >@@ -62,37 +62,14 @@ inline MessageEvent::MessageEvent(DataType&& data, const String& origin, const S > { > } > >-inline MessageEvent::MessageEvent(const AtomString& type, Ref<SerializedScriptValue>&& data, const String& origin, const String& lastEventId) >- : Event(type, CanBubble::No, IsCancelable::No) >- , m_data(WTFMove(data)) >- , m_origin(origin) >- , m_lastEventId(lastEventId) >-{ >-} >- >-Ref<MessageEvent> MessageEvent::create(Vector<RefPtr<MessagePort>>&& ports, Ref<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, std::optional<MessageEventSource>&& source) >-{ >- return adoptRef(*new MessageEvent(WTFMove(data), origin, lastEventId, WTFMove(source), WTFMove(ports))); >-} >- >-Ref<MessageEvent> MessageEvent::create(const AtomString& type, Ref<SerializedScriptValue>&& data, const String& origin, const String& lastEventId) >-{ >- return adoptRef(*new MessageEvent(type, WTFMove(data), origin, lastEventId)); >-} >- >-Ref<MessageEvent> MessageEvent::create(const String& data, const String& origin) >-{ >- return adoptRef(*new MessageEvent(data, origin)); >-} >- >-Ref<MessageEvent> MessageEvent::create(Ref<Blob>&& data, const String& origin) >+Ref<MessageEvent> MessageEvent::create(const AtomString& type, DataType&& data, const String& origin, const String& lastEventId, std::optional<MessageEventSource>&& source, Vector<RefPtr<MessagePort>>&& ports) > { >- return adoptRef(*new MessageEvent(WTFMove(data), origin)); >+ return adoptRef(*new MessageEvent(type, WTFMove(data), origin, lastEventId, WTFMove(source), WTFMove(ports))); > } > >-Ref<MessageEvent> MessageEvent::create(Ref<ArrayBuffer>&& data, const String& origin) >+Ref<MessageEvent> MessageEvent::create(DataType&& data, const String& origin, const String& lastEventId, std::optional<MessageEventSource>&& source, Vector<RefPtr<MessagePort>>&& ports) > { >- return adoptRef(*new MessageEvent(WTFMove(data), origin)); >+ return create(eventNames().messageEvent, WTFMove(data), origin, lastEventId, WTFMove(source), WTFMove(ports)); > } > > Ref<MessageEvent> MessageEvent::createForBindings() >diff --git a/Source/WebCore/dom/MessageEvent.h b/Source/WebCore/dom/MessageEvent.h >index 651069942400..4668807bce45 100644 >--- a/Source/WebCore/dom/MessageEvent.h >+++ b/Source/WebCore/dom/MessageEvent.h >@@ -48,11 +48,10 @@ using MessageEventSource = std::variant<RefPtr<WindowProxy>, RefPtr<MessagePort> > class MessageEvent final : public Event { > WTF_MAKE_ISO_ALLOCATED(MessageEvent); > public: >- static Ref<MessageEvent> create(Vector<RefPtr<MessagePort>>&&, Ref<SerializedScriptValue>&&, const String& origin = { }, const String& lastEventId = { }, std::optional<MessageEventSource>&& source = std::nullopt); >- static Ref<MessageEvent> create(const AtomString& type, Ref<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); >- static Ref<MessageEvent> create(Ref<ArrayBuffer>&& data, const String& origin = { }); >+ struct JSValueTag { }; >+ using DataType = std::variant<JSValueTag, Ref<SerializedScriptValue>, String, Ref<Blob>, Ref<ArrayBuffer>>; >+ static Ref<MessageEvent> create(const AtomString& type, DataType&&, const String& origin = { }, const String& lastEventId = { }, std::optional<MessageEventSource>&& = std::nullopt, Vector<RefPtr<MessagePort>>&& = { }); >+ static Ref<MessageEvent> create(DataType&&, const String& origin = { }, const String& lastEventId = { }, std::optional<MessageEventSource>&& = std::nullopt, Vector<RefPtr<MessagePort>>&& = { }); > static Ref<MessageEvent> createForBindings(); > > struct Init : EventInit { >@@ -73,8 +72,6 @@ public: > const std::optional<MessageEventSource>& source() const { return m_source; } > const Vector<RefPtr<MessagePort>>& ports() const { return m_ports; } > >- struct JSValueTag { }; >- using DataType = std::variant<JSValueTag, Ref<SerializedScriptValue>, String, Ref<Blob>, Ref<ArrayBuffer>>; > const DataType& data() const { return m_data; } > > JSValueInWrappedObject& jsData() { return m_jsData; } >@@ -86,8 +83,7 @@ public: > private: > MessageEvent(); > MessageEvent(const AtomString& type, Init&&, IsTrusted); >- MessageEvent(const AtomString& type, Ref<SerializedScriptValue>&& data, const String& origin, const String& lastEventId); >- MessageEvent(DataType&&, const String& origin, const String& lastEventId = { }, std::optional<MessageEventSource>&& = std::nullopt, Vector<RefPtr<MessagePort>>&& = { }); >+ MessageEvent(const AtomString& type, DataType&&, const String& origin, const String& lastEventId = { }, std::optional<MessageEventSource>&& = std::nullopt, Vector<RefPtr<MessagePort>>&& = { }); > > EventInterface eventInterface() const final; > >diff --git a/Source/WebCore/dom/MessagePort.cpp b/Source/WebCore/dom/MessagePort.cpp >index 177f8e43d458..9251e8466d36 100644 >--- a/Source/WebCore/dom/MessagePort.cpp >+++ b/Source/WebCore/dom/MessagePort.cpp >@@ -284,7 +284,7 @@ void MessagePort::dispatchMessages() > return; > auto ports = MessagePort::entanglePorts(*context, WTFMove(message.transferredPorts)); > // Per specification, each MessagePort object has a task source called the port message queue. >- queueTaskToDispatchEvent(*this, TaskSource::PostedMessageQueue, MessageEvent::create(WTFMove(ports), message.message.releaseNonNull())); >+ queueTaskToDispatchEvent(*this, TaskSource::PostedMessageQueue, MessageEvent::create(message.message.releaseNonNull(), { }, { }, { }, WTFMove(ports))); > } > }; > >diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp >index 60c759dc8af3..2371b3c7cb6c 100644 >--- a/Source/WebCore/page/DOMWindow.cpp >+++ b/Source/WebCore/page/DOMWindow.cpp >@@ -912,7 +912,7 @@ ExceptionOr<void> DOMWindow::postMessage(JSC::JSGlobalObject& lexicalGlobalObjec > } > > Vector<RefPtr<MessagePort>> ports; >- auto messageData = SerializedScriptValue::create(lexicalGlobalObject, messageValue, WTFMove(options.transfer), ports, SerializationContext::WindowPostMessage); >+ auto messageData = SerializedScriptValue::create(lexicalGlobalObject, messageValue, WTFMove(options.transfer), ports, SerializationErrorMode::NonThrowing, SerializationContext::WindowPostMessage); > if (messageData.hasException()) > return messageData.releaseException(); > >@@ -963,7 +963,7 @@ ExceptionOr<void> DOMWindow::postMessage(JSC::JSGlobalObject& lexicalGlobalObjec > UserGestureIndicator userGestureIndicator(userGestureToForward); > InspectorInstrumentation::willDispatchPostMessage(frame, postMessageIdentifier); > >- auto event = MessageEvent::create(MessagePort::entanglePorts(*document(), WTFMove(message.transferredPorts)), message.message.releaseNonNull(), sourceOrigin, { }, incumbentWindowProxy ? std::make_optional(MessageEventSource(WTFMove(incumbentWindowProxy))) : std::nullopt); >+ auto event = MessageEvent::create(message.message.releaseNonNull(), sourceOrigin, { }, incumbentWindowProxy ? std::make_optional(MessageEventSource(WTFMove(incumbentWindowProxy))) : std::nullopt, MessagePort::entanglePorts(*document(), WTFMove(message.transferredPorts))); > dispatchEvent(event); > > InspectorInstrumentation::didDispatchPostMessage(frame, postMessageIdentifier); >diff --git a/Source/WebCore/page/EventSource.cpp b/Source/WebCore/page/EventSource.cpp >index 8cc8df1ac26c..7073ef6173cb 100644 >--- a/Source/WebCore/page/EventSource.cpp >+++ b/Source/WebCore/page/EventSource.cpp >@@ -431,14 +431,13 @@ void EventSource::dispatchMessageEvent() > > auto& name = m_eventName.isEmpty() ? eventNames().messageEvent : m_eventName; > >- // Omit the trailing "\n" character. > ASSERT(!m_data.isEmpty()); >- unsigned size = m_data.size() - 1; >- auto data = SerializedScriptValue::create({ m_data.data(), size }); >- RELEASE_ASSERT(data); >+ >+ // Omit the trailing "\n" character. >+ String data(m_data.data(), m_data.size() - 1); > m_data = { }; > >- dispatchEvent(MessageEvent::create(name, data.releaseNonNull(), m_eventStreamOrigin, m_lastEventId)); >+ dispatchEvent(MessageEvent::create(name, WTFMove(data), m_eventStreamOrigin, m_lastEventId)); > } > > } // namespace WebCore >diff --git a/Source/WebCore/page/History.cpp b/Source/WebCore/page/History.cpp >index f1da2c85a008..d78a7c4fed8f 100644 >--- a/Source/WebCore/page/History.cpp >+++ b/Source/WebCore/page/History.cpp >@@ -239,7 +239,7 @@ ExceptionOr<void> History::stateObjectAdded(RefPtr<SerializedScriptValue>&& data > > Checked<uint64_t> payloadSize = titleSize; > payloadSize += urlSize; >- payloadSize += data ? data->data().size() : 0; >+ payloadSize += data ? data->wireBytes().size() : 0; > > Checked<uint64_t> newTotalUsage = mainHistory.m_totalStateObjectUsage; > >diff --git a/Source/WebCore/page/WindowOrWorkerGlobalScope.cpp b/Source/WebCore/page/WindowOrWorkerGlobalScope.cpp >index 3a5fb7ecf139..b151e9340b46 100644 >--- a/Source/WebCore/page/WindowOrWorkerGlobalScope.cpp >+++ b/Source/WebCore/page/WindowOrWorkerGlobalScope.cpp >@@ -49,7 +49,7 @@ void WindowOrWorkerGlobalScope::reportError(JSDOMGlobalObject& globalObject, JSC > ExceptionOr<JSC::JSValue> WindowOrWorkerGlobalScope::structuredClone(JSDOMGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& relevantGlobalObject, JSC::JSValue value, StructuredSerializeOptions&& options) > { > Vector<RefPtr<MessagePort>> ports; >- auto messageData = SerializedScriptValue::create(lexicalGlobalObject, value, WTFMove(options.transfer), ports, SerializationContext::WindowPostMessage); >+ auto messageData = SerializedScriptValue::create(lexicalGlobalObject, value, WTFMove(options.transfer), ports, SerializationErrorMode::NonThrowing, SerializationContext::WindowPostMessage); > if (messageData.hasException()) > return messageData.releaseException(); > >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index 946eff9744e4..d22b9e3f24c5 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -3841,14 +3841,14 @@ ExceptionOr<String> Internals::getCurrentCursorInfo() > > Ref<ArrayBuffer> Internals::serializeObject(const RefPtr<SerializedScriptValue>& value) const > { >- auto& bytes = value->data(); >+ auto& bytes = value->wireBytes(); > return ArrayBuffer::create(bytes.data(), bytes.size()); > } > > Ref<SerializedScriptValue> Internals::deserializeBuffer(ArrayBuffer& buffer) const > { > Vector<uint8_t> bytes { static_cast<const uint8_t*>(buffer.data()), buffer.byteLength() }; >- return SerializedScriptValue::adopt(WTFMove(bytes)); >+ return SerializedScriptValue::createFromWireBytes(WTFMove(bytes)); > } > > bool Internals::isFromCurrentWorld(JSC::JSValue value) const >diff --git a/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp b/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >index d3fbfe6cda3a..638db1895577 100644 >--- a/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >+++ b/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >@@ -82,7 +82,7 @@ void DedicatedWorkerGlobalScope::prepareForDestruction() > ExceptionOr<void> DedicatedWorkerGlobalScope::postMessage(JSC::JSGlobalObject& state, JSC::JSValue messageValue, StructuredSerializeOptions&& options) > { > Vector<RefPtr<MessagePort>> ports; >- auto message = SerializedScriptValue::create(state, messageValue, WTFMove(options.transfer), ports, SerializationContext::WorkerPostMessage); >+ auto message = SerializedScriptValue::create(state, messageValue, WTFMove(options.transfer), ports, SerializationErrorMode::NonThrowing, SerializationContext::WorkerPostMessage); > if (message.hasException()) > return message.releaseException(); > >diff --git a/Source/WebCore/workers/Worker.cpp b/Source/WebCore/workers/Worker.cpp >index 49f0797657e8..b0a7633af411 100644 >--- a/Source/WebCore/workers/Worker.cpp >+++ b/Source/WebCore/workers/Worker.cpp >@@ -130,7 +130,7 @@ Worker::~Worker() > ExceptionOr<void> Worker::postMessage(JSC::JSGlobalObject& state, JSC::JSValue messageValue, StructuredSerializeOptions&& options) > { > Vector<RefPtr<MessagePort>> ports; >- auto message = SerializedScriptValue::create(state, messageValue, WTFMove(options.transfer), ports, SerializationContext::WorkerPostMessage); >+ auto message = SerializedScriptValue::create(state, messageValue, WTFMove(options.transfer), ports, SerializationErrorMode::NonThrowing, SerializationContext::WorkerPostMessage); > if (message.hasException()) > return message.releaseException(); > >diff --git a/Source/WebCore/workers/WorkerMessagingProxy.cpp b/Source/WebCore/workers/WorkerMessagingProxy.cpp >index 99d1bc026ca1..6ad21776355b 100644 >--- a/Source/WebCore/workers/WorkerMessagingProxy.cpp >+++ b/Source/WebCore/workers/WorkerMessagingProxy.cpp >@@ -104,7 +104,7 @@ void WorkerMessagingProxy::postMessageToWorkerObject(MessageWithMessagePorts&& m > return; > > auto ports = MessagePort::entanglePorts(context, WTFMove(message.transferredPorts)); >- ActiveDOMObject::queueTaskToDispatchEvent(*workerObject, TaskSource::PostedMessageQueue, MessageEvent::create(WTFMove(ports), message.message.releaseNonNull())); >+ ActiveDOMObject::queueTaskToDispatchEvent(*workerObject, TaskSource::PostedMessageQueue, MessageEvent::create(message.message.releaseNonNull(), { }, { }, std::nullopt, WTFMove(ports))); > }); > } > >@@ -124,7 +124,7 @@ void WorkerMessagingProxy::postMessageToWorkerGlobalScope(MessageWithMessagePort > ASSERT_WITH_SECURITY_IMPLICATION(scriptContext.isWorkerGlobalScope()); > auto& context = static_cast<DedicatedWorkerGlobalScope&>(scriptContext); > auto ports = MessagePort::entanglePorts(scriptContext, WTFMove(message.transferredPorts)); >- context.dispatchEvent(MessageEvent::create(WTFMove(ports), message.message.releaseNonNull())); >+ context.dispatchEvent(MessageEvent::create(message.message.releaseNonNull(), { }, { }, std::nullopt, WTFMove(ports))); > context.thread().workerObjectProxy().confirmMessageFromWorkerObject(context.hasPendingActivity()); > }); > } >diff --git a/Source/WebCore/workers/service/ServiceWorker.cpp b/Source/WebCore/workers/service/ServiceWorker.cpp >index 5ad9912e3b0b..8fb3c973f005 100644 >--- a/Source/WebCore/workers/service/ServiceWorker.cpp >+++ b/Source/WebCore/workers/service/ServiceWorker.cpp >@@ -106,7 +106,7 @@ ExceptionOr<void> ServiceWorker::postMessage(JSC::JSGlobalObject& globalObject, > return Exception { InvalidStateError }; > > Vector<RefPtr<MessagePort>> ports; >- auto messageData = SerializedScriptValue::create(globalObject, messageValue, WTFMove(options.transfer), ports, SerializationContext::WorkerPostMessage); >+ auto messageData = SerializedScriptValue::create(globalObject, messageValue, WTFMove(options.transfer), ports, SerializationErrorMode::NonThrowing, SerializationContext::WorkerPostMessage); > if (messageData.hasException()) > return messageData.releaseException(); > >diff --git a/Source/WebCore/workers/service/ServiceWorkerClient.cpp b/Source/WebCore/workers/service/ServiceWorkerClient.cpp >index 596b9cdc994f..9f36ffbb42bd 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerClient.cpp >+++ b/Source/WebCore/workers/service/ServiceWorkerClient.cpp >@@ -86,7 +86,7 @@ String ServiceWorkerClient::id() const > ExceptionOr<void> ServiceWorkerClient::postMessage(JSC::JSGlobalObject& globalObject, JSC::JSValue messageValue, StructuredSerializeOptions&& options) > { > Vector<RefPtr<MessagePort>> ports; >- auto messageData = SerializedScriptValue::create(globalObject, messageValue, WTFMove(options.transfer), ports, SerializationContext::WorkerPostMessage); >+ auto messageData = SerializedScriptValue::create(globalObject, messageValue, WTFMove(options.transfer), ports, SerializationErrorMode::NonThrowing, SerializationContext::WorkerPostMessage); > if (messageData.hasException()) > return messageData.releaseException(); > >diff --git a/Source/WebCore/workers/service/ServiceWorkerContainer.cpp b/Source/WebCore/workers/service/ServiceWorkerContainer.cpp >index f214ac6a0076..41f34c61d009 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerContainer.cpp >+++ b/Source/WebCore/workers/service/ServiceWorkerContainer.cpp >@@ -438,7 +438,7 @@ void ServiceWorkerContainer::postMessage(MessageWithMessagePorts&& message, Serv > auto& context = *scriptExecutionContext(); > MessageEventSource source = RefPtr<ServiceWorker> { ServiceWorker::getOrCreate(context, WTFMove(sourceData)) }; > >- auto messageEvent = MessageEvent::create(MessagePort::entanglePorts(context, WTFMove(message.transferredPorts)), message.message.releaseNonNull(), sourceOrigin, { }, WTFMove(source)); >+ auto messageEvent = MessageEvent::create(message.message.releaseNonNull(), sourceOrigin, { }, WTFMove(source), MessagePort::entanglePorts(context, WTFMove(message.transferredPorts))); > if (m_shouldDeferMessageEvents) > m_deferredMessageEvents.append(WTFMove(messageEvent)); > else { >diff --git a/Source/WebCore/workers/shared/SharedWorkerGlobalScope.cpp b/Source/WebCore/workers/shared/SharedWorkerGlobalScope.cpp >index 12b8e1ac8d01..9fe8db38ea53 100644 >--- a/Source/WebCore/workers/shared/SharedWorkerGlobalScope.cpp >+++ b/Source/WebCore/workers/shared/SharedWorkerGlobalScope.cpp >@@ -65,13 +65,11 @@ void SharedWorkerGlobalScope::close() > void SharedWorkerGlobalScope::postConnectEvent(TransferredMessagePort&& transferredPort, const String& sourceOrigin) > { > SCOPE_RELEASE_LOG("postConnectEvent:"); >- auto value = SerializedScriptValue::create(emptyString()); >- ASSERT(value); > auto ports = MessagePort::entanglePorts(*this, { WTFMove(transferredPort) }); > ASSERT(ports.size() == 1); > auto port = ports[0]; > ASSERT(port); >- auto event = MessageEvent::create(WTFMove(ports), value.releaseNonNull(), sourceOrigin, { }, port); >+ auto event = MessageEvent::create(emptyString(), sourceOrigin, { }, port, WTFMove(ports)); > event->initEvent(eventNames().connectEvent, false, false); > > dispatchEvent(WTFMove(event)); >diff --git a/Source/WebKit/Shared/API/APISerializedScriptValue.h b/Source/WebKit/Shared/API/APISerializedScriptValue.h >index 6fe8576ac38e..4ddc80f14fbe 100644 >--- a/Source/WebKit/Shared/API/APISerializedScriptValue.h >+++ b/Source/WebKit/Shared/API/APISerializedScriptValue.h >@@ -49,9 +49,9 @@ public: > return adoptRef(*new SerializedScriptValue(serializedValue.releaseNonNull())); > } > >- static Ref<SerializedScriptValue> adopt(Vector<uint8_t>&& buffer) >+ static Ref<SerializedScriptValue> createFromWireBytes(Vector<uint8_t>&& buffer) > { >- return adoptRef(*new SerializedScriptValue(WebCore::SerializedScriptValue::adopt(WTFMove(buffer)))); >+ return adoptRef(*new SerializedScriptValue(WebCore::SerializedScriptValue::createFromWireBytes(WTFMove(buffer)))); > } > > JSValueRef deserialize(JSContextRef context, JSValueRef* exception) >@@ -64,7 +64,7 @@ public: > static RefPtr<SerializedScriptValue> createFromNSObject(id); > #endif > >- IPC::DataReference dataReference() const { return m_serializedScriptValue->data(); } >+ IPC::DataReference dataReference() const { return m_serializedScriptValue->wireBytes(); } > > WebCore::SerializedScriptValue& internalRepresentation() { return m_serializedScriptValue.get(); } > >diff --git a/Source/WebKit/Shared/SessionState.cpp b/Source/WebKit/Shared/SessionState.cpp >index a08dd15d3517..bee932d05574 100644 >--- a/Source/WebKit/Shared/SessionState.cpp >+++ b/Source/WebKit/Shared/SessionState.cpp >@@ -183,7 +183,7 @@ void PageState::encode(IPC::Encoder& encoder) const > encoder << title << mainFrameState << !!sessionStateObject; > > if (sessionStateObject) >- encoder << sessionStateObject->toWireBytes(); >+ encoder << sessionStateObject->wireBytes(); > > encoder << shouldOpenExternalURLsPolicy; > } >diff --git a/Source/WebKit/Shared/UserData.cpp b/Source/WebKit/Shared/UserData.cpp >index f8b7edcf4491..e19407372868 100644 >--- a/Source/WebKit/Shared/UserData.cpp >+++ b/Source/WebKit/Shared/UserData.cpp >@@ -426,7 +426,7 @@ bool UserData::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result) > if (!decoder.decode(dataReference)) > return false; > >- result = API::SerializedScriptValue::adopt({ dataReference }); >+ result = API::SerializedScriptValue::createFromWireBytes({ dataReference }); > break; > } > >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >index 5459d2e3bf85..301432082787 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >@@ -1128,7 +1128,7 @@ - (void)_evaluateJavaScript:(NSString *)javaScriptString asAsyncFunction:(BOOL)a > break; > } > >- argumentsMap->set(key, serializedValue->internalRepresentation().toWireBytes()); >+ argumentsMap->set(key, serializedValue->internalRepresentation().wireBytes()); > } > > if (errorMessage && handler) { >diff --git a/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp b/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp >index a80655bfedfc..cdbd345a2bff 100644 >--- a/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp >+++ b/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp >@@ -176,7 +176,7 @@ void WebInspectorUIExtensionControllerProxy::evaluateScriptForExtension(const In > return completionHandler({ returnedValue }); > } > >- completionHandler({ { API::SerializedScriptValue::adopt(Vector { dataReference.data(), dataReference.size() }).ptr() } }); >+ completionHandler({ { API::SerializedScriptValue::createFromWireBytes(Vector { dataReference.data(), dataReference.size() }).ptr() } }); > }); > }); > } >@@ -233,7 +233,7 @@ void WebInspectorUIExtensionControllerProxy::evaluateScriptInExtensionTab(const > return completionHandler({ returnedValue }); > } > >- completionHandler({ { API::SerializedScriptValue::adopt({ dataReference.data(), dataReference.size() }).ptr() } }); >+ completionHandler({ { API::SerializedScriptValue::createFromWireBytes({ dataReference.data(), dataReference.size() }).ptr() } }); > }); > }); > } >diff --git a/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp b/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp >index 5bbe73962052..38deeaa2fb2f 100644 >--- a/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp >+++ b/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp >@@ -340,15 +340,15 @@ void WebUserContentControllerProxy::didPostMessage(WebPageProxyIdentifier pagePr > return; > > if (!handler->client().supportsAsyncReply()) { >- handler->client().didPostMessage(*page, WTFMove(frameInfoData), handler->world(), WebCore::SerializedScriptValue::adopt({ dataReference })); >+ handler->client().didPostMessage(*page, WTFMove(frameInfoData), handler->world(), WebCore::SerializedScriptValue::createFromWireBytes({ dataReference })); > reply({ }, { }); > return; > } > >- handler->client().didPostMessageWithAsyncReply(*page, WTFMove(frameInfoData), handler->world(), WebCore::SerializedScriptValue::adopt({ dataReference }), [reply = WTFMove(reply)](API::SerializedScriptValue* value, const String& errorMessage) mutable { >+ handler->client().didPostMessageWithAsyncReply(*page, WTFMove(frameInfoData), handler->world(), WebCore::SerializedScriptValue::createFromWireBytes({ dataReference }), [reply = WTFMove(reply)](API::SerializedScriptValue* value, const String& errorMessage) mutable { > if (errorMessage.isNull()) { > ASSERT(value); >- reply({ value->internalRepresentation().toWireBytes() }, { }); >+ reply({ value->internalRepresentation().wireBytes() }, { }); > return; > } > >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 855284570eeb..29b6207fcece 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -4399,7 +4399,7 @@ void WebPageProxy::runJavaScriptInFrameInScriptWorld(RunJavaScriptParameters&& p > return callbackFunction(makeUnexpected(WTFMove(*details))); > if (dataReference.empty()) > return callbackFunction({ nullptr }); >- callbackFunction({ API::SerializedScriptValue::adopt(Vector(dataReference)).ptr() }); >+ callbackFunction({ API::SerializedScriptValue::createFromWireBytes(Vector(dataReference)).ptr() }); > }); > } > >diff --git a/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp b/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp >index e84099a3da38..b9c796ae2194 100644 >--- a/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp >+++ b/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp >@@ -287,7 +287,7 @@ void WebInspectorUIExtensionController::evaluateScriptForExtension(const Inspect > return; > } > >- completionHandler(serializedResultValue->data(), std::nullopt, std::nullopt); >+ completionHandler(serializedResultValue->wireBytes(), std::nullopt, std::nullopt); > }); > } > >@@ -438,7 +438,7 @@ void WebInspectorUIExtensionController::evaluateScriptInExtensionTab(const Inspe > return; > } > >- completionHandler(serializedResultValue->data(), std::nullopt, std::nullopt); >+ completionHandler(serializedResultValue->wireBytes(), std::nullopt, std::nullopt); > }); > } > >diff --git a/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp b/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp >index 4ba99019405b..330da6af7ed6 100644 >--- a/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp >+++ b/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp >@@ -278,7 +278,7 @@ private: > completionHandler(value.ptr(), { }); > }; > >- WebProcess::singleton().parentProcessConnection()->sendWithAsyncReply(Messages::WebUserContentControllerProxy::DidPostMessage(webPage->webPageProxyIdentifier(), webFrame->info(), m_identifier, IPC::DataReference(value->data())), WTFMove(messageReplyHandler), m_controller->identifier()); >+ WebProcess::singleton().parentProcessConnection()->sendWithAsyncReply(Messages::WebUserContentControllerProxy::DidPostMessage(webPage->webPageProxyIdentifier(), webFrame->info(), m_identifier, IPC::DataReference(value->wireBytes())), WTFMove(messageReplyHandler), m_controller->identifier()); > } > > RefPtr<WebUserContentController> m_controller; >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp b/Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp >index bcd98749c2cd..42b4e00f0bf6 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp >@@ -74,7 +74,7 @@ static FrameState toFrameState(const HistoryItem& historyItem) > > frameState.setDocumentState(historyItem.documentState()); > if (RefPtr<SerializedScriptValue> stateObject = historyItem.stateObject()) >- frameState.stateObjectData = stateObject->data(); >+ frameState.stateObjectData = stateObject->wireBytes(); > > frameState.documentSequenceNumber = historyItem.documentSequenceNumber(); > frameState.itemSequenceNumber = historyItem.itemSequenceNumber(); >@@ -151,7 +151,7 @@ static void applyFrameState(HistoryItem& historyItem, const FrameState& frameSta > > if (frameState.stateObjectData) { > Vector<uint8_t> stateObjectData = frameState.stateObjectData.value(); >- historyItem.setStateObject(SerializedScriptValue::adopt(WTFMove(stateObjectData))); >+ historyItem.setStateObject(SerializedScriptValue::createFromWireBytes(WTFMove(stateObjectData))); > } > > historyItem.setDocumentSequenceNumber(frameState.documentSequenceNumber); >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index f3636cabd65d..967ceb8fcba4 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -3765,7 +3765,7 @@ void WebPage::runJavaScript(WebFrame* frame, RunJavaScriptParameters&& parameter > > IPC::DataReference dataReference; > if (serializedResultValue) >- dataReference = serializedResultValue->data(); >+ dataReference = serializedResultValue->wireBytes(); > > std::optional<ExceptionDetails> details; > if (!result)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 237241
:
453311
|
453315
|
453317
|
453318
|
453319
|
453320
|
453323
|
453325
|
453326