diff options
author | Luke <luke.wilde@live.co.uk> | 2020-10-10 20:35:00 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-10 23:25:19 +0200 |
commit | 4155de257237bebe96b5d5c976e57fd18ee572eb (patch) | |
tree | b33f6481ec1cdd299bfc30db45956098f2beca25 | |
parent | a5bf6cfff98a52ecceaace5dd8ccc8fd7e79ac90 (diff) | |
download | serenity-4155de257237bebe96b5d5c976e57fd18ee572eb.zip |
LibWeb: Cache the default font if we fail to find the specified font
This is a hack to stop chewing CPU on sites that use a font we don't
have and have a lot of text or changes text often.
Examples are the Serenity 2nd birthday page and the JS specification.
-rw-r--r-- | Libraries/LibWeb/CSS/StyleProperties.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Libraries/LibWeb/CSS/StyleProperties.cpp b/Libraries/LibWeb/CSS/StyleProperties.cpp index 2b4b656a17..2e15aa949d 100644 --- a/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -174,7 +174,9 @@ void StyleProperties::load_font() const m_font = Gfx::Font::default_bold_font(); else m_font = Gfx::Font::default_font(); - return; + // FIXME: This is a hack to stop chewing CPU on sites that use a font we don't have and have a lot of text + // or changes text often. Examples are the Serenity 2nd birthday page and the JS specification. + FontCache::the().set({ font_family, font_weight }, *m_font); } float StyleProperties::line_height(const LayoutNode& layout_node) const |