2026-04-28 07:49:27 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2026-present, the Ladybird developers.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2026-06-19 19:51:56 -03:00
|
|
|
#include <AK/OwnPtr.h>
|
2026-04-28 07:49:27 -03:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
|
|
|
#include <LibWeb/Encoding/TextDecoder.h>
|
|
|
|
|
#include <LibWeb/Encoding/TextDecoderCommon.h>
|
|
|
|
|
#include <LibWeb/Streams/GenericTransformStream.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Encoding {
|
|
|
|
|
|
|
|
|
|
// https://encoding.spec.whatwg.org/#textdecoderstream
|
|
|
|
|
class TextDecoderStream final
|
|
|
|
|
: public Bindings::PlatformObject
|
|
|
|
|
, public Streams::GenericTransformStreamMixin
|
|
|
|
|
, public TextDecoderCommonMixin {
|
|
|
|
|
WEB_PLATFORM_OBJECT(TextDecoderStream, Bindings::PlatformObject);
|
|
|
|
|
GC_DECLARE_ALLOCATOR(TextDecoderStream);
|
|
|
|
|
|
|
|
|
|
public:
|
2026-05-01 14:01:23 -03:00
|
|
|
static WebIDL::ExceptionOr<GC::Ref<TextDecoderStream>> construct_impl(JS::Realm&, FlyString label, Bindings::TextDecoderOptions const&);
|
2026-04-28 07:49:27 -03:00
|
|
|
virtual ~TextDecoderStream() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TextDecoderStream(JS::Realm&, GC::Ref<Streams::TransformStream>, TextCodec::Decoder&, FlyString encoding, ErrorMode, bool ignore_bom);
|
|
|
|
|
|
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
|
|
|
|
WebIDL::ExceptionOr<void> decode_and_enqueue_chunk(JS::Value);
|
|
|
|
|
WebIDL::ExceptionOr<void> flush_and_enqueue();
|
|
|
|
|
|
|
|
|
|
WebIDL::ExceptionOr<void> enqueue_decoded_output(String const&);
|
|
|
|
|
|
|
|
|
|
// https://encoding.spec.whatwg.org/#textdecodercommon-i-o-queue
|
2026-06-19 19:51:56 -03:00
|
|
|
NonnullOwnPtr<TextCodec::StreamingDecoder> m_streaming_decoder;
|
2026-04-28 07:49:27 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|