LibWeb: Separate font computation logic from StyleComputer

Font computation and loading is distinct enough from style computation
that it makes more sense to have this in it's own class.

This will be useful later when we move the font loading process to
`ComputedProperties` in order to respect animated values.
This commit is contained in:
Callum Law 2025-11-06 18:27:22 +13:00 committed by Sam Atkins
parent dfa47d9ed6
commit 6c236d04d8
Notes: github-actions[bot] 2025-12-05 10:04:34 +00:00
13 changed files with 722 additions and 646 deletions

View file

@ -11,6 +11,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/CSSImportRule.h>
#include <LibWeb/CSS/CSSStyleSheet.h>
#include <LibWeb/CSS/FontComputer.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/CSS/StyleSheetList.h>
@ -325,7 +326,7 @@ void CSSStyleSheet::add_owning_document_or_shadow_root(DOM::Node& document_or_sh
// All owning documents or shadow roots must be part of the same document so we only need to load this style
// sheet's fonts against the document of the first
if (this->owning_documents_or_shadow_roots().size() == 1)
document_or_shadow_root.document().style_computer().load_fonts_from_sheet(*this);
document_or_shadow_root.document().font_computer().load_fonts_from_sheet(*this);
for (auto const& import_rule : m_import_rules) {
if (import_rule->loaded_style_sheet())
@ -340,7 +341,7 @@ void CSSStyleSheet::remove_owning_document_or_shadow_root(DOM::Node& document_or
// All owning documents or shadow roots must be part of the same document so we only need to unload this style
// sheet's fonts once we have none remaining.
if (this->owning_documents_or_shadow_roots().size() == 0)
document_or_shadow_root.document().style_computer().unload_fonts_from_sheet(*this);
document_or_shadow_root.document().font_computer().unload_fonts_from_sheet(*this);
for (auto const& import_rule : m_import_rules) {
if (import_rule->loaded_style_sheet())