mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:38:13 +00:00
LibWeb: Use doubles for Stream's high_water_mark and queue_total_size
This matches the IDL types
This commit is contained in:
parent
f63d027b0b
commit
dd65d60069
5 changed files with 17 additions and 17 deletions
|
@ -602,7 +602,7 @@ bool readable_stream_default_controller_should_call_pull(ReadableStreamDefaultCo
|
|||
VERIFY(desired_size.has_value());
|
||||
|
||||
// 7. If desiredSize > 0, return true.
|
||||
if (desired_size.release_value() > 0)
|
||||
if (desired_size.release_value() > 0.0)
|
||||
return true;
|
||||
|
||||
// 8. Return false.
|
||||
|
@ -643,7 +643,7 @@ void readable_stream_default_controller_error(ReadableStreamDefaultController& c
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#readable-stream-default-controller-get-desired-size
|
||||
Optional<float> readable_stream_default_controller_get_desired_size(ReadableStreamDefaultController& controller)
|
||||
Optional<double> readable_stream_default_controller_get_desired_size(ReadableStreamDefaultController& controller)
|
||||
{
|
||||
auto stream = controller.stream();
|
||||
|
||||
|
@ -655,7 +655,7 @@ Optional<float> readable_stream_default_controller_get_desired_size(ReadableStre
|
|||
|
||||
// 3. If state is "closed", return 0.
|
||||
if (stream->is_closed())
|
||||
return 0.0f;
|
||||
return 0.0;
|
||||
|
||||
// 4. Return controller.[[strategyHWM]] − controller.[[queueTotalSize]].
|
||||
return controller.strategy_hwm() - controller.queue_total_size();
|
||||
|
@ -942,7 +942,7 @@ WebIDL::ExceptionOr<void> readable_byte_stream_controller_fill_read_request_from
|
|||
auto& realm = controller.realm();
|
||||
|
||||
// 1. Assert: controller.[[queueTotalSize]] > 0.
|
||||
VERIFY(controller.queue_total_size() > 0);
|
||||
VERIFY(controller.queue_total_size() > 0.0);
|
||||
|
||||
// 2. Let entry be controller.[[queue]][0].
|
||||
// 3. Remove entry from controller.[[queue]].
|
||||
|
@ -988,7 +988,7 @@ WebIDL::ExceptionOr<void> readable_byte_stream_controller_handle_queue_drain(Rea
|
|||
VERIFY(controller.stream()->state() == ReadableStream::State::Readable);
|
||||
|
||||
// 2. If controller.[[queueTotalSize]] is 0 and controller.[[closeRequested]] is true,
|
||||
if (controller.queue_total_size() == 0 && controller.close_requested()) {
|
||||
if (controller.queue_total_size() == 0.0 && controller.close_requested()) {
|
||||
// 1. Perform ! ReadableByteStreamControllerClearAlgorithms(controller).
|
||||
readable_byte_stream_controller_clear_algorithms(controller);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ bool readable_stream_default_controller_should_call_pull(ReadableStreamDefaultCo
|
|||
void readable_stream_default_controller_clear_algorithms(ReadableStreamDefaultController&);
|
||||
|
||||
void readable_stream_default_controller_error(ReadableStreamDefaultController&, JS::Value error);
|
||||
Optional<float> readable_stream_default_controller_get_desired_size(ReadableStreamDefaultController&);
|
||||
Optional<double> readable_stream_default_controller_get_desired_size(ReadableStreamDefaultController&);
|
||||
bool readable_stream_default_controller_can_close_or_enqueue(ReadableStreamDefaultController&);
|
||||
WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller(ReadableStream&, ReadableStreamDefaultController&, StartAlgorithm&&, PullAlgorithm&&, CancelAlgorithm&&, double high_water_mark, SizeAlgorithm&&);
|
||||
WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller_from_underlying_source(ReadableStream&, JS::Value underlying_source_value, UnderlyingSource, double high_water_mark, SizeAlgorithm&&);
|
||||
|
|
|
@ -105,14 +105,14 @@ public:
|
|||
|
||||
SinglyLinkedList<ReadableByteStreamQueueEntry>& queue() { return m_queue; }
|
||||
|
||||
u32 queue_total_size() const { return m_queue_total_size; }
|
||||
void set_queue_total_size(u32 size) { m_queue_total_size = size; }
|
||||
double queue_total_size() const { return m_queue_total_size; }
|
||||
void set_queue_total_size(double size) { m_queue_total_size = size; }
|
||||
|
||||
bool started() const { return m_started; }
|
||||
void set_started(bool value) { m_started = value; }
|
||||
|
||||
u32 strategy_hwm() const { return m_strategy_hwm; }
|
||||
void set_strategy_hwm(u32 value) { m_strategy_hwm = value; }
|
||||
double strategy_hwm() const { return m_strategy_hwm; }
|
||||
void set_strategy_hwm(double value) { m_strategy_hwm = value; }
|
||||
|
||||
JS::GCPtr<ReadableStream const> stream() const { return m_stream; }
|
||||
JS::GCPtr<ReadableStream> stream() { return m_stream; }
|
||||
|
@ -165,7 +165,7 @@ private:
|
|||
|
||||
// https://streams.spec.whatwg.org/#readablestreamdefaultcontroller-queuetotalsize
|
||||
// The total size of all the chunks stored in [[queue]]
|
||||
u32 m_queue_total_size { 0 };
|
||||
double m_queue_total_size { 0 };
|
||||
|
||||
// https://streams.spec.whatwg.org/#readablestreamdefaultcontroller-started
|
||||
// A boolean flag indicating whether the underlying source has finished starting
|
||||
|
@ -173,7 +173,7 @@ private:
|
|||
|
||||
// https://streams.spec.whatwg.org/#readablestreamdefaultcontroller-strategyhwm
|
||||
// A number supplied to the constructor as part of the stream’s queuing strategy, indicating the point at which the stream will apply backpressure to its underlying source
|
||||
u32 m_strategy_hwm { 0 };
|
||||
double m_strategy_hwm { 0 };
|
||||
|
||||
// https://streams.spec.whatwg.org/#readablestreamdefaultcontroller-stream
|
||||
// The ReadableStream instance controlled
|
||||
|
|
|
@ -22,7 +22,7 @@ ReadableStreamDefaultController::ReadableStreamDefaultController(JS::Realm& real
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#rs-default-controller-desired-size
|
||||
Optional<float> ReadableStreamDefaultController::desired_size()
|
||||
Optional<double> ReadableStreamDefaultController::desired_size()
|
||||
{
|
||||
// 1. Return ! ReadableStreamDefaultControllerGetDesiredSize(this).
|
||||
return readable_stream_default_controller_get_desired_size(*this);
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
explicit ReadableStreamDefaultController(JS::Realm&);
|
||||
virtual ~ReadableStreamDefaultController() override = default;
|
||||
|
||||
Optional<float> desired_size();
|
||||
Optional<double> desired_size();
|
||||
|
||||
WebIDL::ExceptionOr<void> close();
|
||||
WebIDL::ExceptionOr<void> enqueue(JS::Value chunk);
|
||||
|
@ -54,8 +54,8 @@ public:
|
|||
bool started() const { return m_started; }
|
||||
void set_started(bool value) { m_started = value; }
|
||||
|
||||
size_t strategy_hwm() const { return m_strategy_hwm; }
|
||||
void set_strategy_hwm(size_t value) { m_strategy_hwm = value; }
|
||||
double strategy_hwm() const { return m_strategy_hwm; }
|
||||
void set_strategy_hwm(double value) { m_strategy_hwm = value; }
|
||||
|
||||
auto& strategy_size_algorithm() { return m_strategy_size_algorithm; }
|
||||
void set_strategy_size_algorithm(Optional<SizeAlgorithm> value) { m_strategy_size_algorithm = move(value); }
|
||||
|
@ -106,7 +106,7 @@ private:
|
|||
|
||||
// https://streams.spec.whatwg.org/#readablestreamdefaultcontroller-strategyhwm
|
||||
// A number supplied to the constructor as part of the stream’s queuing strategy, indicating the point at which the stream will apply backpressure to its underlying source
|
||||
size_t m_strategy_hwm { 0 };
|
||||
double m_strategy_hwm { 0 };
|
||||
|
||||
// https://streams.spec.whatwg.org/#readablestreamdefaultcontroller-strategysizealgorithm
|
||||
// An algorithm to calculate the size of enqueued chunks, as part of the stream’s queuing strategy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue