From 3aa6ef8ac0a95ec082cb2e149bc366247976eeb9 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 29 Apr 2024 17:20:55 -0400 Subject: [PATCH] LibWeb: Use LibJS's is-infinity helper in the enqueue-value-with-size AO --- .../Libraries/LibWeb/Streams/AbstractOperations.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h index 757e27d8db0..1f08cce740c 100644 --- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h +++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h @@ -221,25 +221,23 @@ JS::Value dequeue_value(T& container) // https://streams.spec.whatwg.org/#enqueue-value-with-size template -WebIDL::ExceptionOr enqueue_value_with_size(T& container, JS::Value value, JS::Value size_value) +WebIDL::ExceptionOr enqueue_value_with_size(T& container, JS::Value value, JS::Value size) { // 1. Assert: container has [[queue]] and [[queueTotalSize]] internal slots. // 2. If ! IsNonNegativeNumber(size) is false, throw a RangeError exception. - if (!is_non_negative_number(size_value)) + if (!is_non_negative_number(size)) return WebIDL::SimpleException { WebIDL::SimpleExceptionType::RangeError, "Chunk has non-positive size"sv }; - auto size = size_value.as_double(); - // 3. If size is +∞, throw a RangeError exception. - if (size == HUGE_VAL) + if (size.is_positive_infinity()) return WebIDL::SimpleException { WebIDL::SimpleExceptionType::RangeError, "Chunk has infinite size"sv }; // 4. Append a new value-with-size with value value and size size to container.[[queue]]. - container.queue().append({ value, size }); + container.queue().append({ value, size.as_double() }); // 5. Set container.[[queueTotalSize]] to container.[[queueTotalSize]] + size. - container.set_queue_total_size(container.queue_total_size() + size); + container.set_queue_total_size(container.queue_total_size() + size.as_double()); return {}; }