From 9d5e5382474a41d2fb0d7abf9fd9e2845d1e7d6f Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 29 Apr 2024 17:16:24 -0400 Subject: [PATCH] LibWeb: Mark writable stream abort steps as infallible These don't throw. We can remove a decent amount of exception handling by marking them infallible. --- .../LibWeb/Streams/AbstractOperations.cpp | 100 ++++++++---------- .../LibWeb/Streams/AbstractOperations.h | 26 ++--- .../LibWeb/Streams/WritableStream.cpp | 4 +- .../Libraries/LibWeb/Streams/WritableStream.h | 2 +- .../WritableStreamDefaultController.cpp | 8 +- .../Streams/WritableStreamDefaultController.h | 4 +- .../Streams/WritableStreamDefaultWriter.cpp | 4 +- 7 files changed, 71 insertions(+), 77 deletions(-) diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp index 1f3d6c75da2..589e918d02a 100644 --- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp @@ -309,7 +309,7 @@ JS::NonnullGCPtr readable_stream_pipe_to(ReadableStream& source auto success_steps = [promise, &realm, writer](Vector const& bytes) { for (auto byte_buffer : bytes) { auto buffer = JS::ArrayBuffer::create(realm, move(byte_buffer)); - auto inner_promise = MUST(writable_stream_default_writer_write(writer, JS::Value { buffer })); + auto inner_promise = writable_stream_default_writer_write(writer, JS::Value { buffer }); WebIDL::resolve_promise(realm, inner_promise, JS::js_undefined()); } WebIDL::resolve_promise(realm, promise, JS::js_undefined()); @@ -3442,7 +3442,7 @@ WebIDL::ExceptionOr set_up_readable_stream_controller_with_byte_reading_su } // https://streams.spec.whatwg.org/#writable-stream-abort -WebIDL::ExceptionOr> writable_stream_abort(WritableStream& stream, JS::Value reason) +JS::NonnullGCPtr writable_stream_abort(WritableStream& stream, JS::Value reason) { auto& realm = stream.realm(); @@ -3488,7 +3488,7 @@ WebIDL::ExceptionOr> writable_stream_abort(Wri // 11. If wasAlreadyErroring is false, perform ! WritableStreamStartErroring(stream, reason). if (!was_already_erroring) - TRY(writable_stream_start_erroring(stream, reason)); + writable_stream_start_erroring(stream, reason); // 12. Return promise. return promise; @@ -3568,7 +3568,7 @@ bool writable_stream_close_queued_or_in_flight(WritableStream const& stream) } // https://streams.spec.whatwg.org/#writable-stream-deal-with-rejection -WebIDL::ExceptionOr writable_stream_deal_with_rejection(WritableStream& stream, JS::Value error) +void writable_stream_deal_with_rejection(WritableStream& stream, JS::Value error) { // 1. Let state be stream.[[state]]. auto state = stream.state(); @@ -3576,19 +3576,21 @@ WebIDL::ExceptionOr writable_stream_deal_with_rejection(WritableStream& st // 2. If state is "writable", if (state == WritableStream::State::Writable) { // 1. Perform ! WritableStreamStartErroring(stream, error). + writable_stream_start_erroring(stream, error); + // 2. Return. - return writable_stream_start_erroring(stream, error); + return; } // 3. Assert: state is "erroring". VERIFY(state == WritableStream::State::Erroring); // 4. Perform ! WritableStreamFinishErroring(stream). - return writable_stream_finish_erroring(stream); + writable_stream_finish_erroring(stream); } // https://streams.spec.whatwg.org/#writable-stream-finish-erroring -WebIDL::ExceptionOr writable_stream_finish_erroring(WritableStream& stream) +void writable_stream_finish_erroring(WritableStream& stream) { auto& realm = stream.realm(); @@ -3622,7 +3624,7 @@ WebIDL::ExceptionOr writable_stream_finish_erroring(WritableStream& stream writable_stream_reject_close_and_closed_promise_if_needed(stream); // 2. Return. - return {}; + return; } // 9. Let abortRequest be stream.[[pendingAbortRequest]]. @@ -3638,11 +3640,11 @@ WebIDL::ExceptionOr writable_stream_finish_erroring(WritableStream& stream writable_stream_reject_close_and_closed_promise_if_needed(stream); // 3. Return. - return {}; + return; } // 12. Let promise be ! stream.[[controller]].[[AbortSteps]](abortRequest’s reason). - auto promise = TRY(stream.controller()->abort_steps(abort_request.reason)); + auto promise = stream.controller()->abort_steps(abort_request.reason); // 13. Upon fulfillment of promise, WebIDL::upon_fulfillment(*promise, JS::create_heap_function(realm.heap(), [&realm, &stream, abort_promise = abort_request.promise](JS::Value) -> WebIDL::ExceptionOr { @@ -3665,8 +3667,6 @@ WebIDL::ExceptionOr writable_stream_finish_erroring(WritableStream& stream return JS::js_undefined(); })); - - return {}; } // https://streams.spec.whatwg.org/#writable-stream-finish-in-flight-close @@ -3720,7 +3720,7 @@ void writable_stream_finish_in_flight_close(WritableStream& stream) } // https://streams.spec.whatwg.org/#writable-stream-finish-in-flight-close-with-error -WebIDL::ExceptionOr writable_stream_finish_in_flight_close_with_error(WritableStream& stream, JS::Value error) +void writable_stream_finish_in_flight_close_with_error(WritableStream& stream, JS::Value error) { auto& realm = stream.realm(); @@ -3745,7 +3745,7 @@ WebIDL::ExceptionOr writable_stream_finish_in_flight_close_with_error(Writ } // 6. Perform ! WritableStreamDealWithRejection(stream, error). - return writable_stream_deal_with_rejection(stream, error); + writable_stream_deal_with_rejection(stream, error); } // https://streams.spec.whatwg.org/#writable-stream-finish-in-flight-write @@ -3764,7 +3764,7 @@ void writable_stream_finish_in_flight_write(WritableStream& stream) } // https://streams.spec.whatwg.org/#writable-stream-finish-in-flight-write-with-error -WebIDL::ExceptionOr writable_stream_finish_in_flight_write_with_error(WritableStream& stream, JS::Value error) +void writable_stream_finish_in_flight_write_with_error(WritableStream& stream, JS::Value error) { auto& realm = stream.realm(); @@ -3782,7 +3782,7 @@ WebIDL::ExceptionOr writable_stream_finish_in_flight_write_with_error(Writ VERIFY(state == WritableStream::State::Writable || state == WritableStream::State::Erroring); // 5. Perform ! WritableStreamDealWithRejection(stream, error). - return writable_stream_deal_with_rejection(stream, error); + writable_stream_deal_with_rejection(stream, error); } // https://streams.spec.whatwg.org/#writable-stream-has-operation-marked-in-flight @@ -3863,7 +3863,7 @@ void writable_stream_reject_close_and_closed_promise_if_needed(WritableStream& s } // https://streams.spec.whatwg.org/#writable-stream-start-erroring -WebIDL::ExceptionOr writable_stream_start_erroring(WritableStream& stream, JS::Value reason) +void writable_stream_start_erroring(WritableStream& stream, JS::Value reason) { // 1. Assert: stream.[[storedError]] is undefined. VERIFY(stream.stored_error().is_undefined()); @@ -3892,9 +3892,7 @@ WebIDL::ExceptionOr writable_stream_start_erroring(WritableStream& stream, // 9. If ! WritableStreamHasOperationMarkedInFlight(stream) is false and controller.[[started]] is true, perform ! WritableStreamFinishErroring(stream). if (!writable_stream_has_operation_marked_in_flight(stream) && controller->started()) - TRY(writable_stream_finish_erroring(stream)); - - return {}; + writable_stream_finish_erroring(stream); } // https://streams.spec.whatwg.org/#writable-stream-update-backpressure @@ -3931,7 +3929,7 @@ void writable_stream_update_backpressure(WritableStream& stream, bool backpressu } // https://streams.spec.whatwg.org/#writable-stream-default-writer-abort -WebIDL::ExceptionOr> writable_stream_default_writer_abort(WritableStreamDefaultWriter& writer, JS::Value reason) +JS::NonnullGCPtr writable_stream_default_writer_abort(WritableStreamDefaultWriter& writer, JS::Value reason) { // 1. Let stream be writer.[[stream]]. auto stream = writer.stream(); @@ -4048,7 +4046,7 @@ WebIDL::ExceptionOr writable_stream_default_writer_release(WritableStreamD } // https://streams.spec.whatwg.org/#writable-stream-default-writer-write -WebIDL::ExceptionOr> writable_stream_default_writer_write(WritableStreamDefaultWriter& writer, JS::Value chunk) +JS::NonnullGCPtr writable_stream_default_writer_write(WritableStreamDefaultWriter& writer, JS::Value chunk) { auto& realm = writer.realm(); @@ -4062,7 +4060,7 @@ WebIDL::ExceptionOr> writable_stream_default_w auto controller = stream->controller(); // 4. Let chunkSize be ! WritableStreamDefaultControllerGetChunkSize(controller, chunk). - auto chunk_size = TRY(writable_stream_default_controller_get_chunk_size(*controller, chunk)); + auto chunk_size = writable_stream_default_controller_get_chunk_size(*controller, chunk); // 5. If stream is not equal to writer.[[stream]], return a promise rejected with a TypeError exception. if (stream.ptr() != writer.stream().ptr()) { @@ -4094,7 +4092,7 @@ WebIDL::ExceptionOr> writable_stream_default_w auto promise = writable_stream_add_write_request(*stream); // 12. Perform ! WritableStreamDefaultControllerWrite(controller, chunk, chunkSize). - TRY(writable_stream_default_controller_write(*controller, chunk, chunk_size)); + writable_stream_default_controller_write(*controller, chunk, chunk_size); // 13. Return promise. return promise; @@ -4162,7 +4160,7 @@ WebIDL::ExceptionOr set_up_writable_stream_default_controller(WritableStre controller.set_started(true); // 3. Perform ! WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller). - TRY(writable_stream_default_controller_advance_queue_if_needed(controller)); + writable_stream_default_controller_advance_queue_if_needed(controller); return JS::js_undefined(); })); @@ -4177,7 +4175,7 @@ WebIDL::ExceptionOr set_up_writable_stream_default_controller(WritableStre controller.set_started(true); // 3. Perform ! WritableStreamDealWithRejection(stream, r). - TRY(writable_stream_deal_with_rejection(stream, reason)); + writable_stream_deal_with_rejection(stream, reason); return JS::js_undefined(); })); @@ -4253,18 +4251,18 @@ WebIDL::ExceptionOr set_up_writable_stream_default_controller_from_underly } // https://streams.spec.whatwg.org/#writable-stream-default-controller-advance-queue-if-needed -WebIDL::ExceptionOr writable_stream_default_controller_advance_queue_if_needed(WritableStreamDefaultController& controller) +void writable_stream_default_controller_advance_queue_if_needed(WritableStreamDefaultController& controller) { // 1. Let stream be controller.[[stream]]. auto stream = controller.stream(); // 2. If controller.[[started]] is false, return. if (!controller.started()) - return {}; + return; // 3. If stream.[[inFlightWriteRequest]] is not undefined, return. if (stream->in_flight_write_request()) - return {}; + return; // 4. Let state be stream.[[state]]. auto state = stream->state(); @@ -4275,13 +4273,15 @@ WebIDL::ExceptionOr writable_stream_default_controller_advance_queue_if_ne // 6. If state is "erroring", if (state == WritableStream::State::Erroring) { // 1. Perform ! WritableStreamFinishErroring(stream). + writable_stream_finish_erroring(*stream); + // 2. Return. - return writable_stream_finish_erroring(*stream); + return; } // 7. If controller.[[queue]] is empty, return. if (controller.queue().is_empty()) - return {}; + return; // 8. Let value be ! PeekQueueValue(controller). auto value = peek_queue_value(controller); @@ -4294,8 +4294,6 @@ WebIDL::ExceptionOr writable_stream_default_controller_advance_queue_if_ne else { writable_stream_default_controller_process_write(controller, value); } - - return {}; } // https://streams.spec.whatwg.org/#writable-stream-default-controller-clear-algorithms @@ -4321,13 +4319,13 @@ WebIDL::ExceptionOr writable_stream_default_controller_close(WritableStrea TRY(enqueue_value_with_size(controller, create_close_sentinel(), JS::Value(0.0))); // 2. Perform ! WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller). - TRY(writable_stream_default_controller_advance_queue_if_needed(controller)); + writable_stream_default_controller_advance_queue_if_needed(controller); return {}; } // https://streams.spec.whatwg.org/#writable-stream-default-controller-error -WebIDL::ExceptionOr writable_stream_default_controller_error(WritableStreamDefaultController& controller, JS::Value error) +void writable_stream_default_controller_error(WritableStreamDefaultController& controller, JS::Value error) { // 1. Let stream be controller.[[stream]]. auto stream = controller.stream(); @@ -4339,17 +4337,15 @@ WebIDL::ExceptionOr writable_stream_default_controller_error(WritableStrea writable_stream_default_controller_clear_algorithms(controller); // 4. Perform ! WritableStreamStartErroring(stream, error). - return writable_stream_start_erroring(stream, error); + writable_stream_start_erroring(stream, error); } // https://streams.spec.whatwg.org/#writable-stream-default-controller-error-if-needed -WebIDL::ExceptionOr writable_stream_default_controller_error_if_needed(WritableStreamDefaultController& controller, JS::Value error) +void writable_stream_default_controller_error_if_needed(WritableStreamDefaultController& controller, JS::Value error) { // 1. If controller.[[stream]].[[state]] is "writable", perform ! WritableStreamDefaultControllerError(controller, error). if (controller.stream()->state() == WritableStream::State::Writable) - TRY(writable_stream_default_controller_error(controller, error)); - - return {}; + writable_stream_default_controller_error(controller, error); } // https://streams.spec.whatwg.org/#writable-stream-default-controller-get-backpressure @@ -4363,7 +4359,7 @@ bool writable_stream_default_controller_get_backpressure(WritableStreamDefaultCo } // https://streams.spec.whatwg.org/#writable-stream-default-controller-get-chunk-size -WebIDL::ExceptionOr writable_stream_default_controller_get_chunk_size(WritableStreamDefaultController& controller, JS::Value chunk) +JS::Value writable_stream_default_controller_get_chunk_size(WritableStreamDefaultController& controller, JS::Value chunk) { // 1. Let returnValue be the result of performing controller.[[strategySizeAlgorithm]], passing in chunk, and interpreting the result as a completion record. auto return_value = controller.strategy_size_algorithm()->function()(chunk); @@ -4371,10 +4367,10 @@ WebIDL::ExceptionOr writable_stream_default_controller_get_chunk_size // 2. If returnValue is an abrupt completion, if (return_value.is_abrupt()) { // 1. Perform ! WritableStreamDefaultControllerErrorIfNeeded(controller, returnValue.[[Value]]). - TRY(writable_stream_default_controller_error_if_needed(controller, *return_value.release_value())); + writable_stream_default_controller_error_if_needed(controller, *return_value.release_value()); // 2. Return 1. - return 1.0; + return JS::Value { 1.0 }; } // 3. Return returnValue.[[Value]]. @@ -4420,7 +4416,7 @@ void writable_stream_default_controller_process_close(WritableStreamDefaultContr // 8. Upon rejection of sinkClosePromise with reason reason, WebIDL::upon_rejection(*sink_close_promise, JS::create_heap_function(controller.heap(), [stream = stream](JS::Value reason) -> WebIDL::ExceptionOr { // 1. Perform ! WritableStreamFinishInFlightCloseWithError(stream, reason). - TRY(writable_stream_finish_in_flight_close_with_error(*stream, reason)); + writable_stream_finish_in_flight_close_with_error(*stream, reason); return JS::js_undefined(); })); @@ -4462,7 +4458,7 @@ void writable_stream_default_controller_process_write(WritableStreamDefaultContr } // 6 .Perform ! WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller). - TRY(writable_stream_default_controller_advance_queue_if_needed(controller)); + writable_stream_default_controller_advance_queue_if_needed(controller); return JS::js_undefined(); })); @@ -4474,14 +4470,14 @@ void writable_stream_default_controller_process_write(WritableStreamDefaultContr writable_stream_default_controller_clear_algorithms(controller); // 2. Perform ! WritableStreamFinishInFlightWriteWithError(stream, reason). - TRY(writable_stream_finish_in_flight_write_with_error(*stream, reason)); + writable_stream_finish_in_flight_write_with_error(*stream, reason); return JS::js_undefined(); })); } // https://streams.spec.whatwg.org/#writable-stream-default-controller-write -WebIDL::ExceptionOr writable_stream_default_controller_write(WritableStreamDefaultController& controller, JS::Value chunk, JS::Value chunk_size) +void writable_stream_default_controller_write(WritableStreamDefaultController& controller, JS::Value chunk, JS::Value chunk_size) { auto& vm = controller.vm(); @@ -4493,10 +4489,10 @@ WebIDL::ExceptionOr writable_stream_default_controller_write(WritableStrea auto throw_completion = Bindings::throw_dom_exception_if_needed(vm, [&] { return enqueue_result; }).throw_completion(); // 1. Perform ! WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueResult.[[Value]]). - TRY(writable_stream_default_controller_error_if_needed(controller, *throw_completion.release_value())); + writable_stream_default_controller_error_if_needed(controller, *throw_completion.release_value()); // 2. Return. - return {}; + return; } // 3. Let stream be controller.[[stream]]. @@ -4512,9 +4508,7 @@ WebIDL::ExceptionOr writable_stream_default_controller_write(WritableStrea } // 5. Perform ! WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller). - TRY(writable_stream_default_controller_advance_queue_if_needed(controller)); - - return {}; + writable_stream_default_controller_advance_queue_if_needed(controller); } // https://streams.spec.whatwg.org/#initialize-transform-stream @@ -4911,7 +4905,7 @@ WebIDL::ExceptionOr transform_stream_error_writable_and_unblock_write(Tran transform_stream_default_controller_clear_algorithms(*stream.controller()); // 2. Perform ! WritableStreamDefaultControllerErrorIfNeeded(stream.[[writable]].[[controller]], e). - TRY(writable_stream_default_controller_error_if_needed(*stream.writable()->controller(), error)); + writable_stream_default_controller_error_if_needed(*stream.writable()->controller(), error); // 3. If stream.[[backpressure]] is true, perform ! TransformStreamSetBackpressure(stream, false). if (stream.backpressure().has_value() && *stream.backpressure()) diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h index 44809de6aa1..757e27d8db0 100644 --- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h +++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h @@ -124,45 +124,45 @@ void initialize_writable_stream(WritableStream&); WebIDL::ExceptionOr> acquire_writable_stream_default_writer(WritableStream&); bool is_writable_stream_locked(WritableStream const&); WebIDL::ExceptionOr set_up_writable_stream_default_writer(WritableStreamDefaultWriter&, WritableStream&); -WebIDL::ExceptionOr> writable_stream_abort(WritableStream&, JS::Value reason); +JS::NonnullGCPtr writable_stream_abort(WritableStream&, JS::Value reason); WebIDL::ExceptionOr> writable_stream_close(WritableStream&); JS::NonnullGCPtr writable_stream_add_write_request(WritableStream&); bool writable_stream_close_queued_or_in_flight(WritableStream const&); -WebIDL::ExceptionOr writable_stream_deal_with_rejection(WritableStream&, JS::Value error); -WebIDL::ExceptionOr writable_stream_finish_erroring(WritableStream&); +void writable_stream_deal_with_rejection(WritableStream&, JS::Value error); +void writable_stream_finish_erroring(WritableStream&); void writable_stream_finish_in_flight_close(WritableStream&); -WebIDL::ExceptionOr writable_stream_finish_in_flight_close_with_error(WritableStream&, JS::Value error); +void writable_stream_finish_in_flight_close_with_error(WritableStream&, JS::Value error); void writable_stream_finish_in_flight_write(WritableStream&); -WebIDL::ExceptionOr writable_stream_finish_in_flight_write_with_error(WritableStream&, JS::Value error); +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&); -WebIDL::ExceptionOr writable_stream_start_erroring(WritableStream&, JS::Value reason); +void writable_stream_start_erroring(WritableStream&, JS::Value reason); void writable_stream_update_backpressure(WritableStream&, bool backpressure); -WebIDL::ExceptionOr> writable_stream_default_writer_abort(WritableStreamDefaultWriter&, JS::Value reason); +JS::NonnullGCPtr writable_stream_default_writer_abort(WritableStreamDefaultWriter&, JS::Value reason); WebIDL::ExceptionOr> writable_stream_default_writer_close(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 writable_stream_default_writer_get_desired_size(WritableStreamDefaultWriter const&); WebIDL::ExceptionOr writable_stream_default_writer_release(WritableStreamDefaultWriter&); -WebIDL::ExceptionOr> writable_stream_default_writer_write(WritableStreamDefaultWriter&, JS::Value chunk); +JS::NonnullGCPtr writable_stream_default_writer_write(WritableStreamDefaultWriter&, JS::Value chunk); WebIDL::ExceptionOr set_up_writable_stream_default_controller(WritableStream&, WritableStreamDefaultController&, JS::NonnullGCPtr, JS::NonnullGCPtr, JS::NonnullGCPtr, JS::NonnullGCPtr, double high_water_mark, JS::NonnullGCPtr); WebIDL::ExceptionOr set_up_writable_stream_default_controller_from_underlying_sink(WritableStream&, JS::Value underlying_sink_value, UnderlyingSink&, double high_water_mark, JS::NonnullGCPtr size_algorithm); -WebIDL::ExceptionOr writable_stream_default_controller_advance_queue_if_needed(WritableStreamDefaultController&); +void writable_stream_default_controller_advance_queue_if_needed(WritableStreamDefaultController&); void writable_stream_default_controller_clear_algorithms(WritableStreamDefaultController&); WebIDL::ExceptionOr writable_stream_default_controller_close(WritableStreamDefaultController&); -WebIDL::ExceptionOr writable_stream_default_controller_error(WritableStreamDefaultController&, JS::Value error); -WebIDL::ExceptionOr writable_stream_default_controller_error_if_needed(WritableStreamDefaultController&, JS::Value error); +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&); -WebIDL::ExceptionOr writable_stream_default_controller_get_chunk_size(WritableStreamDefaultController&, JS::Value chunk); +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); -WebIDL::ExceptionOr writable_stream_default_controller_write(WritableStreamDefaultController&, JS::Value chunk, JS::Value chunk_size); +void writable_stream_default_controller_write(WritableStreamDefaultController&, JS::Value chunk, JS::Value chunk_size); WebIDL::ExceptionOr initialize_transform_stream(TransformStream&, JS::NonnullGCPtr start_promise, double writable_high_water_mark, JS::NonnullGCPtr writable_size_algorithm, double readable_high_water_mark, JS::NonnullGCPtr readable_size_algorithm); void set_up_transform_stream_default_controller(TransformStream&, TransformStreamDefaultController&, JS::NonnullGCPtr, JS::NonnullGCPtr); diff --git a/Userland/Libraries/LibWeb/Streams/WritableStream.cpp b/Userland/Libraries/LibWeb/Streams/WritableStream.cpp index 022b7001062..feeb9146186 100644 --- a/Userland/Libraries/LibWeb/Streams/WritableStream.cpp +++ b/Userland/Libraries/LibWeb/Streams/WritableStream.cpp @@ -79,7 +79,7 @@ WebIDL::ExceptionOr> WritableStream::close() } // https://streams.spec.whatwg.org/#ws-abort -WebIDL::ExceptionOr> WritableStream::abort(JS::Value reason) +JS::GCPtr WritableStream::abort(JS::Value reason) { auto& realm = this->realm(); @@ -90,7 +90,7 @@ WebIDL::ExceptionOr> WritableStream::abort(JS::Value reaso } // 2. Return ! WritableStreamAbort(this, reason). - return TRY(writable_stream_abort(*this, reason))->promise(); + return writable_stream_abort(*this, reason)->promise(); } // https://streams.spec.whatwg.org/#ws-get-writer diff --git a/Userland/Libraries/LibWeb/Streams/WritableStream.h b/Userland/Libraries/LibWeb/Streams/WritableStream.h index 263c49bfe12..8ec667785cb 100644 --- a/Userland/Libraries/LibWeb/Streams/WritableStream.h +++ b/Userland/Libraries/LibWeb/Streams/WritableStream.h @@ -49,7 +49,7 @@ public: virtual ~WritableStream() = default; bool locked() const; - WebIDL::ExceptionOr> abort(JS::Value reason); + JS::GCPtr abort(JS::Value reason); WebIDL::ExceptionOr> close(); WebIDL::ExceptionOr> get_writer(); diff --git a/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultController.cpp b/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultController.cpp index 1bcd2f2d75d..535cbc75fca 100644 --- a/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultController.cpp +++ b/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultController.cpp @@ -27,21 +27,21 @@ void WritableStreamDefaultController::visit_edges(Visitor& visitor) } // https://streams.spec.whatwg.org/#ws-default-controller-error -WebIDL::ExceptionOr WritableStreamDefaultController::error(JS::Value error) +void WritableStreamDefaultController::error(JS::Value error) { // 1. Let state be this.[[stream]].[[state]]. auto state = m_stream->state(); // 2. If state is not "writable", return. if (state != WritableStream::State::Writable) - return {}; + return; // 3. Perform ! WritableStreamDefaultControllerError(this, e). - return writable_stream_default_controller_error(*this, error); + writable_stream_default_controller_error(*this, error); } // https://streams.spec.whatwg.org/#ws-default-controller-private-abort -WebIDL::ExceptionOr> WritableStreamDefaultController::abort_steps(JS::Value reason) +JS::NonnullGCPtr WritableStreamDefaultController::abort_steps(JS::Value reason) { // 1. Let result be the result of performing this.[[abortAlgorithm]], passing reason. auto result = m_abort_algorithm->function()(reason); diff --git a/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultController.h b/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultController.h index 14c66dae5a1..9baa2a2c1cf 100644 --- a/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultController.h +++ b/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultController.h @@ -20,7 +20,7 @@ class WritableStreamDefaultController final : public Bindings::PlatformObject { public: virtual ~WritableStreamDefaultController() override = default; - WebIDL::ExceptionOr error(JS::Value error); + void error(JS::Value error); JS::NonnullGCPtr signal() { return *m_signal; } void set_signal(JS::NonnullGCPtr value) { m_signal = value; } @@ -50,7 +50,7 @@ public: JS::GCPtr write_algorithm() { return m_write_algorithm; } void set_write_algorithm(JS::GCPtr value) { m_write_algorithm = value; } - WebIDL::ExceptionOr> abort_steps(JS::Value reason); + JS::NonnullGCPtr abort_steps(JS::Value reason); void error_steps(); private: diff --git a/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp b/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp index 877f9a9c654..dc9b52c4997 100644 --- a/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp +++ b/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp @@ -63,7 +63,7 @@ WebIDL::ExceptionOr> WritableStreamDefaultWriter::abort(JS } // 2. Return ! WritableStreamDefaultWriterAbort(this, reason). - return TRY(writable_stream_default_writer_abort(*this, reason))->promise(); + return writable_stream_default_writer_abort(*this, reason)->promise(); } // https://streams.spec.whatwg.org/#default-writer-close @@ -117,7 +117,7 @@ WebIDL::ExceptionOr> WritableStreamDefaultWriter::write(JS } // 2. Return ! WritableStreamDefaultWriterWrite(this, chunk). - return TRY(writable_stream_default_writer_write(*this, chunk))->promise(); + return writable_stream_default_writer_write(*this, chunk)->promise(); } WritableStreamDefaultWriter::WritableStreamDefaultWriter(JS::Realm& realm)