summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h6
-rw-r--r--Userland/Libraries/LibWeb/Forward.h4
-rw-r--r--Userland/Libraries/LibWeb/Geometry/DOMPoint.h44
-rw-r--r--Userland/Libraries/LibWeb/Geometry/DOMPoint.idl12
-rw-r--r--Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h53
-rw-r--r--Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.idl10
-rw-r--r--Userland/Libraries/LibWeb/idl_files.cmake2
7 files changed, 131 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h b/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
index 09f3b5c2f8..cbde5e5752 100644
--- a/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
+++ b/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
@@ -59,6 +59,10 @@
#include <LibWeb/Bindings/DOMImplementationPrototype.h>
#include <LibWeb/Bindings/DOMParserConstructor.h>
#include <LibWeb/Bindings/DOMParserPrototype.h>
+#include <LibWeb/Bindings/DOMPointConstructor.h>
+#include <LibWeb/Bindings/DOMPointPrototype.h>
+#include <LibWeb/Bindings/DOMPointReadOnlyConstructor.h>
+#include <LibWeb/Bindings/DOMPointReadOnlyPrototype.h>
#include <LibWeb/Bindings/DOMRectConstructor.h>
#include <LibWeb/Bindings/DOMRectListConstructor.h>
#include <LibWeb/Bindings/DOMRectListPrototype.h>
@@ -403,6 +407,8 @@
ADD_WINDOW_OBJECT_INTERFACE(DOMException) \
ADD_WINDOW_OBJECT_INTERFACE(DOMImplementation) \
ADD_WINDOW_OBJECT_INTERFACE(DOMParser) \
+ ADD_WINDOW_OBJECT_INTERFACE(DOMPoint) \
+ ADD_WINDOW_OBJECT_INTERFACE(DOMPointReadOnly) \
ADD_WINDOW_OBJECT_INTERFACE(DOMRect) \
ADD_WINDOW_OBJECT_INTERFACE(DOMRectList) \
ADD_WINDOW_OBJECT_INTERFACE(DOMRectReadOnly) \
diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h
index f01070f085..6eec51afee 100644
--- a/Userland/Libraries/LibWeb/Forward.h
+++ b/Userland/Libraries/LibWeb/Forward.h
@@ -170,6 +170,8 @@ class TextEncoder;
}
namespace Web::Geometry {
+class DOMPoint;
+class DOMPointReadOnly;
class DOMRect;
class DOMRectList;
class DOMRectReadOnly;
@@ -440,6 +442,8 @@ class DocumentWrapper;
class DOMExceptionWrapper;
class DOMImplementationWrapper;
class DOMParserWrapper;
+class DOMPointWrapper;
+class DOMPointReadOnlyWrapper;
class DOMRectListWrapper;
class DOMRectReadOnlyWrapper;
class DOMRectWrapper;
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h
new file mode 100644
index 0000000000..ea75d9a36b
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibWeb/Geometry/DOMPointReadOnly.h>
+
+namespace Web::Geometry {
+
+// https://drafts.fxtf.org/geometry/#DOMPoint
+class DOMPoint final : public DOMPointReadOnly {
+public:
+ using WrapperType = Bindings::DOMPointWrapper;
+
+ static NonnullRefPtr<DOMPoint> create_with_global_object(Bindings::WindowObject&, double x = 0, double y = 0, double z = 0, double w = 0)
+ {
+ return DOMPoint::create(x, y, z, w);
+ }
+
+ static NonnullRefPtr<DOMPoint> create(double x = 0, double y = 0, double z = 0, double w = 0)
+ {
+ return adopt_ref(*new DOMPoint(x, y, z, w));
+ }
+
+ double x() const { return m_x; }
+ double y() const { return m_y; }
+ double z() const { return m_z; }
+ double w() const { return m_w; }
+
+ void set_x(double x) { m_x = x; }
+ void set_y(double y) { m_y = y; }
+ void set_z(double z) { m_z = z; }
+ void set_w(double w) { m_w = w; }
+
+private:
+ DOMPoint(float x, float y, float z, float w)
+ : DOMPointReadOnly(x, y, z, w)
+ {
+ }
+};
+}
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.idl b/Userland/Libraries/LibWeb/Geometry/DOMPoint.idl
new file mode 100644
index 0000000000..21084d87a4
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.idl
@@ -0,0 +1,12 @@
+#import <Geometry/DOMPointReadOnly.idl>
+
+interface DOMPoint : DOMPointReadOnly {
+
+ constructor(optional double x = 0, optional double y = 0, optional double z = 0, optional double w = 0);
+
+ attribute double x;
+ attribute double y;
+ attribute double z;
+ attribute double w;
+
+};
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h
new file mode 100644
index 0000000000..5b088a41eb
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/RefCounted.h>
+#include <LibGfx/Point.h>
+#include <LibWeb/Bindings/Wrappable.h>
+#include <LibWeb/Forward.h>
+
+namespace Web::Geometry {
+
+// https://drafts.fxtf.org/geometry/#dompointreadonly
+class DOMPointReadOnly
+ : public RefCounted<DOMPointReadOnly>
+ , public Bindings::Wrappable {
+public:
+ using WrapperType = Bindings::DOMPointReadOnlyWrapper;
+
+ static NonnullRefPtr<DOMPointReadOnly> create_with_global_object(Bindings::WindowObject&, double x = 0, double y = 0, double z = 0, double w = 0)
+ {
+ return DOMPointReadOnly::create(x, y, z, w);
+ }
+
+ static NonnullRefPtr<DOMPointReadOnly> create(double x = 0, double y = 0, double z = 0, double w = 0)
+ {
+ return adopt_ref(*new DOMPointReadOnly(x, y, z, w));
+ }
+
+ double x() const { return m_x; }
+ double y() const { return m_y; }
+ double z() const { return m_z; }
+ double w() const { return m_w; }
+
+protected:
+ DOMPointReadOnly(double x, double y, double z, double w)
+ : m_x(x)
+ , m_y(y)
+ , m_z(z)
+ , m_w(w)
+ {
+ }
+
+ double m_x;
+ double m_y;
+ double m_z;
+ double m_w;
+};
+
+}
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.idl b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.idl
new file mode 100644
index 0000000000..43338b7316
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.idl
@@ -0,0 +1,10 @@
+interface DOMPointReadOnly {
+
+ constructor(optional double x = 0, optional double y = 0, optional double z = 0, optional double w = 0);
+
+ readonly attribute double x;
+ readonly attribute double y;
+ readonly attribute double z;
+ readonly attribute double w;
+
+};
diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake
index 9d841cb89f..ca6f0c5429 100644
--- a/Userland/Libraries/LibWeb/idl_files.cmake
+++ b/Userland/Libraries/LibWeb/idl_files.cmake
@@ -53,6 +53,8 @@ libweb_js_wrapper(DOM/TreeWalker)
libweb_js_wrapper(DOMParsing/XMLSerializer)
libweb_js_wrapper(Encoding/TextDecoder)
libweb_js_wrapper(Encoding/TextEncoder)
+libweb_js_wrapper(Geometry/DOMPoint)
+libweb_js_wrapper(Geometry/DOMPointReadOnly)
libweb_js_wrapper(Geometry/DOMRect)
libweb_js_wrapper(Geometry/DOMRectList)
libweb_js_wrapper(Geometry/DOMRectReadOnly)