mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +00:00
This needs to happen before prototype/constructor intitialization can be made lazy. Otherwise, GC could run during the C++ constructor and try to collect the object currently being created.
38 lines
902 B
C++
38 lines
902 B
C++
/*
|
|
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Forward.h>
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <AK/RefCounted.h>
|
|
#include <LibJS/Forward.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::Encoding {
|
|
|
|
// https://encoding.spec.whatwg.org/#textencoder
|
|
class TextEncoder final : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(TextEncoder, Bindings::PlatformObject);
|
|
|
|
public:
|
|
static JS::NonnullGCPtr<TextEncoder> construct_impl(JS::Realm&);
|
|
|
|
virtual ~TextEncoder() override;
|
|
|
|
JS::Uint8Array* encode(DeprecatedString const& input) const;
|
|
|
|
static DeprecatedFlyString const& encoding();
|
|
|
|
protected:
|
|
// https://encoding.spec.whatwg.org/#dom-textencoder
|
|
explicit TextEncoder(JS::Realm&);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
};
|
|
|
|
}
|