Просмотр исходного кода

LibWeb: Add AO set_up_transform_stream_default_controller()

Kenneth Myhra 2 лет назад
Родитель
Сommit
f7c532d093

+ 20 - 0
Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp

@@ -2888,6 +2888,26 @@ WebIDL::ExceptionOr<void> initialize_transform_stream(TransformStream& stream, J
     return {};
 }
 
+// https://streams.spec.whatwg.org/#set-up-transform-stream-default-controller
+void set_up_transform_stream_default_controller(TransformStream& stream, TransformStreamDefaultController& controller, TransformAlgorithm&& transform_algorithm, FlushAlgorithm&& flush_algorithm)
+{
+    // 1. Assert: stream implements TransformStream.
+    // 2. Assert: stream.[[controller]] is undefined.
+    VERIFY(!stream.controller());
+
+    // 3. Set controller.[[stream]] to stream.
+    controller.set_stream(stream);
+
+    // 4. Set stream.[[controller]] to controller.
+    stream.set_controller(controller);
+
+    // 5. Set controller.[[transformAlgorithm]] to transformAlgorithm.
+    controller.set_transform_algorithm(move(transform_algorithm));
+
+    // 6. Set controller.[[flushAlgorithm]] to flushAlgorithm.
+    controller.set_flush_algorithm(move(flush_algorithm));
+}
+
 // https://streams.spec.whatwg.org/#transform-stream-default-controller-clear-algorithms
 void transform_stream_default_controller_clear_algorithms(TransformStreamDefaultController& controller)
 {

+ 1 - 0
Userland/Libraries/LibWeb/Streams/AbstractOperations.h

@@ -139,6 +139,7 @@ WebIDL::ExceptionOr<void> writable_stream_default_controller_process_write(Writa
 WebIDL::ExceptionOr<void> writable_stream_default_controller_write(WritableStreamDefaultController&, JS::Value chunk, JS::Value chunk_size);
 
 WebIDL::ExceptionOr<void> initialize_transform_stream(TransformStream&, JS::NonnullGCPtr<JS::PromiseCapability> start_promise, double writable_high_water_mark, SizeAlgorithm&& writable_size_algorithm, double readable_high_water_mark, SizeAlgorithm&& readable_size_algorithm);
+void set_up_transform_stream_default_controller(TransformStream&, TransformStreamDefaultController&, TransformAlgorithm&&, FlushAlgorithm&&);
 void transform_stream_default_controller_clear_algorithms(TransformStreamDefaultController&);
 WebIDL::ExceptionOr<void> transform_stream_default_controller_enqueue(TransformStreamDefaultController&, JS::Value chunk);
 WebIDL::ExceptionOr<void> transform_stream_default_controller_error(TransformStreamDefaultController&, JS::Value error);