From 0ac133d73bfa4dc762d07be4d9dc384541da00b8 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Tue, 4 Feb 2025 15:39:06 +0000 Subject: [PATCH] LibWeb/CSS: Replace is_generic_font_family() with a CSS enum Also add the missing "math" value to it. --- Libraries/LibWeb/CSS/Enums.json | 12 ++++++++++++ Libraries/LibWeb/CSS/Parser/Parser.cpp | 18 ------------------ .../LibWeb/CSS/Parser/PropertyParsing.cpp | 2 +- Libraries/LibWeb/CSS/Parser/RuleParsing.cpp | 2 +- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Libraries/LibWeb/CSS/Enums.json b/Libraries/LibWeb/CSS/Enums.json index deb5a0d8aa3..1343df0aa9a 100644 --- a/Libraries/LibWeb/CSS/Enums.json +++ b/Libraries/LibWeb/CSS/Enums.json @@ -301,6 +301,18 @@ "extra-expanded", "ultra-expanded" ], + "generic-font-family": [ + "serif", + "sans-serif", + "cursive", + "fantasy", + "monospace", + "math", + "ui-serif", + "ui-sans-serif", + "ui-monospace", + "ui-rounded" + ], "image-rendering": [ "auto", "crisp-edges", diff --git a/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Libraries/LibWeb/CSS/Parser/Parser.cpp index a85ca7d2982..48465b44ca1 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -1504,24 +1504,6 @@ bool Parser::context_allows_quirky_length() const return unitless_length_allowed; } -bool Parser::is_generic_font_family(Keyword keyword) -{ - switch (keyword) { - case Keyword::Cursive: - case Keyword::Fantasy: - case Keyword::Monospace: - case Keyword::Serif: - case Keyword::SansSerif: - case Keyword::UiMonospace: - case Keyword::UiRounded: - case Keyword::UiSerif: - case Keyword::UiSansSerif: - return true; - default: - return false; - } -} - Vector Parser::parse_as_font_face_src() { return parse_font_face_src(m_token_stream); diff --git a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp index ec221211a2d..ed26cf21f67 100644 --- a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp @@ -2385,7 +2385,7 @@ RefPtr Parser::parse_font_family_value(TokenStream Parser::convert_to_font_face_rule(AtRule const& rule) break; } auto keyword = keyword_from_string(part.token().ident()); - if (keyword.has_value() && is_generic_font_family(keyword.value())) { + if (keyword.has_value() && keyword_to_generic_font_family(keyword.value()).has_value()) { dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face font-family format invalid; discarding."); had_syntax_error = true; break;