mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibJS+LibWeb: Implement resizable ArrayBuffer support for TypedArray
This is (part of) a normative change in the ECMA-262 spec. See: https://github.com/tc39/ecma262/commit/a9ae96e
This commit is contained in:
committed by
Andreas Kling
parent
c7fec9424c
commit
9258d7b98a
Notes:
sideshowbarker
2024-07-17 06:51:48 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/9258d7b98a Pull-request: https://github.com/SerenityOS/serenity/pull/22424 Reviewed-by: https://github.com/shannonbooth ✅
@@ -38,6 +38,12 @@ ErrorOr<ByteBuffer> get_buffer_source_copy(JS::Object const& buffer_source)
|
||||
if (is<JS::TypedArrayBase>(buffer_source)) {
|
||||
auto const& es_buffer_source = static_cast<JS::TypedArrayBase const&>(buffer_source);
|
||||
|
||||
auto typed_array_record = JS::make_typed_array_with_buffer_witness_record(es_buffer_source, JS::ArrayBuffer::Order::SeqCst);
|
||||
|
||||
// AD-HOC: The WebIDL spec has not been updated for resizable ArrayBuffer objects. This check follows the behavior of step 7.
|
||||
if (JS::is_typed_array_out_of_bounds(typed_array_record))
|
||||
return ByteBuffer {};
|
||||
|
||||
// 1. Set esArrayBuffer to esBufferSource.[[ViewedArrayBuffer]].
|
||||
es_array_buffer = es_buffer_source.viewed_array_buffer();
|
||||
|
||||
@@ -45,7 +51,7 @@ ErrorOr<ByteBuffer> get_buffer_source_copy(JS::Object const& buffer_source)
|
||||
offset = es_buffer_source.byte_offset();
|
||||
|
||||
// 3. Set length to esBufferSource.[[ByteLength]].
|
||||
length = es_buffer_source.byte_length();
|
||||
length = JS::typed_array_byte_length(typed_array_record);
|
||||
} else if (is<JS::DataView>(buffer_source)) {
|
||||
auto const& es_buffer_source = static_cast<JS::DataView const&>(buffer_source);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user