mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
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:
parent
336ccdb5f1
commit
f29a95e2fe
Notes:
github-actions[bot]
2025-04-15 08:41:46 +00:00
Author: https://github.com/AtkinsSJ
Commit: f29a95e2fe
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4352
5 changed files with 30 additions and 5 deletions
|
@ -487,13 +487,11 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru
|
||||||
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
|
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
|
||||||
} else {
|
} else {
|
||||||
auto const decoded_string = maybe_decoded_string.release_value();
|
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) {
|
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(
|
document_or_shadow_root_style_sheets().create_a_css_style_sheet(
|
||||||
"text/css"_string,
|
"text/css"_string,
|
||||||
this,
|
this,
|
||||||
|
|
5
Tests/LibWeb/Layout/data/import-a.css
Normal file
5
Tests/LibWeb/Layout/data/import-a.css
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
@import "import-b.css";
|
||||||
|
|
||||||
|
#target {
|
||||||
|
width: 50px;
|
||||||
|
}
|
3
Tests/LibWeb/Layout/data/import-b.css
Normal file
3
Tests/LibWeb/Layout/data/import-b.css
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#target {
|
||||||
|
width: 200px !important;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
|
BlockContainer <html> at (0,0) content-size 800x33 [BFC] children: not-inline
|
||||||
|
BlockContainer <body> at (8,8) content-size 784x17 children: not-inline
|
||||||
|
BlockContainer <div#target> at (8,8) content-size 200x17 children: inline
|
||||||
|
frag 0 from TextNode start: 0, length: 5, rect: [8,8 39.78125x17] baseline: 13.296875
|
||||||
|
"Hello"
|
||||||
|
TextNode <#text>
|
||||||
|
BlockContainer <(anonymous)> at (8,25) content-size 784x0 children: inline
|
||||||
|
TextNode <#text>
|
||||||
|
|
||||||
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x33]
|
||||||
|
PaintableWithLines (BlockContainer<BODY>) [8,8 784x17]
|
||||||
|
PaintableWithLines (BlockContainer<DIV>#target) [8,8 200x17]
|
||||||
|
TextPaintable (TextNode<#text>)
|
||||||
|
PaintableWithLines (BlockContainer(anonymous)) [8,25 784x0]
|
|
@ -0,0 +1,3 @@
|
||||||
|
<!doctype html>
|
||||||
|
<link rel="stylesheet" href="../data/import-a.css">
|
||||||
|
<div id="target">Hello</div>
|
Loading…
Add table
Add a link
Reference in a new issue