summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/PlatformObject.cpp18
-rw-r--r--Userland/Libraries/LibWeb/Bindings/PlatformObject.h24
-rw-r--r--Userland/Libraries/LibWeb/Bindings/Wrapper.cpp18
-rw-r--r--Userland/Libraries/LibWeb/Bindings/Wrapper.h16
-rw-r--r--Userland/Libraries/LibWeb/CMakeLists.txt2
6 files changed, 70 insertions, 10 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
index f3470bafc5..f138bc92dd 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
@@ -972,7 +972,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (includes_wrappable_type) {
// 5. If V is a platform object, then:
union_generator.append(R"~~~(
- if (is<Wrapper>(@js_name@@js_suffix@_object)) {
+ if (is<PlatformObject>(@js_name@@js_suffix@_object)) {
)~~~");
// 1. If types includes an interface type that V implements, then return the IDL value that is a reference to the object V.
diff --git a/Userland/Libraries/LibWeb/Bindings/PlatformObject.cpp b/Userland/Libraries/LibWeb/Bindings/PlatformObject.cpp
new file mode 100644
index 0000000000..b334f15265
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Bindings/PlatformObject.cpp
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibWeb/Bindings/PlatformObject.h>
+
+namespace Web::Bindings {
+
+PlatformObject::PlatformObject(JS::Object& prototype)
+ : JS::Object(prototype)
+{
+}
+
+PlatformObject::~PlatformObject() = default;
+
+}
diff --git a/Userland/Libraries/LibWeb/Bindings/PlatformObject.h b/Userland/Libraries/LibWeb/Bindings/PlatformObject.h
new file mode 100644
index 0000000000..38cff70ca1
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Bindings/PlatformObject.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibJS/Runtime/Object.h>
+
+namespace Web::Bindings {
+
+// https://webidl.spec.whatwg.org/#dfn-platform-object
+class PlatformObject : public JS::Object {
+ JS_OBJECT(PlatformObject, JS::Object);
+
+public:
+ virtual ~PlatformObject() override;
+
+protected:
+ explicit PlatformObject(JS::Object& prototype);
+};
+
+}
diff --git a/Userland/Libraries/LibWeb/Bindings/Wrapper.cpp b/Userland/Libraries/LibWeb/Bindings/Wrapper.cpp
new file mode 100644
index 0000000000..4a12406440
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Bindings/Wrapper.cpp
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibWeb/Bindings/Wrapper.h>
+
+namespace Web::Bindings {
+
+Wrapper::Wrapper(Object& prototype)
+ : PlatformObject(prototype)
+{
+}
+
+Wrapper::~Wrapper() = default;
+
+}
diff --git a/Userland/Libraries/LibWeb/Bindings/Wrapper.h b/Userland/Libraries/LibWeb/Bindings/Wrapper.h
index 2ac7c4851c..86b39899c9 100644
--- a/Userland/Libraries/LibWeb/Bindings/Wrapper.h
+++ b/Userland/Libraries/LibWeb/Bindings/Wrapper.h
@@ -1,29 +1,27 @@
/*
- * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
-#include <AK/NonnullRefPtr.h>
#include <AK/Weakable.h>
-#include <LibJS/Runtime/Object.h>
+#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/Forward.h>
namespace Web::Bindings {
class Wrapper
- : public JS::Object
+ : public PlatformObject
, public Weakable<Wrapper> {
- JS_OBJECT(Wrapper, JS::Object);
+ JS_OBJECT(Wrapper, PlatformObject);
public:
+ virtual ~Wrapper() override;
+
protected:
- explicit Wrapper(Object& prototype)
- : Object(prototype)
- {
- }
+ explicit Wrapper(Object& prototype);
};
}
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt
index 7856ca08db..5c4b549abd 100644
--- a/Userland/Libraries/LibWeb/CMakeLists.txt
+++ b/Userland/Libraries/LibWeb/CMakeLists.txt
@@ -18,10 +18,12 @@ set(SOURCES
Bindings/NavigatorObject.cpp
Bindings/NodeWrapperFactory.cpp
Bindings/OptionConstructor.cpp
+ Bindings/PlatformObject.cpp
Bindings/WindowConstructor.cpp
Bindings/WindowObject.cpp
Bindings/WindowProxy.cpp
Bindings/Wrappable.cpp
+ Bindings/Wrapper.cpp
Crypto/Crypto.cpp
Crypto/SubtleCrypto.cpp
CSS/Angle.cpp