mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:08:12 +00:00
LibWeb: Add the TextEncoder interface
This is from the Encoding Standard (https://encoding.spec.whatwg.org), and therefore gets its own namespace and subdirectory within LibWeb :^)
This commit is contained in:
parent
0306cf2030
commit
35d3a1e77b
6 changed files with 69 additions and 1 deletions
40
Userland/Libraries/LibWeb/Encoding/TextEncoder.h
Normal file
40
Userland/Libraries/LibWeb/Encoding/TextEncoder.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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/Wrappable.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::Encoding {
|
||||
|
||||
// https://encoding.spec.whatwg.org/#textencoder
|
||||
class TextEncoder
|
||||
: public RefCounted<TextEncoder>
|
||||
, public Bindings::Wrappable {
|
||||
public:
|
||||
using WrapperType = Bindings::TextEncoderWrapper;
|
||||
|
||||
static NonnullRefPtr<TextEncoder> create()
|
||||
{
|
||||
return adopt_ref(*new TextEncoder());
|
||||
}
|
||||
|
||||
static NonnullRefPtr<TextEncoder> create_with_global_object(Bindings::WindowObject&)
|
||||
{
|
||||
return TextEncoder::create();
|
||||
}
|
||||
|
||||
protected:
|
||||
// https://encoding.spec.whatwg.org/#dom-textencoder
|
||||
TextEncoder() = default;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue