1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

LibWeb: Load fonts from style sheet once when sheet is added

Previously, we were running the "load fonts if needed" machine at the
start of every style computation. That was a lot of unnecessary work,
especially on sites with lots of style rules, since we had to traverse
every style sheet to see if any @font-face rules needed loading.

With this patch, we now load fonts once per sheet, right after adding
it to a document's style sheet list.
This commit is contained in:
Andreas Kling 2022-04-08 21:27:35 +02:00
parent 5b72a9cb11
commit 6e70670e0b
3 changed files with 19 additions and 20 deletions

View file

@ -74,6 +74,8 @@ public:
void did_load_font(FlyString const& family_name);
void load_fonts_from_sheet(CSSStyleSheet const&);
private:
void compute_cascaded_values(StyleProperties&, DOM::Element&, Optional<CSS::Selector::PseudoElement>) const;
void compute_font(StyleProperties&, DOM::Element const*, Optional<CSS::Selector::PseudoElement>) const;
@ -113,8 +115,6 @@ private:
};
OwnPtr<RuleCache> m_rule_cache;
void load_fonts_if_needed() const;
class FontLoader;
HashMap<String, NonnullOwnPtr<FontLoader>> m_loaded_fonts;
};