summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp12
-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
6 files changed, 69 insertions, 1 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
index 1af9659b30..916ce15a34 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
@@ -807,7 +807,7 @@ int main(int argc, char** argv)
auto interface = IDL::parse_interface(path, data, import_base_path);
- if (namespace_.is_one_of("Crypto", "CSS", "DOM", "HTML", "UIEvents", "Geometry", "HighResolutionTime", "IntersectionObserver", "NavigationTiming", "RequestIdleCallback", "ResizeObserver", "SVG", "Selection", "XHR", "URL")) {
+ if (namespace_.is_one_of("Crypto", "CSS", "DOM", "Encoding", "HTML", "UIEvents", "Geometry", "HighResolutionTime", "IntersectionObserver", "NavigationTiming", "RequestIdleCallback", "ResizeObserver", "SVG", "Selection", "XHR", "URL")) {
StringBuilder builder;
builder.append(namespace_);
builder.append("::");
@@ -1452,6 +1452,8 @@ static void generate_header(IDL::Interface const& interface)
# include <LibWeb/CSS/@name@.h>
#elif __has_include(<LibWeb/DOM/@name@.h>)
# include <LibWeb/DOM/@name@.h>
+#elif __has_include(<LibWeb/Encoding/@name@.h>)
+# include <LibWeb/Encoding/@name@.h>
#elif __has_include(<LibWeb/Geometry/@name@.h>)
# include <LibWeb/Geometry/@name@.h>
#elif __has_include(<LibWeb/HTML/@name@.h>)
@@ -2500,6 +2502,8 @@ void generate_constructor_implementation(IDL::Interface const& interface)
# include <LibWeb/CSS/@name@.h>
#elif __has_include(<LibWeb/DOM/@name@.h>)
# include <LibWeb/DOM/@name@.h>
+#elif __has_include(<LibWeb/Encoding/@name@.h>)
+# include <LibWeb/Encoding/@name@.h>
#elif __has_include(<LibWeb/Geometry/@name@.h>)
# include <LibWeb/Geometry/@name@.h>
#elif __has_include(<LibWeb/HTML/@name@.h>)
@@ -2815,6 +2819,8 @@ void generate_prototype_implementation(IDL::Interface const& interface)
# include <LibWeb/CSS/@name@.h>
#elif __has_include(<LibWeb/DOM/@name@.h>)
# include <LibWeb/DOM/@name@.h>
+#elif __has_include(<LibWeb/Encoding/@name@.h>)
+# include <LibWeb/Encoding/@name@.h>
#elif __has_include(<LibWeb/Geometry/@name@.h>)
# include <LibWeb/Geometry/@name@.h>
#elif __has_include(<LibWeb/HTML/@name@.h>)
@@ -3268,6 +3274,8 @@ static void generate_iterator_header(IDL::Interface const& interface)
# include <LibWeb/CSS/@name@.h>
#elif __has_include(<LibWeb/DOM/@name@.h>)
# include <LibWeb/DOM/@name@.h>
+#elif __has_include(<LibWeb/Encoding/@name@.h>)
+# include <LibWeb/Encoding/@name@.h>
#elif __has_include(<LibWeb/Geometry/@name@.h>)
# include <LibWeb/Geometry/@name@.h>
#elif __has_include(<LibWeb/HTML/@name@.h>)
@@ -3456,6 +3464,8 @@ void generate_iterator_prototype_implementation(IDL::Interface const& interface)
# include <LibWeb/CSS/@name@.h>
#elif __has_include(<LibWeb/DOM/@name@.h>)
# include <LibWeb/DOM/@name@.h>
+#elif __has_include(<LibWeb/Encoding/@name@.h>)
+# include <LibWeb/Encoding/@name@.h>
#elif __has_include(<LibWeb/Geometry/@name@.h>)
# include <LibWeb/Geometry/@name@.h>
#elif __has_include(<LibWeb/HTML/@name@.h>)
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;