mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-14 05:22:24 +00:00
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.
This commit is contained in:
parent
21bfa001b1
commit
e800605ad3
Notes:
sideshowbarker
2024-07-17 04:41:05 +09:00
Author: https://github.com/shannonbooth
Commit: e800605ad3
Pull-request: https://github.com/SerenityOS/serenity/pull/23443
Issue: https://github.com/SerenityOS/serenity/issues/22884
Reviewed-by: https://github.com/trflynn89
403 changed files with 1336 additions and 1305 deletions
|
@ -314,8 +314,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::create_and_initialize(
|
|||
auto const& referrer = navigation_params.request->referrer();
|
||||
|
||||
// 3. If referrer is a URL record, then set document's referrer to the serialization of referrer.
|
||||
if (referrer.has<URL>()) {
|
||||
document->m_referrer = MUST(String::from_byte_string(referrer.get<URL>().serialize()));
|
||||
if (referrer.has<URL::URL>()) {
|
||||
document->m_referrer = MUST(String::from_byte_string(referrer.get<URL::URL>().serialize()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,12 +339,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::construct_impl(JS::Rea
|
|||
return Document::create(realm);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Document> Document::create(JS::Realm& realm, URL const& url)
|
||||
JS::NonnullGCPtr<Document> Document::create(JS::Realm& realm, URL::URL const& url)
|
||||
{
|
||||
return realm.heap().allocate<Document>(realm, realm, url);
|
||||
}
|
||||
|
||||
Document::Document(JS::Realm& realm, const URL& url)
|
||||
Document::Document(JS::Realm& realm, const URL::URL& url)
|
||||
: ParentNode(realm, *this, NodeType::DOCUMENT_NODE)
|
||||
, m_page(Bindings::host_defined_page(realm))
|
||||
, m_style_computer(make<CSS::StyleComputer>(*this))
|
||||
|
@ -945,7 +945,7 @@ JS::GCPtr<HTML::HTMLBaseElement const> Document::first_base_element_with_href_in
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fallback-base-url
|
||||
URL Document::fallback_base_url() const
|
||||
URL::URL Document::fallback_base_url() const
|
||||
{
|
||||
// 1. If document is an iframe srcdoc document, then:
|
||||
if (HTML::url_matches_about_srcdoc(m_url)) {
|
||||
|
@ -965,7 +965,7 @@ URL Document::fallback_base_url() const
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#document-base-url
|
||||
URL Document::base_url() const
|
||||
URL::URL Document::base_url() const
|
||||
{
|
||||
// 1. If there is no base element that has an href attribute in the Document, then return the Document's fallback base URL.
|
||||
auto base_element = first_base_element_with_href_in_tree_order();
|
||||
|
@ -977,7 +977,7 @@ URL Document::base_url() const
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url
|
||||
URL Document::parse_url(StringView url) const
|
||||
URL::URL Document::parse_url(StringView url) const
|
||||
{
|
||||
// FIXME: Pass in document's character encoding.
|
||||
return base_url().complete_url(url);
|
||||
|
@ -2747,7 +2747,7 @@ String Document::domain() const
|
|||
return String {};
|
||||
|
||||
// 3. Return effectiveDomain, serialized.
|
||||
return MUST(URLParser::serialize_host(effective_domain.release_value()));
|
||||
return MUST(URL::Parser::serialize_host(effective_domain.release_value()));
|
||||
}
|
||||
|
||||
void Document::set_domain(String const& domain)
|
||||
|
@ -3803,7 +3803,7 @@ void Document::update_for_history_step_application(JS::NonnullGCPtr<HTML::Sessio
|
|||
// The doNotReactivate argument distinguishes between these two cases.
|
||||
if (documents_entry_changed) {
|
||||
// 1. Let oldURL be document's latest entry's URL.
|
||||
auto old_url = m_latest_entry ? m_latest_entry->url : URL {};
|
||||
auto old_url = m_latest_entry ? m_latest_entry->url : URL::URL {};
|
||||
|
||||
// 2. Set document's latest entry to entry.
|
||||
m_latest_entry = entry;
|
||||
|
@ -3866,7 +3866,7 @@ void Document::update_for_history_step_application(JS::NonnullGCPtr<HTML::Sessio
|
|||
}
|
||||
}
|
||||
|
||||
HashMap<URL, JS::GCPtr<HTML::SharedImageRequest>>& Document::shared_image_requests()
|
||||
HashMap<URL::URL, JS::GCPtr<HTML::SharedImageRequest>>& Document::shared_image_requests()
|
||||
{
|
||||
return m_shared_image_requests;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/URL.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibURL/URL.h>
|
||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||
#include <LibWeb/CSS/StyleSheetList.h>
|
||||
#include <LibWeb/Cookie/Cookie.h>
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create_and_initialize(Type, String content_type, HTML::NavigationParams&);
|
||||
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Document> create(JS::Realm&, URL const& url = "about:blank"sv);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Document> create(JS::Realm&, URL::URL const& url = "about:blank"sv);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> construct_impl(JS::Realm&);
|
||||
virtual ~Document() override;
|
||||
|
||||
|
@ -107,10 +107,10 @@ public:
|
|||
String referrer() const;
|
||||
void set_referrer(String);
|
||||
|
||||
void set_url(const URL& url) { m_url = url; }
|
||||
URL url() const { return m_url; }
|
||||
URL fallback_base_url() const;
|
||||
URL base_url() const;
|
||||
void set_url(const URL::URL& url) { m_url = url; }
|
||||
URL::URL url() const { return m_url; }
|
||||
URL::URL fallback_base_url() const;
|
||||
URL::URL base_url() const;
|
||||
|
||||
void update_base_element(Badge<HTML::HTMLBaseElement>);
|
||||
JS::GCPtr<HTML::HTMLBaseElement const> first_base_element_with_href_in_tree_order() const;
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
HTML::CrossOriginOpenerPolicy const& cross_origin_opener_policy() const { return m_cross_origin_opener_policy; }
|
||||
void set_cross_origin_opener_policy(HTML::CrossOriginOpenerPolicy policy) { m_cross_origin_opener_policy = move(policy); }
|
||||
|
||||
URL parse_url(StringView) const;
|
||||
URL::URL parse_url(StringView) const;
|
||||
|
||||
CSS::StyleComputer& style_computer() { return *m_style_computer; }
|
||||
const CSS::StyleComputer& style_computer() const { return *m_style_computer; }
|
||||
|
@ -454,8 +454,8 @@ public:
|
|||
void set_is_initial_about_blank(bool b) { m_is_initial_about_blank = b; }
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#concept-document-about-base-url
|
||||
Optional<URL> about_base_url() const { return m_about_base_url; }
|
||||
void set_about_base_url(Optional<URL> url) { m_about_base_url = url; }
|
||||
Optional<URL::URL> about_base_url() const { return m_about_base_url; }
|
||||
void set_about_base_url(Optional<URL::URL> url) { m_about_base_url = url; }
|
||||
|
||||
String domain() const;
|
||||
void set_domain(String const&);
|
||||
|
@ -547,7 +547,7 @@ public:
|
|||
|
||||
void update_for_history_step_application(JS::NonnullGCPtr<HTML::SessionHistoryEntry>, bool do_not_reactivate, size_t script_history_length, size_t script_history_index, Optional<Vector<JS::NonnullGCPtr<HTML::SessionHistoryEntry>>> entries_for_navigation_api = {}, bool update_navigation_api = true);
|
||||
|
||||
HashMap<URL, JS::GCPtr<HTML::SharedImageRequest>>& shared_image_requests();
|
||||
HashMap<URL::URL, JS::GCPtr<HTML::SharedImageRequest>>& shared_image_requests();
|
||||
|
||||
void restore_the_history_object_state(JS::NonnullGCPtr<HTML::SessionHistoryEntry> entry);
|
||||
|
||||
|
@ -612,7 +612,7 @@ protected:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
Document(JS::Realm&, URL const&);
|
||||
Document(JS::Realm&, URL::URL const&);
|
||||
|
||||
private:
|
||||
// ^HTML::GlobalEventHandlers
|
||||
|
@ -641,7 +641,7 @@ private:
|
|||
Optional<CSS::Selector::PseudoElement::Type> m_inspected_pseudo_element;
|
||||
JS::GCPtr<Node> m_active_favicon;
|
||||
WeakPtr<HTML::BrowsingContext> m_browsing_context;
|
||||
URL m_url;
|
||||
URL::URL m_url;
|
||||
|
||||
JS::GCPtr<HTML::Window> m_window;
|
||||
|
||||
|
@ -742,7 +742,7 @@ private:
|
|||
bool m_is_initial_about_blank { false };
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#concept-document-about-base-url
|
||||
Optional<URL> m_about_base_url;
|
||||
Optional<URL::URL> m_about_base_url;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#concept-document-coop
|
||||
HTML::CrossOriginOpenerPolicy m_cross_origin_opener_policy;
|
||||
|
@ -818,7 +818,7 @@ private:
|
|||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#latest-entry
|
||||
JS::GCPtr<HTML::SessionHistoryEntry> m_latest_entry;
|
||||
|
||||
HashMap<URL, JS::GCPtr<HTML::SharedImageRequest>> m_shared_image_requests;
|
||||
HashMap<URL::URL, JS::GCPtr<HTML::SharedImageRequest>> m_shared_image_requests;
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#timeline-associated-with-a-document
|
||||
HashTable<JS::NonnullGCPtr<Animations::AnimationTimeline>> m_associated_animation_timelines;
|
||||
|
|
|
@ -31,7 +31,7 @@ JS::NonnullGCPtr<DOM::Document> create_document_for_inline_content(JS::GCPtr<HTM
|
|||
// origin: origin
|
||||
// cross-origin opener policy: coop
|
||||
HTML::CrossOriginOpenerPolicyEnforcementResult coop_enforcement_result {
|
||||
.url = URL("about:error"), // AD-HOC
|
||||
.url = URL::URL("about:error"), // AD-HOC
|
||||
.origin = origin,
|
||||
.cross_origin_opener_policy = coop
|
||||
};
|
||||
|
@ -52,7 +52,7 @@ JS::NonnullGCPtr<DOM::Document> create_document_for_inline_content(JS::GCPtr<HTM
|
|||
// FIXME: navigation timing type: navTimingType
|
||||
// about base URL: null
|
||||
auto response = Fetch::Infrastructure::Response::create(vm);
|
||||
response->url_list().append(URL("about:error")); // AD-HOC: https://github.com/whatwg/html/issues/9122
|
||||
response->url_list().append(URL::URL("about:error")); // AD-HOC: https://github.com/whatwg/html/issues/9122
|
||||
HTML::NavigationParams navigation_params {
|
||||
.id = navigation_id,
|
||||
.navigable = navigable,
|
||||
|
|
|
@ -11,12 +11,12 @@ namespace Web::DOM {
|
|||
|
||||
JS_DEFINE_ALLOCATOR(XMLDocument);
|
||||
|
||||
JS::NonnullGCPtr<XMLDocument> XMLDocument::create(JS::Realm& realm, URL const& url)
|
||||
JS::NonnullGCPtr<XMLDocument> XMLDocument::create(JS::Realm& realm, URL::URL const& url)
|
||||
{
|
||||
return realm.heap().allocate<XMLDocument>(realm, realm, url);
|
||||
}
|
||||
|
||||
XMLDocument::XMLDocument(JS::Realm& realm, URL const& url)
|
||||
XMLDocument::XMLDocument(JS::Realm& realm, URL::URL const& url)
|
||||
: Document(realm, url)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ class XMLDocument final : public Document {
|
|||
JS_DECLARE_ALLOCATOR(XMLDocument);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<XMLDocument> create(JS::Realm&, URL const& url = "about:blank"sv);
|
||||
static JS::NonnullGCPtr<XMLDocument> create(JS::Realm&, URL::URL const& url = "about:blank"sv);
|
||||
virtual ~XMLDocument() override = default;
|
||||
|
||||
private:
|
||||
XMLDocument(JS::Realm& realm, URL const& url);
|
||||
XMLDocument(JS::Realm& realm, URL::URL const& url);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue