mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibWeb: Mark stream AOs as infallible as required by the spec
There were several instances where the spec marks an AO invocation as infallible, but we were propagating WebIDL::ExceptionOr. These mostly cannot throw due to knowledge about the values they are provided. By unwinding these, we can remove a decent amount of exception handling.
This commit is contained in:
parent
3aa6ef8ac0
commit
c29916775e
Notes:
sideshowbarker
2024-07-17 01:51:00 +09:00
Author: https://github.com/trflynn89
Commit: c29916775e
Pull-request: https://github.com/SerenityOS/serenity/pull/24165
Reviewed-by: https://github.com/kennethmyhra ✅
Reviewed-by: https://github.com/shannonbooth ✅
13 changed files with 77 additions and 98 deletions
|
@ -288,14 +288,14 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::slice(Optional<i64> start, Opt
|
|||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#dom-blob-stream
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Streams::ReadableStream>> Blob::stream()
|
||||
JS::NonnullGCPtr<Streams::ReadableStream> Blob::stream()
|
||||
{
|
||||
// The stream() method, when invoked, must return the result of calling get stream on this.
|
||||
return this->get_stream();
|
||||
return get_stream();
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#blob-get-stream
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Streams::ReadableStream>> Blob::get_stream()
|
||||
JS::NonnullGCPtr<Streams::ReadableStream> Blob::get_stream()
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
@ -303,7 +303,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Streams::ReadableStream>> Blob::get_stream(
|
|||
auto stream = realm.heap().allocate<Streams::ReadableStream>(realm, realm);
|
||||
|
||||
// 2. Set up stream with byte reading support.
|
||||
TRY(set_up_readable_stream_controller_with_byte_reading_support(stream));
|
||||
set_up_readable_stream_controller_with_byte_reading_support(stream);
|
||||
|
||||
// FIXME: 3. Run the following steps in parallel:
|
||||
{
|
||||
|
@ -357,13 +357,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Streams::ReadableStream>> Blob::get_stream(
|
|||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#dom-blob-text
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> Blob::text()
|
||||
JS::NonnullGCPtr<JS::Promise> Blob::text()
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
auto& vm = realm.vm();
|
||||
|
||||
// 1. Let stream be the result of calling get stream on this.
|
||||
auto stream = TRY(this->get_stream());
|
||||
auto stream = get_stream();
|
||||
|
||||
// 2. Let reader be the result of getting a reader from stream. If that threw an exception, return a new promise rejected with that exception.
|
||||
auto reader_or_exception = acquire_readable_stream_default_reader(*stream);
|
||||
|
@ -387,12 +387,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> Blob::text()
|
|||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#dom-blob-arraybuffer
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> Blob::array_buffer()
|
||||
JS::NonnullGCPtr<JS::Promise> Blob::array_buffer()
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
// 1. Let stream be the result of calling get stream on this.
|
||||
auto stream = TRY(this->get_stream());
|
||||
auto stream = get_stream();
|
||||
|
||||
// 2. Let reader be the result of getting a reader from stream. If that threw an exception, return a new promise rejected with that exception.
|
||||
auto reader_or_exception = acquire_readable_stream_default_reader(*stream);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue