mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Remove all font loaders linked to a StyleSheet when it's deleted
When a style sheet is removed, all font loaders created from that style sheet should also be removed.
This commit is contained in:
parent
8472b2b1fb
commit
74588a0a16
Notes:
github-actions[bot]
2024-09-22 18:11:26 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 74588a0a16
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1486
Reviewed-by: https://github.com/awesomekling
5 changed files with 35 additions and 3 deletions
|
@ -2794,12 +2794,24 @@ Optional<FontLoader&> StyleComputer::load_font_face(ParsedFontFace const& font_f
|
|||
return loader_ref;
|
||||
}
|
||||
|
||||
void StyleComputer::load_fonts_from_sheet(CSSStyleSheet const& sheet)
|
||||
void StyleComputer::load_fonts_from_sheet(CSSStyleSheet& sheet)
|
||||
{
|
||||
for (auto const& rule : sheet.rules()) {
|
||||
if (!is<CSSFontFaceRule>(*rule))
|
||||
continue;
|
||||
(void)load_font_face(static_cast<CSSFontFaceRule const&>(*rule).font_face());
|
||||
auto font_loader = load_font_face(static_cast<CSSFontFaceRule const&>(*rule).font_face());
|
||||
if (font_loader.has_value()) {
|
||||
sheet.add_associated_font_loader(font_loader.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StyleComputer::unload_fonts_from_sheet(CSSStyleSheet& sheet)
|
||||
{
|
||||
for (auto& [_, font_loader_list] : m_loaded_fonts) {
|
||||
font_loader_list.remove_all_matching([&](auto& font_loader) {
|
||||
return sheet.has_associated_font_loader(*font_loader);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue