mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:28:11 +00:00
LibWeb: Let get_buffer_source_copy() return ErrorOr instead of Optional
This is a minor refactor of IDL::get_buffer_source_copy() letting it return ErrorOr<ByteBuffer> instead of Optional<ByteBuffer>. This also updates all places that use IDL::get_buffer_source_copy().
This commit is contained in:
parent
7a2bef7fe1
commit
9fe12c1851
5 changed files with 15 additions and 18 deletions
|
@ -71,10 +71,8 @@ ErrorOr<ByteBuffer> Blob::process_blob_parts(Vector<BlobPart> const& blob_parts)
|
|||
},
|
||||
// 2. If element is a BufferSource, get a copy of the bytes held by the buffer source, and append those bytes to bytes.
|
||||
[&](JS::Handle<JS::Object> const& buffer_source) -> ErrorOr<void> {
|
||||
auto data_buffer = Bindings::IDL::get_buffer_source_copy(*buffer_source.cell());
|
||||
if (data_buffer.has_value())
|
||||
return bytes.try_append(data_buffer->bytes());
|
||||
return {};
|
||||
auto data_buffer = TRY(Bindings::IDL::get_buffer_source_copy(*buffer_source.cell()));
|
||||
return bytes.try_append(data_buffer.bytes());
|
||||
},
|
||||
// 3. If element is a Blob, append the bytes it represents to bytes.
|
||||
[&](NonnullRefPtr<Blob> const& blob) -> ErrorOr<void> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue