mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 23:25:20 +00:00
LibWeb: Give CSSLoader a backpointer to its owner element
This allows CSSLoader to set up the style sheet owner node internally, and avoids an awkward weak link between CSSLoader and Document.
This commit is contained in:
@@ -34,7 +34,7 @@ namespace Web::HTML {
|
||||
|
||||
HTMLStyleElement::HTMLStyleElement(DOM::Document& document, QualifiedName qualified_name)
|
||||
: HTMLElement(document, move(qualified_name))
|
||||
, m_css_loader(document)
|
||||
, m_css_loader(*this)
|
||||
{
|
||||
m_css_loader.on_load = [&] {
|
||||
document.update_style();
|
||||
@@ -54,10 +54,8 @@ void HTMLStyleElement::children_changed()
|
||||
});
|
||||
m_css_loader.load_from_text(builder.to_string());
|
||||
|
||||
if (auto sheet = m_css_loader.style_sheet()) {
|
||||
sheet->set_owner_node(this);
|
||||
if (auto sheet = m_css_loader.style_sheet())
|
||||
document().style_sheets().add_sheet(sheet.release_nonnull());
|
||||
}
|
||||
|
||||
HTMLElement::children_changed();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user