LibWeb: Make FontCache per-StyleComputer

This effectively makes it per-Document, but we hang it off of
StyleComputer since that's what it's used for.

The purpose of this is to prevent downloaded fonts from escaping the
context that loaded them. There's probably a more elegant solution where
we still share caching of system fonts, but let's start here.
This commit is contained in:
Andreas Kling 2023-08-17 18:51:32 +02:00
commit 429b2e5860
Notes: sideshowbarker 2024-07-17 02:21:14 +09:00
6 changed files with 13 additions and 13 deletions

View file

@ -33,13 +33,12 @@ struct Traits<FontSelector> : public GenericTraits<FontSelector> {
class FontCache {
public:
static FontCache& the();
FontCache() = default;
RefPtr<Gfx::Font const> get(FontSelector const&) const;
void set(FontSelector const&, NonnullRefPtr<Gfx::Font const>);
NonnullRefPtr<Gfx::Font const> scaled_font(Gfx::Font const&, float scale_factor);
private:
FontCache() = default;
mutable HashMap<FontSelector, NonnullRefPtr<Gfx::Font const>> m_fonts;
};