mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Move WritableStream AOs into their own file
The main streams AO file has gotten very large, and is a bit difficult to navigate. In an effort to improve DX, this migrates WritableStream AOs to their own file.
This commit is contained in:
parent
a9ddd427cb
commit
26c01f0957
Notes:
github-actions[bot]
2025-04-18 10:56:46 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/26c01f09576 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4392
11 changed files with 1372 additions and 1326 deletions
|
@ -760,6 +760,7 @@ set(SOURCES
|
|||
Streams/WritableStream.cpp
|
||||
Streams/WritableStreamDefaultController.cpp
|
||||
Streams/WritableStreamDefaultWriter.cpp
|
||||
Streams/WritableStreamOperations.cpp
|
||||
SVG/AttributeNames.cpp
|
||||
SVG/AttributeParser.cpp
|
||||
SVG/SVGAElement.cpp
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,53 +23,6 @@ WebIDL::ExceptionOr<double> extract_high_water_mark(QueuingStrategy const&, doub
|
|||
|
||||
WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> transfer_array_buffer(JS::Realm& realm, JS::ArrayBuffer& buffer);
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<WritableStream>> create_writable_stream(JS::Realm& realm, GC::Ref<StartAlgorithm> start_algorithm, GC::Ref<WriteAlgorithm> write_algorithm, GC::Ref<CloseAlgorithm> close_algorithm, GC::Ref<AbortAlgorithm> abort_algorithm, double high_water_mark, GC::Ref<SizeAlgorithm> size_algorithm);
|
||||
void initialize_writable_stream(WritableStream&);
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<WritableStreamDefaultWriter>> acquire_writable_stream_default_writer(WritableStream&);
|
||||
bool is_writable_stream_locked(WritableStream const&);
|
||||
WebIDL::ExceptionOr<void> set_up_writable_stream_default_writer(WritableStreamDefaultWriter&, WritableStream&);
|
||||
GC::Ref<WebIDL::Promise> writable_stream_abort(WritableStream&, JS::Value reason);
|
||||
GC::Ref<WebIDL::Promise> writable_stream_close(WritableStream&);
|
||||
|
||||
GC::Ref<WebIDL::Promise> writable_stream_add_write_request(WritableStream&);
|
||||
bool writable_stream_close_queued_or_in_flight(WritableStream const&);
|
||||
void writable_stream_deal_with_rejection(WritableStream&, JS::Value error);
|
||||
void writable_stream_finish_erroring(WritableStream&);
|
||||
void writable_stream_finish_in_flight_close(WritableStream&);
|
||||
void writable_stream_finish_in_flight_close_with_error(WritableStream&, JS::Value error);
|
||||
void writable_stream_finish_in_flight_write(WritableStream&);
|
||||
void writable_stream_finish_in_flight_write_with_error(WritableStream&, JS::Value error);
|
||||
bool writable_stream_has_operation_marked_in_flight(WritableStream const&);
|
||||
void writable_stream_mark_close_request_in_flight(WritableStream&);
|
||||
void writable_stream_mark_first_write_request_in_flight(WritableStream&);
|
||||
void writable_stream_reject_close_and_closed_promise_if_needed(WritableStream&);
|
||||
void writable_stream_start_erroring(WritableStream&, JS::Value reason);
|
||||
void writable_stream_update_backpressure(WritableStream&, bool backpressure);
|
||||
|
||||
GC::Ref<WebIDL::Promise> writable_stream_default_writer_abort(WritableStreamDefaultWriter&, JS::Value reason);
|
||||
GC::Ref<WebIDL::Promise> writable_stream_default_writer_close(WritableStreamDefaultWriter&);
|
||||
GC::Ref<WebIDL::Promise> writable_stream_default_writer_close_with_error_propagation(WritableStreamDefaultWriter&);
|
||||
void writable_stream_default_writer_ensure_closed_promise_rejected(WritableStreamDefaultWriter&, JS::Value error);
|
||||
void writable_stream_default_writer_ensure_ready_promise_rejected(WritableStreamDefaultWriter&, JS::Value error);
|
||||
Optional<double> writable_stream_default_writer_get_desired_size(WritableStreamDefaultWriter const&);
|
||||
void writable_stream_default_writer_release(WritableStreamDefaultWriter&);
|
||||
GC::Ref<WebIDL::Promise> writable_stream_default_writer_write(WritableStreamDefaultWriter&, JS::Value chunk);
|
||||
|
||||
WebIDL::ExceptionOr<void> set_up_writable_stream_default_controller(WritableStream&, WritableStreamDefaultController&, GC::Ref<StartAlgorithm>, GC::Ref<WriteAlgorithm>, GC::Ref<CloseAlgorithm>, GC::Ref<AbortAlgorithm>, double high_water_mark, GC::Ref<SizeAlgorithm>);
|
||||
WebIDL::ExceptionOr<void> set_up_writable_stream_default_controller_from_underlying_sink(WritableStream&, JS::Value underlying_sink_value, UnderlyingSink&, double high_water_mark, GC::Ref<SizeAlgorithm> size_algorithm);
|
||||
void writable_stream_default_controller_advance_queue_if_needed(WritableStreamDefaultController&);
|
||||
void writable_stream_default_controller_clear_algorithms(WritableStreamDefaultController&);
|
||||
void writable_stream_default_controller_close(WritableStreamDefaultController&);
|
||||
void writable_stream_default_controller_error(WritableStreamDefaultController&, JS::Value error);
|
||||
void writable_stream_default_controller_error_if_needed(WritableStreamDefaultController&, JS::Value error);
|
||||
bool writable_stream_default_controller_get_backpressure(WritableStreamDefaultController const&);
|
||||
JS::Value writable_stream_default_controller_get_chunk_size(WritableStreamDefaultController&, JS::Value chunk);
|
||||
double writable_stream_default_controller_get_desired_size(WritableStreamDefaultController const&);
|
||||
void writable_stream_default_controller_process_close(WritableStreamDefaultController&);
|
||||
void writable_stream_default_controller_process_write(WritableStreamDefaultController&, JS::Value chunk);
|
||||
void writable_stream_default_controller_write(WritableStreamDefaultController&, JS::Value chunk, JS::Value chunk_size);
|
||||
|
||||
void initialize_transform_stream(TransformStream&, GC::Ref<WebIDL::Promise> start_promise, double writable_high_water_mark, GC::Ref<SizeAlgorithm> writable_size_algorithm, double readable_high_water_mark, GC::Ref<SizeAlgorithm> readable_size_algorithm);
|
||||
void set_up_transform_stream_default_controller(TransformStream&, TransformStreamDefaultController&, GC::Ref<TransformAlgorithm>, GC::Ref<FlushAlgorithm>, GC::Ref<CancelAlgorithm>);
|
||||
void set_up_transform_stream_default_controller_from_transformer(TransformStream&, JS::Value transformer, Transformer&);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <LibWeb/Streams/TransformStream.h>
|
||||
#include <LibWeb/Streams/UnderlyingSource.h>
|
||||
#include <LibWeb/Streams/WritableStream.h>
|
||||
#include <LibWeb/Streams/WritableStreamOperations.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <LibWeb/Streams/UnderlyingSource.h>
|
||||
#include <LibWeb/Streams/WritableStream.h>
|
||||
#include <LibWeb/Streams/WritableStreamDefaultWriter.h>
|
||||
#include <LibWeb/Streams/WritableStreamOperations.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/Streams/AbstractOperations.h>
|
||||
#include <LibWeb/Streams/ReadableStreamDefaultReader.h>
|
||||
#include <LibWeb/Streams/ReadableStreamOperations.h>
|
||||
#include <LibWeb/Streams/ReadableStreamPipeTo.h>
|
||||
#include <LibWeb/Streams/WritableStream.h>
|
||||
#include <LibWeb/Streams/WritableStreamDefaultWriter.h>
|
||||
#include <LibWeb/Streams/WritableStreamOperations.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
namespace Web::Streams::Detail {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <LibWeb/Streams/WritableStream.h>
|
||||
#include <LibWeb/Streams/WritableStreamDefaultController.h>
|
||||
#include <LibWeb/Streams/WritableStreamDefaultWriter.h>
|
||||
#include <LibWeb/Streams/WritableStreamOperations.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
@ -45,7 +46,7 @@ WebIDL::ExceptionOr<GC::Ref<WritableStream>> WritableStream::construct_impl(JS::
|
|||
auto high_water_mark = TRY(extract_high_water_mark(strategy, 1));
|
||||
|
||||
// 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, size_algorithm));
|
||||
|
||||
return writable_stream;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <LibWeb/DOM/AbortSignal.h>
|
||||
#include <LibWeb/Streams/WritableStream.h>
|
||||
#include <LibWeb/Streams/WritableStreamDefaultController.h>
|
||||
#include <LibWeb/Streams/WritableStreamOperations.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#include <LibJS/Runtime/PromiseCapability.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/WritableStreamDefaultWriterPrototype.h>
|
||||
#include <LibWeb/Streams/AbstractOperations.h>
|
||||
#include <LibWeb/Streams/WritableStream.h>
|
||||
#include <LibWeb/Streams/WritableStreamDefaultWriter.h>
|
||||
#include <LibWeb/Streams/WritableStreamOperations.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
|
1293
Libraries/LibWeb/Streams/WritableStreamOperations.cpp
Normal file
1293
Libraries/LibWeb/Streams/WritableStreamOperations.cpp
Normal file
File diff suppressed because it is too large
Load diff
70
Libraries/LibWeb/Streams/WritableStreamOperations.h
Normal file
70
Libraries/LibWeb/Streams/WritableStreamOperations.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
||||
* Copyright (c) 2023-2025, Shannon Booth <shannon@serenityos.org>
|
||||
* Copyright (c) 2023-2024, Kenneth Myhra <kennethmyhra@serenityos.org>
|
||||
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/Streams/Algorithms.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
||||
// 5.5.1. Working with writable streams, https://streams.spec.whatwg.org/#ws-abstract-ops
|
||||
WebIDL::ExceptionOr<GC::Ref<WritableStreamDefaultWriter>> acquire_writable_stream_default_writer(WritableStream&);
|
||||
WebIDL::ExceptionOr<GC::Ref<WritableStream>> create_writable_stream(JS::Realm& realm, GC::Ref<StartAlgorithm> start_algorithm, GC::Ref<WriteAlgorithm> write_algorithm, GC::Ref<CloseAlgorithm> close_algorithm, GC::Ref<AbortAlgorithm> abort_algorithm, double high_water_mark, GC::Ref<SizeAlgorithm> size_algorithm);
|
||||
void initialize_writable_stream(WritableStream&);
|
||||
bool is_writable_stream_locked(WritableStream const&);
|
||||
WebIDL::ExceptionOr<void> set_up_writable_stream_default_writer(WritableStreamDefaultWriter&, WritableStream&);
|
||||
GC::Ref<WebIDL::Promise> writable_stream_abort(WritableStream&, JS::Value reason);
|
||||
GC::Ref<WebIDL::Promise> writable_stream_close(WritableStream&);
|
||||
|
||||
// 5.5.2. Interfacing with controllers, https://streams.spec.whatwg.org/#ws-abstract-ops-used-by-controllers
|
||||
GC::Ref<WebIDL::Promise> writable_stream_add_write_request(WritableStream&);
|
||||
bool writable_stream_close_queued_or_in_flight(WritableStream const&);
|
||||
void writable_stream_deal_with_rejection(WritableStream&, JS::Value error);
|
||||
void writable_stream_finish_erroring(WritableStream&);
|
||||
void writable_stream_finish_in_flight_close(WritableStream&);
|
||||
void writable_stream_finish_in_flight_close_with_error(WritableStream&, JS::Value error);
|
||||
void writable_stream_finish_in_flight_write(WritableStream&);
|
||||
void writable_stream_finish_in_flight_write_with_error(WritableStream&, JS::Value error);
|
||||
bool writable_stream_has_operation_marked_in_flight(WritableStream const&);
|
||||
void writable_stream_mark_close_request_in_flight(WritableStream&);
|
||||
void writable_stream_mark_first_write_request_in_flight(WritableStream&);
|
||||
void writable_stream_reject_close_and_closed_promise_if_needed(WritableStream&);
|
||||
void writable_stream_start_erroring(WritableStream&, JS::Value reason);
|
||||
void writable_stream_update_backpressure(WritableStream&, bool backpressure);
|
||||
|
||||
// 5.5.3. Writers, https://streams.spec.whatwg.org/#ws-writer-abstract-ops
|
||||
GC::Ref<WebIDL::Promise> writable_stream_default_writer_abort(WritableStreamDefaultWriter&, JS::Value reason);
|
||||
GC::Ref<WebIDL::Promise> writable_stream_default_writer_close(WritableStreamDefaultWriter&);
|
||||
GC::Ref<WebIDL::Promise> writable_stream_default_writer_close_with_error_propagation(WritableStreamDefaultWriter&);
|
||||
void writable_stream_default_writer_ensure_closed_promise_rejected(WritableStreamDefaultWriter&, JS::Value error);
|
||||
void writable_stream_default_writer_ensure_ready_promise_rejected(WritableStreamDefaultWriter&, JS::Value error);
|
||||
Optional<double> writable_stream_default_writer_get_desired_size(WritableStreamDefaultWriter const&);
|
||||
void writable_stream_default_writer_release(WritableStreamDefaultWriter&);
|
||||
GC::Ref<WebIDL::Promise> writable_stream_default_writer_write(WritableStreamDefaultWriter&, JS::Value chunk);
|
||||
|
||||
// 5.5.4. Default controllers, https://streams.spec.whatwg.org/#ws-default-controller-abstract-ops
|
||||
WebIDL::ExceptionOr<void> set_up_writable_stream_default_controller(WritableStream&, WritableStreamDefaultController&, GC::Ref<StartAlgorithm>, GC::Ref<WriteAlgorithm>, GC::Ref<CloseAlgorithm>, GC::Ref<AbortAlgorithm>, double high_water_mark, GC::Ref<SizeAlgorithm>);
|
||||
WebIDL::ExceptionOr<void> set_up_writable_stream_default_controller_from_underlying_sink(WritableStream&, JS::Value underlying_sink_value, UnderlyingSink&, double high_water_mark, GC::Ref<SizeAlgorithm> size_algorithm);
|
||||
void writable_stream_default_controller_advance_queue_if_needed(WritableStreamDefaultController&);
|
||||
void writable_stream_default_controller_clear_algorithms(WritableStreamDefaultController&);
|
||||
void writable_stream_default_controller_close(WritableStreamDefaultController&);
|
||||
void writable_stream_default_controller_error(WritableStreamDefaultController&, JS::Value error);
|
||||
void writable_stream_default_controller_error_if_needed(WritableStreamDefaultController&, JS::Value error);
|
||||
bool writable_stream_default_controller_get_backpressure(WritableStreamDefaultController const&);
|
||||
JS::Value writable_stream_default_controller_get_chunk_size(WritableStreamDefaultController&, JS::Value chunk);
|
||||
double writable_stream_default_controller_get_desired_size(WritableStreamDefaultController const&);
|
||||
void writable_stream_default_controller_process_close(WritableStreamDefaultController&);
|
||||
void writable_stream_default_controller_process_write(WritableStreamDefaultController&, JS::Value chunk);
|
||||
void writable_stream_default_controller_write(WritableStreamDefaultController&, JS::Value chunk, JS::Value chunk_size);
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue