From cdcc1ebbba26a52c7634287a534b75b435cec8dc Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 19 Nov 2023 12:03:45 +1300 Subject: [PATCH] LibWeb: Implement ReadableByteStreamControllerFillHeadPullIntoDescriptor --- .../Libraries/LibWeb/Streams/AbstractOperations.cpp | 13 +++++++++++++ .../Libraries/LibWeb/Streams/AbstractOperations.h | 1 + 2 files changed, 14 insertions(+) diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp index cef810d0d6..73b6c0d597 100644 --- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp @@ -493,6 +493,19 @@ void readable_stream_byob_reader_error_read_into_requests(ReadableStreamBYOBRead } } +// https://streams.spec.whatwg.org/#readable-byte-stream-controller-fill-head-pull-into-descriptor +void readable_byte_stream_controller_fill_head_pull_into_descriptor(ReadableByteStreamController const& controller, u64 size, PullIntoDescriptor& pull_into_descriptor) +{ + // 1. Assert: either controller.[[pendingPullIntos]] is empty, or controller.[[pendingPullIntos]][0] is pullIntoDescriptor. + VERIFY(controller.pending_pull_intos().is_empty() || &controller.pending_pull_intos().first() == &pull_into_descriptor); + + // 2. Assert: controller.[[byobRequest]] is null. + VERIFY(!controller.byob_request()); + + // 3. Set pullIntoDescriptor’s bytes filled to bytes filled + size. + pull_into_descriptor.bytes_filled += size; +} + // https://streams.spec.whatwg.org/#readable-stream-default-reader-read WebIDL::ExceptionOr readable_stream_default_reader_read(ReadableStreamDefaultReader& reader, ReadRequest& read_request) { diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h index 8fdd7ed98e..a7c17a5888 100644 --- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h +++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h @@ -54,6 +54,7 @@ WebIDL::ExceptionOr readable_stream_reader_generic_release(ReadableStreamG void readable_stream_default_reader_error_read_requests(ReadableStreamDefaultReader&, JS::Value error); void readable_stream_byob_reader_error_read_into_requests(ReadableStreamBYOBReader&, JS::Value error); JS::Value readable_byte_stream_controller_convert_pull_into_descriptor(JS::Realm&, PullIntoDescriptor const&); +void readable_byte_stream_controller_fill_head_pull_into_descriptor(ReadableByteStreamController const&, u64 size, PullIntoDescriptor&); WebIDL::ExceptionOr readable_stream_default_reader_read(ReadableStreamDefaultReader&, ReadRequest&); WebIDL::ExceptionOr readable_stream_default_reader_release(ReadableStreamDefaultReader&);