Skip to content

Truly independent web browser

LibWeb: Implement the queuing strategies in Rust

Aliaksandr Kalenikd89e38c5b14e
diff --git a/Libraries/LibWeb/Bindings/Rust/src/lib.rs b/Libraries/LibWeb/Bindings/Rust/src/lib.rs
index 7235142c4e3..025156b13d5 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/lib.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/lib.rs
@@ -42,6 +42,11 @@ pub(crate) mod speech;
not(web_idl_bindings),
allow(dead_code, reason = "only the generated bindings use the interfaces")
)]
+pub(crate) mod streams;
+#[cfg_attr(
+ not(web_idl_bindings),
+ allow(dead_code, reason = "only the generated bindings use the interfaces")
+)]
pub(crate) mod url_pattern;
// NB: Only C++ calls into libweb_rust, so nothing in this crate names it. Linking it keeps its extern "C" functions in
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/byte_length_queuing_strategy.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/byte_length_queuing_strategy.rs
new file mode 100644
index 00000000000..cd0c447f289
--- /dev/null
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/byte_length_queuing_strategy.rs
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! ByteLengthQueuingStrategy, https://streams.spec.whatwg.org/#blqs-class
+
+use libjs_rust::api::{
+ FunctionObject, Gc, PropertyKey, RawNativeFunction, ThrowCompletionOr, Trace, Value, Vm, raw_native,
+};
+
+use crate::bindings::realm_data::realm_data;
+use crate::bindings::{CallContext, WebIdlResult};
+use crate::streams::queuing_strategy_init::QueuingStrategyInit;
+
+#[derive(Trace)]
+#[gc(crate = libjs_rust)]
+pub(crate) struct ByteLengthQueuingStrategy {
+ high_water_mark: f64,
+}
+
+#[expect(
+ clippy::unnecessary_wraps,
+ reason = "the bindings call every method of an implementation for its WebIDL result, whether or not it can fail"
+)]
+impl ByteLengthQueuingStrategy {
+ // https://streams.spec.whatwg.org/#blqs-constructor
+ pub(crate) fn construct(_: &mut CallContext, init: QueuingStrategyInit) -> WebIdlResult<Self> {
+ // 1. Set this.[[highWaterMark]] to init["highWaterMark"].
+ Ok(Self {
+ high_water_mark: init.high_water_mark,
+ })
+ }
+
+ // https://streams.spec.whatwg.org/#blqs-high-water-mark
+ pub(crate) fn high_water_mark(&self, _: &mut CallContext) -> WebIdlResult<f64> {
+ // The highWaterMark getter steps are:
+ // 1. Return this.[[highWaterMark]].
+ Ok(self.high_water_mark)
+ }
+
+ // https://streams.spec.whatwg.org/#blqs-size
+ pub(crate) fn size(&self, cx: &mut CallContext) -> WebIdlResult<Gc<FunctionObject>> {
+ // 1. Return this's relevant global object's byte length queuing strategy size function.
+ Ok(byte_length_queuing_strategy_size_function(cx))
+ }
+}
+
+/// The byte length queuing strategy size function of the global object of the realm of the call context,
+/// https://streams.spec.whatwg.org/#byte-length-queuing-strategy-size-function, which the first use in the realm
+/// creates.
+fn byte_length_queuing_strategy_size_function(cx: &CallContext) -> Gc<FunctionObject> {
+ let data = realm_data(cx.vm(), cx.realm());
+ if let Some(function) = data.byte_length_queuing_strategy_size_function.get() {
+ return function;
+ }
+
+ // 1. Let steps be the following steps, given chunk:
+ fn steps(vm: &Vm) -> ThrowCompletionOr<Value> {
+ let chunk = vm.argument(0);
+
+ // 1. Return ? GetV(chunk, "byteLength").
+ chunk.get(vm, &vm.names.byteLength)
+ }
+
+ // 2. Let F be ! CreateBuiltinFunction(steps, 1, "size", « », globalObject's relevant Realm).
+ let function = RawNativeFunction::create(
+ cx.vm(),
+ raw_native!(steps),
+ 1,
+ &PropertyKey::from_utf8("size"),
+ Some(cx.realm()),
+ None,
+ None,
+ );
+
+ // 3. Set globalObject's byte length queuing strategy size function to a Function that represents a reference
+ // to F, with callback context equal to globalObject's relevant settings object.
+ let function: Gc<FunctionObject> = function.upcast();
+ data.byte_length_queuing_strategy_size_function.set(Some(function));
+ function
+}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/count_queuing_strategy.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/count_queuing_strategy.rs
new file mode 100644
index 00000000000..345bd26e31a
--- /dev/null
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/count_queuing_strategy.rs
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! CountQueuingStrategy, https://streams.spec.whatwg.org/#cqs-class
+
+use libjs_rust::api::{
+ FunctionObject, Gc, PropertyKey, RawNativeFunction, ThrowCompletionOr, Trace, Value, Vm, raw_native,
+};
+
+use crate::bindings::realm_data::realm_data;
+use crate::bindings::{CallContext, WebIdlResult};
+use crate::streams::queuing_strategy_init::QueuingStrategyInit;
+
+#[derive(Trace)]
+#[gc(crate = libjs_rust)]
+pub(crate) struct CountQueuingStrategy {
+ high_water_mark: f64,
+}
+
+#[expect(
+ clippy::unnecessary_wraps,
+ reason = "the bindings call every method of an implementation for its WebIDL result, whether or not it can fail"
+)]
+impl CountQueuingStrategy {
+ // https://streams.spec.whatwg.org/#cqs-constructor
+ pub(crate) fn construct(_: &mut CallContext, init: QueuingStrategyInit) -> WebIdlResult<Self> {
+ // 1. Set this.[[highWaterMark]] to init["highWaterMark"].
+ Ok(Self {
+ high_water_mark: init.high_water_mark,
+ })
+ }
+
+ // https://streams.spec.whatwg.org/#cqs-high-water-mark
+ pub(crate) fn high_water_mark(&self, _: &mut CallContext) -> WebIdlResult<f64> {
+ // The highWaterMark getter steps are:
+ // 1. Return this.[[highWaterMark]].
+ Ok(self.high_water_mark)
+ }
+
+ // https://streams.spec.whatwg.org/#cqs-size
+ pub(crate) fn size(&self, cx: &mut CallContext) -> WebIdlResult<Gc<FunctionObject>> {
+ // 1. Return this's relevant global object's count queuing strategy size function.
+ Ok(count_queuing_strategy_size_function(cx))
+ }
+}
+
+/// The count queuing strategy size function of the global object of the realm of the call context,
+/// https://streams.spec.whatwg.org/#count-queuing-strategy-size-function, which the first use in the realm creates.
+fn count_queuing_strategy_size_function(cx: &CallContext) -> Gc<FunctionObject> {
+ let data = realm_data(cx.vm(), cx.realm());
+ if let Some(function) = data.count_queuing_strategy_size_function.get() {
+ return function;
+ }
+
+ // 1. Let steps be the following steps:
+ #[expect(
+ clippy::unnecessary_wraps,
+ reason = "the steps of a native function return a completion, whether or not they can throw"
+ )]
+ fn steps(_: &Vm) -> ThrowCompletionOr<Value> {
+ // 1. Return 1.
+ Ok(Value::from_i32(1))
+ }
+
+ // 2. Let F be ! CreateBuiltinFunction(steps, 0, "size", « », globalObject's relevant Realm).
+ let function = RawNativeFunction::create(
+ cx.vm(),
+ raw_native!(steps),
+ 0,
+ &PropertyKey::from_utf8("size"),
+ Some(cx.realm()),
+ None,
+ None,
+ );
+
+ // 3. Set globalObject's count queuing strategy size function to a Function that represents a reference to F,
+ // with callback context equal to globalObject's relevant settings object.
+ let function: Gc<FunctionObject> = function.upcast();
+ data.count_queuing_strategy_size_function.set(Some(function));
+ function
+}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/mod.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/mod.rs
new file mode 100644
index 00000000000..e7302f49111
--- /dev/null
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/mod.rs
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! The Streams Standard, https://streams.spec.whatwg.org/
+
+#[cfg(not(test))]
+pub(crate) mod byte_length_queuing_strategy;
+#[cfg(not(test))]
+pub(crate) mod count_queuing_strategy;
+pub(crate) mod queuing_strategy_init;
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/queuing_strategy_init.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/queuing_strategy_init.rs
new file mode 100644
index 00000000000..2296087151e
--- /dev/null
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/queuing_strategy_init.rs
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! QueuingStrategyInit, https://streams.spec.whatwg.org/#dictdef-queuingstrategyinit
+
+/// The dictionary QueuingStrategyInit of Streams/QueuingStrategyInit.idl, whose members the bindings convert.
+pub(crate) struct QueuingStrategyInit {
+ pub(crate) high_water_mark: f64,
+}
diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt
index e82c2aad40d..2608c4db6d3 100644
--- a/Libraries/LibWeb/CMakeLists.txt
+++ b/Libraries/LibWeb/CMakeLists.txt
@@ -848,8 +848,6 @@ set(SOURCES
StorageAPI/StorageManager.cpp
StorageAPI/StorageShelf.cpp
Streams/AbstractOperations.cpp
- Streams/ByteLengthQueuingStrategy.cpp
- Streams/CountQueuingStrategy.cpp
Streams/GenericTransformStream.cpp
Streams/ReadableByteStreamController.cpp
Streams/ReadableStream.cpp
diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h
index 23034bbdc24..f640f062452 100644
--- a/Libraries/LibWeb/Forward.h
+++ b/Libraries/LibWeb/Forward.h
@@ -1088,8 +1088,6 @@ class SpeechSynthesisVoice;
namespace Web::Streams {
-class ByteLengthQueuingStrategy;
-class CountQueuingStrategy;
class ReadableByteStreamController;
class ReadableStream;
class ReadableStreamAsyncIterator;
diff --git a/Libraries/LibWeb/HTML/UniversalGlobalScope.cpp b/Libraries/LibWeb/HTML/UniversalGlobalScope.cpp
index f1609f4b487..f812c9cc02a 100644
--- a/Libraries/LibWeb/HTML/UniversalGlobalScope.cpp
+++ b/Libraries/LibWeb/HTML/UniversalGlobalScope.cpp
@@ -43,8 +43,6 @@ static JS::Realm& relevant_realm_for_universal_global_scope(DOM::EventTarget& gl
void UniversalGlobalScopeMixin::visit_edges(GC::Cell::Visitor& visitor)
{
- visitor.visit(m_count_queuing_strategy_size_function);
- visitor.visit(m_byte_length_queuing_strategy_size_function);
visitor.ignore(m_outstanding_rejected_promises_weak_set);
visitor.visit(m_about_to_be_notified_rejected_promises_list);
}
@@ -116,54 +114,6 @@ WebIDL::ExceptionOr<JS::Value> UniversalGlobalScopeMixin::structured_clone(JS::R
return deserialized.deserialized;
}
-// https://streams.spec.whatwg.org/#count-queuing-strategy-size-function
-GC::Ref<WebIDL::CallbackType> UniversalGlobalScopeMixin::count_queuing_strategy_size_function()
-{
- auto& realm = relevant_realm_for_universal_global_scope(this_impl());
-
- if (!m_count_queuing_strategy_size_function) {
- // 1. Let steps be the following steps:
- auto steps = [](auto const&) {
- // 1. Return 1.
- return 1.0;
- };
-
- // 2. Let F be ! CreateBuiltinFunction(steps, 0, "size", « », globalObject’s relevant Realm).
- auto function = JS::NativeFunction::create(realm, move(steps), 0, "size"_utf16_fly_string, &realm);
-
- // 3. Set globalObject’s count queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object.
- // FIXME: Update spec comment to pass globalObject's relevant realm once Streams spec is updated for ShadowRealm spec
- m_count_queuing_strategy_size_function = GC::Heap::the().allocate<WebIDL::CallbackType>(*function, realm);
- }
-
- return GC::Ref { *m_count_queuing_strategy_size_function };
-}
-
-// https://streams.spec.whatwg.org/#byte-length-queuing-strategy-size-function
-GC::Ref<WebIDL::CallbackType> UniversalGlobalScopeMixin::byte_length_queuing_strategy_size_function()
-{
- auto& realm = relevant_realm_for_universal_global_scope(this_impl());
-
- if (!m_byte_length_queuing_strategy_size_function) {
- // 1. Let steps be the following steps, given chunk:
- auto steps = [](JS::VM& vm) {
- auto chunk = vm.argument(0);
-
- // 1. Return ? GetV(chunk, "byteLength").
- return chunk.get(vm, vm.names.byteLength);
- };
-
- // 2. Let F be ! CreateBuiltinFunction(steps, 1, "size", « », globalObject’s relevant Realm).
- auto function = JS::NativeFunction::create(realm, Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)> { move(steps) }, 1, "size"_utf16_fly_string, &realm);
-
- // 3. Set globalObject’s byte length queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object.
- // FIXME: Update spec comment to pass globalObject's relevant realm once Streams spec is updated for ShadowRealm spec
- m_byte_length_queuing_strategy_size_function = GC::Heap::the().allocate<WebIDL::CallbackType>(*function, realm);
- }
-
- return GC::Ref { *m_byte_length_queuing_strategy_size_function };
-}
-
void UniversalGlobalScopeMixin::push_onto_outstanding_rejected_promises_weak_set(GC::Ptr<JS::Promise> promise)
{
m_outstanding_rejected_promises_weak_set.append(promise);
diff --git a/Libraries/LibWeb/HTML/UniversalGlobalScope.h b/Libraries/LibWeb/HTML/UniversalGlobalScope.h
index 3a54cc78e7a..9c707043b53 100644
--- a/Libraries/LibWeb/HTML/UniversalGlobalScope.h
+++ b/Libraries/LibWeb/HTML/UniversalGlobalScope.h
@@ -36,8 +36,6 @@ public:
WebIDL::ExceptionOr<Utf16String> atob(Utf16View data) const;
void queue_microtask(WebIDL::CallbackType&);
WebIDL::ExceptionOr<JS::Value> structured_clone(JS::Realm&, JS::Value, Bindings::StructuredSerializeOptions const&);
- GC::Ref<WebIDL::CallbackType> count_queuing_strategy_size_function();
- GC::Ref<WebIDL::CallbackType> byte_length_queuing_strategy_size_function();
void push_onto_outstanding_rejected_promises_weak_set(GC::Ptr<JS::Promise>);
bool remove_from_outstanding_rejected_promises_weak_set(GC::Ptr<JS::Promise>);
@@ -58,8 +56,6 @@ protected:
void visit_edges(GC::Cell::Visitor&);
private:
- GC::Ptr<WebIDL::CallbackType> m_count_queuing_strategy_size_function;
- GC::Ptr<WebIDL::CallbackType> m_byte_length_queuing_strategy_size_function;
GC::Ptr<GC::HeapVector<GC::Ref<JS::Promise>>> m_about_to_be_notified_rejected_promises_list;
Vector<GC::Ptr<JS::Promise>> m_outstanding_rejected_promises_weak_set;
ImportMap m_import_map;
diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
index 58847988a2c..a0af5d9dac8 100644
--- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
+++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
@@ -147,8 +147,6 @@ void WindowOrWorkerGlobalScopeMixin::visit_edges(JS::Cell::Visitor& visitor)
visitor.visit(m_cache_storage);
visitor.visit(m_resource_timing_secondary_buffer);
visitor.visit(m_trusted_type_policy_factory);
- visitor.visit(m_count_queuing_strategy_size_function);
- visitor.visit(m_byte_length_queuing_strategy_size_function);
visitor.ignore(m_outstanding_rejected_promises_weak_set);
visitor.visit(m_about_to_be_notified_rejected_promises_list);
}
@@ -1512,54 +1510,6 @@ void WindowOrWorkerGlobalScopeMixin::document_audio_play_state_changed(Badge<DOM
realign_timers();
}
-// https://streams.spec.whatwg.org/#count-queuing-strategy-size-function
-GC::Ref<WebIDL::CallbackType> WindowOrWorkerGlobalScopeMixin::count_queuing_strategy_size_function()
-{
- auto& realm = HTML::relevant_realm(*this);
-
- if (!m_count_queuing_strategy_size_function) {
- // 1. Let steps be the following steps:
- auto steps = [](auto const&) {
- // 1. Return 1.
- return 1.0;
- };
-
- // 2. Let F be ! CreateBuiltinFunction(steps, 0, "size", « », globalObject’s relevant Realm).
- auto function = JS::NativeFunction::create(realm, move(steps), 0, "size"_utf16_fly_string, &realm);
-
- // 3. Set globalObject’s count queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object.
- // FIXME: Update spec comment to pass globalObject's relevant realm once Streams spec is updated for ShadowRealm spec
- m_count_queuing_strategy_size_function = GC::Heap::the().allocate<WebIDL::CallbackType>(*function, realm);
- }
-
- return GC::Ref { *m_count_queuing_strategy_size_function };
-}
-
-// https://streams.spec.whatwg.org/#byte-length-queuing-strategy-size-function
-GC::Ref<WebIDL::CallbackType> WindowOrWorkerGlobalScopeMixin::byte_length_queuing_strategy_size_function()
-{
- auto& realm = HTML::relevant_realm(*this);
-
- if (!m_byte_length_queuing_strategy_size_function) {
- // 1. Let steps be the following steps, given chunk:
- auto steps = [](JS::VM& vm) {
- auto chunk = vm.argument(0);
-
- // 1. Return ? GetV(chunk, "byteLength").
- return chunk.get(vm, vm.names.byteLength);
- };
-
- // 2. Let F be ! CreateBuiltinFunction(steps, 1, "size", « », globalObject’s relevant Realm).
- auto function = JS::NativeFunction::create(realm, Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)> { move(steps) }, 1, "size"_utf16_fly_string, &realm);
-
- // 3. Set globalObject’s byte length queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object.
- // FIXME: Update spec comment to pass globalObject's relevant realm once Streams spec is updated for ShadowRealm spec
- m_byte_length_queuing_strategy_size_function = GC::Heap::the().allocate<WebIDL::CallbackType>(*function, realm);
- }
-
- return GC::Ref { *m_byte_length_queuing_strategy_size_function };
-}
-
void WindowOrWorkerGlobalScopeMixin::push_onto_outstanding_rejected_promises_weak_set(GC::Ptr<JS::Promise> promise)
{
m_outstanding_rejected_promises_weak_set.append(promise);
diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h
index efe8e2efc81..c0091c39768 100644
--- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h
+++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h
@@ -125,9 +125,6 @@ public:
};
void report_an_exception(JS::Value exception, OmitError = OmitError::No);
- GC::Ref<WebIDL::CallbackType> count_queuing_strategy_size_function();
- GC::Ref<WebIDL::CallbackType> byte_length_queuing_strategy_size_function();
-
void push_onto_outstanding_rejected_promises_weak_set(GC::Ptr<JS::Promise>);
bool remove_from_outstanding_rejected_promises_weak_set(GC::Ptr<JS::Promise>);
@@ -244,12 +241,6 @@ private:
// A resource timing secondary buffer to store PerformanceResourceTiming objects that is initially empty.
Vector<GC::Ref<ResourceTiming::PerformanceResourceTiming>> m_resource_timing_secondary_buffer;
- // https://streams.spec.whatwg.org/#count-queuing-strategy-size-function
- GC::Ptr<WebIDL::CallbackType> m_count_queuing_strategy_size_function;
-
- // https://streams.spec.whatwg.org/#byte-length-queuing-strategy-size-function
- GC::Ptr<WebIDL::CallbackType> m_byte_length_queuing_strategy_size_function;
-
// https://html.spec.whatwg.org/multipage/webappapis.html#about-to-be-notified-rejected-promises-list
GC::Ptr<GC::HeapVector<GC::Ref<JS::Promise>>> m_about_to_be_notified_rejected_promises_list;
diff --git a/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp b/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp
deleted file mode 100644
index 10353cb8066..00000000000
--- a/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2023, Shannon Booth <[email protected]>
- * Copyright (c) 2023, Matthew Olsson <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibGC/Heap.h>
-#include <LibWeb/HTML/Scripting/Environments.h>
-#include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
-#include <LibWeb/Streams/ByteLengthQueuingStrategy.h>
-
-namespace Web::Streams {
-
-GC_DEFINE_ALLOCATOR(ByteLengthQueuingStrategy);
-
-// https://streams.spec.whatwg.org/#blqs-constructor
-GC::Ref<ByteLengthQueuingStrategy> ByteLengthQueuingStrategy::create(double high_water_mark)
-{
- // The new ByteLengthQueuingStrategy(init) constructor steps are:
- // 1. Set this.[[highWaterMark]] to init["highWaterMark"].
- return GC::Heap::the().allocate<ByteLengthQueuingStrategy>(high_water_mark);
-}
-
-GC::Ref<ByteLengthQueuingStrategy> ByteLengthQueuingStrategy::create_for_constructor(Bindings::QueuingStrategyInit const& init)
-{
- return create(init.high_water_mark);
-}
-
-ByteLengthQueuingStrategy::ByteLengthQueuingStrategy(double high_water_mark)
- : m_high_water_mark(high_water_mark)
-{
-}
-
-ByteLengthQueuingStrategy::~ByteLengthQueuingStrategy() = default;
-
-// https://streams.spec.whatwg.org/#blqs-size
-GC::Ref<WebIDL::CallbackType> ByteLengthQueuingStrategy::size(JS::Object& relevant_global_object)
-{
- // 1. Return this's relevant global object's byte length queuing strategy size function.
- auto& global = HTML::relevant_window_or_worker_global_scope(relevant_global_object);
- return global.byte_length_queuing_strategy_size_function();
-}
-
-}
diff --git a/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.h b/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.h
deleted file mode 100644
index fd9bcffee1b..00000000000
--- a/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2023, Shannon Booth <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Forward.h>
-#include <LibJS/Forward.h>
-#include <LibWeb/Bindings/QueuingStrategyInit.h>
-#include <LibWeb/Bindings/Wrappable.h>
-#include <LibWeb/Forward.h>
-
-namespace Web::Streams {
-
-// https://streams.spec.whatwg.org/#bytelengthqueuingstrategy
-class ByteLengthQueuingStrategy final : public Bindings::GCAllocatedWrappable {
- WEB_WRAPPABLE(ByteLengthQueuingStrategy, Bindings::GCAllocatedWrappable);
- GC_DECLARE_ALLOCATOR(ByteLengthQueuingStrategy);
-
-public:
- static GC::Ref<ByteLengthQueuingStrategy> create(double high_water_mark);
- static GC::Ref<ByteLengthQueuingStrategy> create_for_constructor(Bindings::QueuingStrategyInit const&);
-
- virtual ~ByteLengthQueuingStrategy() override;
-
- // https://streams.spec.whatwg.org/#blqs-high-water-mark
- double high_water_mark() const
- {
- // The highWaterMark getter steps are:
- // 1. Return this.[[highWaterMark]].
- return m_high_water_mark;
- }
-
- GC::Ref<WebIDL::CallbackType> size(JS::Object& relevant_global_object);
-
-private:
- explicit ByteLengthQueuingStrategy(double high_water_mark);
-
- // https://streams.spec.whatwg.org/#bytelengthqueuingstrategy-highwatermark
- double m_high_water_mark { 0 };
-};
-
-}
diff --git a/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.idl b/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.idl
index 58f4145ad89..2e7a86c06e0 100644
--- a/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.idl
+++ b/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.idl
@@ -1,5 +1,5 @@
// https://streams.spec.whatwg.org/#blqs-class-definition
-[Exposed=*]
+[Exposed=*, ImplementedIn=Rust]
interface ByteLengthQueuingStrategy {
constructor(QueuingStrategyInit init);
diff --git a/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp b/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp
deleted file mode 100644
index 56e6c198b49..00000000000
--- a/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2023, Shannon Booth <[email protected]>
- * Copyright (c) 2023, Matthew Olsson <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibGC/Heap.h>
-#include <LibWeb/HTML/Scripting/Environments.h>
-#include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
-#include <LibWeb/Streams/CountQueuingStrategy.h>
-
-namespace Web::Streams {
-
-GC_DEFINE_ALLOCATOR(CountQueuingStrategy);
-
-// https://streams.spec.whatwg.org/#blqs-constructor
-GC::Ref<CountQueuingStrategy> CountQueuingStrategy::create(double high_water_mark)
-{
- // The new CountQueuingStrategy(init) constructor steps are:
- // 1. Set this.[[highWaterMark]] to init["highWaterMark"].
- return GC::Heap::the().allocate<CountQueuingStrategy>(high_water_mark);
-}
-
-GC::Ref<CountQueuingStrategy> CountQueuingStrategy::create_for_constructor(Bindings::QueuingStrategyInit const& init)
-{
- return create(init.high_water_mark);
-}
-
-CountQueuingStrategy::CountQueuingStrategy(double high_water_mark)
- : m_high_water_mark(high_water_mark)
-{
-}
-
-CountQueuingStrategy::~CountQueuingStrategy() = default;
-
-// https://streams.spec.whatwg.org/#cqs-size
-GC::Ref<WebIDL::CallbackType> CountQueuingStrategy::size(JS::Object& relevant_global_object)
-{
- // 1. Return this's relevant global object's count queuing strategy size function.
- auto& global = HTML::relevant_window_or_worker_global_scope(relevant_global_object);
- return global.count_queuing_strategy_size_function();
-}
-
-}
diff --git a/Libraries/LibWeb/Streams/CountQueuingStrategy.h b/Libraries/LibWeb/Streams/CountQueuingStrategy.h
deleted file mode 100644
index 41ff515d30a..00000000000
--- a/Libraries/LibWeb/Streams/CountQueuingStrategy.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2023, Shannon Booth <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Forward.h>
-#include <LibJS/Forward.h>
-#include <LibWeb/Bindings/QueuingStrategyInit.h>
-#include <LibWeb/Bindings/Wrappable.h>
-#include <LibWeb/Forward.h>
-
-namespace Web::Streams {
-
-// https://streams.spec.whatwg.org/#countqueuingstrategy
-class CountQueuingStrategy final : public Bindings::GCAllocatedWrappable {
- WEB_WRAPPABLE(CountQueuingStrategy, Bindings::GCAllocatedWrappable);
- GC_DECLARE_ALLOCATOR(CountQueuingStrategy);
-
-public:
- static GC::Ref<CountQueuingStrategy> create(double high_water_mark);
- static GC::Ref<CountQueuingStrategy> create_for_constructor(Bindings::QueuingStrategyInit const&);
-
- virtual ~CountQueuingStrategy() override;
-
- // https://streams.spec.whatwg.org/#cqs-high-water-mark
- double high_water_mark() const
- {
- // The highWaterMark getter steps are:
- // 1. Return this.[[highWaterMark]].
- return m_high_water_mark;
- }
-
- GC::Ref<WebIDL::CallbackType> size(JS::Object& relevant_global_object);
-
-private:
- explicit CountQueuingStrategy(double high_water_mark);
-
- // https://streams.spec.whatwg.org/#countqueuingstrategy-highwatermark
- double m_high_water_mark { 0 };
-};
-
-}
diff --git a/Libraries/LibWeb/Streams/CountQueuingStrategy.idl b/Libraries/LibWeb/Streams/CountQueuingStrategy.idl
index 6f2bbeaa56c..25f7d966d93 100644
--- a/Libraries/LibWeb/Streams/CountQueuingStrategy.idl
+++ b/Libraries/LibWeb/Streams/CountQueuingStrategy.idl
@@ -1,5 +1,5 @@
// https://streams.spec.whatwg.org/#cqs-class-definition
-[Exposed=*]
+[Exposed=*, ImplementedIn=Rust]
interface CountQueuingStrategy {
constructor(QueuingStrategyInit init);