summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibWeb/CMakeLists.txt2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp26
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h29
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp20
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/Script.h28
5 files changed, 105 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt
index c04837f9b1..1568ef5429 100644
--- a/Userland/Libraries/LibWeb/CMakeLists.txt
+++ b/Userland/Libraries/LibWeb/CMakeLists.txt
@@ -157,6 +157,8 @@ set(SOURCES
HTML/Parser/HTMLTokenizer.cpp
HTML/Parser/ListOfActiveFormattingElements.cpp
HTML/Parser/StackOfOpenElements.cpp
+ HTML/Scripting/ClassicScript.cpp
+ HTML/Scripting/Script.cpp
HTML/SubmitEvent.cpp
HTML/SyntaxHighlighter/SyntaxHighlighter.cpp
HTML/TagNames.cpp
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp
new file mode 100644
index 0000000000..b43439153c
--- /dev/null
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibWeb/HTML/Scripting/ClassicScript.h>
+
+namespace Web::HTML {
+
+NonnullRefPtr<ClassicScript> ClassicScript::create(URL base_url, RefPtr<JS::Script> script_record)
+{
+ return adopt_ref(*new ClassicScript(move(base_url), move(script_record)));
+}
+
+ClassicScript::ClassicScript(URL base_url, RefPtr<JS::Script> script_record)
+ : Script(move(base_url))
+ , m_script_record(move(script_record))
+{
+}
+
+ClassicScript::~ClassicScript()
+{
+}
+
+}
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h
new file mode 100644
index 0000000000..2959b308fc
--- /dev/null
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibJS/Script.h>
+#include <LibWeb/HTML/Scripting/Script.h>
+
+namespace Web::HTML {
+
+// https://html.spec.whatwg.org/multipage/webappapis.html#classic-script
+class ClassicScript final : public Script {
+public:
+ ~ClassicScript();
+ static NonnullRefPtr<ClassicScript> create(URL base_url, RefPtr<JS::Script>);
+
+ JS::Script* script_record() { return m_script_record; }
+ JS::Script const* script_record() const { return m_script_record; }
+
+private:
+ explicit ClassicScript(URL base_url, RefPtr<JS::Script>);
+
+ RefPtr<JS::Script> m_script_record;
+};
+
+}
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp
new file mode 100644
index 0000000000..afd528880f
--- /dev/null
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibWeb/HTML/Scripting/Script.h>
+
+namespace Web::HTML {
+
+Script::Script(URL base_url)
+ : m_base_url(move(base_url))
+{
+}
+
+Script::~Script()
+{
+}
+
+}
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Script.h b/Userland/Libraries/LibWeb/HTML/Scripting/Script.h
new file mode 100644
index 0000000000..4781a621ad
--- /dev/null
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Script.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/RefCounted.h>
+#include <AK/URL.h>
+
+namespace Web::HTML {
+
+// https://html.spec.whatwg.org/multipage/webappapis.html#concept-script
+class Script : public RefCounted<Script> {
+public:
+ virtual ~Script();
+
+ URL const& base_url() const { return m_base_url; }
+
+protected:
+ explicit Script(URL base_url);
+
+private:
+ URL m_base_url;
+};
+
+}