LibJS+LibWeb: Allow instantiating DataBlock with an external buffer

This requires the minimal API exposed by ByteBuffer, allowing external
users to implement them as needed instead of being forced to use a
ByteBuffer.
This commit is contained in:
Ali Mohammad Pur
2026-04-04 19:25:48 +02:00
committed by Ali Mohammad Pur
parent 0a7bef349d
commit 0bb987e809
Notes: github-actions[bot] 2026-05-10 14:43:40 +00:00
22 changed files with 163 additions and 68 deletions

View File

@@ -2077,7 +2077,11 @@ bool readable_byte_stream_controller_fill_pull_into_descriptor_from_queue(Readab
VERIFY(can_copy_data_block_bytes_buffer(descriptor_buffer, dest_start, queue_buffer, queue_byte_offset, bytes_to_copy));
// 8. Perform ! CopyDataBlockBytes(pullIntoDescriptors buffer.[[ArrayBufferData]], destStart, headOfQueues buffer.[[ArrayBufferData]], headOfQueues byte offset, bytesToCopy).
JS::copy_data_block_bytes(pull_into_descriptor.buffer->buffer(), dest_start, head_of_queue.buffer->buffer(), head_of_queue.byte_offset, bytes_to_copy);
// NOTE: Stream buffers are never externally backed, so copy_data_block_bytes is safe here.
if (pull_into_descriptor.buffer->is_external() || head_of_queue.buffer->is_external())
pull_into_descriptor.buffer->overwrite(dest_start, head_of_queue.buffer->data() + head_of_queue.byte_offset, bytes_to_copy);
else
JS::copy_data_block_bytes(pull_into_descriptor.buffer->buffer(), dest_start, head_of_queue.buffer->buffer(), head_of_queue.byte_offset, bytes_to_copy);
// 9. If headOfQueues byte length is bytesToCopy,
if (head_of_queue.byte_length == bytes_to_copy) {