LibWeb: Unload fonts when adopted style sheet is removed

Add missing unloading step that we do for regular style sheets but
mistakenly missed for adopted style sheets.
This commit is contained in:
Aliaksandr Kalenik 2025-01-10 17:25:42 +03:00 committed by Alexander Kalenik
commit cf57efd252
Notes: github-actions[bot] 2025-01-10 16:13:44 +00:00
3 changed files with 15 additions and 4 deletions

View file

@ -35,7 +35,13 @@ GC::Ref<WebIDL::ObservableArray> create_adopted_style_sheets_list(Document& docu
document.invalidate_style(DOM::StyleInvalidationReason::AdoptedStyleSheetsList);
return {};
});
adopted_style_sheets->set_on_delete_an_indexed_value_callback([&document]() -> WebIDL::ExceptionOr<void> {
adopted_style_sheets->set_on_delete_an_indexed_value_callback([&document](JS::Value value) -> WebIDL::ExceptionOr<void> {
VERIFY(value.is_object());
auto& object = value.as_object();
VERIFY(is<CSS::CSSStyleSheet>(object));
auto& style_sheet = static_cast<CSS::CSSStyleSheet&>(object);
document.style_computer().unload_fonts_from_sheet(style_sheet);
document.style_computer().invalidate_rule_cache();
document.invalidate_style(DOM::StyleInvalidationReason::AdoptedStyleSheetsList);
return {};