mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 14:28:49 +00:00
LibWeb: Implement TextEncoderStream
Required by the server-side rendering mode of React Router, used by https://chatgpt.com/ Note that the imported tests do not have the worker variants to prevent freezing on macOS.
This commit is contained in:
parent
24d5f24749
commit
cae0ee6fa7
Notes:
github-actions[bot]
2025-02-07 16:05:51 +00:00
Author: https://github.com/Lubrsi
Commit: cae0ee6fa7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3481
Reviewed-by: https://github.com/trflynn89 ✅
36 changed files with 1375 additions and 0 deletions
41
Libraries/LibWeb/Encoding/TextEncoderStream.h
Normal file
41
Libraries/LibWeb/Encoding/TextEncoderStream.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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:
|
||||
static WebIDL::ExceptionOr<GC::Ref<TextEncoderStream>> construct_impl(JS::Realm&);
|
||||
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();
|
||||
|
||||
Optional<u32> convert_code_unit_to_scalar_value(u32 item, Utf8CodePointIterator& code_point_iterator);
|
||||
|
||||
// https://encoding.spec.whatwg.org/#textencoderstream-pending-high-surrogate
|
||||
Optional<u32> m_leading_surrogate;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue