1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

LibJS+LibWeb: Implement resizable ArrayBuffer support for TypedArray

This is (part of) a normative change in the ECMA-262 spec. See:
a9ae96e
This commit is contained in:
Timothy Flynn 2023-12-24 14:55:10 -05:00 committed by Andreas Kling
parent c7fec9424c
commit 9258d7b98a
47 changed files with 2059 additions and 884 deletions

View file

@ -13,7 +13,16 @@ namespace Web::WebIDL {
u32 BufferableObjectBase::byte_length() const
{
return m_bufferable_object.visit([](auto& obj) { return static_cast<u32>(obj->byte_length()); });
return m_bufferable_object.visit(
[](JS::NonnullGCPtr<JS::TypedArrayBase> typed_array) {
auto typed_array_record = JS::make_typed_array_with_buffer_witness_record(typed_array, JS::ArrayBuffer::Order::SeqCst);
return JS::typed_array_byte_length(typed_array_record);
},
[](JS::NonnullGCPtr<JS::DataView> data_view) {
auto view_record = JS::make_data_view_with_buffer_witness_record(data_view, JS::ArrayBuffer::Order::SeqCst);
return JS::get_view_byte_length(view_record);
},
[](JS::NonnullGCPtr<JS::ArrayBuffer> array_buffer) { return static_cast<u32>(array_buffer->byte_length()); });
}
JS::NonnullGCPtr<JS::Object> BufferableObjectBase::raw_object()