LibWeb/CSS: Let CSSStyleValue know its CSSStyleSheet

The CSS `fetch_foo()` functions resolve the URL relative to the
CSSStyleSheet if one is provided. So, style values that do so need to
know what CSSStyleSheet they are part of so that, for example, `url
(foo.png)` is loaded relative to the style sheet's URL instead of the
document's one.

That all works without this change because we currently absolutize URLs
during parsing, but we're in the process of stopping that.

This commit adds the infrastructure for telling style values what their
CSSStyleSheet is.
This commit is contained in:
Sam Atkins 2025-04-10 16:35:59 +01:00
commit 9f00425dad
Notes: github-actions[bot] 2025-04-15 09:30:34 +00:00
7 changed files with 34 additions and 2 deletions

View file

@ -433,4 +433,11 @@ String ShorthandStyleValue::to_string(SerializationMode mode) const
}
}
void ShorthandStyleValue::set_style_sheet(GC::Ptr<CSSStyleSheet> style_sheet)
{
Base::set_style_sheet(style_sheet);
for (auto& value : m_properties.values)
const_cast<CSSStyleValue&>(*value).set_style_sheet(style_sheet);
}
}