mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
LibWeb: Invalidate font cache when web fonts are downloaded
In case we've looked up the family name before and cached the result of font fallback, we now invalidate any cached entries with the same family name so that the next lookup may consider the newly downloaded font.
This commit is contained in:
parent
c98829f7c9
commit
418f9ceadd
Notes:
sideshowbarker
2024-07-17 07:06:47 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/418f9ceadd Pull-request: https://github.com/SerenityOS/serenity/pull/20752 Reviewed-by: https://github.com/AtkinsSJ ✅
@ -2794,8 +2794,9 @@ CSSPixelRect StyleComputer::viewport_rect() const
|
||||
return {};
|
||||
}
|
||||
|
||||
void StyleComputer::did_load_font([[maybe_unused]] FlyString const& family_name)
|
||||
void StyleComputer::did_load_font(FlyString const& family_name)
|
||||
{
|
||||
m_font_cache.did_load_font({}, family_name);
|
||||
document().invalidate_style();
|
||||
}
|
||||
|
||||
|
@ -39,4 +39,11 @@ void FontCache::set(FontSelector const& font_selector, NonnullRefPtr<Gfx::Font c
|
||||
m_fonts.set(font_selector, move(font));
|
||||
}
|
||||
|
||||
void FontCache::did_load_font(Badge<CSS::StyleComputer>, FlyString const& family_name)
|
||||
{
|
||||
m_fonts.remove_all_matching([&family_name](auto& key, auto&) -> bool {
|
||||
return key.family == family_name;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ public:
|
||||
|
||||
NonnullRefPtr<Gfx::Font const> scaled_font(Gfx::Font const&, float scale_factor);
|
||||
|
||||
void did_load_font(Badge<CSS::StyleComputer>, FlyString const& family_name);
|
||||
|
||||
private:
|
||||
mutable HashMap<FontSelector, NonnullRefPtr<Gfx::Font const>> m_fonts;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user