From 4e18fce3a586651894844c7ef0a06c774ce9eb2c Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 21 Aug 2024 14:49:08 +0100 Subject: [PATCH] LibWeb: Set the location URL for `@import`-ed/``-ed style sheets The spec text had changed for the value of ``'s location, so I've updated that. --- Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp | 2 +- Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp index 8e60d649808..0b9e28860e2 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -97,7 +97,7 @@ void CSSImportRule::resource_did_load() dbgln_if(CSS_LOADER_DEBUG, "CSSImportRule: Resource did load, has encoded data. URL: {}", resource()->url()); } - auto* sheet = parse_css_stylesheet(CSS::Parser::ParsingContext(*m_document, resource()->url()), resource()->encoded_data()); + auto* sheet = parse_css_stylesheet(CSS::Parser::ParsingContext(*m_document, resource()->url()), resource()->encoded_data(), resource()->url()); if (!sheet) { dbgln_if(CSS_LOADER_DEBUG, "CSSImportRule: Failed to parse stylesheet: {}", resource()->url()); return; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index bc80c11743b..3d998776c96 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -391,7 +391,7 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru // type // text/css // location - // The resulting URL string determined during the fetch and process the linked resource algorithm. + // response's URL list[0] // owner node // element // media @@ -438,6 +438,10 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru m_loaded_style_sheet = parse_css_stylesheet(CSS::Parser::ParsingContext(document(), *response.url()), decoded_string); if (m_loaded_style_sheet) { + Optional location; + if (!response.url_list().is_empty()) + location = MUST(response.url_list().first().to_string()); + document().style_sheets().create_a_css_style_sheet( "text/css"_string, this, @@ -445,7 +449,7 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru in_a_document_tree() ? attribute(HTML::AttributeNames::title).value_or({}) : String {}, m_relationship & Relationship::Alternate && !m_explicitly_enabled, true, - {}, + move(location), nullptr, nullptr, *m_loaded_style_sheet);