summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h3
-rw-r--r--Userland/Libraries/LibWeb/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibWeb/Encoding/TextEncoder.h40
-rw-r--r--Userland/Libraries/LibWeb/Encoding/TextEncoder.idl9
-rw-r--r--Userland/Libraries/LibWeb/Forward.h5
5 files changed, 58 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h b/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
index 7988bc1966..3faa49a98e 100644
--- a/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
+++ b/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
@@ -262,6 +262,8 @@
#include <LibWeb/Bindings/SubmitEventConstructor.h>
#include <LibWeb/Bindings/SubmitEventPrototype.h>
#include <LibWeb/Bindings/TextConstructor.h>
+#include <LibWeb/Bindings/TextEncoderConstructor.h>
+#include <LibWeb/Bindings/TextEncoderPrototype.h>
#include <LibWeb/Bindings/TextPrototype.h>
#include <LibWeb/Bindings/UIEventConstructor.h>
#include <LibWeb/Bindings/UIEventPrototype.h>
@@ -416,6 +418,7 @@
ADD_WINDOW_OBJECT_INTERFACE(SVGPathElement) \
ADD_WINDOW_OBJECT_INTERFACE(SVGSVGElement) \
ADD_WINDOW_OBJECT_INTERFACE(Text) \
+ ADD_WINDOW_OBJECT_INTERFACE(TextEncoder) \
ADD_WINDOW_OBJECT_INTERFACE(UIEvent) \
ADD_WINDOW_OBJECT_INTERFACE(URLSearchParams) \
ADD_WINDOW_OBJECT_INTERFACE(URL) \
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt
index 81dbfa84aa..cd37ce8d66 100644
--- a/Userland/Libraries/LibWeb/CMakeLists.txt
+++ b/Userland/Libraries/LibWeb/CMakeLists.txt
@@ -396,6 +396,7 @@ libweb_js_wrapper(DOM/ProcessingInstruction)
libweb_js_wrapper(DOM/Range)
libweb_js_wrapper(DOM/ShadowRoot)
libweb_js_wrapper(DOM/Text)
+libweb_js_wrapper(Encoding/TextEncoder)
libweb_js_wrapper(Geometry/DOMRect)
libweb_js_wrapper(Geometry/DOMRectReadOnly)
libweb_js_wrapper(HTML/CanvasRenderingContext2D)
diff --git a/Userland/Libraries/LibWeb/Encoding/TextEncoder.h b/Userland/Libraries/LibWeb/Encoding/TextEncoder.h
new file mode 100644
index 0000000000..b30d9264ce
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Encoding/TextEncoder.h
@@ -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;
+};
+
+}
diff --git a/Userland/Libraries/LibWeb/Encoding/TextEncoder.idl b/Userland/Libraries/LibWeb/Encoding/TextEncoder.idl
new file mode 100644
index 0000000000..09713478b7
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Encoding/TextEncoder.idl
@@ -0,0 +1,9 @@
+[Exposed=(Window,Worker)]
+interface TextEncoder {
+ constructor();
+
+ // [NewObject] Uint8Array encode(optional USVString input = "");
+ // TextEncoderEncodeIntoResult encodeInto(USVString source, [AllowShared] Uint8Array destination);
+
+ // readonly attribute DOMString encoding;
+};
diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h
index 7205762ba7..618a7cf1f8 100644
--- a/Userland/Libraries/LibWeb/Forward.h
+++ b/Userland/Libraries/LibWeb/Forward.h
@@ -109,6 +109,10 @@ template<typename ValueType>
class ExceptionOr;
}
+namespace Web::Encoding {
+class TextEncoder;
+}
+
namespace Web::Geometry {
class DOMRect;
class DOMRectReadOnly;
@@ -432,6 +436,7 @@ class SVGGeometryElementWrapper;
class SVGGraphicsElementWrapper;
class SVGPathElementWrapper;
class SVGSVGElementWrapper;
+class TextEncoderWrapper;
class TextWrapper;
class UIEventWrapper;
class URLConstructor;