1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 13:47:35 +00:00

LibWeb: Implement QueuingStrategy for Web::Streams::WritableStream

This commit is contained in:
Shannon Booth 2023-06-18 21:58:04 +12:00 committed by Andreas Kling
parent 33f6e5d516
commit 9cb4bf0683
3 changed files with 9 additions and 8 deletions

View file

@ -17,7 +17,7 @@
namespace Web::Streams { namespace Web::Streams {
// https://streams.spec.whatwg.org/#ws-constructor // https://streams.spec.whatwg.org/#ws-constructor
WebIDL::ExceptionOr<JS::NonnullGCPtr<WritableStream>> WritableStream::construct_impl(JS::Realm& realm, Optional<JS::Handle<JS::Object>> const& underlying_sink_object) WebIDL::ExceptionOr<JS::NonnullGCPtr<WritableStream>> WritableStream::construct_impl(JS::Realm& realm, Optional<JS::Handle<JS::Object>> const& underlying_sink_object, QueuingStrategy const& strategy)
{ {
auto& vm = realm.vm(); auto& vm = realm.vm();
@ -36,11 +36,11 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WritableStream>> WritableStream::construct_
// 4. Perform ! InitializeWritableStream(this). // 4. Perform ! InitializeWritableStream(this).
// Note: This AO configures slot values which are already specified in the class's field initializers. // Note: This AO configures slot values which are already specified in the class's field initializers.
// FIXME: 5. Let sizeAlgorithm be ! ExtractSizeAlgorithm(strategy). // 5. Let sizeAlgorithm be ! ExtractSizeAlgorithm(strategy).
SizeAlgorithm size_algorithm = [](auto const&) { return JS::normal_completion(JS::Value(1)); }; auto size_algorithm = extract_size_algorithm(strategy);
// FIXME: 6. Let highWaterMark be ? ExtractHighWaterMark(strategy, 1). // 6. Let highWaterMark be ? ExtractHighWaterMark(strategy, 1).
auto high_water_mark = 1.0; auto high_water_mark = TRY(extract_high_water_mark(strategy, 1));
// 7. Perform ? SetUpWritableStreamDefaultControllerFromUnderlyingSink(this, underlyingSink, underlyingSinkDict, highWaterMark, sizeAlgorithm). // 7. Perform ? SetUpWritableStreamDefaultControllerFromUnderlyingSink(this, underlyingSink, underlyingSinkDict, highWaterMark, sizeAlgorithm).
TRY(set_up_writable_stream_default_controller_from_underlying_sink(*writable_stream, underlying_sink, underlying_sink_dict, high_water_mark, move(size_algorithm))); TRY(set_up_writable_stream_default_controller_from_underlying_sink(*writable_stream, underlying_sink, underlying_sink_dict, high_water_mark, move(size_algorithm)));

View file

@ -11,6 +11,7 @@
#include <LibJS/Forward.h> #include <LibJS/Forward.h>
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
#include <LibWeb/Streams/QueuingStrategy.h>
#include <LibWeb/WebIDL/Promise.h> #include <LibWeb/WebIDL/Promise.h>
namespace Web::Streams { namespace Web::Streams {
@ -42,7 +43,7 @@ public:
Errored, Errored,
}; };
static WebIDL::ExceptionOr<JS::NonnullGCPtr<WritableStream>> construct_impl(JS::Realm& realm, Optional<JS::Handle<JS::Object>> const& underlying_sink); static WebIDL::ExceptionOr<JS::NonnullGCPtr<WritableStream>> construct_impl(JS::Realm& realm, Optional<JS::Handle<JS::Object>> const& underlying_sink, QueuingStrategy const& = {});
virtual ~WritableStream() = default; virtual ~WritableStream() = default;

View file

@ -1,9 +1,9 @@
#import <Streams/QueuingStrategy.idl>
#import <Streams/WritableStreamDefaultWriter.idl> #import <Streams/WritableStreamDefaultWriter.idl>
[Exposed=*, Transferable] [Exposed=*, Transferable]
interface WritableStream { interface WritableStream {
// FIXME: optional QueuingStrategy strategy = {} constructor(optional object underlyingSink, optional QueuingStrategy strategy = {});
constructor(optional object underlyingSink);
readonly attribute boolean locked; readonly attribute boolean locked;