LibWeb: Assign linked style sheet location when parsing it

Before this change, we assigned the style sheet's location *after* its
content rules were parsed and added to it. This meant any `@import`s
would try to fetch their style sheet before they knew the URL they
should fetch it relative to.
This commit is contained in:
Sam Atkins 2025-04-14 17:44:17 +01:00
parent 336ccdb5f1
commit f29a95e2fe
Notes: github-actions[bot] 2025-04-15 08:41:46 +00:00
5 changed files with 30 additions and 5 deletions

View file

@ -487,13 +487,11 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
} else {
auto const decoded_string = maybe_decoded_string.release_value();
m_loaded_style_sheet = parse_css_stylesheet(CSS::Parser::ParsingParams(document(), *response.url()), decoded_string);
VERIFY(!response.url_list().is_empty());
auto location = response.url_list().first();
m_loaded_style_sheet = parse_css_stylesheet(CSS::Parser::ParsingParams(document(), location), decoded_string, location);
if (m_loaded_style_sheet) {
Optional<::URL::URL> location;
if (!response.url_list().is_empty())
location = response.url_list().first();
document_or_shadow_root_style_sheets().create_a_css_style_sheet(
"text/css"_string,
this,