Skip to content

Truly independent web browser

LibWeb: Remove the C++ serialization steps of platform objects

Shannon Boothb4a955e298b6
diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rs b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rs
index 89b64a8fb65..ac1d6c3a79e 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rs
@@ -173,16 +173,6 @@ unsafe extern "C" {
reader: *mut c_void,
memory: *mut c_void,
) -> RawNativeFunctionResult;
- fn web_structured_serialize_create_serialized_platform_object(
- interface_name: u16,
- realm: *mut c_void,
- ) -> *mut c_void;
- fn web_structured_serialize_deserialization_steps(
- realm: *mut c_void,
- object: *mut c_void,
- reader: *mut c_void,
- memory: *mut c_void,
- ) -> RawNativeFunctionResult;
fn web_structured_serialize_is_transferable(object: *mut c_void) -> bool;
fn web_structured_serialize_transferable_is_detached(object: *mut c_void) -> bool;
@@ -888,8 +878,6 @@ pub(crate) enum SerializableSteps {
QuotaExceededError,
/// The steps of CryptoKey, which run in crate::crypto::crypto_key.
CryptoKey,
- /// The steps of an interface implemented in C++, which C++ runs.
- Cpp,
}
pub(crate) fn serializable_steps(interface_name: u16) -> SerializableSteps {
@@ -899,7 +887,6 @@ pub(crate) fn serializable_steps(interface_name: u16) -> SerializableSteps {
1 => SerializableSteps::DOMException,
2 => SerializableSteps::QuotaExceededError,
3 => SerializableSteps::CryptoKey,
- 4 => SerializableSteps::Cpp,
steps => unreachable!("LibWeb names no serializable steps {steps}"),
}
}
@@ -921,36 +908,6 @@ pub(crate) fn deserialize_rust_platform_object(
})
}
-/// A new instance of the interface implemented in C++, created in the realm, which its deserialization steps fill in.
-pub(crate) fn create_serialized_platform_object(interface_name: u16, realm: Gc<Realm>) -> Gc<Object> {
- // SAFETY: The realm is live, and LibWeb returns a live object.
- unsafe {
- object_from_abi(web_structured_serialize_create_serialized_platform_object(
- interface_name,
- realm.as_ptr().cast(),
- ))
- }
- .expect("LibWeb creates the instance")
-}
-
-/// The deserialization steps of the interface of the instance, given the record and the realm.
-pub(crate) fn deserialization_steps(
- object: Gc<Object>,
- serialized: StructuredSerializeReader,
- memory: DeserializationMemory,
-) -> WebIdlResult<()> {
- // SAFETY: The realm and the object are live, and the reader and the memory are lent.
- completion(unsafe {
- web_structured_serialize_deserialization_steps(
- serialized.realm_raw(),
- object_into_abi(object),
- serialized.as_raw(),
- memory.as_raw(),
- )
- })?;
- Ok(())
-}
-
/// Whether the object is a platform object that is a transferable object, which has a [[Detached]] internal slot.
pub(crate) fn is_transferable(object: Gc<Object>) -> bool {
// SAFETY: The object is live.
diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/mod.rs b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/mod.rs
index f33c9bb2afa..9ac91b52126 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/mod.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/mod.rs
@@ -32,13 +32,12 @@ use crate::crypto::crypto_key;
use crate::html::structured_serialize::cpp::{
DeserializationMemory, OwnedDeserializationMemory, OwnedSerializedTransferRecord, OwnedStructuredSerializeWriter,
SerializableSteps, SerializationMemory, SerializationType, SerializedTransferRecord, StructuredSerializeReader,
- StructuredSerializeWriter, TransferDataDecoder, TransferDataHolder, create_serialized_platform_object,
- create_transferred_platform_object, current_settings_object_agent_cluster,
- current_settings_object_cross_origin_isolated_capability, data_clone_error_from_serialization_error,
- deserialization_steps, deserialize_rust_platform_object, is_exposed, is_platform_object, is_transferable,
- is_transferable_interface_exposed, realm_agent_cluster, serializable_interface_name, serializable_payload_version,
- serializable_steps, serialization_steps, transfer_steps, transferable_is_detached, transferable_primary_interface,
- transferable_set_detached,
+ StructuredSerializeWriter, TransferDataDecoder, TransferDataHolder, create_transferred_platform_object,
+ current_settings_object_agent_cluster, current_settings_object_cross_origin_isolated_capability,
+ data_clone_error_from_serialization_error, deserialize_rust_platform_object, is_exposed, is_platform_object,
+ is_transferable, is_transferable_interface_exposed, realm_agent_cluster, serializable_interface_name,
+ serializable_payload_version, serializable_steps, serialization_steps, transfer_steps, transferable_is_detached,
+ transferable_primary_interface, transferable_set_detached,
};
use crate::webidl::dom_exception::{self, DOMExceptionFields};
use crate::webidl::quota_exceeded_error::{self, QuotaExceededErrorFields};
@@ -854,7 +853,7 @@ impl Serializer<'_> {
quota_exceeded_error::serialization_steps(&QuotaExceededErrorFields::of(object), serialized);
}
SerializableSteps::CryptoKey => crypto_key::serialization_steps(object, serialized),
- SerializableSteps::Rust | SerializableSteps::Cpp => {
+ SerializableSteps::Rust => {
let realm = self.realm.unwrap_or_else(|| object.shape().realm());
serialization_steps(
&CallContext::new(vm, realm),
@@ -1370,40 +1369,6 @@ impl Deserializer<'_, '_> {
return Err(data_clone_error("Unsupported type"));
}
- // NB: The deserialization steps of an interface implemented in Rust, and those that run here for
- // DOMException, QuotaExceededError and CryptoKey, create the new instance from what they read, so
- // they run here, at the position in memory that the instance has.
- let steps = serializable_steps(interface_name);
- if steps != SerializableSteps::Cpp {
- if version.is_some_and(|version| version != serializable_payload_version()) {
- return Err(data_clone_error_from_serialization_error(
- realm,
- "Unsupported serializable payload version",
- ));
- }
- let memory_index = self.memory.size();
- self.memory.append(Value::UNDEFINED);
- let value = match steps {
- SerializableSteps::DOMException => {
- let fields = dom_exception::deserialization_steps(self.serialized)?;
- Value::from_object(dom_exception::create(realm, &fields))
- }
- SerializableSteps::QuotaExceededError => {
- let fields = quota_exceeded_error::deserialization_steps(self.serialized)?;
- Value::from_object(quota_exceeded_error::create(realm, &fields))
- }
- SerializableSteps::CryptoKey => {
- Value::from_object(crypto_key::deserialization_steps(realm, self.serialized)?)
- }
- _ => deserialize_rust_platform_object(interface_name, self.serialized, self.memory)?,
- };
- self.memory.set(memory_index, value);
- return Ok(value);
- }
-
- // 3. Set value to a new instance of the interface identified by interfaceName, created in targetRealm.
- value = Value::from_object(create_serialized_platform_object(interface_name, realm));
-
if version.is_some_and(|version| version != serializable_payload_version()) {
return Err(data_clone_error_from_serialization_error(
realm,
@@ -1411,8 +1376,31 @@ impl Deserializer<'_, '_> {
));
}
+ // 3. Set value to a new instance of the interface identified by interfaceName, created in targetRealm.
// 4. Set deep to true.
- deep = true;
+ // NB: The deserialization steps of an interface implemented in Rust, and those that run here for
+ // DOMException, QuotaExceededError and CryptoKey, create the new instance from what they read, so
+ // they run here, at the position in memory that the instance has, rather than in step 25.4.
+ let memory_index = self.memory.size();
+ self.memory.append(Value::UNDEFINED);
+ let value = match serializable_steps(interface_name) {
+ SerializableSteps::DOMException => {
+ let fields = dom_exception::deserialization_steps(self.serialized)?;
+ Value::from_object(dom_exception::create(realm, &fields))
+ }
+ SerializableSteps::QuotaExceededError => {
+ let fields = quota_exceeded_error::deserialization_steps(self.serialized)?;
+ Value::from_object(quota_exceeded_error::create(realm, &fields))
+ }
+ SerializableSteps::CryptoKey => {
+ Value::from_object(crypto_key::deserialization_steps(realm, self.serialized)?)
+ }
+ SerializableSteps::Rust => {
+ deserialize_rust_platform_object(interface_name, self.serialized, self.memory)?
+ }
+ };
+ self.memory.set(memory_index, value);
+ return Ok(value);
}
}
@@ -1490,10 +1478,8 @@ impl Deserializer<'_, '_> {
}
}
// 4. Otherwise:
- else {
- // 1. Perform the appropriate deserialization steps for the interface identified by serialized.[[Type]], given serialized, value, and targetRealm.
- deserialization_steps(value.as_object(), self.serialized, self.memory)?;
- }
+ // 1. Perform the appropriate deserialization steps for the interface identified by serialized.[[Type]], given serialized, value, and targetRealm.
+ // NB: Step 23 runs the deserialization steps of a platform object.
}
// 26. Return value.
diff --git a/Libraries/LibWeb/Bindings/Serializable.h b/Libraries/LibWeb/Bindings/Serializable.h
deleted file mode 100644
index d982954d094..00000000000
--- a/Libraries/LibWeb/Bindings/Serializable.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2024, Kenneth Myhra <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <LibJS/Forward.h>
-#include <LibWeb/Bindings/IntrinsicDefinitions.h>
-#include <LibWeb/Export.h>
-#include <LibWeb/Forward.h>
-#include <LibWeb/HTML/StructuredSerializeTypes.h>
-
-namespace Web::Bindings {
-
-// https://html.spec.whatwg.org/multipage/structured-data.html#serializable-objects
-class WEB_API Serializable {
-public:
- virtual ~Serializable() = default;
-
- // https://html.spec.whatwg.org/multipage/structured-data.html#serialization-steps
- virtual WebIDL::ExceptionOr<void> serialization_steps(HTML::StructuredSerializeWriter&, bool for_storage, HTML::SerializationMemory&) = 0;
-
- // https://html.spec.whatwg.org/multipage/structured-data.html#deserialization-steps
- virtual WebIDL::ExceptionOr<void> deserialization_steps(JS::Realm&, HTML::StructuredSerializeReader&, HTML::DeserializationMemory&) = 0;
-};
-
-}
diff --git a/Libraries/LibWeb/Crypto/CryptoKey.cpp b/Libraries/LibWeb/Crypto/CryptoKey.cpp
index 68ed4cc7741..5931465a2f8 100644
--- a/Libraries/LibWeb/Crypto/CryptoKey.cpp
+++ b/Libraries/LibWeb/Crypto/CryptoKey.cpp
@@ -131,23 +131,12 @@ GC::Ref<CryptoKey> CryptoKey::create(InternalKeyData key_data)
return GC::Heap::the().allocate<CryptoKey>(move(key_data));
}
-GC::Ref<CryptoKey> CryptoKey::create()
-{
- return GC::Heap::the().allocate<CryptoKey>();
-}
-
CryptoKey::CryptoKey(InternalKeyData key_data)
: m_algorithm(KeyAlgorithmData {})
, m_key_data(move(key_data))
{
}
-CryptoKey::CryptoKey()
- : m_algorithm(KeyAlgorithmData {})
- , m_key_data(MUST(ByteBuffer::create_uninitialized(0)))
-{
-}
-
void CryptoKey::finalize()
{
Base::finalize();
diff --git a/Libraries/LibWeb/Crypto/CryptoKey.h b/Libraries/LibWeb/Crypto/CryptoKey.h
index bda7a9a87f2..e283b68cc1b 100644
--- a/Libraries/LibWeb/Crypto/CryptoKey.h
+++ b/Libraries/LibWeb/Crypto/CryptoKey.h
@@ -115,7 +115,6 @@ public:
using InternalAlgorithmData = Variant<KeyAlgorithmData, RsaKeyAlgorithmData, RsaHashedKeyAlgorithmData, EcKeyAlgorithmData, AesKeyAlgorithmData, HmacKeyAlgorithmData, KmacKeyAlgorithmData>;
[[nodiscard]] static GC::Ref<CryptoKey> create(InternalKeyData);
- [[nodiscard]] static GC::Ref<CryptoKey> create();
bool extractable() const { return m_extractable; }
KeyType type() const { return m_type; }
@@ -139,7 +138,6 @@ public:
private:
explicit CryptoKey(InternalKeyData);
- CryptoKey();
virtual void finalize() override;
virtual void visit_edges(Cell::Visitor&) override;
diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Libraries/LibWeb/HTML/StructuredSerialize.cpp
index c300b141693..a50741eda4c 100644
--- a/Libraries/LibWeb/HTML/StructuredSerialize.cpp
+++ b/Libraries/LibWeb/HTML/StructuredSerialize.cpp
@@ -41,7 +41,6 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/PredefinedColorSpace.h>
#include <LibWeb/Bindings/QuotaExceededError.h>
-#include <LibWeb/Bindings/Serializable.h>
#include <LibWeb/Bindings/Transferable.h>
#include <LibWeb/Crypto/CryptoKey.h>
#include <LibWeb/FileAPI/Blob.h>
diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.h b/Libraries/LibWeb/HTML/StructuredSerialize.h
index af55f253e38..ec5484a99ef 100644
--- a/Libraries/LibWeb/HTML/StructuredSerialize.h
+++ b/Libraries/LibWeb/HTML/StructuredSerialize.h
@@ -231,13 +231,12 @@ struct ImageBitmapSharedPixels;
namespace Web::Bindings {
class RustInterfaceCell;
-class Serializable;
class Transferable;
-// A platform object that is a serializable object: an implementation object of an interface implemented in C++, or
-// the cell of an object of an interface implemented in Rust, whose steps the Rust bindings run.
+// A platform object that is a serializable object: an implementation object of an interface implemented in C++, whose
+// steps run in Rust over its fields, or the cell of an object of an interface implemented in Rust, whose steps the Rust
+// bindings run.
struct SerializablePlatformObject {
- Serializable* serializable { nullptr };
GC::Ptr<RustInterfaceCell> rust_object { nullptr };
InterfaceName interface_name;
GC::Ptr<JS::Realm> realm;
@@ -262,7 +261,6 @@ struct TransferablePlatformObject {
WEB_API Optional<TransferablePlatformObject> transferable_from_object(JS::Object&);
WEB_API Optional<SerializablePlatformObject> serializable_from_object(JS::Object&);
WEB_API bool is_platform_object(JS::Object const&);
-WEB_API GC::Ref<JS::HostObject> create_serialized_platform_object(InterfaceName, JS::Realm&);
WEB_API WebIDL::ExceptionOr<GC::Ref<JS::HostObject>> create_transferred_platform_object(HTML::TransferType, JS::Realm&, HTML::TransferDataDecoder&);
// The deserialization steps of an interface implemented in Rust create its object from what they read, rather than
diff --git a/Libraries/LibWeb/HTML/StructuredSerializeRustIntegration.cpp b/Libraries/LibWeb/HTML/StructuredSerializeRustIntegration.cpp
index eab9d36dcb0..14a8a7b3419 100644
--- a/Libraries/LibWeb/HTML/StructuredSerializeRustIntegration.cpp
+++ b/Libraries/LibWeb/HTML/StructuredSerializeRustIntegration.cpp
@@ -22,7 +22,6 @@
#include <LibWeb/Bindings/PrincipalHostDefined.h>
#include <LibWeb/Bindings/ReadableStream.h>
#include <LibWeb/Bindings/RustSerialization.h>
-#include <LibWeb/Bindings/Serializable.h>
#include <LibWeb/Bindings/TransformStream.h>
#include <LibWeb/Bindings/WritableStream.h>
#include <LibWeb/HTML/ImageBitmap.h>
@@ -45,7 +44,6 @@ enum class SerializableSteps : u8 {
DOMException,
QuotaExceededError,
CryptoKey,
- Cpp,
};
extern "C" {
@@ -116,8 +114,6 @@ JSCompletion web_structured_serialize_serialization_steps(void* realm, JSObject*
bool web_structured_serialize_is_exposed(u16 interface_name, void* realm);
u8 web_structured_serialize_serializable_steps(u16 interface_name);
JSCompletion web_structured_serialize_deserialize_rust_platform_object(u16 interface_name, void* realm, StructuredSerializeReader*, DeserializationMemory*);
-JSObject* web_structured_serialize_create_serialized_platform_object(u16 interface_name, void* realm);
-JSCompletion web_structured_serialize_deserialization_steps(void* realm, JSObject*, StructuredSerializeReader*, DeserializationMemory*);
bool web_structured_serialize_is_transferable(JSObject*);
bool web_structured_serialize_transferable_is_detached(JSObject*);
@@ -594,9 +590,8 @@ u8 web_structured_serialize_serializable_steps(u16 interface_name)
case Bindings::InterfaceName::CryptoKey:
return to_underlying(SerializableSteps::CryptoKey);
default:
- if (Bindings::serializable_interface_is_implemented_in_rust(static_cast<Bindings::InterfaceName>(interface_name)))
- return to_underlying(SerializableSteps::Rust);
- return to_underlying(SerializableSteps::Cpp);
+ VERIFY(Bindings::serializable_interface_is_implemented_in_rust(static_cast<Bindings::InterfaceName>(interface_name)));
+ return to_underlying(SerializableSteps::Rust);
}
}
@@ -609,19 +604,6 @@ JSCompletion web_structured_serialize_deserialize_rust_platform_object(u16 inter
return JS::HostABI::completion_to_abi(JS::ThrowCompletionOr<JS::Value> { object.release_value() });
}
-JSObject* web_structured_serialize_create_serialized_platform_object(u16 interface_name, void* realm)
-{
- return JS::HostABI::object_to_abi(Bindings::create_serialized_platform_object(static_cast<Bindings::InterfaceName>(interface_name), realm_from_abi(realm)).ptr());
-}
-
-JSCompletion web_structured_serialize_deserialization_steps(void* realm, JSObject* object, StructuredSerializeReader* reader, DeserializationMemory* memory)
-{
- auto& js_realm = realm_from_abi(realm);
- auto serializable = Bindings::serializable_from_object(*JS::HostABI::object_from_abi(object));
- VERIFY(serializable.has_value() && serializable->serializable);
- return void_completion_to_abi(js_realm, serializable->serializable->deserialization_steps(js_realm, *reader, *memory));
-}
-
bool web_structured_serialize_is_transferable(JSObject* object)
{
return Bindings::transferable_from_object(*JS::HostABI::object_from_abi(object)).has_value();
diff --git a/Libraries/LibWeb/WebIDL/DOMException.cpp b/Libraries/LibWeb/WebIDL/DOMException.cpp
index 930fe2f6e27..f741a182719 100644
--- a/Libraries/LibWeb/WebIDL/DOMException.cpp
+++ b/Libraries/LibWeb/WebIDL/DOMException.cpp
@@ -24,11 +24,6 @@ GC::Ref<DOMException> DOMException::create(Utf16FlyString name, Utf16String cons
return GC::Heap::the().allocate<DOMException>(move(name), message);
}
-GC::Ref<DOMException> DOMException::create()
-{
- return GC::Heap::the().allocate<DOMException>();
-}
-
DOMException::DOMException(FlyString name, Utf16String const& message)
: m_error_data(JS::ErrorDataCell::capture(JS::VM::the()))
, m_name(Utf16FlyString::from_fly_string(name))
@@ -43,11 +38,6 @@ DOMException::DOMException(Utf16FlyString name, Utf16String const& message)
{
}
-DOMException::DOMException()
- : m_error_data(JS::ErrorDataCell::capture(JS::VM::the()))
-{
-}
-
DOMException::~DOMException() = default;
void DOMException::visit_edges(GC::Cell::Visitor& visitor)
diff --git a/Libraries/LibWeb/WebIDL/DOMException.h b/Libraries/LibWeb/WebIDL/DOMException.h
index d69103edc92..2a33c0bad9d 100644
--- a/Libraries/LibWeb/WebIDL/DOMException.h
+++ b/Libraries/LibWeb/WebIDL/DOMException.h
@@ -102,7 +102,6 @@ class WEB_API DOMException : public Bindings::GCAllocatedWrappable {
public:
static GC::Ref<DOMException> create(FlyString name, Utf16String const& message);
static GC::Ref<DOMException> create(Utf16FlyString name, Utf16String const& message);
- static GC::Ref<DOMException> create();
static GC::Ref<DOMException> create_for_constructor(Utf16String const& message, Utf16String const& name) { return create(Utf16FlyString::from_utf16(name.utf16_view()), message); }
virtual ~DOMException() override;
@@ -117,7 +116,6 @@ public:
protected:
DOMException(FlyString name, Utf16String const& message);
DOMException(Utf16FlyString name, Utf16String const& message);
- DOMException();
virtual void visit_edges(GC::Cell::Visitor&) override;
diff --git a/Libraries/LibWeb/WebIDL/QuotaExceededError.cpp b/Libraries/LibWeb/WebIDL/QuotaExceededError.cpp
index 89b103b414a..60767e0a9c3 100644
--- a/Libraries/LibWeb/WebIDL/QuotaExceededError.cpp
+++ b/Libraries/LibWeb/WebIDL/QuotaExceededError.cpp
@@ -15,11 +15,6 @@ namespace Web::WebIDL {
GC_DEFINE_ALLOCATOR(QuotaExceededError);
-QuotaExceededError::QuotaExceededError()
- : DOMException()
-{
-}
-
QuotaExceededError::QuotaExceededError(Utf16String const& message)
: DOMException("QuotaExceededError"_fly_string, message)
{
@@ -32,11 +27,6 @@ QuotaExceededError::QuotaExceededError(Utf16FlyString name, Utf16String const& m
{
}
-GC::Ref<QuotaExceededError> QuotaExceededError::create()
-{
- return GC::Heap::the().allocate<QuotaExceededError>();
-}
-
GC::Ref<QuotaExceededError> QuotaExceededError::create(Utf16String const& message)
{
return GC::Heap::the().allocate<QuotaExceededError>(message);
diff --git a/Libraries/LibWeb/WebIDL/QuotaExceededError.h b/Libraries/LibWeb/WebIDL/QuotaExceededError.h
index 1f084bd4ca7..8b2475c717d 100644
--- a/Libraries/LibWeb/WebIDL/QuotaExceededError.h
+++ b/Libraries/LibWeb/WebIDL/QuotaExceededError.h
@@ -26,7 +26,6 @@ class WEB_API QuotaExceededError final : public DOMException {
public:
static GC::Ref<QuotaExceededError> create(Utf16String const& message);
- static GC::Ref<QuotaExceededError> create();
static ExceptionOr<GC::Ref<QuotaExceededError>> create(JS::VM&, Utf16String const& message, QuotaExceededErrorOptions const&);
@@ -42,7 +41,6 @@ public:
protected:
explicit QuotaExceededError(Utf16String const& message);
QuotaExceededError(Utf16FlyString name, Utf16String const& message, Optional<double> quota, Optional<double> requested);
- QuotaExceededError();
private:
// https://webidl.spec.whatwg.org/#quotaexceedederror-quota
diff --git a/Meta/Generators/libweb_bindings/structured_serialize.py b/Meta/Generators/libweb_bindings/structured_serialize.py
index 2e1b7e8ed46..df6efbaae88 100644
--- a/Meta/Generators/libweb_bindings/structured_serialize.py
+++ b/Meta/Generators/libweb_bindings/structured_serialize.py
@@ -72,7 +72,6 @@ def write_structured_serialize_bindings_implementation(out: TextIO, interfaces:
#include <LibJS/HostClassBuilder.h>
#include <LibWeb/Bindings/RustInterface.h>
#include <LibWeb/Bindings/RustSerialization.h>
-#include <LibWeb/Bindings/Serializable.h>
#include <LibWeb/Bindings/Transferable.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/Bindings/WrapperWorld.h>
@@ -84,8 +83,9 @@ def write_structured_serialize_bindings_implementation(out: TextIO, interfaces:
for interface in included_interfaces:
out.write(f"#include <LibWeb/Bindings/{interface.implemented_name}.h>\n")
# NB: The bindings find the cells of the objects of an interface implemented in Rust by the class of their
- # wrappers, which LibWeb/Bindings/<interface>.h declares, so they need no C++ class of the interface.
- if not is_implemented_in_rust(interface):
+ # wrappers, which LibWeb/Bindings/<interface>.h declares, so they need no C++ class of the interface. A
+ # serializable interface implemented in C++ needs none either, as its steps run in Rust.
+ if interface in transferable and not is_implemented_in_rust(interface):
out.write(f"#include <{implementation_header_for_interface(interface)}>\n")
out.write(
@@ -199,7 +199,7 @@ Optional<SerializablePlatformObject> serializable_from_object(JS::Object& object
return SerializablePlatformObject {{ .rust_object = cell, .interface_name = InterfaceName::{interface.name}, .realm = &object.shape().realm() }};
"""
)
- # NB: An object is a serializable object if its primary interface is [Serializable]. The steps of some interfaces
+ # NB: An object is a serializable object if its primary interface is [Serializable]. The steps of the interfaces
# implemented in C++ run in Rust, so their classes have no C++ steps.
cpp_serializable = [interface for interface in serializable if not is_implemented_in_rust(interface)]
out.write(
@@ -215,8 +215,8 @@ Optional<SerializablePlatformObject> serializable_from_object(JS::Object& object
out.write(f" case InterfaceName::{interface.name}:\n")
if cpp_serializable:
out.write(
- " return SerializablePlatformObject { .serializable = as_if<Serializable>(*wrappable), "
- ".interface_name = wrappable->interface_name(), .realm = &object.shape().realm() };\n"
+ " return SerializablePlatformObject { .interface_name = wrappable->interface_name(), "
+ ".realm = &object.shape().realm() };\n"
)
out.write(
""" default:
@@ -226,9 +226,6 @@ Optional<SerializablePlatformObject> serializable_from_object(JS::Object& object
WebIDL::ExceptionOr<void> SerializablePlatformObject::serialization_steps(HTML::StructuredSerializeWriter& serialized, bool for_storage, HTML::SerializationMemory& memory) const
{
- if (serializable)
- return serializable->serialization_steps(serialized, for_storage, memory);
-
[[maybe_unused]] RustSerializationWriter writer { .realm = *realm, .serialized = serialized, .for_storage = for_storage, .memory = memory };
switch (interface_name) {
"""
@@ -281,28 +278,6 @@ WebIDL::ExceptionOr<GC::Ref<JS::HostObject>> deserialize_rust_platform_object(In
}
}
-GC::Ref<JS::HostObject> create_serialized_platform_object(InterfaceName serialize_type, JS::Realm& realm)
-{
- auto& wrapper_world = Bindings::host_defined_wrapper_world(realm);
-
- switch (serialize_type) {
-"""
- )
- for interface in serializable:
- if is_implemented_in_rust(interface):
- continue
- out.write(f" case InterfaceName::{interface.name}:\n")
- out.write(
- f" return Bindings::wrap(wrapper_world, realm, {fully_qualified_name_for_interface(interface)}::create());\n"
- )
-
- out.write(
- """ case InterfaceName::Unknown:
- default:
- VERIFY_NOT_REACHED();
- }
-}
-
WebIDL::ExceptionOr<GC::Ref<JS::HostObject>> create_transferred_platform_object(HTML::TransferType name, JS::Realm& target_realm, HTML::TransferDataDecoder& decoder)
{
auto& wrapper_world = Bindings::host_defined_wrapper_world(target_realm);
diff --git a/Meta/Linters/check_libweb_realm_mentions.py b/Meta/Linters/check_libweb_realm_mentions.py
index ee1a0dabf66..fa43b6c6a93 100755
--- a/Meta/Linters/check_libweb_realm_mentions.py
+++ b/Meta/Linters/check_libweb_realm_mentions.py
@@ -52,7 +52,7 @@ ALLOWED_REALM_MENTIONS = {
"FileAPI": (2, 9, "Blob glue still creates streams and buffers in selected realms"),
"HTML": (
65,
- 195,
+ 194,
"HTML algorithms still contain structured serialization, including posted-message preparation, canvas, navigation transfer/reconstruction, worker/worklet, and event realm use, and cross-origin Window/Location property functions are created in the current realm; RemoteWindow mirrors Window's postMessage; "
"the C++ glue of the Rust structured serialization reads records and creates platform objects in a given realm",
),
diff --git a/Tests/LibWeb/TestStructuredSerializeFormat.cpp b/Tests/LibWeb/TestStructuredSerializeFormat.cpp
index a901cec059c..0cedc872b33 100644
--- a/Tests/LibWeb/TestStructuredSerializeFormat.cpp
+++ b/Tests/LibWeb/TestStructuredSerializeFormat.cpp
@@ -15,7 +15,6 @@
#include <LibJS/Runtime/TypedArray.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/Module.h>
-#include <LibWeb/Bindings/Serializable.h>
#include <LibWeb/Crypto/CryptoKeySerializationTags.h>
#include <LibWeb/FileAPI/File.h>
#include <LibWeb/FileAPI/FileList.h>