mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibWeb: Implement Streams AO ExtractSizeAlgorithm(strategy)
This commit is contained in:
parent
060c130c82
commit
33f6e5d516
Notes:
sideshowbarker
2024-07-17 22:09:47 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/33f6e5d516 Pull-request: https://github.com/SerenityOS/serenity/pull/19458 Reviewed-by: https://github.com/kennethmyhra Reviewed-by: https://github.com/mattco98 ✅
@ -187,6 +187,20 @@ bool readable_stream_has_default_reader(ReadableStream const& stream)
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#make-size-algorithm-from-size-function
|
||||
SizeAlgorithm extract_size_algorithm(QueuingStrategy const& strategy)
|
||||
{
|
||||
// 1. If strategy["size"] does not exist, return an algorithm that returns 1.
|
||||
if (!strategy.size)
|
||||
return [](auto const&) { return JS::normal_completion(JS::Value(1)); };
|
||||
|
||||
// 2. Return an algorithm that performs the following steps, taking a chunk argument:
|
||||
return [strategy](auto const& chunk) {
|
||||
// 1. Return the result of invoking strategy["size"] with argument list « chunk ».
|
||||
return WebIDL::invoke_callback(*strategy.size, JS::js_undefined(), chunk);
|
||||
};
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#validate-and-normalize-high-water-mark
|
||||
WebIDL::ExceptionOr<double> extract_high_water_mark(QueuingStrategy const& strategy, double default_hwm)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ using WriteAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::NonnullGCPtr<Web
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStreamDefaultReader>> acquire_readable_stream_default_reader(ReadableStream&);
|
||||
bool is_readable_stream_locked(ReadableStream const&);
|
||||
|
||||
SizeAlgorithm extract_size_algorithm(QueuingStrategy const&);
|
||||
WebIDL::ExceptionOr<double> extract_high_water_mark(QueuingStrategy const&, double default_hwm);
|
||||
|
||||
void readable_stream_close(ReadableStream&);
|
||||
|
Loading…
Reference in New Issue
Block a user