2025-02-05 16:51:33 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
|
|
|
#include <LibWeb/Encoding/TextEncoderCommon.h>
|
|
|
|
|
#include <LibWeb/Streams/GenericTransformStream.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Encoding {
|
|
|
|
|
|
|
|
|
|
class TextEncoderStream final
|
|
|
|
|
: public Bindings::PlatformObject
|
|
|
|
|
, public Streams::GenericTransformStreamMixin
|
|
|
|
|
, public TextEncoderCommonMixin {
|
|
|
|
|
WEB_PLATFORM_OBJECT(TextEncoderStream, Bindings::PlatformObject);
|
|
|
|
|
GC_DECLARE_ALLOCATOR(TextEncoderStream);
|
|
|
|
|
|
|
|
|
|
public:
|
2026-06-22 09:15:53 -03:00
|
|
|
static GC::Ref<TextEncoderStream> construct_impl(JS::Realm&);
|
2025-02-05 16:51:33 -03:00
|
|
|
virtual ~TextEncoderStream() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TextEncoderStream(JS::Realm&, GC::Ref<Streams::TransformStream>);
|
|
|
|
|
|
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
|
|
|
|
WebIDL::ExceptionOr<void> encode_and_enqueue_chunk(JS::Value);
|
|
|
|
|
WebIDL::ExceptionOr<void> encode_and_flush();
|
|
|
|
|
|
2026-06-21 14:03:01 -03:00
|
|
|
Optional<u32> convert_code_unit_to_scalar_value(u32 item, size_t& code_unit_index);
|
2025-02-05 16:51:33 -03:00
|
|
|
|
|
|
|
|
// https://encoding.spec.whatwg.org/#textencoderstream-pending-high-surrogate
|
|
|
|
|
Optional<u32> m_leading_surrogate;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|