1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:37:46 +00:00

LibWeb: Use ArrayBufferView in ReadableStreamBYOBRequest

This commit is contained in:
Shannon Booth 2023-11-25 22:18:43 +13:00 committed by Andreas Kling
parent 4893dfdc57
commit a9a3dcd952
3 changed files with 8 additions and 6 deletions

View file

@ -1,18 +1,20 @@
/* /*
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org> * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <LibWeb/Streams/ReadableByteStreamController.h> #include <LibWeb/Streams/ReadableByteStreamController.h>
#include <LibWeb/Streams/ReadableStreamBYOBRequest.h> #include <LibWeb/Streams/ReadableStreamBYOBRequest.h>
#include <LibWeb/WebIDL/Buffers.h>
namespace Web::Streams { namespace Web::Streams {
JS_DEFINE_ALLOCATOR(ReadableStreamBYOBRequest); JS_DEFINE_ALLOCATOR(ReadableStreamBYOBRequest);
// https://streams.spec.whatwg.org/#rs-byob-request-view // https://streams.spec.whatwg.org/#rs-byob-request-view
JS::GCPtr<JS::TypedArrayBase> ReadableStreamBYOBRequest::view() JS::GCPtr<WebIDL::ArrayBufferView> ReadableStreamBYOBRequest::view()
{ {
// 1. Return this.[[view]]. // 1. Return this.[[view]].
return m_view; return m_view;

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org> * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -21,11 +22,11 @@ class ReadableStreamBYOBRequest : public Bindings::PlatformObject {
public: public:
virtual ~ReadableStreamBYOBRequest() override = default; virtual ~ReadableStreamBYOBRequest() override = default;
JS::GCPtr<JS::TypedArrayBase> view(); JS::GCPtr<WebIDL::ArrayBufferView> view();
void set_controller(JS::GCPtr<ReadableByteStreamController> value) { m_controller = value; } void set_controller(JS::GCPtr<ReadableByteStreamController> value) { m_controller = value; }
void set_view(JS::GCPtr<JS::TypedArrayBase> value) { m_view = value; } void set_view(JS::GCPtr<WebIDL::ArrayBufferView> value) { m_view = value; }
private: private:
explicit ReadableStreamBYOBRequest(JS::Realm&); explicit ReadableStreamBYOBRequest(JS::Realm&);
@ -38,7 +39,7 @@ private:
// https://streams.spec.whatwg.org/#readablestreambyobrequest-view // https://streams.spec.whatwg.org/#readablestreambyobrequest-view
// A typed array representing the destination region to which the controller can write generated data, or null after the BYOB request has been invalidated. // A typed array representing the destination region to which the controller can write generated data, or null after the BYOB request has been invalidated.
JS::GCPtr<JS::TypedArrayBase> m_view; JS::GCPtr<WebIDL::ArrayBufferView> m_view;
}; };
} }

View file

@ -1,8 +1,7 @@
// https://streams.spec.whatwg.org/#readablestreambyobrequest // https://streams.spec.whatwg.org/#readablestreambyobrequest
[Exposed=*] [Exposed=*]
interface ReadableStreamBYOBRequest { interface ReadableStreamBYOBRequest {
// FIXME: This should be an ArrayBufferView readonly attribute ArrayBufferView? view;
readonly attribute any view;
// FIXME: undefined respond([EnforceRange] unsigned long long bytesWritten); // FIXME: undefined respond([EnforceRange] unsigned long long bytesWritten);
// FIXME: undefined respondWithNewView(ArrayBufferView view); // FIXME: undefined respondWithNewView(ArrayBufferView view);