1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:57:35 +00:00

LibJS+LibWeb: Implement resizable ArrayBuffer support for DataView

This is (part of) a normative change in the ECMA-262 spec. See:
a9ae96e
This commit is contained in:
Timothy Flynn 2023-10-15 09:46:09 -04:00 committed by Andreas Kling
parent 29ac6e3689
commit c7fec9424c
12 changed files with 377 additions and 94 deletions

View file

@ -480,14 +480,22 @@ ErrorOr<void> print_typed_array(JS::PrintContext& print_context, JS::TypedArrayB
ErrorOr<void> print_data_view(JS::PrintContext& print_context, JS::DataView const& data_view, HashTable<JS::Object*>& seen_objects)
{
auto view_record = JS::make_data_view_with_buffer_witness_record(data_view, JS::ArrayBuffer::Order::SeqCst);
TRY(print_type(print_context, "DataView"sv));
TRY(js_out(print_context, "\n byteLength: "));
TRY(print_value(print_context, JS::Value(data_view.byte_length()), seen_objects));
TRY(js_out(print_context, "\n byteOffset: "));
TRY(print_value(print_context, JS::Value(data_view.byte_offset()), seen_objects));
TRY(js_out(print_context, "\n buffer: "));
TRY(print_type(print_context, "ArrayBuffer"sv));
TRY(js_out(print_context, " @ {:p}", data_view.viewed_array_buffer()));
if (JS::is_view_out_of_bounds(view_record)) {
TRY(js_out(print_context, "\n <out of bounds>"));
return {};
}
TRY(js_out(print_context, "\n byteLength: "));
TRY(print_value(print_context, JS::Value(JS::get_view_byte_length(view_record)), seen_objects));
TRY(js_out(print_context, "\n byteOffset: "));
TRY(print_value(print_context, JS::Value(data_view.byte_offset()), seen_objects));
return {};
}