2021-12-12 18:03:22 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2022-09-04 17:09:45 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2021-12-12 18:03:22 +00:00
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
|
|
|
namespace Web::Encoding {
|
|
|
|
|
|
|
|
// https://encoding.spec.whatwg.org/#textencoder
|
2022-09-04 10:56:37 +02:00
|
|
|
class TextEncoder final : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(TextEncoder, Bindings::PlatformObject);
|
2021-12-12 18:03:22 +00:00
|
|
|
|
2022-09-04 10:56:37 +02:00
|
|
|
public:
|
2023-02-19 16:53:44 +01:00
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TextEncoder>> construct_impl(JS::Realm&);
|
2021-12-12 18:03:22 +00:00
|
|
|
|
2022-09-04 10:56:37 +02:00
|
|
|
virtual ~TextEncoder() override;
|
2021-12-12 18:03:22 +00:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
JS::Uint8Array* encode(DeprecatedString const& input) const;
|
2021-12-12 18:05:11 +00:00
|
|
|
|
2023-01-08 19:23:00 -05:00
|
|
|
static DeprecatedFlyString const& encoding();
|
2021-12-12 18:06:07 +00:00
|
|
|
|
2021-12-12 18:03:22 +00:00
|
|
|
protected:
|
|
|
|
// https://encoding.spec.whatwg.org/#dom-textencoder
|
LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
2022-09-25 18:11:21 -06:00
|
|
|
explicit TextEncoder(JS::Realm&);
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
2021-12-12 18:03:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|