Skip to content

Commit 2d4d16a

Browse files
trflynn89awesomekling
authored andcommitted
LibWeb: Remove exceptional return types from infallible stream IDL
1 parent 572a7bb commit 2d4d16a

15 files changed

+26
-29
lines changed

Userland/Libraries/LibWeb/FileAPI/FileReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ WebIDL::ExceptionOr<void> FileReader::read_operation(Blob& blob, Type type, Opti
139139
ByteBuffer bytes;
140140

141141
// 8. Let chunkPromise be the result of reading a chunk from stream with reader.
142-
auto chunk_promise = TRY(reader->read());
142+
auto chunk_promise = reader->read();
143143

144144
// 9. Let isFirstChunk be true.
145145
bool is_first_chunk = true;
@@ -183,7 +183,7 @@ WebIDL::ExceptionOr<void> FileReader::read_operation(Blob& blob, Type type, Opti
183183
// 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.
184184

185185
// 4. Set chunkPromise to the result of reading a chunk from stream with reader.
186-
chunk_promise = MUST(reader->read());
186+
chunk_promise = reader->read();
187187
}
188188
// 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:
189189
else if (chunk_promise->state() == JS::Promise::State::Fulfilled && done.as_bool()) {

Userland/Libraries/LibWeb/HTML/Window.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ Vector<JS::NonnullGCPtr<MimeType>> Window::pdf_viewer_mime_type_objects()
738738
}
739739

740740
// https://streams.spec.whatwg.org/#count-queuing-strategy-size-function
741-
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> Window::count_queuing_strategy_size_function()
741+
JS::NonnullGCPtr<WebIDL::CallbackType> Window::count_queuing_strategy_size_function()
742742
{
743743
auto& realm = this->realm();
744744

@@ -760,7 +760,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> Window::count_queuin
760760
}
761761

762762
// https://streams.spec.whatwg.org/#byte-length-queuing-strategy-size-function
763-
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> Window::byte_length_queuing_strategy_size_function()
763+
JS::NonnullGCPtr<WebIDL::CallbackType> Window::byte_length_queuing_strategy_size_function()
764764
{
765765
auto& realm = this->realm();
766766

Userland/Libraries/LibWeb/HTML/Window.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ class Window final
127127
CrossOriginPropertyDescriptorMap const& cross_origin_property_descriptor_map() const { return m_cross_origin_property_descriptor_map; }
128128
CrossOriginPropertyDescriptorMap& cross_origin_property_descriptor_map() { return m_cross_origin_property_descriptor_map; }
129129

130-
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> count_queuing_strategy_size_function();
131-
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> byte_length_queuing_strategy_size_function();
130+
JS::NonnullGCPtr<WebIDL::CallbackType> count_queuing_strategy_size_function();
131+
JS::NonnullGCPtr<WebIDL::CallbackType> byte_length_queuing_strategy_size_function();
132132

133133
// JS API functions
134134
JS::NonnullGCPtr<WindowProxy> window() const;

Userland/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
#include <LibWeb/Bindings/Intrinsics.h>
1010
#include <LibWeb/HTML/Window.h>
1111
#include <LibWeb/Streams/ByteLengthQueuingStrategy.h>
12-
#include <LibWeb/WebIDL/ExceptionOr.h>
1312

1413
namespace Web::Streams {
1514

1615
JS_DEFINE_ALLOCATOR(ByteLengthQueuingStrategy);
1716

1817
// https://streams.spec.whatwg.org/#blqs-constructor
19-
WebIDL::ExceptionOr<JS::NonnullGCPtr<ByteLengthQueuingStrategy>> ByteLengthQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
18+
JS::NonnullGCPtr<ByteLengthQueuingStrategy> ByteLengthQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
2019
{
2120
// The new ByteLengthQueuingStrategy(init) constructor steps are:
2221
// 1. Set this.[[highWaterMark]] to init["highWaterMark"].
@@ -32,7 +31,7 @@ ByteLengthQueuingStrategy::ByteLengthQueuingStrategy(JS::Realm& realm, double hi
3231
ByteLengthQueuingStrategy::~ByteLengthQueuingStrategy() = default;
3332

3433
// https://streams.spec.whatwg.org/#blqs-size
35-
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> ByteLengthQueuingStrategy::size()
34+
JS::NonnullGCPtr<WebIDL::CallbackType> ByteLengthQueuingStrategy::size()
3635
{
3736
// 1. Return this's relevant global object's byte length queuing strategy size function.
3837
return global_object().byte_length_queuing_strategy_size_function();

Userland/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ByteLengthQueuingStrategy final : public Bindings::PlatformObject {
2020
JS_DECLARE_ALLOCATOR(ByteLengthQueuingStrategy);
2121

2222
public:
23-
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ByteLengthQueuingStrategy>> construct_impl(JS::Realm&, QueuingStrategyInit const&);
23+
static JS::NonnullGCPtr<ByteLengthQueuingStrategy> construct_impl(JS::Realm&, QueuingStrategyInit const&);
2424

2525
virtual ~ByteLengthQueuingStrategy() override;
2626

@@ -32,7 +32,7 @@ class ByteLengthQueuingStrategy final : public Bindings::PlatformObject {
3232
return m_high_water_mark;
3333
}
3434

35-
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> size();
35+
JS::NonnullGCPtr<WebIDL::CallbackType> size();
3636

3737
private:
3838
explicit ByteLengthQueuingStrategy(JS::Realm&, double high_water_mark);

Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
#include <LibWeb/Bindings/Intrinsics.h>
1010
#include <LibWeb/HTML/Window.h>
1111
#include <LibWeb/Streams/CountQueuingStrategy.h>
12-
#include <LibWeb/WebIDL/ExceptionOr.h>
1312

1413
namespace Web::Streams {
1514

1615
JS_DEFINE_ALLOCATOR(CountQueuingStrategy);
1716

1817
// https://streams.spec.whatwg.org/#blqs-constructor
19-
WebIDL::ExceptionOr<JS::NonnullGCPtr<CountQueuingStrategy>> CountQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
18+
JS::NonnullGCPtr<CountQueuingStrategy> CountQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
2019
{
2120
// The new CountQueuingStrategy(init) constructor steps are:
2221
// 1. Set this.[[highWaterMark]] to init["highWaterMark"].
@@ -32,7 +31,7 @@ CountQueuingStrategy::CountQueuingStrategy(JS::Realm& realm, double high_water_m
3231
CountQueuingStrategy::~CountQueuingStrategy() = default;
3332

3433
// https://streams.spec.whatwg.org/#cqs-size
35-
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> CountQueuingStrategy::size()
34+
JS::NonnullGCPtr<WebIDL::CallbackType> CountQueuingStrategy::size()
3635
{
3736
// 1. Return this's relevant global object's count queuing strategy size function.
3837
return global_object().count_queuing_strategy_size_function();

Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CountQueuingStrategy final : public Bindings::PlatformObject {
2020
JS_DECLARE_ALLOCATOR(CountQueuingStrategy);
2121

2222
public:
23-
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CountQueuingStrategy>> construct_impl(JS::Realm&, QueuingStrategyInit const&);
23+
static JS::NonnullGCPtr<CountQueuingStrategy> construct_impl(JS::Realm&, QueuingStrategyInit const&);
2424

2525
virtual ~CountQueuingStrategy() override;
2626

@@ -32,7 +32,7 @@ class CountQueuingStrategy final : public Bindings::PlatformObject {
3232
return m_high_water_mark;
3333
}
3434

35-
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> size();
35+
JS::NonnullGCPtr<WebIDL::CallbackType> size();
3636

3737
private:
3838
explicit CountQueuingStrategy(JS::Realm&, double high_water_mark);

Userland/Libraries/LibWeb/Streams/ReadableStream.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ bool ReadableStream::locked() const
8383
}
8484

8585
// https://streams.spec.whatwg.org/#rs-cancel
86-
WebIDL::ExceptionOr<JS::GCPtr<JS::Object>> ReadableStream::cancel(JS::Value reason)
86+
JS::NonnullGCPtr<JS::Object> ReadableStream::cancel(JS::Value reason)
8787
{
8888
auto& realm = this->realm();
8989

@@ -134,7 +134,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> ReadableStream::pipe_throu
134134
return JS::NonnullGCPtr { *transform.readable };
135135
}
136136

137-
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Object>> ReadableStream::pipe_to(WritableStream& destination, StreamPipeOptions const& options)
137+
JS::NonnullGCPtr<JS::Object> ReadableStream::pipe_to(WritableStream& destination, StreamPipeOptions const& options)
138138
{
139139
auto& realm = this->realm();
140140

Userland/Libraries/LibWeb/Streams/ReadableStream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ class ReadableStream final : public Bindings::PlatformObject {
7373
virtual ~ReadableStream() override;
7474

7575
bool locked() const;
76-
WebIDL::ExceptionOr<JS::GCPtr<JS::Object>> cancel(JS::Value reason);
76+
JS::NonnullGCPtr<JS::Object> cancel(JS::Value reason);
7777
WebIDL::ExceptionOr<ReadableStreamReader> get_reader(ReadableStreamGetReaderOptions const& = {});
7878
WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> pipe_through(ReadableWritablePair transform, StreamPipeOptions const& = {});
79-
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Object>> pipe_to(WritableStream& destination, StreamPipeOptions const& = {});
79+
JS::NonnullGCPtr<JS::Object> pipe_to(WritableStream& destination, StreamPipeOptions const& = {});
8080
WebIDL::ExceptionOr<ReadableStreamPair> tee();
8181

8282
Optional<ReadableStreamController>& controller() { return m_controller; }

Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class BYOBReaderReadIntoRequest : public ReadIntoRequest {
107107
JS_DEFINE_ALLOCATOR(BYOBReaderReadIntoRequest);
108108

109109
// https://streams.spec.whatwg.org/#byob-reader-read
110-
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> ReadableStreamBYOBReader::read(JS::Handle<WebIDL::ArrayBufferView>& view)
110+
JS::NonnullGCPtr<JS::Promise> ReadableStreamBYOBReader::read(JS::Handle<WebIDL::ArrayBufferView>& view)
111111
{
112112
auto& realm = this->realm();
113113

0 commit comments

Comments
 (0)