From d8d0e8a6ea0a5f87af680c52b951d4cb8bf1674a Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Fri, 7 Jul 2023 16:06:18 +0200 Subject: [PATCH] LibWeb: Add AO transform_stream_default_controller_clear_algorithms() --- .../Libraries/LibWeb/Streams/AbstractOperations.cpp | 13 +++++++++++++ .../Libraries/LibWeb/Streams/AbstractOperations.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp index 6d44514027..40f5bb17d6 100644 --- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp @@ -2,6 +2,7 @@ * Copyright (c) 2022, Linus Groh * Copyright (c) 2023, Matthew Olsson * Copyright (c) 2023, Shannon Booth + * Copyright (c) 2023, Kenneth Myhra * * SPDX-License-Identifier: BSD-2-Clause */ @@ -20,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -2720,6 +2722,17 @@ WebIDL::ExceptionOr writable_stream_default_controller_write(WritableStrea return {}; } +// https://streams.spec.whatwg.org/#transform-stream-default-controller-clear-algorithms +void transform_stream_default_controller_clear_algorithms(TransformStreamDefaultController& controller) +{ + // NOTE: This is observable using weak references. See tc39/proposal-weakrefs#31 for more detail. + // 1. Set controller.[[transformAlgorithm]] to undefined. + controller.set_transform_algorithm({}); + + // 2. Set controller.[[flushAlgorithm]] to undefined. + controller.set_flush_algorithm({}); +} + // https://streams.spec.whatwg.org/#is-non-negative-number bool is_non_negative_number(JS::Value value) { diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h index bebeee04b8..2ff9e92f79 100644 --- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h +++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h @@ -2,6 +2,7 @@ * Copyright (c) 2022, Linus Groh * Copyright (c) 2023, Matthew Olsson * Copyright (c) 2023, Shannon Booth + * Copyright (c) 2023, Kenneth Myhra * * SPDX-License-Identifier: BSD-2-Clause */ @@ -131,6 +132,8 @@ WebIDL::ExceptionOr writable_stream_default_controller_process_close(Writa WebIDL::ExceptionOr 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 transform_stream_default_controller_clear_algorithms(TransformStreamDefaultController&); + bool is_non_negative_number(JS::Value); JS::Value create_close_sentinel();