mirror of
https://github.com/RGBCube/serenity
synced 2025-06-30 10:12:07 +00:00
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:
parent
69a81243f5
commit
429b2e5860
6 changed files with 13 additions and 13 deletions
|
@ -8,12 +8,6 @@
|
|||
#include <LibGfx/Font/Font.h>
|
||||
#include <LibWeb/FontCache.h>
|
||||
|
||||
FontCache& FontCache::the()
|
||||
{
|
||||
static FontCache cache;
|
||||
return cache;
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Font const> FontCache::get(FontSelector const& font_selector) const
|
||||
{
|
||||
auto cached_font = m_fonts.get(font_selector);
|
||||
|
@ -26,7 +20,7 @@ NonnullRefPtr<Gfx::Font const> FontCache::scaled_font(Gfx::Font const& font, flo
|
|||
{
|
||||
auto device_font_pt_size = font.point_size() * scale_factor;
|
||||
FontSelector font_selector = { FlyString::from_deprecated_fly_string(font.family()).release_value_but_fixme_should_propagate_errors(), device_font_pt_size, font.weight(), font.width(), font.slope() };
|
||||
if (auto cached_font = FontCache::the().get(font_selector)) {
|
||||
if (auto cached_font = get(font_selector)) {
|
||||
return *cached_font;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue