summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2023-04-14 13:47:17 +0200
committerLinus Groh <mail@linusgroh.de>2023-04-14 16:35:17 +0200
commitd192f4452375e9d34a9a078a302be66104091b88 (patch)
tree3542bae0c425d4f4cf0d0094c77e8a83c8cc838a /Userland/Libraries/LibWeb
parentfc15fc36ce03fc6639f182c42607fa1661dedf2d (diff)
downloadserenity-d192f4452375e9d34a9a078a302be66104091b88.zip
LibWeb/Streams: Make most algorithms return a NonnullGCPtr
Only the 'start algorithm' ever returns undefined (as a null GCPtr), so let's type the others more strictly.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp10
-rw-r--r--Userland/Libraries/LibWeb/Streams/AbstractOperations.h10
-rw-r--r--Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.h2
-rw-r--r--Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultController.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultController.h2
6 files changed, 14 insertions, 14 deletions
diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp
index 75c8150f0f..f9c73773e0 100644
--- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp
+++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp
@@ -733,7 +733,7 @@ WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller_from_underly
// 6. If underlyingSourceDict["pull"] exists, then set pullAlgorithm to an algorithm which returns the result of invoking underlyingSourceDict["pull"] with argument list « controller » and callback this value underlyingSource.
if (underlying_source.pull) {
- pull_algorithm = [&, pull = underlying_source.pull]() -> WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> {
+ pull_algorithm = [&, pull = underlying_source.pull]() -> WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> {
auto result = TRY(WebIDL::invoke_callback(*pull, underlying_source_value, controller)).release_value();
return WebIDL::create_resolved_promise(realm, result);
};
@@ -741,7 +741,7 @@ WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller_from_underly
// 7. If underlyingSourceDict["cancel"] exists, then set cancelAlgorithm to an algorithm which takes an argument reason and returns the result of invoking underlyingSourceDict["cancel"] with argument list « reason » and callback this value underlyingSource.
if (underlying_source.cancel) {
- cancel_algorithm = [&, cancel = underlying_source.cancel](auto const& reason) -> WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> {
+ cancel_algorithm = [&, cancel = underlying_source.cancel](auto const& reason) -> WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> {
auto result = TRY(WebIDL::invoke_callback(*cancel, underlying_source_value, reason)).release_value();
return WebIDL::create_resolved_promise(realm, result);
};
@@ -1736,7 +1736,7 @@ WebIDL::ExceptionOr<void> set_up_writable_stream_default_controller_from_underly
// 7. If underlyingSinkDict["write"] exists, then set writeAlgorithm to an algorithm which takes an argument chunk and returns the result of invoking underlyingSinkDict["write"] with argument list « chunk, controller » and callback this value underlyingSink.
if (underlying_sink.write) {
- write_algorithm = [&, callback = underlying_sink.write](JS::Value chunk) -> WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> {
+ write_algorithm = [&, callback = underlying_sink.write](JS::Value chunk) -> WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> {
auto result = TRY(WebIDL::invoke_callback(*callback, underlying_sink_value, chunk, controller)).release_value();
return WebIDL::create_resolved_promise(realm, result);
};
@@ -1744,7 +1744,7 @@ WebIDL::ExceptionOr<void> set_up_writable_stream_default_controller_from_underly
// 8. If underlyingSinkDict["close"] exists, then set closeAlgorithm to an algorithm which returns the result of invoking underlyingSinkDict["close"] with argument list «» and callback this value underlyingSink.
if (underlying_sink.close) {
- close_algorithm = [&, callback = underlying_sink.close]() -> WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> {
+ close_algorithm = [&, callback = underlying_sink.close]() -> WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> {
auto result = TRY(WebIDL::invoke_callback(*callback, underlying_sink_value)).release_value();
return WebIDL::create_resolved_promise(realm, result);
};
@@ -1752,7 +1752,7 @@ WebIDL::ExceptionOr<void> set_up_writable_stream_default_controller_from_underly
// 9. If underlyingSinkDict["abort"] exists, then set abortAlgorithm to an algorithm which takes an argument reason and returns the result of invoking underlyingSinkDict["abort"] with argument list « reason » and callback this value underlyingSink.
if (underlying_sink.abort) {
- abort_algorithm = [&, callback = underlying_sink.abort](JS::Value reason) -> WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> {
+ abort_algorithm = [&, callback = underlying_sink.abort](JS::Value reason) -> WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> {
auto result = TRY(WebIDL::invoke_callback(*callback, underlying_sink_value, reason)).release_value();
return WebIDL::create_resolved_promise(realm, result);
};
diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h
index 9bb4bb9985..b46a2c5187 100644
--- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h
+++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h
@@ -15,12 +15,12 @@
namespace Web::Streams {
using SizeAlgorithm = JS::SafeFunction<JS::Completion(JS::Value)>;
-using PullAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>()>;
-using CancelAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>(JS::Value)>;
+using PullAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>>()>;
+using CancelAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>>(JS::Value)>;
using StartAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>()>;
-using AbortAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>(JS::Value)>;
-using CloseAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>()>;
-using WriteAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>(JS::Value)>;
+using AbortAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>>(JS::Value)>;
+using CloseAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>>()>;
+using WriteAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>>(JS::Value)>;
WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStreamDefaultReader>> acquire_readable_stream_default_reader(ReadableStream&);
bool is_readable_stream_locked(ReadableStream const&);
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.cpp b/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.cpp
index 56b0d19e8c..738dd7800c 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.cpp
+++ b/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.cpp
@@ -24,7 +24,7 @@ ReadableByteStreamController::ReadableByteStreamController(JS::Realm& realm)
}
// https://streams.spec.whatwg.org/#rbs-controller-private-cancel
-WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> ReadableByteStreamController::cancel_steps(JS::Value reason)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> ReadableByteStreamController::cancel_steps(JS::Value reason)
{
// 1. Perform ! ReadableByteStreamControllerClearPendingPullIntos(this).
readable_byte_stream_controller_clear_pending_pull_intos(*this);
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.h b/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.h
index ca16d3190a..2afbfdc3d7 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.h
+++ b/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.h
@@ -116,7 +116,7 @@ public:
JS::GCPtr<ReadableStream> stream() { return m_stream; }
void set_stream(JS::GCPtr<ReadableStream> stream) { m_stream = stream; }
- WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> cancel_steps(JS::Value reason);
+ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> cancel_steps(JS::Value reason);
WebIDL::ExceptionOr<void> pull_steps(NonnullRefPtr<ReadRequest>);
WebIDL::ExceptionOr<void> release_steps();
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultController.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultController.cpp
index 07422c9655..f6d8c92e66 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultController.cpp
+++ b/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultController.cpp
@@ -63,7 +63,7 @@ void ReadableStreamDefaultController::error(JS::Value error)
}
// https://streams.spec.whatwg.org/#rs-default-controller-private-cancel
-WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> ReadableStreamDefaultController::cancel_steps(JS::Value reason)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> ReadableStreamDefaultController::cancel_steps(JS::Value reason)
{
// 1. Perform ! ResetQueue(this).
reset_queue(*this);
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultController.h b/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultController.h
index e2deea907d..bb03e0e2e9 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultController.h
+++ b/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultController.h
@@ -63,7 +63,7 @@ public:
JS::GCPtr<ReadableStream> stream() { return m_stream; }
void set_stream(JS::GCPtr<ReadableStream> value) { m_stream = value; }
- WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> cancel_steps(JS::Value reason);
+ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> cancel_steps(JS::Value reason);
WebIDL::ExceptionOr<void> pull_steps(ReadRequest&);
WebIDL::ExceptionOr<void> release_steps();