mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
LibWeb: Remove exceptional return types from infallible stream IDL
This commit is contained in:
parent
572a7bb313
commit
2d4d16ac37
Notes:
sideshowbarker
2024-07-16 23:51:07 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/2d4d16ac37 Pull-request: https://github.com/SerenityOS/serenity/pull/24165 Reviewed-by: https://github.com/kennethmyhra ✅ Reviewed-by: https://github.com/shannonbooth ✅
15 changed files with 26 additions and 29 deletions
|
@ -139,7 +139,7 @@ WebIDL::ExceptionOr<void> FileReader::read_operation(Blob& blob, Type type, Opti
|
|||
ByteBuffer bytes;
|
||||
|
||||
// 8. Let chunkPromise be the result of reading a chunk from stream with reader.
|
||||
auto chunk_promise = TRY(reader->read());
|
||||
auto chunk_promise = reader->read();
|
||||
|
||||
// 9. Let isFirstChunk be true.
|
||||
bool is_first_chunk = true;
|
||||
|
@ -183,7 +183,7 @@ WebIDL::ExceptionOr<void> FileReader::read_operation(Blob& blob, Type type, Opti
|
|||
// FIXME: 3. If roughly 50ms have passed since these steps were last invoked, queue a task to fire a progress event called progress at fr.
|
||||
|
||||
// 4. Set chunkPromise to the result of reading a chunk from stream with reader.
|
||||
chunk_promise = MUST(reader->read());
|
||||
chunk_promise = reader->read();
|
||||
}
|
||||
// 5. Otherwise, if chunkPromise is fulfilled with an object whose done property is true, queue a task to run the following steps and abort this algorithm:
|
||||
else if (chunk_promise->state() == JS::Promise::State::Fulfilled && done.as_bool()) {
|
||||
|
|
|
@ -738,7 +738,7 @@ Vector<JS::NonnullGCPtr<MimeType>> Window::pdf_viewer_mime_type_objects()
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#count-queuing-strategy-size-function
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> Window::count_queuing_strategy_size_function()
|
||||
JS::NonnullGCPtr<WebIDL::CallbackType> Window::count_queuing_strategy_size_function()
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
@ -760,7 +760,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> Window::count_queuin
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#byte-length-queuing-strategy-size-function
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> Window::byte_length_queuing_strategy_size_function()
|
||||
JS::NonnullGCPtr<WebIDL::CallbackType> Window::byte_length_queuing_strategy_size_function()
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
|
|
@ -127,8 +127,8 @@ public:
|
|||
CrossOriginPropertyDescriptorMap const& cross_origin_property_descriptor_map() const { return m_cross_origin_property_descriptor_map; }
|
||||
CrossOriginPropertyDescriptorMap& cross_origin_property_descriptor_map() { return m_cross_origin_property_descriptor_map; }
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> count_queuing_strategy_size_function();
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> byte_length_queuing_strategy_size_function();
|
||||
JS::NonnullGCPtr<WebIDL::CallbackType> count_queuing_strategy_size_function();
|
||||
JS::NonnullGCPtr<WebIDL::CallbackType> byte_length_queuing_strategy_size_function();
|
||||
|
||||
// JS API functions
|
||||
JS::NonnullGCPtr<WindowProxy> window() const;
|
||||
|
|
|
@ -9,14 +9,13 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Streams/ByteLengthQueuingStrategy.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ByteLengthQueuingStrategy);
|
||||
|
||||
// https://streams.spec.whatwg.org/#blqs-constructor
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<ByteLengthQueuingStrategy>> ByteLengthQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
|
||||
JS::NonnullGCPtr<ByteLengthQueuingStrategy> ByteLengthQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
|
||||
{
|
||||
// The new ByteLengthQueuingStrategy(init) constructor steps are:
|
||||
// 1. Set this.[[highWaterMark]] to init["highWaterMark"].
|
||||
|
@ -32,7 +31,7 @@ ByteLengthQueuingStrategy::ByteLengthQueuingStrategy(JS::Realm& realm, double hi
|
|||
ByteLengthQueuingStrategy::~ByteLengthQueuingStrategy() = default;
|
||||
|
||||
// https://streams.spec.whatwg.org/#blqs-size
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> ByteLengthQueuingStrategy::size()
|
||||
JS::NonnullGCPtr<WebIDL::CallbackType> ByteLengthQueuingStrategy::size()
|
||||
{
|
||||
// 1. Return this's relevant global object's byte length queuing strategy size function.
|
||||
return global_object().byte_length_queuing_strategy_size_function();
|
||||
|
|
|
@ -20,7 +20,7 @@ class ByteLengthQueuingStrategy final : public Bindings::PlatformObject {
|
|||
JS_DECLARE_ALLOCATOR(ByteLengthQueuingStrategy);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ByteLengthQueuingStrategy>> construct_impl(JS::Realm&, QueuingStrategyInit const&);
|
||||
static JS::NonnullGCPtr<ByteLengthQueuingStrategy> construct_impl(JS::Realm&, QueuingStrategyInit const&);
|
||||
|
||||
virtual ~ByteLengthQueuingStrategy() override;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
return m_high_water_mark;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> size();
|
||||
JS::NonnullGCPtr<WebIDL::CallbackType> size();
|
||||
|
||||
private:
|
||||
explicit ByteLengthQueuingStrategy(JS::Realm&, double high_water_mark);
|
||||
|
|
|
@ -9,14 +9,13 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Streams/CountQueuingStrategy.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CountQueuingStrategy);
|
||||
|
||||
// https://streams.spec.whatwg.org/#blqs-constructor
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CountQueuingStrategy>> CountQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
|
||||
JS::NonnullGCPtr<CountQueuingStrategy> CountQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
|
||||
{
|
||||
// The new CountQueuingStrategy(init) constructor steps are:
|
||||
// 1. Set this.[[highWaterMark]] to init["highWaterMark"].
|
||||
|
@ -32,7 +31,7 @@ CountQueuingStrategy::CountQueuingStrategy(JS::Realm& realm, double high_water_m
|
|||
CountQueuingStrategy::~CountQueuingStrategy() = default;
|
||||
|
||||
// https://streams.spec.whatwg.org/#cqs-size
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> CountQueuingStrategy::size()
|
||||
JS::NonnullGCPtr<WebIDL::CallbackType> CountQueuingStrategy::size()
|
||||
{
|
||||
// 1. Return this's relevant global object's count queuing strategy size function.
|
||||
return global_object().count_queuing_strategy_size_function();
|
||||
|
|
|
@ -20,7 +20,7 @@ class CountQueuingStrategy final : public Bindings::PlatformObject {
|
|||
JS_DECLARE_ALLOCATOR(CountQueuingStrategy);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CountQueuingStrategy>> construct_impl(JS::Realm&, QueuingStrategyInit const&);
|
||||
static JS::NonnullGCPtr<CountQueuingStrategy> construct_impl(JS::Realm&, QueuingStrategyInit const&);
|
||||
|
||||
virtual ~CountQueuingStrategy() override;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
return m_high_water_mark;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> size();
|
||||
JS::NonnullGCPtr<WebIDL::CallbackType> size();
|
||||
|
||||
private:
|
||||
explicit CountQueuingStrategy(JS::Realm&, double high_water_mark);
|
||||
|
|
|
@ -83,7 +83,7 @@ bool ReadableStream::locked() const
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#rs-cancel
|
||||
WebIDL::ExceptionOr<JS::GCPtr<JS::Object>> ReadableStream::cancel(JS::Value reason)
|
||||
JS::NonnullGCPtr<JS::Object> ReadableStream::cancel(JS::Value reason)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
@ -134,7 +134,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> ReadableStream::pipe_throu
|
|||
return JS::NonnullGCPtr { *transform.readable };
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Object>> ReadableStream::pipe_to(WritableStream& destination, StreamPipeOptions const& options)
|
||||
JS::NonnullGCPtr<JS::Object> ReadableStream::pipe_to(WritableStream& destination, StreamPipeOptions const& options)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
|
|
@ -73,10 +73,10 @@ public:
|
|||
virtual ~ReadableStream() override;
|
||||
|
||||
bool locked() const;
|
||||
WebIDL::ExceptionOr<JS::GCPtr<JS::Object>> cancel(JS::Value reason);
|
||||
JS::NonnullGCPtr<JS::Object> cancel(JS::Value reason);
|
||||
WebIDL::ExceptionOr<ReadableStreamReader> get_reader(ReadableStreamGetReaderOptions const& = {});
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> pipe_through(ReadableWritablePair transform, StreamPipeOptions const& = {});
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Object>> pipe_to(WritableStream& destination, StreamPipeOptions const& = {});
|
||||
JS::NonnullGCPtr<JS::Object> pipe_to(WritableStream& destination, StreamPipeOptions const& = {});
|
||||
WebIDL::ExceptionOr<ReadableStreamPair> tee();
|
||||
|
||||
Optional<ReadableStreamController>& controller() { return m_controller; }
|
||||
|
|
|
@ -107,7 +107,7 @@ private:
|
|||
JS_DEFINE_ALLOCATOR(BYOBReaderReadIntoRequest);
|
||||
|
||||
// https://streams.spec.whatwg.org/#byob-reader-read
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> ReadableStreamBYOBReader::read(JS::Handle<WebIDL::ArrayBufferView>& view)
|
||||
JS::NonnullGCPtr<JS::Promise> ReadableStreamBYOBReader::read(JS::Handle<WebIDL::ArrayBufferView>& view)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
virtual ~ReadableStreamBYOBReader() override = default;
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> read(JS::Handle<WebIDL::ArrayBufferView>&);
|
||||
JS::NonnullGCPtr<JS::Promise> read(JS::Handle<WebIDL::ArrayBufferView>&);
|
||||
|
||||
void release_lock();
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ private:
|
|||
JS_DEFINE_ALLOCATOR(DefaultReaderReadRequest);
|
||||
|
||||
// https://streams.spec.whatwg.org/#default-reader-read
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> ReadableStreamDefaultReader::read()
|
||||
JS::NonnullGCPtr<JS::Promise> ReadableStreamDefaultReader::read()
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
|
||||
virtual ~ReadableStreamDefaultReader() override = default;
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> read();
|
||||
JS::NonnullGCPtr<JS::Promise> read();
|
||||
|
||||
void read_all_bytes(ReadLoopReadRequest::SuccessSteps, ReadLoopReadRequest::FailureSteps);
|
||||
JS::NonnullGCPtr<WebIDL::Promise> read_all_bytes_deprecated();
|
||||
|
|
|
@ -9,20 +9,19 @@
|
|||
#include <LibWeb/Streams/AbstractOperations.h>
|
||||
#include <LibWeb/Streams/ReadableStream.h>
|
||||
#include <LibWeb/Streams/ReadableStreamGenericReader.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
||||
// https://streams.spec.whatwg.org/#generic-reader-closed
|
||||
WebIDL::ExceptionOr<JS::GCPtr<JS::Promise>> ReadableStreamGenericReaderMixin::closed()
|
||||
JS::GCPtr<JS::Promise> ReadableStreamGenericReaderMixin::closed()
|
||||
{
|
||||
// 1. Return this.[[closedPromise]].
|
||||
return JS::GCPtr { verify_cast<JS::Promise>(*m_closed_promise->promise()) };
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#generic-reader-cancel
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> ReadableStreamGenericReaderMixin::cancel(JS::Value reason)
|
||||
JS::NonnullGCPtr<JS::Promise> ReadableStreamGenericReaderMixin::cancel(JS::Value reason)
|
||||
{
|
||||
// 1. If this.[[stream]] is undefined, return a promise rejected with a TypeError exception.
|
||||
if (!m_stream) {
|
||||
|
|
|
@ -19,9 +19,9 @@ class ReadableStreamGenericReaderMixin {
|
|||
public:
|
||||
virtual ~ReadableStreamGenericReaderMixin() = default;
|
||||
|
||||
WebIDL::ExceptionOr<JS::GCPtr<JS::Promise>> closed();
|
||||
JS::GCPtr<JS::Promise> closed();
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> cancel(JS::Value reason);
|
||||
JS::NonnullGCPtr<JS::Promise> cancel(JS::Value reason);
|
||||
|
||||
JS::GCPtr<ReadableStream> stream() const { return m_stream; }
|
||||
void set_stream(JS::GCPtr<ReadableStream> stream) { m_stream = stream; }
|
||||
|
|
Loading…
Reference in a new issue