mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 10:18:15 +09:00
LibWeb/CSS: Replace is_generic_font_family() with a CSS enum
Also add the missing "math" value to it.
This commit is contained in:
parent
6da7a6eab5
commit
0ac133d73b
Notes:
github-actions[bot]
2025-02-06 16:49:09 +00:00
Author: https://github.com/AtkinsSJ
Commit: 0ac133d73b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3464
Reviewed-by: https://github.com/ADKaster
4 changed files with 14 additions and 20 deletions
|
@ -301,6 +301,18 @@
|
||||||
"extra-expanded",
|
"extra-expanded",
|
||||||
"ultra-expanded"
|
"ultra-expanded"
|
||||||
],
|
],
|
||||||
|
"generic-font-family": [
|
||||||
|
"serif",
|
||||||
|
"sans-serif",
|
||||||
|
"cursive",
|
||||||
|
"fantasy",
|
||||||
|
"monospace",
|
||||||
|
"math",
|
||||||
|
"ui-serif",
|
||||||
|
"ui-sans-serif",
|
||||||
|
"ui-monospace",
|
||||||
|
"ui-rounded"
|
||||||
|
],
|
||||||
"image-rendering": [
|
"image-rendering": [
|
||||||
"auto",
|
"auto",
|
||||||
"crisp-edges",
|
"crisp-edges",
|
||||||
|
|
|
@ -1504,24 +1504,6 @@ bool Parser::context_allows_quirky_length() const
|
||||||
return unitless_length_allowed;
|
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<ParsedFontFace::Source> Parser::parse_as_font_face_src()
|
Vector<ParsedFontFace::Source> Parser::parse_as_font_face_src()
|
||||||
{
|
{
|
||||||
return parse_font_face_src(m_token_stream);
|
return parse_font_face_src(m_token_stream);
|
||||||
|
|
|
@ -2385,7 +2385,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_family_value(TokenStream<ComponentValue
|
||||||
|
|
||||||
auto maybe_keyword = keyword_from_string(peek.token().ident());
|
auto maybe_keyword = keyword_from_string(peek.token().ident());
|
||||||
// Can't have a generic-font-name as a token in an unquoted font name.
|
// Can't have a generic-font-name as a token in an unquoted font name.
|
||||||
if (maybe_keyword.has_value() && is_generic_font_family(maybe_keyword.value())) {
|
if (maybe_keyword.has_value() && keyword_to_generic_font_family(maybe_keyword.value()).has_value()) {
|
||||||
if (!current_name_parts.is_empty())
|
if (!current_name_parts.is_empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
tokens.discard_a_token(); // Ident
|
tokens.discard_a_token(); // Ident
|
||||||
|
|
|
@ -796,7 +796,7 @@ GC::Ptr<CSSFontFaceRule> Parser::convert_to_font_face_rule(AtRule const& rule)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto keyword = keyword_from_string(part.token().ident());
|
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.");
|
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face font-family format invalid; discarding.");
|
||||||
had_syntax_error = true;
|
had_syntax_error = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue