LibWeb: Add the IDL for the GenericTransformStream mixin

This commit is contained in:
Timothy Flynn 2024-11-15 07:32:57 -05:00 committed by Andreas Kling
parent 5a2260a0bc
commit 35ba7c7e00
Notes: github-actions[bot] 2024-11-17 22:22:14 +00:00
4 changed files with 78 additions and 0 deletions

View file

@ -664,6 +664,7 @@ set(SOURCES
Streams/AbstractOperations.cpp
Streams/ByteLengthQueuingStrategy.cpp
Streams/CountQueuingStrategy.cpp
Streams/GenericTransformStream.cpp
Streams/ReadableByteStreamController.cpp
Streams/ReadableStream.cpp
Streams/ReadableStreamBYOBReader.cpp

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Streams/GenericTransformStream.h>
#include <LibWeb/Streams/ReadableStream.h>
#include <LibWeb/Streams/TransformStream.h>
#include <LibWeb/Streams/WritableStream.h>
namespace Web::Streams {
GenericTransformStreamMixin::GenericTransformStreamMixin(GC::Ref<TransformStream> transform)
: m_transform(transform)
{
}
GenericTransformStreamMixin::~GenericTransformStreamMixin() = default;
void GenericTransformStreamMixin::visit_edges(GC::Cell::Visitor& visitor)
{
visitor.visit(m_transform);
}
// https://streams.spec.whatwg.org/#dom-generictransformstream-readable
GC::Ref<ReadableStream> GenericTransformStreamMixin::readable()
{
// The readable getter steps are to return this's transform.[[readable]].
return m_transform->readable();
}
// https://streams.spec.whatwg.org/#dom-generictransformstream-writable
GC::Ref<WritableStream> GenericTransformStreamMixin::writable()
{
// The writable getter steps are to return this's transform.[[writable]].
return m_transform->writable();
}
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGC/Cell.h>
#include <LibGC/Ptr.h>
#include <LibWeb/Forward.h>
namespace Web::Streams {
class GenericTransformStreamMixin {
public:
virtual ~GenericTransformStreamMixin();
GC::Ref<ReadableStream> readable();
GC::Ref<WritableStream> writable();
protected:
explicit GenericTransformStreamMixin(GC::Ref<TransformStream>);
void visit_edges(GC::Cell::Visitor&);
// https://streams.spec.whatwg.org/#generictransformstream-transform
GC::Ref<TransformStream> m_transform;
};
}

View file

@ -0,0 +1,7 @@
#import <Streams/ReadableStream.idl>
#import <Streams/WritableStream.idl>
interface mixin GenericTransformStream {
readonly attribute ReadableStream readable;
readonly attribute WritableStream writable;
};