mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-10 02:51:55 +00:00
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:
parent
bf873a2d5b
commit
9f00425dad
Notes:
github-actions[bot]
2025-04-15 09:30:34 +00:00
Author: https://github.com/AtkinsSJ
Commit: 9f00425dad
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4319
7 changed files with 34 additions and 2 deletions
|
@ -205,6 +205,16 @@ void CSSStyleRule::clear_caches()
|
|||
m_cached_absolutized_selectors.clear();
|
||||
}
|
||||
|
||||
void CSSStyleRule::set_parent_style_sheet(CSSStyleSheet* parent_style_sheet)
|
||||
{
|
||||
Base::set_parent_style_sheet(parent_style_sheet);
|
||||
|
||||
// This is annoying: Style values that request resources need to know their CSSStyleSheet in order to fetch them.
|
||||
for (auto const& property : m_declaration->properties()) {
|
||||
const_cast<CSSStyleValue&>(*property.value).set_style_sheet(parent_style_sheet);
|
||||
}
|
||||
}
|
||||
|
||||
CSSStyleRule const* CSSStyleRule::parent_style_rule() const
|
||||
{
|
||||
for (auto* parent = parent_rule(); parent; parent = parent->parent_rule()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue