ladybird/Userland/Libraries/LibWeb/HTML/Scripting/Script.h
Shannon Booth e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00

57 lines
1.6 KiB
C++

/*
* Copyright (c) 2021-2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Heap/Cell.h>
#include <LibJS/Script.h>
#include <LibURL/URL.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-script
class Script
: public JS::Cell
, public JS::Script::HostDefined {
JS_CELL(Script, JS::Cell);
JS_DECLARE_ALLOCATOR(Script);
public:
virtual ~Script() override;
URL::URL const& base_url() const { return m_base_url; }
ByteString const& filename() const { return m_filename; }
EnvironmentSettingsObject& settings_object() { return m_settings_object; }
[[nodiscard]] JS::Value error_to_rethrow() const { return m_error_to_rethrow; }
void set_error_to_rethrow(JS::Value value) { m_error_to_rethrow = value; }
[[nodiscard]] JS::Value parse_error() const { return m_parse_error; }
void set_parse_error(JS::Value value) { m_parse_error = value; }
protected:
Script(URL::URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object);
virtual void visit_edges(Visitor&) override;
private:
virtual void visit_host_defined_self(JS::Cell::Visitor&) override;
URL::URL m_base_url;
ByteString m_filename;
JS::NonnullGCPtr<EnvironmentSettingsObject> m_settings_object;
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-parse-error
JS::Value m_parse_error;
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-error-to-rethrow
JS::Value m_error_to_rethrow;
};
}