mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +00:00
LibWeb: Add ReadableStreamBYOBRequest interface
This commit is contained in:
parent
dc5f213fa0
commit
c7aa4fa166
6 changed files with 79 additions and 0 deletions
|
@ -465,6 +465,7 @@ set(SOURCES
|
||||||
SecureContexts/AbstractOperations.cpp
|
SecureContexts/AbstractOperations.cpp
|
||||||
Streams/AbstractOperations.cpp
|
Streams/AbstractOperations.cpp
|
||||||
Streams/ReadableStream.cpp
|
Streams/ReadableStream.cpp
|
||||||
|
Streams/ReadableStreamBYOBRequest.cpp
|
||||||
Streams/ReadableStreamDefaultController.cpp
|
Streams/ReadableStreamDefaultController.cpp
|
||||||
Streams/ReadableStreamDefaultReader.cpp
|
Streams/ReadableStreamDefaultReader.cpp
|
||||||
Streams/ReadableStreamGenericReader.cpp
|
Streams/ReadableStreamGenericReader.cpp
|
||||||
|
|
|
@ -426,6 +426,7 @@ class Selection;
|
||||||
|
|
||||||
namespace Web::Streams {
|
namespace Web::Streams {
|
||||||
class ReadableStream;
|
class ReadableStream;
|
||||||
|
class ReadableStreamBYOBRequest;
|
||||||
class ReadableStreamDefaultController;
|
class ReadableStreamDefaultController;
|
||||||
class ReadableStreamDefaultReader;
|
class ReadableStreamDefaultReader;
|
||||||
class ReadableStreamGenericReaderMixin;
|
class ReadableStreamGenericReaderMixin;
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Streams/ReadableStreamBYOBRequest.h>
|
||||||
|
|
||||||
|
namespace Web::Streams {
|
||||||
|
|
||||||
|
// https://streams.spec.whatwg.org/#rs-byob-request-view
|
||||||
|
JS::GCPtr<JS::TypedArrayBase> ReadableStreamBYOBRequest::view()
|
||||||
|
{
|
||||||
|
// 1. Return this.[[view]].
|
||||||
|
return m_view;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReadableStreamBYOBRequest::ReadableStreamBYOBRequest(JS::Realm& realm)
|
||||||
|
: Bindings::PlatformObject(realm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadableStreamBYOBRequest::visit_edges(Cell::Visitor& visitor)
|
||||||
|
{
|
||||||
|
Base::visit_edges(visitor);
|
||||||
|
visitor.visit(m_controller);
|
||||||
|
visitor.visit(m_view);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/TypedArray.h>
|
||||||
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
|
||||||
|
namespace Web::Streams {
|
||||||
|
|
||||||
|
// https://streams.spec.whatwg.org/#readablestreambyobrequest
|
||||||
|
class ReadableStreamBYOBRequest : public Bindings::PlatformObject {
|
||||||
|
WEB_PLATFORM_OBJECT(ReadableStreamBYOBRequest, Bindings::PlatformObject);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~ReadableStreamBYOBRequest() override = default;
|
||||||
|
|
||||||
|
JS::GCPtr<JS::TypedArrayBase> view();
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit ReadableStreamBYOBRequest(JS::Realm&);
|
||||||
|
|
||||||
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
// https://streams.spec.whatwg.org/#readablestreambyobrequest-controller
|
||||||
|
// The parent ReadableByteStreamController instance
|
||||||
|
JS::GCPtr<JS::Object> m_controller;
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
JS::GCPtr<JS::TypedArrayBase> m_view;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Exposed=*]
|
||||||
|
interface ReadableStreamBYOBRequest {
|
||||||
|
// FIXME: This should be an ArrayBufferView
|
||||||
|
readonly attribute any? view;
|
||||||
|
|
||||||
|
// FIXME: Implement
|
||||||
|
// undefined respond([EnforceRange] unsigned long long bytesWritten);
|
||||||
|
// undefined respondWithNewView(ArrayBufferView view);
|
||||||
|
};
|
|
@ -180,6 +180,7 @@ libweb_js_bindings(PerformanceTimeline/PerformanceEntry)
|
||||||
libweb_js_bindings(RequestIdleCallback/IdleDeadline)
|
libweb_js_bindings(RequestIdleCallback/IdleDeadline)
|
||||||
libweb_js_bindings(ResizeObserver/ResizeObserver)
|
libweb_js_bindings(ResizeObserver/ResizeObserver)
|
||||||
libweb_js_bindings(Streams/ReadableStream)
|
libweb_js_bindings(Streams/ReadableStream)
|
||||||
|
libweb_js_bindings(Streams/ReadableStreamBYOBRequest)
|
||||||
libweb_js_bindings(Streams/ReadableStreamDefaultController)
|
libweb_js_bindings(Streams/ReadableStreamDefaultController)
|
||||||
libweb_js_bindings(Streams/ReadableStreamDefaultReader)
|
libweb_js_bindings(Streams/ReadableStreamDefaultReader)
|
||||||
libweb_js_bindings(Streams/WritableStream)
|
libweb_js_bindings(Streams/WritableStream)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue