Truly independent web browser
LibWeb: Let Rust transfer steps write and read records and handles
Shannon Booth10b310b0f370
diff --git a/Libraries/LibIPC/TransportHandle.h b/Libraries/LibIPC/TransportHandle.hindex cb7294ccd59..eb1d7475827 100644--- a/Libraries/LibIPC/TransportHandle.h+++ b/Libraries/LibIPC/TransportHandle.h@@ -25,6 +25,8 @@ class TransportHandle {AK_MAKE_NONCOPYABLE(TransportHandle);public:+ AK_ALLOC_WITH_KMALLOC;+TransportHandle() = default;TransportHandle(TransportHandle&&) = default;TransportHandle& operator=(TransportHandle&&) = default;diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/mod.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/mod.rsindex 7b2cbee4341..0f66a0cedf5 100644--- a/Libraries/LibWeb/Bindings/Rust/src/bindings/mod.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/mod.rs@@ -31,6 +31,7 @@ pub(crate) mod promise;pub(crate) mod realm_data;pub(crate) mod services;pub(crate) mod structured_data;+pub(crate) mod transport;use core::ptr::NonNull;diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/structured_data.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/structured_data.rsindex 395c7223872..fffe0362716 100644--- a/Libraries/LibWeb/Bindings/Rust/src/bindings/structured_data.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/structured_data.rs@@ -24,7 +24,12 @@ use ak::Utf16String;use libjs_rust::api::{RawNativeFunctionResult, ThrowCompletionOr, Value};use crate::bindings::interface::{ConstructedObject, Interface, Ref, cell_from_abi, realm_arguments, wrap};+use crate::bindings::transport::TransportHandle;use crate::bindings::{CallContext, WebIdlResult};+use crate::html::structured_serialize::cpp::{OwnedSerializedTransferRecord, TransferDataDecoder};+use crate::html::structured_serialize::{+ structured_deserialize_with_transfer_internal, structured_serialize_with_transfer,+};unsafe extern "C" {fn web_bindings_serialize_value(serialized: *mut c_void, value: u64) -> RawNativeFunctionResult;@@ -59,6 +64,31 @@ unsafe extern "C" {serialized: *mut c_void,interface_name: u16,) -> RawNativeFunctionResult;+ fn web_bindings_transfer_data_encode_bool(data_holder: *mut c_void, value: bool) -> RawNativeFunctionResult;+ fn web_bindings_transfer_data_encode_records(+ data_holder: *mut c_void,+ records: *const *mut c_void,+ count: usize,+ ) -> RawNativeFunctionResult;+ fn web_bindings_transfer_data_encode_transport_handle(+ data_holder: *mut c_void,+ handle: *mut c_void,+ ) -> RawNativeFunctionResult;+ fn web_bindings_transfer_data_extend(data_holder: *mut c_void, record: *mut c_void);+ fn web_bindings_transfer_data_decode_bool(+ data_holder: *mut c_void,+ out_value: &mut bool,+ ) -> RawNativeFunctionResult;+ fn web_bindings_transfer_data_decode_records(+ data_holder: *mut c_void,+ records: *mut c_void,+ append: unsafe extern "C" fn(*mut c_void, *mut c_void),+ ) -> RawNativeFunctionResult;+ fn web_bindings_transfer_data_decode_transport_handle(+ data_holder: *mut c_void,+ out_handle: &mut *mut c_void,+ ) -> RawNativeFunctionResult;+ fn web_bindings_transfer_data_decoder(data_holder: *mut c_void) -> *mut c_void;}/// The record of a structured serialization, which the serialization steps of an object write to: a@@ -234,7 +264,7 @@ pub(crate) trait Serializable: Interface {}/// The data holder of a transferred object, which its transfer steps write to: a Web::Bindings::RustTransferDataWriter-/// that C++ lends for the steps.+/// that C++ lends for the steps. What the steps write that cannot be encoded throws a "DataCloneError" DOMException.pub(crate) struct TransferDataWriter<'a> {raw: NonNull<c_void>,_lent: PhantomData<&'a mut c_void>,@@ -245,10 +275,43 @@ impl TransferDataWriter<'_> {pub(crate) fn as_raw(&mut self) -> *mut c_void {self.raw.as_ptr()}++ pub(crate) fn write_bool(&mut self, value: bool) -> WebIdlResult<()> {+ // SAFETY: The data holder is lent for the steps.+ unsafe { web_bindings_transfer_data_encode_bool(self.raw.as_ptr(), value) }.into_completion()?;+ Ok(())+ }++ /// Writes the records of structured serializations with transfer, as a list.+ pub(crate) fn write_records(&mut self, records: &[OwnedSerializedTransferRecord]) -> WebIdlResult<()> {+ let records: Vec<*mut c_void> = records.iter().map(|record| record.record().as_raw()).collect();+ // SAFETY: The data holder is lent for the steps, and the call borrows the records.+ unsafe { web_bindings_transfer_data_encode_records(self.raw.as_ptr(), records.as_ptr(), records.len()) }+ .into_completion()?;+ Ok(())+ }++ /// Writes the handle of one end of an IPC transport, whose rights the data holder takes.+ pub(crate) fn write_transport_handle(&mut self, handle: TransportHandle) -> WebIdlResult<()> {+ // SAFETY: The data holder is lent for the steps, and the call borrows the handle.+ unsafe { web_bindings_transfer_data_encode_transport_handle(self.raw.as_ptr(), handle.as_raw()) }+ .into_completion()?;+ Ok(())+ }++ /// Writes ! StructuredSerializeWithTransfer(value, « value ») as the data holder of value, which is all that the+ /// record holds: its [[Serialized]] is a reference to the transferred value. read_transferred_value() reads it.+ pub(crate) fn write_transferred_value(&mut self, cx: &CallContext, value: Value) -> WebIdlResult<()> {+ let record = structured_serialize_with_transfer(cx, value, &[value.as_object()])?;+ // SAFETY: The data holder is lent for the steps, and the call borrows the record.+ unsafe { web_bindings_transfer_data_extend(self.raw.as_ptr(), record.record().as_raw()) };+ Ok(())+ }}/// The data holder of a received object, which its transfer-receiving steps read from: a-/// Web::Bindings::RustTransferDataReader that C++ lends for the steps.+/// Web::Bindings::RustTransferDataReader that C++ lends for the steps. What it reads that the data holder does not hold+/// throws a "DataCloneError" DOMException.pub(crate) struct TransferDataReader<'a> {raw: NonNull<c_void>,_lent: PhantomData<&'a mut c_void>,@@ -259,6 +322,47 @@ impl TransferDataReader<'_> {pub(crate) fn as_raw(&mut self) -> *mut c_void {self.raw.as_ptr()}++ pub(crate) fn read_bool(&mut self) -> WebIdlResult<bool> {+ let mut value = false;+ // SAFETY: The data holder is lent for the steps.+ unsafe { web_bindings_transfer_data_decode_bool(self.raw.as_ptr(), &mut value) }.into_completion()?;+ Ok(value)+ }++ /// Reads what TransferDataWriter::write_records() writes.+ pub(crate) fn read_records(&mut self) -> WebIdlResult<Vec<OwnedSerializedTransferRecord>> {+ unsafe extern "C" fn append(records: *mut c_void, record: *mut c_void) {+ // SAFETY: The records are the Vec that read_records() lends, and LibWeb hands over the record.+ unsafe {+ (*records.cast::<Vec<OwnedSerializedTransferRecord>>())+ .push(OwnedSerializedTransferRecord::from_raw(record));+ }+ }+ let mut records = Vec::new();+ // SAFETY: The data holder and the records are lent for the steps.+ unsafe { web_bindings_transfer_data_decode_records(self.raw.as_ptr(), (&raw mut records).cast(), append) }+ .into_completion()?;+ Ok(records)+ }++ /// Reads what TransferDataWriter::write_transport_handle() writes.+ pub(crate) fn read_transport_handle(&mut self) -> WebIdlResult<TransportHandle> {+ let mut handle = core::ptr::null_mut();+ // SAFETY: The data holder is lent for the steps.+ unsafe { web_bindings_transfer_data_decode_transport_handle(self.raw.as_ptr(), &mut handle) }+ .into_completion()?;+ // SAFETY: LibWeb hands over the handle it read.+ Ok(unsafe { TransportHandle::from_raw(handle) })+ }++ /// ! StructuredDeserializeWithTransfer(dataHolder, the current Realm).[[Deserialized]] for what+ /// TransferDataWriter::write_transferred_value() wrote: the transferred value, created in the realm.+ pub(crate) fn read_transferred_value(&mut self, cx: &CallContext) -> WebIdlResult<Value> {+ // SAFETY: The data holder is lent for the steps, and LibWeb returns its decoder.+ let decoder = unsafe { TransferDataDecoder::from_raw(web_bindings_transfer_data_decoder(self.raw.as_ptr())) };+ structured_deserialize_with_transfer_internal(cx, decoder)+ }}/// An interface that is transferable, [Transferable] in its IDL.diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/transport.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/transport.rsnew file mode 100644index 00000000000..1ea69fbed15--- /dev/null+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/transport.rs@@ -0,0 +1,39 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++//! What LibWeb's C++ IPC transports lend to Rust, which the Rust bindings hold as opaque pointers. They are reached+//! through the C ABI of RustBindingsServices.cpp.++use core::ffi::c_void;+use core::ptr::NonNull;++unsafe extern "C" {+ fn web_bindings_transport_handle_destroy(handle: *mut c_void);+}++/// A handle to one end of an IPC transport that this owns: an IPC::TransportHandle, which holds the rights of that end+/// until a data holder carries them to another agent.+pub(crate) struct TransportHandle(NonNull<c_void>);++impl TransportHandle {+ /// # Safety+ ///+ /// `handle` must be a handle that LibWeb hands over.+ pub(crate) unsafe fn from_raw(handle: *mut c_void) -> Self {+ Self(NonNull::new(handle).expect("LibWeb hands over a handle"))+ }++ pub(crate) fn as_raw(&self) -> *mut c_void {+ self.0.as_ptr()+ }+}++impl Drop for TransportHandle {+ fn drop(&mut self) {+ // SAFETY: This owns the handle.+ unsafe { web_bindings_transport_handle_destroy(self.0.as_ptr()) };+ }+}diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rs b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rsindex 35e5d010a49..24232a564de 100644--- a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rs@@ -1014,6 +1014,10 @@ impl SerializedTransferRecord {Self(NonNull::new(record).expect("C++ lends a record"))}+ pub(crate) fn as_raw(self) -> *mut c_void {+ self.0.as_ptr()+ }+/// Sets the record's [[Serialized]] to what the writer wrote, with the shared memory of the SharedArrayBuffers it/// shared.pub(crate) fn set_serialized(self, writer: StructuredSerializeWriter) {@@ -1067,6 +1071,14 @@ impl OwnedSerializedTransferRecord {Self(unsafe { SerializedTransferRecord::from_raw(web_structured_serialize_transfer_record_create()) })}+ /// # Safety+ ///+ /// `record` must be a record that LibWeb hands over.+ pub(crate) unsafe fn from_raw(record: *mut c_void) -> Self {+ // SAFETY: The caller hands over the record.+ Self(unsafe { SerializedTransferRecord::from_raw(record) })+ }+pub(crate) fn record(&self) -> SerializedTransferRecord {self.0}diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/cross_realm_transform.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/cross_realm_transform.rsindex dcc5ea44ee2..635404184f3 100644--- a/Libraries/LibWeb/Bindings/Rust/src/streams/cross_realm_transform.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/cross_realm_transform.rs@@ -74,13 +74,6 @@ unsafe extern "C" {/// The wrapper of the MessagePort in the realm.fn web_streams_message_port_wrapper(realm: *mut c_void, port: *mut c_void) -> *mut c_void;-- /// Sets the data holder to ! StructuredSerializeWithTransfer(value, « value »).- fn web_streams_serialize_with_transfer(data_holder: *mut c_void, value: u64);-- /// ! StructuredDeserializeWithTransfer(dataHolder, the current Realm).[[Deserialized]], for the next value that the- /// data holder holds.- fn web_streams_deserialize_with_transfer(data_holder: *mut c_void) -> u64;}/// The steps of a port's message event handler, given the state of the transform and the data of the message.@@ -620,15 +613,17 @@ pub(crate) fn serialize_message_port(let wrapper = NonNull::new(wrapper.cast::<Object>()).expect("LibWeb returns a wrapper");// SAFETY: LibWeb returns a live wrapper.let wrapper = unsafe { Gc::from_non_null(wrapper) };- serialize_with_transfer(data_holder, Value::from_object(wrapper));+ data_holder+ .write_transferred_value(cx, Value::from_object(wrapper))+ .must();}/// The MessagePort of ! StructuredDeserializeWithTransfer(dataHolder.[[port]], the current Realm).pub(crate) fn deserialize_message_port(- _: &CallContext,+ cx: &CallContext,data_holder: &mut TransferDataReader,) -> CrossRealmTransformPort {- let deserialized = deserialize_with_transfer(data_holder);+ let deserialized = data_holder.read_transferred_value(cx).must();assert!(deserialized.is_object());// SAFETY: The object is live, and LibWeb returns the MessagePort that it wraps.unsafe {@@ -636,15 +631,3 @@ pub(crate) fn deserialize_message_port(CrossRealmTransformPort(CppCell::from_raw(port))}}--/// Sets the data holder to ! StructuredSerializeWithTransfer(value, « value »).-pub(crate) fn serialize_with_transfer(data_holder: &mut TransferDataWriter, value: Value) {- // SAFETY: The data holder is lent for the transfer steps, and the value is live.- unsafe { web_streams_serialize_with_transfer(data_holder.as_raw(), value.to_raw()) };-}--/// ! StructuredDeserializeWithTransfer(dataHolder, the current Realm).[[Deserialized]]-pub(crate) fn deserialize_with_transfer(data_holder: &mut TransferDataReader) -> Value {- // SAFETY: The data holder is lent for the transfer-receiving steps, which return a live value.- unsafe { Value::from_raw(web_streams_deserialize_with_transfer(data_holder.as_raw())) }-}diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream.rsindex f070cf281ed..c2193160e0a 100644--- a/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream.rs@@ -23,7 +23,6 @@ use crate::streams::algorithms::{AbortAlgorithm, CancelAlgorithm, CloseAlgorithm, FlushAlgorithm, PullAlgorithm, SizeAlgorithm, StartAlgorithm,TransformAlgorithm, WriteAlgorithm,};-use crate::streams::cross_realm_transform::{deserialize_with_transfer, serialize_with_transfer};use crate::streams::queuing_strategy::{QueuingStrategy, extract_high_water_mark, extract_size_algorithm};use crate::streams::readable_stream::{ReadableStream, ReadableStreamState, create_readable_stream, is_readable_stream_locked,@@ -335,10 +334,14 @@ impl Transferable for TransformStream {}// 5. Set dataHolder.[[readable]] to ! StructuredSerializeWithTransfer(readable, « readable »).- serialize_with_transfer(data_holder, Value::from_object(wrap(cx, readable)));+ data_holder+ .write_transferred_value(cx, Value::from_object(wrap(cx, readable)))+ .must();// 6. Set dataHolder.[[writable]] to ! StructuredSerializeWithTransfer(writable, « writable »).- serialize_with_transfer(data_holder, Value::from_object(wrap(cx, writable)));+ data_holder+ .write_transferred_value(cx, Value::from_object(wrap(cx, writable)))+ .must();Ok(())}@@ -348,10 +351,10 @@ impl Transferable for TransformStream {let value = allocate(cx.vm(), |_| Self::new(cx.realm()));// 1. Let readableRecord be ! StructuredDeserializeWithTransfer(dataHolder.[[readable]], the current Realm).- let readable_record = deserialize_with_transfer(data_holder);+ let readable_record = data_holder.read_transferred_value(cx).must();// 2. Let writableRecord be ! StructuredDeserializeWithTransfer(dataHolder.[[writable]], the current Realm).- let writable_record = deserialize_with_transfer(data_holder);+ let writable_record = data_holder.read_transferred_value(cx).must();// 3. Set value.[[readable]] to readableRecord.[[Deserialized]].assert!(readable_record.is_object());diff --git a/Libraries/LibWeb/Bindings/RustBindingsServices.cpp b/Libraries/LibWeb/Bindings/RustBindingsServices.cppindex 2ed81a7b7e5..17e340d49f6 100644--- a/Libraries/LibWeb/Bindings/RustBindingsServices.cpp+++ b/Libraries/LibWeb/Bindings/RustBindingsServices.cpp@@ -4,6 +4,7 @@* SPDX-License-Identifier: BSD-2-Clause*/+#include <LibIPC/TransportHandle.h>#include <LibJS/HostClassBuilder.h>#include <LibJS/Runtime/HostObject.h>#include <LibJS/Runtime/Realm.h>@@ -87,6 +88,27 @@ static JSCompletion deserialize_plain_value(RustSerializationReader* reader, T*return completion_to_abi(reader->realm, JS::js_undefined());}+// A value that the data holder of a transferred object holds, which its transfer steps write.+template<typename T>+static JSCompletion encode_transfer_data(RustTransferDataWriter* writer, T const& value)+{+ auto result = HTML::encode_or_throw_data_clone_error(writer->realm, writer->data_holder, value);+ if (result.is_exception())+ return completion_to_abi(writer->realm, result.exception());+ return completion_to_abi(writer->realm, JS::js_undefined());+}++// A value of the type that the data holder of a received object holds next, which its transfer-receiving steps read.+template<typename T>+static JSCompletion decode_transfer_data(RustTransferDataReader* reader, T* out_value)+{+ auto value = HTML::decode_or_throw_data_clone_error<T>(reader->realm, reader->data_holder);+ if (value.is_exception())+ return completion_to_abi(reader->realm, value.exception());+ *out_value = value.release_value();+ return completion_to_abi(reader->realm, JS::js_undefined());+}+extern "C" {void* web_bindings_wrapper_world(void* realm, bool* is_main_world);@@ -125,6 +147,15 @@ JSCompletion web_bindings_deserialize_bytes(RustSerializationReader*, void* byteJSCompletion web_bindings_deserialize_utf16_string(RustSerializationReader*, FlatPtr* out_string);void web_bindings_serialize_inline_object_header(RustSerializationWriter*, u16 interface_name);JSCompletion web_bindings_deserialize_inline_object_header(RustSerializationReader*, u16 interface_name);+JSCompletion web_bindings_transfer_data_encode_bool(RustTransferDataWriter*, bool);+JSCompletion web_bindings_transfer_data_encode_records(RustTransferDataWriter*, HTML::SerializedTransferRecord const* const*, size_t count);+JSCompletion web_bindings_transfer_data_encode_transport_handle(RustTransferDataWriter*, IPC::TransportHandle const*);+void web_bindings_transfer_data_extend(RustTransferDataWriter*, HTML::SerializedTransferRecord*);+JSCompletion web_bindings_transfer_data_decode_bool(RustTransferDataReader*, bool* out_value);+JSCompletion web_bindings_transfer_data_decode_records(RustTransferDataReader*, void* records, void (*append)(void*, HTML::SerializedTransferRecord*));+JSCompletion web_bindings_transfer_data_decode_transport_handle(RustTransferDataReader*, IPC::TransportHandle** out_handle);+HTML::TransferDataDecoder* web_bindings_transfer_data_decoder(RustTransferDataReader*);+void web_bindings_transport_handle_destroy(IPC::TransportHandle*);void* web_bindings_wrapper_world(void* realm, bool* is_main_world){@@ -318,6 +349,71 @@ JSCompletion web_bindings_deserialize_inline_object_header(RustSerializationReadreturn completion_to_abi(reader->realm, move(result));}+JSCompletion web_bindings_transfer_data_encode_bool(RustTransferDataWriter* writer, bool value)+{+ return encode_transfer_data(writer, value);+}++// Writes the records as a Vector of them is encoded, which web_bindings_transfer_data_decode_records() and C++ read.+JSCompletion web_bindings_transfer_data_encode_records(RustTransferDataWriter* writer, HTML::SerializedTransferRecord const* const* records, size_t count)+{+ auto result = [&]() -> WebIDL::ExceptionOr<JS::Value> {+ if (auto encoded = writer->data_holder.encode_size(count); encoded.is_error())+ return HTML::data_clone_error_from_serialization_error(writer->realm, encoded.release_error());+ for (size_t i = 0; i < count; ++i)+ TRY(HTML::encode_or_throw_data_clone_error(writer->realm, writer->data_holder, *records[i]));+ return JS::js_undefined();+ }();+ return completion_to_abi(writer->realm, move(result));+}++JSCompletion web_bindings_transfer_data_encode_transport_handle(RustTransferDataWriter* writer, IPC::TransportHandle const* handle)+{+ return encode_transfer_data(writer, *handle);+}++void web_bindings_transfer_data_extend(RustTransferDataWriter* writer, HTML::SerializedTransferRecord* record)+{+ writer->data_holder.extend(move(record->transfer_data_holders));+}++JSCompletion web_bindings_transfer_data_decode_bool(RustTransferDataReader* reader, bool* out_value)+{+ return decode_transfer_data(reader, out_value);+}++// Reads what web_bindings_transfer_data_encode_records() writes, and hands each record over.+JSCompletion web_bindings_transfer_data_decode_records(RustTransferDataReader* reader, void* records, void (*append)(void*, HTML::SerializedTransferRecord*))+{+ auto decoded = HTML::decode_or_throw_data_clone_error<Vector<HTML::SerializedTransferRecord>>(reader->realm, reader->data_holder);+ if (decoded.is_exception())+ return completion_to_abi(reader->realm, decoded.exception());+ for (auto& record : decoded.value())+ append(records, new HTML::SerializedTransferRecord(move(record)));+ return completion_to_abi(reader->realm, JS::js_undefined());+}++// Reads a transport handle, and hands it over.+JSCompletion web_bindings_transfer_data_decode_transport_handle(RustTransferDataReader* reader, IPC::TransportHandle** out_handle)+{+ auto handle = HTML::decode_or_throw_data_clone_error<IPC::TransportHandle>(reader->realm, reader->data_holder);+ if (handle.is_exception())+ return completion_to_abi(reader->realm, handle.exception());+ *out_handle = new IPC::TransportHandle(handle.release_value());+ return completion_to_abi(reader->realm, JS::js_undefined());+}++// The decoder of the data holder, for what the transfer-receiving steps read through structured deserialization.+HTML::TransferDataDecoder* web_bindings_transfer_data_decoder(RustTransferDataReader* reader)+{+ return &reader->data_holder;+}++void web_bindings_transport_handle_destroy(IPC::TransportHandle* handle)+{+ delete handle;+}+JSObject* web_bindings_rejected_promise(void* current_realm, JSValue this_value, JSValue reason){auto& realm = *static_cast<JS::Realm*>(current_realm);diff --git a/Libraries/LibWeb/Streams/ReadableStream.cpp b/Libraries/LibWeb/Streams/ReadableStream.cppindex 1642f3a1802..db1fb6634c0 100644--- a/Libraries/LibWeb/Streams/ReadableStream.cpp+++ b/Libraries/LibWeb/Streams/ReadableStream.cpp@@ -79,8 +79,6 @@ void web_streams_message_port_disentangle(HTML::MessagePort*);void web_streams_message_port_enable(HTML::MessagePort*);void* web_streams_message_port_from_object(JSObject*);JSObject* web_streams_message_port_wrapper(void* realm, HTML::MessagePort*);-void web_streams_serialize_with_transfer(Bindings::RustTransferDataWriter*, JSValue);-JSValue web_streams_deserialize_with_transfer(Bindings::RustTransferDataReader*);}static JSVM* vm_abi()@@ -427,16 +425,4 @@ JSObject* web_streams_message_port_wrapper(void* realm, HTML::MessagePort* port)return JS::HostABI::object_to_abi(Bindings::message_port(realm_of(realm), *port).ptr());}-void web_streams_serialize_with_transfer(Bindings::RustTransferDataWriter* writer, JSValue value)-{- auto js_value = JS::HostABI::value_from_abi(value);- auto result = MUST(HTML::structured_serialize_with_transfer(writer->realm, js_value, { { js_value.as_object() } }));- writer->data_holder.extend(move(result.transfer_data_holders));-}--JSValue web_streams_deserialize_with_transfer(Bindings::RustTransferDataReader* reader)-{- return JS::HostABI::value_to_abi(MUST(HTML::structured_deserialize_with_transfer_internal(reader->data_holder, reader->realm)));-}-}diff --git a/Libraries/LibWebCommon/HTML/SerializationRecords.h b/Libraries/LibWebCommon/HTML/SerializationRecords.hindex 64fe9beec0f..79dcce29949 100644--- a/Libraries/LibWebCommon/HTML/SerializationRecords.h+++ b/Libraries/LibWebCommon/HTML/SerializationRecords.h@@ -128,6 +128,13 @@ public:return m_encoder.encode(value);}+ // The size of a list, as the encoding of a Vector begins.+ ErrorOr<void> encode_size(size_t size)+ {+ VERIFY(!m_buffer_has_been_taken);+ return m_encoder.encode_size(size);+ }+void append(IPCSerializationRecord&&);void extend(Vector<TransferDataEncoder>);void encode_unsigned_big_integer(::Crypto::UnsignedBigInteger const&);