mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 19:51:45 +00:00
LibWeb: Align some BYOB stream AOs with spec text/reality
A couple of minor things I came across while debugging BYOB streams. Adjust some spec text to match the latest spec, and use GC::Ref instead of a raw pointer where applicable.
This commit is contained in:
parent
9d33b3632f
commit
f22fa827ec
Notes:
github-actions[bot]
2025-04-14 23:58:01 +00:00
Author: https://github.com/trflynn89
Commit: f22fa827ec
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4358
1 changed files with 26 additions and 10 deletions
|
@ -2310,17 +2310,15 @@ void readable_byte_stream_controller_pull_into(ReadableByteStreamController& con
|
||||||
size_t element_size = 1;
|
size_t element_size = 1;
|
||||||
|
|
||||||
// 3. Let ctor be %DataView%.
|
// 3. Let ctor be %DataView%.
|
||||||
JS::NativeFunction* ctor = realm.intrinsics().data_view_constructor();
|
GC::Ref<JS::NativeFunction> ctor = realm.intrinsics().data_view_constructor();
|
||||||
|
|
||||||
// 4. If view has a [[TypedArrayName]] internal slot (i.e., it is not a DataView),
|
// 4. If view has a [[TypedArrayName]] internal slot (i.e., it is not a DataView),
|
||||||
if (view.bufferable_object().has<GC::Ref<JS::TypedArrayBase>>()) {
|
if (auto const* typed_array = view.bufferable_object().get_pointer<GC::Ref<JS::TypedArrayBase>>()) {
|
||||||
auto const& typed_array = *view.bufferable_object().get<GC::Ref<JS::TypedArrayBase>>();
|
|
||||||
|
|
||||||
// 1. Set elementSize to the element size specified in the typed array constructors table for view.[[TypedArrayName]].
|
// 1. Set elementSize to the element size specified in the typed array constructors table for view.[[TypedArrayName]].
|
||||||
element_size = typed_array.element_size();
|
element_size = (*typed_array)->element_size();
|
||||||
|
|
||||||
// 2. Set ctor to the constructor specified in the typed array constructors table for view.[[TypedArrayName]].
|
// 2. Set ctor to the constructor specified in the typed array constructors table for view.[[TypedArrayName]].
|
||||||
switch (typed_array.kind()) {
|
switch ((*typed_array)->kind()) {
|
||||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
|
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
|
||||||
case JS::TypedArrayBase::Kind::ClassName: \
|
case JS::TypedArrayBase::Kind::ClassName: \
|
||||||
ctor = realm.intrinsics().snake_name##_constructor(); \
|
ctor = realm.intrinsics().snake_name##_constructor(); \
|
||||||
|
@ -2361,8 +2359,26 @@ void readable_byte_stream_controller_pull_into(ReadableByteStreamController& con
|
||||||
// 9. Let buffer be bufferResult.[[Value]].
|
// 9. Let buffer be bufferResult.[[Value]].
|
||||||
auto buffer = buffer_result.value();
|
auto buffer = buffer_result.value();
|
||||||
|
|
||||||
// 10. Let pullIntoDescriptor be a new pull-into descriptor with buffer buffer, buffer byte length buffer.[[ArrayBufferByteLength]],
|
// 10. Let pullIntoDescriptor be a new pull-into descriptor with
|
||||||
// byte offset byteOffset, byte length byteLength, bytes filled 0, element size elementSize, view constructor ctor, and reader type "byob".
|
//
|
||||||
|
// buffer
|
||||||
|
// buffer
|
||||||
|
// buffer byte length
|
||||||
|
// buffer.[[ArrayBufferByteLength]]
|
||||||
|
// byte offset
|
||||||
|
// byteOffset
|
||||||
|
// byte length
|
||||||
|
// byteLength
|
||||||
|
// bytes filled
|
||||||
|
// 0
|
||||||
|
// minimum fill
|
||||||
|
// minimumFill
|
||||||
|
// element size
|
||||||
|
// elementSize
|
||||||
|
// view constructor
|
||||||
|
// ctor
|
||||||
|
// reader type
|
||||||
|
// "byob"
|
||||||
auto pull_into_descriptor = vm.heap().allocate<PullIntoDescriptor>(
|
auto pull_into_descriptor = vm.heap().allocate<PullIntoDescriptor>(
|
||||||
buffer,
|
buffer,
|
||||||
buffer->byte_length(),
|
buffer->byte_length(),
|
||||||
|
@ -2457,9 +2473,9 @@ void readable_stream_byob_reader_read(ReadableStreamBYOBReader& reader, WebIDL::
|
||||||
if (stream->is_errored()) {
|
if (stream->is_errored()) {
|
||||||
read_into_request.on_error(stream->stored_error());
|
read_into_request.on_error(stream->stored_error());
|
||||||
}
|
}
|
||||||
// 5. Otherwise, perform ! ReadableByteStreamControllerPullInto(stream.[[controller]], view, readIntoRequest).
|
// 5. Otherwise, perform ! ReadableByteStreamControllerPullInto(stream.[[controller]], view, min, readIntoRequest).
|
||||||
else {
|
else {
|
||||||
readable_byte_stream_controller_pull_into(*stream->controller()->get<GC::Ref<ReadableByteStreamController>>(), view, min, read_into_request);
|
readable_byte_stream_controller_pull_into(stream->controller()->get<GC::Ref<ReadableByteStreamController>>(), view, min, read_into_request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue