mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-31 13:48:25 +00:00
LibWeb+Meta: Add wrapper for the BufferSource/ArrayBufferView IDL types
These wrappers will make it much easier to do various operations on the different ArrayBuffer-related classes in LibWeb compared to the current solution, which is to just accept a Handle<Object> everywhere (and use "any" in the *.idl files). Co-Authored-By: Matthew Olsson <mattco@serenityos.org>
This commit is contained in:
committed by
Andreas Kling
parent
54d0aafff0
commit
04c094343f
@@ -19,6 +19,7 @@
|
||||
#include <LibWeb/Streams/AbstractOperations.h>
|
||||
#include <LibWeb/Streams/ReadableStreamDefaultReader.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
|
||||
namespace Web::FileAPI {
|
||||
|
||||
@@ -99,8 +100,8 @@ ErrorOr<ByteBuffer> process_blob_parts(Vector<BlobPart> const& blob_parts, Optio
|
||||
return bytes.try_append(s.bytes());
|
||||
},
|
||||
// 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 = TRY(WebIDL::get_buffer_source_copy(*buffer_source.cell()));
|
||||
[&](JS::Handle<WebIDL::BufferSource> const& buffer_source) -> ErrorOr<void> {
|
||||
auto data_buffer = TRY(WebIDL::get_buffer_source_copy(*buffer_source->raw_object()));
|
||||
return bytes.try_append(data_buffer.bytes());
|
||||
},
|
||||
// 3. If element is a Blob, append the bytes it represents to bytes.
|
||||
|
||||
Reference in New Issue
Block a user